mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-24 09:08:30 +00:00
fix: credit note receive payment entry
(cherry picked from commit 4015723591)
This commit is contained in:
@@ -33,6 +33,7 @@ from erpnext.accounts.utils import (
|
|||||||
get_account_currency,
|
get_account_currency,
|
||||||
get_balance_on,
|
get_balance_on,
|
||||||
get_outstanding_invoices,
|
get_outstanding_invoices,
|
||||||
|
get_party_types_from_account_type,
|
||||||
)
|
)
|
||||||
from erpnext.controllers.accounts_controller import (
|
from erpnext.controllers.accounts_controller import (
|
||||||
AccountsController,
|
AccountsController,
|
||||||
@@ -1071,10 +1072,24 @@ class PaymentEntry(AccountsController):
|
|||||||
against_voucher_type = d.reference_doctype
|
against_voucher_type = d.reference_doctype
|
||||||
against_voucher = d.reference_name
|
against_voucher = d.reference_name
|
||||||
|
|
||||||
|
reverse_dr_or_cr = 0
|
||||||
|
if d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
|
is_return = frappe.db.get_value(d.reference_doctype, d.reference_name, "is_return")
|
||||||
|
payable_party_types = get_party_types_from_account_type("Payable")
|
||||||
|
receivable_party_types = get_party_types_from_account_type("Receivable")
|
||||||
|
if is_return and self.party_type in receivable_party_types and self.payment_type == "Pay":
|
||||||
|
reverse_dr_or_cr = 1
|
||||||
|
elif is_return and self.party_type in payable_party_types and self.payment_type == "Receive":
|
||||||
|
reverse_dr_or_cr = 1
|
||||||
|
|
||||||
gle.update(
|
gle.update(
|
||||||
{
|
{
|
||||||
dr_or_cr: abs(allocated_amount_in_company_currency),
|
dr_or_cr: abs(allocated_amount_in_company_currency)
|
||||||
dr_or_cr + "_in_account_currency": abs(d.allocated_amount),
|
if reverse_dr_or_cr
|
||||||
|
else allocated_amount_in_company_currency,
|
||||||
|
dr_or_cr + "_in_account_currency": abs(d.allocated_amount)
|
||||||
|
if reverse_dr_or_cr
|
||||||
|
else d.allocated_amount,
|
||||||
"against_voucher_type": against_voucher_type,
|
"against_voucher_type": against_voucher_type,
|
||||||
"against_voucher": against_voucher,
|
"against_voucher": against_voucher,
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
|
|||||||
@@ -2040,3 +2040,7 @@ def create_gain_loss_journal(
|
|||||||
journal_entry.save()
|
journal_entry.save()
|
||||||
journal_entry.submit()
|
journal_entry.submit()
|
||||||
return journal_entry.name
|
return journal_entry.name
|
||||||
|
|
||||||
|
|
||||||
|
def get_party_types_from_account_type(account_type):
|
||||||
|
return frappe.db.get_list("Party Type", {"account_type": account_type}, pluck="name")
|
||||||
|
|||||||
Reference in New Issue
Block a user