我正在创建一个Frappe App,存在类似(工作)功能,所以我试图重用此代码。我在这个 python 文档中的任何地方都找不到lst
变量的实际赋值(使用搜索,它是这个函数的局部变量)。到目前为止,它在声明时似乎是一个空列表,但是,它被视为包含一个值。
还是我只是误解了代码本身?
首先,lst
被声明为一个列表(空)
lst = []
它被分配给 reconciled_entry (仍然为空)
reconciled_entry = lst
然后按如下方式使用:(还是空的)
if lst:
reconcile_against_document(lst)
函数 reconcile_against_document 函数需要一个实际列表:
还是空的???
def reconcile_against_document(args):
"""
Cancel JV, Update against document, split if required and resubmit jv
"""
for d in args:
check_if_advance_entry_modified(d)
validate_allocated_amount(d)
# cancel advance entry
doc = frappe.get_doc(d.voucher_type, d.voucher_no)
doc.make_gl_entries(cancel=1, adv_adj=1)
...
主功能:
def reconcile(self, args):
for e in self.get('payments'):
e.invoice_type = None
if e.invoice_number and " | " in e.invoice_number:
e.invoice_type, e.invoice_number = e.invoice_number.split(" | ")
self.get_invoice_entries()
self.validate_invoice()
dr_or_cr = ("credit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency")
lst = []
dr_or_cr_notes = []
for e in self.get('payments'):
reconciled_entry = []
if e.invoice_number and e.allocated_amount:
if e.reference_type in ['Sales Invoice', 'Purchase Invoice']:
reconciled_entry = dr_or_cr_notes
else:
reconciled_entry = lst
reconciled_entry.append(self.get_payment_details(e, dr_or_cr))
if lst:
reconcile_against_document(lst)
if dr_or_cr_notes:
reconcile_dr_cr_note(dr_or_cr_notes)
msgprint(_("Successfully Reconciled"))
self.get_unreconciled_entries()