Revised the fill_transaction_from_previous_form() utility in the accounting application.
This commit is contained in:
parent
4c3f3465d5
commit
ec51884414
@ -315,12 +315,14 @@ def fill_transaction_from_previous_form(request, transaction):
|
|||||||
max_debit_no = 0
|
max_debit_no = 0
|
||||||
max_credit_no = 0
|
max_credit_no = 0
|
||||||
for key in form.keys():
|
for key in form.keys():
|
||||||
m = re.match("^debit-([1-9][0-9]*)-", key)
|
m = re.match(
|
||||||
|
"^debit-([1-9][0-9]*)-(sn|ord|account|summary|amount)", key)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
no = int(m.group(1))
|
no = int(m.group(1))
|
||||||
if max_debit_no < no:
|
if max_debit_no < no:
|
||||||
max_debit_no = no
|
max_debit_no = no
|
||||||
m = re.match("^credit-([1-9][0-9]*)-", key)
|
m = re.match(
|
||||||
|
"^credit-([1-9][0-9]*)-(sn|ord|account|summary|amount)", key)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
no = int(m.group(1))
|
no = int(m.group(1))
|
||||||
if max_credit_no < no:
|
if max_credit_no < no:
|
||||||
@ -328,7 +330,7 @@ def fill_transaction_from_previous_form(request, transaction):
|
|||||||
records = []
|
records = []
|
||||||
for i in range(max_debit_no):
|
for i in range(max_debit_no):
|
||||||
no = i + 1
|
no = i + 1
|
||||||
record = Record(ord=no, is_credit=False)
|
record = Record(ord=no, is_credit=False, transaction=transaction)
|
||||||
if F"debit-{no}-sn" in form:
|
if F"debit-{no}-sn" in form:
|
||||||
record.pk = form[F"debit-{no}-sn"]
|
record.pk = form[F"debit-{no}-sn"]
|
||||||
if F"debit-{no}-account" in form:
|
if F"debit-{no}-account" in form:
|
||||||
@ -340,7 +342,7 @@ def fill_transaction_from_previous_form(request, transaction):
|
|||||||
records.append(record)
|
records.append(record)
|
||||||
for i in range(max_credit_no):
|
for i in range(max_credit_no):
|
||||||
no = i + 1
|
no = i + 1
|
||||||
record = Record(ord=no, is_credit=True)
|
record = Record(ord=no, is_credit=False, transaction=transaction)
|
||||||
if F"credit-{no}-sn" in form:
|
if F"credit-{no}-sn" in form:
|
||||||
record.pk = form[F"credit-{no}-sn"]
|
record.pk = form[F"credit-{no}-sn"]
|
||||||
if F"credit-{no}-account" in form:
|
if F"credit-{no}-account" in form:
|
||||||
|
Loading…
Reference in New Issue
Block a user