Renamed "side" to "debit-credit".

This commit is contained in:
2023-03-20 20:35:10 +08:00
parent 02fffc3400
commit e26af6f3fc
22 changed files with 225 additions and 224 deletions

View File

@ -101,7 +101,7 @@ class OffsetTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# The same side
# The same debit or credit
form = voucher_data.new_form(self.csrf_token)
form["currency-1-credit-1-original_line_item_id"] \
= self.data.e_p_or1c.id
@ -210,7 +210,7 @@ class OffsetTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# The same side
# The same debit or credit
form = voucher_data.update_form(self.csrf_token)
form["currency-1-credit-1-original_line_item_id"] \
= self.data.e_p_or1c.id
@ -417,7 +417,7 @@ class OffsetTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# The same side
# The same debit or credit
form = voucher_data.new_form(self.csrf_token)
form["currency-1-debit-1-original_line_item_id"] \
= self.data.e_r_or1d.id
@ -524,7 +524,7 @@ class OffsetTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# The same side
# The same debit or credit
form = voucher_data.update_form(self.csrf_token)
form["currency-1-debit-1-original_line_item_id"] \
= self.data.e_r_or1d.id

View File

@ -231,7 +231,7 @@ class CashReceiptVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# A receivable line item cannot start from the credit side
# A receivable line item cannot start from credit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-credit-" in x][0]
@ -391,7 +391,7 @@ class CashReceiptVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# A receivable line item cannot start from the credit side
# A receivable line item cannot start from credit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-credit-" in x][0]
@ -803,7 +803,7 @@ class CashDisbursementVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# A payable line item cannot start from the debit side
# A payable line item cannot start from debit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-debit-" in x][0]
@ -966,7 +966,7 @@ class CashDisbursementVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# A payable line item cannot start from the debit side
# A payable line item cannot start from debit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-debit-" in x][0]
@ -1398,7 +1398,7 @@ class TransferVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# A receivable line item cannot start from the credit side
# A receivable line item cannot start from credit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-credit-" in x][0]
@ -1407,7 +1407,7 @@ class TransferVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], create_uri)
# A payable line item cannot start from the debit side
# A payable line item cannot start from debit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-debit-" in x][0]
@ -1597,7 +1597,7 @@ class TransferVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# A receivable line item cannot start from the credit side
# A receivable line item cannot start from credit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-credit-" in x][0]
@ -1606,7 +1606,7 @@ class TransferVoucherTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], edit_uri)
# A payable line item cannot start from the debit side
# A payable line item cannot start from debit
form = self.__get_add_form()
key: str = [x for x in form.keys()
if x.endswith("-account_code") and "-debit-" in x][0]

View File

@ -50,17 +50,17 @@ class VoucherLineItemData:
self.description: str = description
self.amount: Decimal = Decimal(amount)
def form(self, prefix: str, side: str, index: int, is_update: bool) \
-> dict[str, str]:
def form(self, prefix: str, debit_credit: str, index: int,
is_update: bool) -> dict[str, str]:
"""Returns the line item as form data.
:param prefix: The prefix of the form fields.
:param side: The side, either "debit" or "credit".
:param debit_credit: Either "debit" or "credit".
:param index: The line item index.
:param is_update: True for an update operation, or False otherwise
:return: The form data.
"""
prefix = f"{prefix}-{side}-{index}"
prefix = f"{prefix}-{debit_credit}-{index}"
form: dict[str, str] = {f"{prefix}-account_code": self.account,
f"{prefix}-description": self.description,
f"{prefix}-amount": str(self.amount)}