fix: update outstanding amount and unpaid status on cancellation of payment entry
This commit is contained in:
parent
033e4e84f5
commit
442e3f2aa2
@ -872,7 +872,7 @@ class PaymentEntry(AccountsController):
|
||||
|
||||
self.set("remarks", "\n".join(remarks))
|
||||
|
||||
def build_gl_map(self, is_reconcile=False):
|
||||
def build_gl_map(self, is_reconcile=True):
|
||||
if self.payment_type in ("Receive", "Pay") and not self.get("party_account_field"):
|
||||
self.setup_party_account_field()
|
||||
|
||||
@ -918,16 +918,15 @@ class PaymentEntry(AccountsController):
|
||||
if (
|
||||
d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]
|
||||
and book_advance_payments_as_liability
|
||||
and is_advance
|
||||
and (is_advance or is_reconcile)
|
||||
):
|
||||
if not is_reconcile:
|
||||
self.make_invoice_liability_entry(gl_entries, d)
|
||||
gle.update(
|
||||
{
|
||||
"against_voucher_type": "Payment Entry",
|
||||
"against_voucher": self.name,
|
||||
}
|
||||
)
|
||||
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)
|
||||
gle.update(
|
||||
@ -939,8 +938,8 @@ class PaymentEntry(AccountsController):
|
||||
if not gle.get("against_voucher_type"):
|
||||
gle.update(
|
||||
{
|
||||
"against_voucher_type": d.reference_doctype,
|
||||
"against_voucher": d.reference_name,
|
||||
"against_voucher_type": d.reference_doctype if is_advance else "Payment Entry",
|
||||
"against_voucher": d.reference_name if is_advance else self.name,
|
||||
}
|
||||
)
|
||||
gl_entries.append(gle)
|
||||
@ -954,6 +953,8 @@ class PaymentEntry(AccountsController):
|
||||
{
|
||||
dr_or_cr + "_in_account_currency": self.unallocated_amount,
|
||||
dr_or_cr: base_unallocated_amount,
|
||||
"against_voucher_type": "Payment Entry",
|
||||
"against_voucher": self.name,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -223,6 +223,7 @@ def check_if_in_list(gle, gl_map, dimensions=None):
|
||||
"party_type",
|
||||
"project",
|
||||
"finance_book",
|
||||
"voucher_no",
|
||||
]
|
||||
|
||||
if dimensions:
|
||||
|
@ -437,7 +437,7 @@ def add_cc(args=None):
|
||||
|
||||
|
||||
def reconcile_against_document(
|
||||
args, skip_ref_details_update_for_pe=False, is_reconcile=False
|
||||
args, skip_ref_details_update_for_pe=False, is_reconcile=True
|
||||
): # nosemgrep
|
||||
"""
|
||||
Cancel PE or JV, Update against document, split if required and resubmit
|
||||
|
@ -1021,7 +1021,7 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
)
|
||||
|
||||
def update_against_document_in_jv(self):
|
||||
def update_against_document_in_jv(self, is_reconcile=True):
|
||||
"""
|
||||
Links invoice and advance voucher:
|
||||
1. cancel advance voucher
|
||||
@ -1078,7 +1078,7 @@ class AccountsController(TransactionBase):
|
||||
if lst:
|
||||
from erpnext.accounts.utils import reconcile_against_document
|
||||
|
||||
reconcile_against_document(lst, is_reconcile=True)
|
||||
reconcile_against_document(lst, is_reconcile)
|
||||
|
||||
def on_cancel(self):
|
||||
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
||||
@ -2919,7 +2919,6 @@ def make_advance_liability_entry(
|
||||
rev = "credit"
|
||||
against = invoice.debit_to
|
||||
party = invoice.customer
|
||||
voucher_type = "Sales Invoice"
|
||||
else:
|
||||
invoice = frappe.get_doc("Purchase Invoice", invoice)
|
||||
account = pe.paid_to
|
||||
@ -2927,9 +2926,8 @@ def make_advance_liability_entry(
|
||||
rev = "debit"
|
||||
against = invoice.credit_to
|
||||
party = invoice.supplier
|
||||
voucher_type = "Purchase Invoice"
|
||||
gl_entries.append(
|
||||
invoice.get_gl_dict(
|
||||
pe.get_gl_dict(
|
||||
{
|
||||
"account": account,
|
||||
"party_type": party_type,
|
||||
@ -2940,42 +2938,35 @@ def make_advance_liability_entry(
|
||||
dr_or_cr + "_in_account_currency": allocated_amount,
|
||||
rev: 0,
|
||||
rev + "_in_account_currency": 0,
|
||||
"against_voucher": pe.name,
|
||||
"against_voucher_type": "Payment Entry",
|
||||
"cost_center": invoice.cost_center,
|
||||
"project": invoice.project,
|
||||
"voucher_type": voucher_type,
|
||||
"voucher_no": invoice.name,
|
||||
"against_voucher_type": "Payment Entry",
|
||||
"against_voucher": pe.name,
|
||||
},
|
||||
invoice.party_account_currency,
|
||||
item=invoice,
|
||||
item=pe,
|
||||
)
|
||||
)
|
||||
|
||||
(dr_or_cr, rev) = ("credit", "debit") if party_type == "Customer" else ("debit", "credit")
|
||||
gl_entries.append(
|
||||
invoice.get_gl_dict(
|
||||
pe.get_gl_dict(
|
||||
{
|
||||
"account": against,
|
||||
"party_type": party_type,
|
||||
"party": party,
|
||||
"due_date": invoice.due_date,
|
||||
"against": account,
|
||||
dr_or_cr: allocated_amount,
|
||||
dr_or_cr + "_in_account_currency": allocated_amount,
|
||||
rev: 0,
|
||||
rev + "_in_account_currency": 0,
|
||||
"against_voucher": invoice.return_against
|
||||
if cint(invoice.is_return) and invoice.return_against
|
||||
else invoice.name,
|
||||
"against_voucher_type": invoice.doctype,
|
||||
"cost_center": invoice.cost_center,
|
||||
"project": invoice.project,
|
||||
"voucher_type": "Payment Entry" if references else voucher_type,
|
||||
"voucher_no": pe.name if references else invoice.name,
|
||||
"against_voucher_type": invoice.doctype,
|
||||
"against_voucher": invoice.name,
|
||||
},
|
||||
invoice.party_account_currency,
|
||||
item=invoice,
|
||||
item=pe,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -72,9 +72,9 @@
|
||||
"default_finance_book",
|
||||
"advance_payments_section",
|
||||
"book_advance_payments_as_liability",
|
||||
"column_break_fwcf",
|
||||
"default_advance_received_account",
|
||||
"default_advance_paid_account",
|
||||
"column_break_cui0",
|
||||
"auto_accounting_for_stock_settings",
|
||||
"enable_perpetual_inventory",
|
||||
"enable_provisional_accounting_for_non_stock_items",
|
||||
@ -702,19 +702,16 @@
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "Enabling this option will allow you to record - <br><br> 1. Advances Received in a <b>Liability Account</b> instead of the <b>Receivable Account</b><br><br>2. Advances Paid in an <b>Asset Account</b> instead of the <b> Payable Account</b>",
|
||||
"fieldname": "book_advance_payments_as_liability",
|
||||
"fieldtype": "Check",
|
||||
"label": "Book Advance Payments as Liability"
|
||||
"label": "Book Advance Payments in Separate Party Account"
|
||||
},
|
||||
{
|
||||
"fieldname": "advance_payments_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Advance Payments"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_cui0",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.book_advance_payments_as_liability",
|
||||
"fieldname": "default_advance_received_account",
|
||||
@ -730,6 +727,10 @@
|
||||
"label": "Default Advance Paid Account",
|
||||
"mandatory_depends_on": "book_advance_payments_as_liability",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_fwcf",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-building",
|
||||
@ -737,7 +738,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2023-06-12 12:51:12.007410",
|
||||
"modified": "2023-06-16 13:32:48.790947",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
Loading…
x
Reference in New Issue
Block a user