Fixed the fill_txn_from_post() utility when constructing the records in the accounting application.
This commit is contained in:
parent
fe8dae191e
commit
330b43c71b
@ -284,13 +284,13 @@ def find_order_holes(records):
|
|||||||
|
|
||||||
|
|
||||||
def fill_txn_from_post(txn, post):
|
def fill_txn_from_post(txn, post):
|
||||||
"""Fills the transaction from the POSTed data.
|
"""Fills the transaction from the POSTed data. The POSTed data must be
|
||||||
|
validated and clean at this moment.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
txn (Transaction): The transaction.
|
txn (Transaction): The transaction.
|
||||||
post (dict): The POSTed data.
|
post (dict): The POSTed data.
|
||||||
"""
|
"""
|
||||||
if "date" in post:
|
|
||||||
txn.date = post["date"]
|
txn.date = post["date"]
|
||||||
if "notes" in post:
|
if "notes" in post:
|
||||||
txn.notes = post["notes"]
|
txn.notes = post["notes"]
|
||||||
@ -300,17 +300,17 @@ def fill_txn_from_post(txn, post):
|
|||||||
for rec_type in max_no.keys():
|
for rec_type in max_no.keys():
|
||||||
for i in range(max_no[rec_type]):
|
for i in range(max_no[rec_type]):
|
||||||
no = i + 1
|
no = i + 1
|
||||||
|
if F"{rec_type}-{no}-id" in post:
|
||||||
|
record = Record.objects.get(pk=post[F"{rec_type}-{no}-id"])
|
||||||
|
else:
|
||||||
record = Record(
|
record = Record(
|
||||||
ord=no,
|
|
||||||
is_credit=(rec_type == "credit"),
|
is_credit=(rec_type == "credit"),
|
||||||
transaction=txn)
|
transaction=txn)
|
||||||
if F"{rec_type}-{no}-id" in post:
|
record.ord = no
|
||||||
record.pk = post[F"{rec_type}-{no}-id"]
|
record.account = Account.objects.get(
|
||||||
if F"{rec_type}-{no}-account" in post:
|
code=post[F"{rec_type}-{no}-account"])
|
||||||
record.account = Account(code=post[F"{rec_type}-{no}-account"])
|
|
||||||
if F"{rec_type}-{no}-summary" in post:
|
if F"{rec_type}-{no}-summary" in post:
|
||||||
record.summary = post[F"{rec_type}-{no}-summary"]
|
record.summary = post[F"{rec_type}-{no}-summary"]
|
||||||
if F"{rec_type}-{no}-amount" in post:
|
|
||||||
record.amount = post[F"{rec_type}-{no}-amount"]
|
record.amount = post[F"{rec_type}-{no}-amount"]
|
||||||
records.append(record)
|
records.append(record)
|
||||||
txn.records = records
|
txn.records = records
|
||||||
|
Loading…
Reference in New Issue
Block a user