fix: changed account types in controller method
This commit is contained in:
parent
17341adf1c
commit
ba4ab06ae3
@ -99,11 +99,11 @@ class PaymentEntry(AccountsController):
|
|||||||
)
|
)
|
||||||
if not book_advance_payments_as_liability:
|
if not book_advance_payments_as_liability:
|
||||||
return
|
return
|
||||||
root_type = frappe.get_value(
|
account_type = frappe.get_value(
|
||||||
"Account", {"name": self.party_account, "company": self.company}, "root_type"
|
"Account", {"name": self.party_account, "company": self.company}, "account_type"
|
||||||
)
|
)
|
||||||
if (root_type == "Liability" and self.party_type == "Customer") or (
|
if (account_type == "Payable" and self.party_type == "Customer") or (
|
||||||
root_type == "Asset" and self.party_type == "Supplier"
|
account_type == "Receivable" and self.party_type == "Supplier"
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
if self.unallocated_amount == 0:
|
if self.unallocated_amount == 0:
|
||||||
@ -908,6 +908,8 @@ class PaymentEntry(AccountsController):
|
|||||||
},
|
},
|
||||||
item=self,
|
item=self,
|
||||||
)
|
)
|
||||||
|
is_advance = self.get_advance_flag()
|
||||||
|
|
||||||
for d in self.get("references"):
|
for d in self.get("references"):
|
||||||
gle = party_dict.copy()
|
gle = party_dict.copy()
|
||||||
book_advance_payments_as_liability = frappe.get_value(
|
book_advance_payments_as_liability = frappe.get_value(
|
||||||
@ -916,13 +918,14 @@ class PaymentEntry(AccountsController):
|
|||||||
if (
|
if (
|
||||||
d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]
|
d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]
|
||||||
and book_advance_payments_as_liability
|
and book_advance_payments_as_liability
|
||||||
|
and is_advance
|
||||||
):
|
):
|
||||||
if not is_reconcile:
|
if not is_reconcile:
|
||||||
self.make_invoice_liability_entry(gl_entries, d)
|
self.make_invoice_liability_entry(gl_entries, d)
|
||||||
gle.update(
|
gle.update(
|
||||||
{
|
{
|
||||||
"against_voucher_type": "Payment Entry",
|
"voucher_type": "Payment Entry",
|
||||||
"against_voucher": self.name,
|
"voucher_no": self.name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -940,7 +943,6 @@ class PaymentEntry(AccountsController):
|
|||||||
"against_voucher": d.reference_name,
|
"against_voucher": d.reference_name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
gl_entries.append(gle)
|
gl_entries.append(gle)
|
||||||
|
|
||||||
if self.unallocated_amount:
|
if self.unallocated_amount:
|
||||||
@ -952,13 +954,19 @@ 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,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
gl_entries.append(gle)
|
gl_entries.append(gle)
|
||||||
|
|
||||||
|
def get_advance_flag(self):
|
||||||
|
for d in self.get("references"):
|
||||||
|
if d.reference_doctype == "Sales Order":
|
||||||
|
return True
|
||||||
|
if self.unallocated_amount > 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def make_invoice_liability_entry(self, gl_entries, invoice):
|
def make_invoice_liability_entry(self, gl_entries, invoice):
|
||||||
args_dict = {
|
args_dict = {
|
||||||
"party_type": self.party_type,
|
"party_type": self.party_type,
|
||||||
@ -967,8 +975,6 @@ class PaymentEntry(AccountsController):
|
|||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
"voucher_type": invoice.reference_doctype,
|
"voucher_type": invoice.reference_doctype,
|
||||||
"voucher_no": invoice.reference_name,
|
"voucher_no": invoice.reference_name,
|
||||||
"against_voucher_type": invoice.reference_doctype,
|
|
||||||
"against_voucher": invoice.reference_name,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit"
|
dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit"
|
||||||
@ -987,6 +993,12 @@ class PaymentEntry(AccountsController):
|
|||||||
args_dict["account"] = self.party_account
|
args_dict["account"] = self.party_account
|
||||||
args_dict[dr_or_cr] = invoice.allocated_amount
|
args_dict[dr_or_cr] = invoice.allocated_amount
|
||||||
args_dict[dr_or_cr + "_in_account_currency"] = invoice.allocated_amount
|
args_dict[dr_or_cr + "_in_account_currency"] = invoice.allocated_amount
|
||||||
|
args_dict.update(
|
||||||
|
{
|
||||||
|
"against_voucher_type": "Payment Entry",
|
||||||
|
"against_voucher": self.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
gle = self.get_gl_dict(
|
gle = self.get_gl_dict(
|
||||||
args_dict,
|
args_dict,
|
||||||
item=self,
|
item=self,
|
||||||
|
@ -436,7 +436,9 @@ def add_cc(args=None):
|
|||||||
return cc.name
|
return cc.name
|
||||||
|
|
||||||
|
|
||||||
def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # nosemgrep
|
def reconcile_against_document(
|
||||||
|
args, skip_ref_details_update_for_pe=False, is_reconcile=False
|
||||||
|
): # nosemgrep
|
||||||
"""
|
"""
|
||||||
Cancel PE or JV, Update against document, split if required and resubmit
|
Cancel PE or JV, Update against document, split if required and resubmit
|
||||||
"""
|
"""
|
||||||
@ -472,7 +474,7 @@ def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # n
|
|||||||
doc.save(ignore_permissions=True)
|
doc.save(ignore_permissions=True)
|
||||||
# re-submit advance entry
|
# re-submit advance entry
|
||||||
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
|
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
|
||||||
gl_map = doc.build_gl_map(is_reconcile=True)
|
gl_map = doc.build_gl_map(is_reconcile)
|
||||||
create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1)
|
create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1)
|
||||||
|
|
||||||
# Only update outstanding for newly linked vouchers
|
# Only update outstanding for newly linked vouchers
|
||||||
|
@ -1078,7 +1078,7 @@ class AccountsController(TransactionBase):
|
|||||||
if lst:
|
if lst:
|
||||||
from erpnext.accounts.utils import reconcile_against_document
|
from erpnext.accounts.utils import reconcile_against_document
|
||||||
|
|
||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst, is_reconcile=True)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user