test: modify test to check posting date

This commit is contained in:
Gursheen Anand
2023-06-12 18:00:15 +05:30
parent a06017c2c3
commit 5e9821dce2
3 changed files with 35 additions and 9 deletions

View File

@@ -909,6 +909,7 @@ class PaymentEntry(AccountsController):
item=self, item=self,
) )
for d in self.get("references"): for d in self.get("references"):
gle = party_dict.copy()
book_advance_payments_as_liability = frappe.get_value( book_advance_payments_as_liability = frappe.get_value(
"Company", {"company_name": self.company}, "book_advance_payments_as_liability" "Company", {"company_name": self.company}, "book_advance_payments_as_liability"
) )
@@ -917,17 +918,27 @@ class PaymentEntry(AccountsController):
and book_advance_payments_as_liability and book_advance_payments_as_liability
): ):
self.make_invoice_liability_entry(gl_entries, d) self.make_invoice_liability_entry(gl_entries, d)
gle.update(
{
"against_voucher_type": "Payment Entry",
"against_voucher": self.name,
}
)
allocated_amount_in_company_currency = self.calculate_base_allocated_amount_for_reference(d) allocated_amount_in_company_currency = self.calculate_base_allocated_amount_for_reference(d)
gle = party_dict.copy()
gle.update( gle.update(
{ {
dr_or_cr: allocated_amount_in_company_currency, dr_or_cr: allocated_amount_in_company_currency,
dr_or_cr + "_in_account_currency": d.allocated_amount, dr_or_cr + "_in_account_currency": d.allocated_amount,
"against_voucher_type": "Payment Entry",
"against_voucher": self.name,
} }
) )
if not gle.get("against_voucher_type"):
gle.update(
{
"against_voucher_type": d.reference_doctype,
"against_voucher": d.reference_name,
}
)
gl_entries.append(gle) gl_entries.append(gle)
@@ -940,6 +951,8 @@ class PaymentEntry(AccountsController):
{ {
dr_or_cr + "_in_account_currency": self.unallocated_amount, dr_or_cr + "_in_account_currency": self.unallocated_amount,
dr_or_cr: base_unallocated_amount, dr_or_cr: base_unallocated_amount,
"against_voucher_type": "Payment Entry",
"against_voucher": self.name,
} }
) )

View File

@@ -1694,13 +1694,18 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
pi.save() pi.save()
pi.submit() pi.submit()
expected_gle = [ expected_gle = [
["Creditors - _TC", 50, 100], ["Creditors - _TC", 50, 100, nowdate()],
["Debtors - _TC", 0.0, 50], ["Debtors - _TC", 0.0, 50, nowdate()],
["Stock Received But Not Billed - _TC", 100, 0.0], ["Stock Received But Not Billed - _TC", 100, 0.0, nowdate()],
] ]
check_gl_entries(self, pi.name, expected_gle, nowdate()) check_gl_entries(self, pi.name, expected_gle, nowdate())
self.assertEqual(pi.outstanding_amount, 200) self.assertEqual(pi.outstanding_amount, 200)
frappe.db.set_value(
"Company",
"_Test Company",
{"book_advance_payments_as_liability": 0, "default_advance_paid_account": ""},
)
def check_gl_entries(doc, voucher_no, expected_gle, posting_date): def check_gl_entries(doc, voucher_no, expected_gle, posting_date):

View File

@@ -3348,13 +3348,21 @@ class TestSalesInvoice(unittest.TestCase):
si.save() si.save()
si.submit() si.submit()
expected_gle = [ expected_gle = [
["Creditors - _TC", 50, 0.0], ["Creditors - _TC", 50, 0.0, nowdate()],
["Debtors - _TC", 100, 50], ["Debtors - _TC", 100, 50, nowdate()],
["Sales - _TC", 0.0, 100], ["Sales - _TC", 0.0, 100, nowdate()],
] ]
check_gl_entries(self, si.name, expected_gle, nowdate()) check_gl_entries(self, si.name, expected_gle, nowdate())
self.assertEqual(si.outstanding_amount, 50) self.assertEqual(si.outstanding_amount, 50)
frappe.db.set_value(
"Company",
"_Test Company",
{
"book_advance_payments_as_liability": 0,
"default_advance_received_account": "",
},
)
def get_sales_invoice_for_e_invoice(): def get_sales_invoice_for_e_invoice():