For the time being, I was able to clear the coding that enjoyed the benefits of the class and the approach to the problem (here, the processing for the approval form), and thankfully I was able to point out the coding method for the class. However, as an accounting member, I have a desire to have the person in charge of approval documents do more work.
Last time, I was able to embody the processing for the "newly-circulated approval form". However, the processing for "fixed assets that have already been turned around and have not yet started to be used" is sloppy. There will be no new approval documents for this "fixed asset that has already been turned around and has not yet started to be used". Therefore, you have to email the person in charge if you are taking care of it continuously and starting to use it every month.
The new job that will occur here is to send regular emails to projects that did not start using the service last time. We will try to achieve this by means of class inheritance. The previous coding was a process for "newly coming approval documents".
qiita.rb
import openpyxl
import datetime
class NewAssets():
def __init__(self,apdnum,apdmen,unitname,assetname,money):
self.apdnum=apdnum
self.apdmen=apdmen
self.unitname=unitname
self.assetname=assetname
self.money=money
#Function to attach PDF to emails Work to pick up destination email addresses from the person in charge and the department in charge
def make_mail(self):
mail=("{}{}Thank you for your hard work. I am in charge of fixed assets in the accounting department. Approval No.{}of{}About\
\n Please tell us about the situation this month if you have started using it. Also, if there is an invoice, you can also attach an invoice\
\n Thank you.".format(self.unitname,self.apdmen,self.apdnum,self.assetname))
print(mail)
def insert_excel(self):
wb=openpyxl.load_workbook("../data/Order fixed asset management table.xlsx")
sh=wb.active
for dt_row in range(2,50):
if sh["A"+str(dt_row)].value!=None:
continue
else:
sh["A"+str(dt_row)].value=self.apdnum
sh["B"+str(dt_row)].value=self.unitname
sh["C"+str(dt_row)].value=self.apdmen
sh["D"+str(dt_row)].value=self.assetname
sh["E"+str(dt_row)].value=self.money
break
wb.save("../data/Order fixed asset management table_{}_Create johannesrome.xlsx".format(datetime.date.today()))
#The code that corresponds to the core part I wrote last time
#Below new code
#New_Buying, a subclass of the Assets class_Create Assets and consume as an attribute(Expenditure)Add
class BuyingAssets(NewAssets):
def __init__(self,apdnum,apdmen,unitname,assetname,money,consume):
super().__init__(apdnum,apdmen,unitname,assetname,money)
self.consume=consume
def make_buying_mail(self):
if self.consume=="Not yet":
print("{}of{}様お疲れ様です。経理部of固定資産担当です。先月未使用であった稟議書No{}of{}About\
\n Please tell us about the situation this month if you have started using it. Also, if there is an invoice, you can also attach an invoice\
\n Thank you.".format(self.unitname,self.apdmen,self.apdnum,self.assetname))
sh["G"+str(dt_row)].value="✔"
else:
None
#Output code below
wb=openpyxl.load_workbook("../data/Order fixed asset management table_Create johannesrome.xlsx")
sh=wb.active
for dt_row in range(2,50):
apdnum=sh["A"+str(dt_row)].value
unitname=sh["B"+str(dt_row)].value
apdmen=sh["C"+str(dt_row)].value
assetname=sh["D"+str(dt_row)].value
money=sh["E"+str(dt_row)].value
consume=sh["F"+str(dt_row)].value
m=Buying_Assets(apdnum,apdmen,unitname,assetname,money,consume)
m.make_buying_mail()
wb.save("../data/Order fixed asset management table_Create johannesrome.xlsx")
The coding method you pointed out last time has been corrected I just created Buyin_Assets as a subclass as a class inheritance and added consume as an attribute And, as a program I want you to do this time, you can create an email for unused assets and put ✔ in Excel after creating it.
Click here for Excel before execution
And when you run
Checked (∩´∀ `) ∩
It came well (◠‿◠)
I didn't use the methods and data before inheritance this time, so I thought it would be a bad idea as a setting theme and approach. More personally, I had the image of making good use of the method before inheritance.
However, while I was coding, I noticed that the merit of the class was that I noticed that it was possible to change to coding that makes use of the attributes of the class in the middle of the coding that opened openpyxl and processed it at def make_buying_mail (self) :. I got it. I want to use the class more and more and get used to it quickly.
Also, if you have any opinions such as you can enjoy the benefits of the class with such a theme, please comment! (`・ Ω ・ ´)
Recommended Posts