mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
Merge pull request #48782 from ljain112/fix-silly
fix: attribute error in payment entry
This commit is contained in:
@@ -1560,13 +1560,14 @@ class PaymentEntry(AccountsController):
|
|||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
"voucher_detail_no": invoice.name,
|
"voucher_detail_no": invoice.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if invoice.reconcile_effect_on:
|
if invoice.reconcile_effect_on:
|
||||||
posting_date = invoice.reconcile_effect_on
|
posting_date = invoice.reconcile_effect_on
|
||||||
else:
|
else:
|
||||||
# For backwards compatibility
|
# For backwards compatibility
|
||||||
# Supporting reposting on payment entries reconciled before select field introduction
|
# Supporting reposting on payment entries reconciled before select field introduction
|
||||||
posting_date = get_reconciliation_effect_date(invoice, self.company, self.posting_date)
|
posting_date = get_reconciliation_effect_date(
|
||||||
|
invoice.reference_doctype, invoice.reference_name, self.company, self.posting_date
|
||||||
|
)
|
||||||
frappe.db.set_value("Payment Entry Reference", invoice.name, "reconcile_effect_on", posting_date)
|
frappe.db.set_value("Payment Entry Reference", invoice.name, "reconcile_effect_on", posting_date)
|
||||||
|
|
||||||
dr_or_cr, account = self.get_dr_and_account_for_advances(invoice)
|
dr_or_cr, account = self.get_dr_and_account_for_advances(invoice)
|
||||||
|
|||||||
@@ -1714,6 +1714,67 @@ class TestPaymentReconciliation(IntegrationTestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(len(pl_entries), 3)
|
self.assertEqual(len(pl_entries), 3)
|
||||||
|
|
||||||
|
def test_advance_payment_reconciliation_date_for_older_date(self):
|
||||||
|
old_settings = frappe.db.get_value(
|
||||||
|
"Company",
|
||||||
|
self.company,
|
||||||
|
[
|
||||||
|
"reconciliation_takes_effect_on",
|
||||||
|
"default_advance_paid_account",
|
||||||
|
"book_advance_payments_in_separate_party_account",
|
||||||
|
],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Company",
|
||||||
|
self.company,
|
||||||
|
{
|
||||||
|
"book_advance_payments_in_separate_party_account": 1,
|
||||||
|
"default_advance_paid_account": self.advance_payable_account,
|
||||||
|
"reconciliation_takes_effect_on": "Oldest Of Invoice Or Advance",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.supplier = "_Test Supplier"
|
||||||
|
|
||||||
|
pi1 = self.create_purchase_invoice(qty=10, rate=100)
|
||||||
|
po = self.create_purchase_order(qty=10, rate=100)
|
||||||
|
|
||||||
|
pay = get_payment_entry(po.doctype, po.name)
|
||||||
|
pay.paid_amount = 1000
|
||||||
|
pay.save().submit()
|
||||||
|
|
||||||
|
pr = frappe.new_doc("Payment Reconciliation")
|
||||||
|
pr.company = self.company
|
||||||
|
pr.party_type = "Supplier"
|
||||||
|
pr.party = self.supplier
|
||||||
|
pr.receivable_payable_account = get_party_account(pr.party_type, pr.party, pr.company)
|
||||||
|
pr.default_advance_account = self.advance_payable_account
|
||||||
|
pr.get_unreconciled_entries()
|
||||||
|
invoices = [x.as_dict() for x in pr.invoices]
|
||||||
|
payments = [x.as_dict() for x in pr.payments]
|
||||||
|
pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
|
||||||
|
pr.allocation[0].allocated_amount = 100
|
||||||
|
pr.reconcile()
|
||||||
|
|
||||||
|
pay.reload()
|
||||||
|
self.assertEqual(getdate(pay.references[0].reconcile_effect_on), getdate(pi1.posting_date))
|
||||||
|
|
||||||
|
# test setting of date if not available
|
||||||
|
frappe.db.set_value("Payment Entry Reference", pay.references[1].name, "reconcile_effect_on", None)
|
||||||
|
pay.reload()
|
||||||
|
pay.cancel()
|
||||||
|
|
||||||
|
pay.reload()
|
||||||
|
pi1.reload()
|
||||||
|
po.reload()
|
||||||
|
|
||||||
|
self.assertEqual(getdate(pay.references[0].reconcile_effect_on), getdate(pi1.posting_date))
|
||||||
|
pi1.cancel()
|
||||||
|
po.cancel()
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", self.company, old_settings)
|
||||||
|
|
||||||
def test_advance_payment_reconciliation_against_journal_for_customer(self):
|
def test_advance_payment_reconciliation_against_journal_for_customer(self):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Company",
|
"Company",
|
||||||
|
|||||||
@@ -733,7 +733,9 @@ def update_reference_in_payment_entry(
|
|||||||
|
|
||||||
# Update Reconciliation effect date in reference
|
# Update Reconciliation effect date in reference
|
||||||
if payment_entry.book_advance_payments_in_separate_party_account:
|
if payment_entry.book_advance_payments_in_separate_party_account:
|
||||||
reconcile_on = get_reconciliation_effect_date(d, payment_entry.company, payment_entry.posting_date)
|
reconcile_on = get_reconciliation_effect_date(
|
||||||
|
d.against_voucher_type, d.against_voucher, payment_entry.company, payment_entry.posting_date
|
||||||
|
)
|
||||||
reference_details.update({"reconcile_effect_on": reconcile_on})
|
reference_details.update({"reconcile_effect_on": reconcile_on})
|
||||||
|
|
||||||
if d.voucher_detail_no:
|
if d.voucher_detail_no:
|
||||||
@@ -788,20 +790,21 @@ def update_reference_in_payment_entry(
|
|||||||
return row, update_advance_paid
|
return row, update_advance_paid
|
||||||
|
|
||||||
|
|
||||||
def get_reconciliation_effect_date(reference, company, posting_date):
|
def get_reconciliation_effect_date(against_voucher_type, against_voucher, company, posting_date):
|
||||||
reconciliation_takes_effect_on = frappe.get_cached_value(
|
reconciliation_takes_effect_on = frappe.get_cached_value(
|
||||||
"Company", company, "reconciliation_takes_effect_on"
|
"Company", company, "reconciliation_takes_effect_on"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# default
|
||||||
|
reconcile_on = posting_date
|
||||||
|
|
||||||
if reconciliation_takes_effect_on == "Advance Payment Date":
|
if reconciliation_takes_effect_on == "Advance Payment Date":
|
||||||
reconcile_on = posting_date
|
reconcile_on = posting_date
|
||||||
elif reconciliation_takes_effect_on == "Oldest Of Invoice Or Advance":
|
elif reconciliation_takes_effect_on == "Oldest Of Invoice Or Advance":
|
||||||
date_field = "posting_date"
|
date_field = "posting_date"
|
||||||
if reference.against_voucher_type in ["Sales Order", "Purchase Order"]:
|
if against_voucher_type in ["Sales Order", "Purchase Order"]:
|
||||||
date_field = "transaction_date"
|
date_field = "transaction_date"
|
||||||
reconcile_on = frappe.db.get_value(
|
reconcile_on = frappe.db.get_value(against_voucher_type, against_voucher, date_field)
|
||||||
reference.against_voucher_type, reference.against_voucher, date_field
|
|
||||||
)
|
|
||||||
if getdate(reconcile_on) < getdate(posting_date):
|
if getdate(reconcile_on) < getdate(posting_date):
|
||||||
reconcile_on = posting_date
|
reconcile_on = posting_date
|
||||||
elif reconciliation_takes_effect_on == "Reconciliation Date":
|
elif reconciliation_takes_effect_on == "Reconciliation Date":
|
||||||
|
|||||||
Reference in New Issue
Block a user