Skip to content

Commit

Permalink
fix(test): replace hardcoded reference to adv with dynamic one
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Aug 14, 2023
1 parent b3f4c14 commit 2e6bfa3
Showing 1 changed file with 42 additions and 23 deletions.
65 changes: 42 additions & 23 deletions erpnext/controllers/tests/test_accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,23 @@ def test_11_advance_against_sales_invoice(self):
for exc_rate in [75.9, 83.1, 80.01]:
with self.subTest(exc_rate=exc_rate):
si = self.create_sales_invoice(qty=1, conversion_rate=exc_rate, rate=1, do_not_submit=True)
advances = si.get_advance_entries()
self.assertEqual(len(advances), 1)
self.assertEqual(advances[0].reference_name, adv.name)
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": adv.doctype,
"reference_name": adv.name,
"reference_type": advances[0].reference_type,
"reference_name": advances[0].reference_name,
"reference_row": advances[0].reference_row,
"advance_amount": 1,
"allocated_amount": 1,
"ref_exchange_rate": 85,
"remarks": "Test",
"ref_exchange_rate": advances[0].exchange_rate,
"remarks": advances[0].remarks,
},
)

si = si.save()
si = si.submit()

Expand Down Expand Up @@ -398,16 +403,19 @@ def test_12_partial_advance_and_payment_for_sales_invoice(self):
si = self.create_sales_invoice(
qty=2, conversion_rate=80, rate=rate_in_account_currency, do_not_submit=True
)
advances = si.get_advance_entries()
self.assertEqual(len(advances), 1)
self.assertEqual(advances[0].reference_name, adv.name)
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": adv.doctype,
"reference_name": adv.name,
"reference_type": advances[0].reference_type,
"reference_name": advances[0].reference_name,
"advance_amount": 1,
"allocated_amount": 1,
"ref_exchange_rate": 85,
"remarks": "Test",
"ref_exchange_rate": advances[0].exchange_rate,
"remarks": advances[0].remarks,
},
)
si = si.save()
Expand Down Expand Up @@ -470,16 +478,19 @@ def test_13_partial_advance_and_payment_for_invoice_with_cancellation(self):

# invoice with advance(partial amount)
si = self.create_sales_invoice(qty=2, conversion_rate=80, rate=1, do_not_submit=True)
advances = si.get_advance_entries()
self.assertEqual(len(advances), 1)
self.assertEqual(advances[0].reference_name, adv.name)
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": adv.doctype,
"reference_name": adv.name,
"reference_type": advances[0].reference_type,
"reference_name": advances[0].reference_name,
"advance_amount": 1,
"allocated_amount": 1,
"ref_exchange_rate": 85,
"remarks": "Test",
"ref_exchange_rate": advances[0].exchange_rate,
"remarks": advances[0].remarks,
},
)
si = si.save()
Expand Down Expand Up @@ -678,22 +689,26 @@ def test_21_advance_journal_against_sales_invoice(self):
adv.reload()

# Sales Invoices in different exchange rates
for exc_rate in [75.9, 83.1, 80.01]:
for exc_rate in [75.9, 83.1]:
with self.subTest(exc_rate=exc_rate):
si = self.create_sales_invoice(qty=1, conversion_rate=exc_rate, rate=1, do_not_submit=True)
advances = si.get_advance_entries()
self.assertEqual(len(advances), 1)
self.assertEqual(advances[0].reference_name, adv.name)
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": adv.doctype,
"reference_name": adv.name,
"reference_row": adv.accounts[0].name,
"reference_type": advances[0].reference_type,
"reference_name": advances[0].reference_name,
"reference_row": advances[0].reference_row,
"advance_amount": 1,
"allocated_amount": 1,
"ref_exchange_rate": adv_exc_rate,
"remarks": "Test",
"ref_exchange_rate": advances[0].exchange_rate,
"remarks": advances[0].remarks,
},
)

si = si.save()
si = si.submit()

Expand Down Expand Up @@ -741,19 +756,23 @@ def test_22_partial_advance_and_payment_for_invoice_with_cancellation(self):

# invoice with advance(partial amount)
si = self.create_sales_invoice(qty=3, conversion_rate=80, rate=1, do_not_submit=True)
advances = si.get_advance_entries()
self.assertEqual(len(advances), 1)
self.assertEqual(advances[0].reference_name, adv.name)
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": adv.doctype,
"reference_name": adv.name,
"reference_row": adv.accounts[0].name,
"reference_type": advances[0].reference_type,
"reference_name": advances[0].reference_name,
"reference_row": advances[0].reference_row,
"advance_amount": 1,
"allocated_amount": 1,
"ref_exchange_rate": adv_exc_rate,
"remarks": "Test",
"ref_exchange_rate": advances[0].exchange_rate,
"remarks": advances[0].remarks,
},
)

si = si.save()
si = si.submit()

Expand Down

0 comments on commit 2e6bfa3

Please sign in to comment.