Renamed the fill_transaction_from_form() to fill_transaction_from_post(), and the parameter form to post in the accounting application.
This commit is contained in:
parent
db4100cb9c
commit
413c0fe112
@ -283,23 +283,23 @@ def find_order_holes(records):
|
|||||||
record.has_order_hole = record.transaction.date in holes
|
record.has_order_hole = record.transaction.date in holes
|
||||||
|
|
||||||
|
|
||||||
def fill_transaction_from_form(transaction, form):
|
def fill_transaction_from_post(transaction, post):
|
||||||
"""Fills the transaction from the form.
|
"""Fills the transaction from the POSTed data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
transaction (Transaction): The transaction.
|
transaction (Transaction): The transaction.
|
||||||
form (dict): The form
|
post (dict): The POSTed data.
|
||||||
"""
|
"""
|
||||||
if "date" in form:
|
if "date" in post:
|
||||||
transaction.date = form["date"]
|
transaction.date = post["date"]
|
||||||
if "notes" in form:
|
if "notes" in post:
|
||||||
transaction.notes = form["notes"]
|
transaction.notes = post["notes"]
|
||||||
# The records
|
# The records
|
||||||
max_no = {
|
max_no = {
|
||||||
"debit": 0,
|
"debit": 0,
|
||||||
"credit": 0,
|
"credit": 0,
|
||||||
}
|
}
|
||||||
for key in form.keys():
|
for key in post.keys():
|
||||||
m = re.match(
|
m = re.match(
|
||||||
"^(debit|credit)-([1-9][0-9]*)-(id|ord|account|summary|amount)$",
|
"^(debit|credit)-([1-9][0-9]*)-(id|ord|account|summary|amount)$",
|
||||||
key)
|
key)
|
||||||
@ -316,14 +316,14 @@ def fill_transaction_from_form(transaction, form):
|
|||||||
ord=no,
|
ord=no,
|
||||||
is_credit=(rec_type == "credit"),
|
is_credit=(rec_type == "credit"),
|
||||||
transaction=transaction)
|
transaction=transaction)
|
||||||
if F"{rec_type}-{no}-id" in form:
|
if F"{rec_type}-{no}-id" in post:
|
||||||
record.pk = form[F"{rec_type}-{no}-id"]
|
record.pk = post[F"{rec_type}-{no}-id"]
|
||||||
if F"{rec_type}-{no}-account" in form:
|
if F"{rec_type}-{no}-account" in post:
|
||||||
record.account = Account(code=form[F"{rec_type}-{no}-account"])
|
record.account = Account(code=post[F"{rec_type}-{no}-account"])
|
||||||
if F"{rec_type}-{no}-summary" in form:
|
if F"{rec_type}-{no}-summary" in post:
|
||||||
record.summary = form[F"{rec_type}-{no}-summary"]
|
record.summary = post[F"{rec_type}-{no}-summary"]
|
||||||
if F"{rec_type}-{no}-amount" in form:
|
if F"{rec_type}-{no}-amount" in post:
|
||||||
record.amount = form[F"{rec_type}-{no}-amount"]
|
record.amount = post[F"{rec_type}-{no}-amount"]
|
||||||
records.append(record)
|
records.append(record)
|
||||||
transaction.records = records
|
transaction.records = records
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ from mia_core.utils import Pagination, get_multi_lingual_search, UrlBuilder, \
|
|||||||
strip_form
|
strip_form
|
||||||
from .models import Record, Transaction, Account, RecordSummary
|
from .models import Record, Transaction, Account, RecordSummary
|
||||||
from .utils import ReportUrl, get_cash_accounts, get_ledger_accounts, \
|
from .utils import ReportUrl, get_cash_accounts, get_ledger_accounts, \
|
||||||
find_imbalanced, find_order_holes, fill_transaction_from_form, \
|
find_imbalanced, find_order_holes, fill_transaction_from_post, \
|
||||||
sort_form_transaction_records, make_transaction_form_from_status, \
|
sort_form_transaction_records, make_transaction_form_from_status, \
|
||||||
make_transaction_form_from_model, make_transaction_form_from_post
|
make_transaction_form_from_model, make_transaction_form_from_post
|
||||||
|
|
||||||
@ -866,7 +866,7 @@ def transaction_store(request, txn_type, transaction=None):
|
|||||||
post)
|
post)
|
||||||
if transaction is None:
|
if transaction is None:
|
||||||
transaction = Transaction()
|
transaction = Transaction()
|
||||||
fill_transaction_from_form(transaction, post)
|
fill_transaction_from_post(transaction, post)
|
||||||
# TODO: Stores the data
|
# TODO: Stores the data
|
||||||
return success_redirect(
|
return success_redirect(
|
||||||
request,
|
request,
|
||||||
|
Loading…
Reference in New Issue
Block a user