我在python(oops)中使用以下代码来维护贷方借方报表。Classdef_Cash.py文件具有程序的主要结构,Cash_001.py文件具有贷方和借方代码。一切正常,除了贷方和借方值不会定期更新。有人可以帮助我吗?请同时引用两个文件并运行Cash_001.py文件。“”“
Classdef_Cash_001.py
是第一个文件,Cash_001.py
是第二个文件
class Cash:
def __init__(self, DATE, VOUCHER, SPECIFICATION, INITIAL_AMOUNT, CREDIT,DEBIT, REMARKS, BALANCE):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.CREDIT = CREDIT
self.DEBIT = DEBIT
self.REMARKS = REMARKS
self.BALANCE = INITIAL_AMOUNT
def Spending(self,DATE,VOUCHER,SPECIFICATION,DEBIT,REMARKS):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.REMARKS = REMARKS
self.BALANCE -= DEBIT
def CashInflow(self,DATE,VOUCHER,SPECIFICATION,CREDIT,REMARKS):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.REMARKS = REMARKS
self.BALANCE += CREDIT
def dump(self):
s = 'DATE: %s, VOUCHER: %s, SPECIFICATION: %s , CREDIT: %s ,DEBIT: %s ,REMARKS :%s ,BALANCE :%s ' % \
(self.DATE,self.VOUCHER, self.SPECIFICATION, self.CREDIT, self.DEBIT, self.REMARKS,self.BALANCE)
print s
Cash_001.py
是第二个文件
from Classdef_Cash_001 import Cash
p1=Cash('01/10/2018','000','CARRY FORWARD',2000,0,0,'REMAINDER','0')
p1.dump()
p1.Spending('01/10/2018','001','OIL',200,'JOHN')
p1.dump()
p1.CashInflow('02/10/2018','002','SALES',10000,'REF179800')
p1.dump()
p1.Spending('03/10/2018','003','GAS',200,'GEORGE')
p1.dump()
p1.CashInflow('03/10/2018','004','SALES',50000,'REF179801')
p1.dump()
答案 0 :(得分:0)
请参考以下代码。这正是我在寻找统一的信用借方余额表。正是在资金流入时,借方被强制为零,而在有支出时,信用被迫为零。贷项和借项仅在输出的第一行中保持为零,该行从上个月结转。这类似于有输入,禁用输出和有输出时输入的概念已被禁用。请运行Cash_001.py文件。
#Classdef_Cash_001.py
class Cash:
def __init__(self, DATE, VOUCHER, SPECIFICATION, INITIAL_AMOUNT, CREDIT,DEBIT,
REMARKS, BALANCE):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.CREDIT = CREDIT
self.DEBIT = DEBIT
self.REMARKS = REMARKS
self.BALANCE = INITIAL_AMOUNT
def Spending(self,DATE,VOUCHER,SPECIFICATION,DEBIT,CREDIT,REMARKS):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.REMARKS = REMARKS
self.DEBIT = DEBIT
self.CREDIT = 0
self.BALANCE -= DEBIT
def CashInflow(self,DATE,VOUCHER,SPECIFICATION,CREDIT,DEBIT,REMARKS):
self.DATE = DATE
self.VOUCHER = VOUCHER
self.SPECIFICATION = SPECIFICATION
self.REMARKS = REMARKS
self.CREDIT = CREDIT
self.DEBIT = 0
self.BALANCE += CREDIT
def dump(self):
s = 'DATE: %s, VOUCHER: %s, SPECIFICATION: %s , CREDIT: %s ,DEBIT: %s
,REMARKS :%s ,BALANCE :%s ' % \
(self.DATE,self.VOUCHER, self.SPECIFICATION, self.CREDIT, self.DEBIT,
self.REMARKS, self.BALANCE)
print s
#Cash_001.py
from Classdef_Cash_001 import Cash
p1=Cash('01/10/2018','000','CARRY FORWARD',2000,0,0,'REMAINDER',0)
p1.dump()
p1.Spending('01/10/2018','001','OIL',200,0,'JOHN')
p1.dump()
p1.CashInflow('02/10/2018','002','SALES',1000,0,'REF179800')
p1.dump()
p1.Spending('03/10/2018','003','GAS',200,0,'GEORGE')
p1.dump()
p1.CashInflow('03/10/2018','004','SALES',5000,0,'REF179801')
p1.dump()