Renamed the variable rec_type as record_type in the fill_txn_from_post() and make_txn_form_from_post() utilities in the accounting application.
This commit is contained in:
parent
8d9e4cdf93
commit
62978474c8
@ -299,23 +299,23 @@ def fill_txn_from_post(txn, post):
|
|||||||
# The records
|
# The records
|
||||||
max_no = _find_max_record_no(post)
|
max_no = _find_max_record_no(post)
|
||||||
records = []
|
records = []
|
||||||
for rec_type in max_no.keys():
|
for record_type in max_no.keys():
|
||||||
for i in range(max_no[rec_type]):
|
for i in range(max_no[record_type]):
|
||||||
no = i + 1
|
no = i + 1
|
||||||
if F"{rec_type}-{no}-id" in post:
|
if F"{record_type}-{no}-id" in post:
|
||||||
record = Record.objects.get(pk=post[F"{rec_type}-{no}-id"])
|
record = Record.objects.get(pk=post[F"{record_type}-{no}-id"])
|
||||||
else:
|
else:
|
||||||
record = Record(
|
record = Record(
|
||||||
is_credit=(rec_type == "credit"),
|
is_credit=(record_type == "credit"),
|
||||||
transaction=txn)
|
transaction=txn)
|
||||||
record.ord = no
|
record.ord = no
|
||||||
record.account = Account.objects.get(
|
record.account = Account.objects.get(
|
||||||
code=post[F"{rec_type}-{no}-account"])
|
code=post[F"{record_type}-{no}-account"])
|
||||||
if F"{rec_type}-{no}-summary" in post:
|
if F"{record_type}-{no}-summary" in post:
|
||||||
record.summary = post[F"{rec_type}-{no}-summary"]
|
record.summary = post[F"{record_type}-{no}-summary"]
|
||||||
else:
|
else:
|
||||||
record.summary = None
|
record.summary = None
|
||||||
record.amount = post[F"{rec_type}-{no}-amount"]
|
record.amount = post[F"{record_type}-{no}-amount"]
|
||||||
records.append(record)
|
records.append(record)
|
||||||
txn.records = records
|
txn.records = records
|
||||||
|
|
||||||
@ -428,19 +428,19 @@ def make_txn_form_from_post(post, txn_type, txn):
|
|||||||
max_no["debit"] = 1
|
max_no["debit"] = 1
|
||||||
if max_no["credit"] == 0:
|
if max_no["credit"] == 0:
|
||||||
max_no["credit"] = 1
|
max_no["credit"] = 1
|
||||||
for rec_type in max_no.keys():
|
for record_type in max_no.keys():
|
||||||
records = []
|
records = []
|
||||||
is_credit = (rec_type == "credit")
|
is_credit = (record_type == "credit")
|
||||||
for i in range(max_no[rec_type]):
|
for i in range(max_no[record_type]):
|
||||||
no = i + 1
|
no = i + 1
|
||||||
record_form = RecordForm(
|
record_form = RecordForm(
|
||||||
{x: post[F"{rec_type}-{no}-{x}"]
|
{x: post[F"{record_type}-{no}-{x}"]
|
||||||
for x in ["id", "account", "summary", "amount"]
|
for x in ["id", "account", "summary", "amount"]
|
||||||
if F"{rec_type}-{no}-{x}" in post})
|
if F"{record_type}-{no}-{x}" in post})
|
||||||
record_form.transaction = form.transaction
|
record_form.transaction = form.transaction
|
||||||
record_form.is_credit = is_credit
|
record_form.is_credit = is_credit
|
||||||
records.append(record_form)
|
records.append(record_form)
|
||||||
if rec_type == "debit":
|
if record_type == "debit":
|
||||||
form.debit_records = records
|
form.debit_records = records
|
||||||
else:
|
else:
|
||||||
form.credit_records = records
|
form.credit_records = records
|
||||||
|
Loading…
Reference in New Issue
Block a user