refactor: only apply configuration on normal payments

patch to update default value

(cherry picked from commit b2c3da135e)

# Conflicts:
#	erpnext/controllers/accounts_controller.py
#	erpnext/patches.txt
This commit is contained in:
ruthra kumar
2025-01-23 14:10:15 +05:30
committed by Mergify
parent 5a62bd6e85
commit ef6e264887
3 changed files with 99 additions and 4 deletions

View File

@@ -270,6 +270,7 @@ class PaymentReconciliation(Document):
for payment in non_reconciled_payments:
row = self.append("payments", {})
row.update(payment)
row.is_advance = payment.book_advance_payments_in_separate_party_account
def get_invoice_entries(self):
# Fetch JVs, Sales and Purchase Invoices for 'invoices' to reconcile against
@@ -383,10 +384,11 @@ class PaymentReconciliation(Document):
res.difference_account = default_exchange_gain_loss_account
res.exchange_rate = inv.get("exchange_rate")
res.update({"gain_loss_posting_date": pay.get("posting_date")})
if exc_gain_loss_posting_date == "Invoice":
res.update({"gain_loss_posting_date": inv.get("invoice_date")})
elif exc_gain_loss_posting_date == "Reconciliation Date":
res.update({"gain_loss_posting_date": nowdate()})
if not pay.get("is_advance"):
if exc_gain_loss_posting_date == "Invoice":
res.update({"gain_loss_posting_date": inv.get("invoice_date")})
elif exc_gain_loss_posting_date == "Reconciliation Date":
res.update({"gain_loss_posting_date": nowdate()})
if pay.get("amount") == 0:
entries.append(res)

View File

@@ -2767,6 +2767,7 @@ def get_advance_payment_entries(
condition.append(pe.name.like(f"%%{payment_name}%%"))
if order_list or against_all_orders:
<<<<<<< HEAD
orders_condition = []
if order_list:
orders_condition.append(per.reference_name.isin(order_list))
@@ -2784,6 +2785,87 @@ def get_advance_payment_entries(
pe.posting_date,
pe[currency_field].as_("currency"),
pe[exchange_rate_field].as_("exchange_rate"),
=======
q = get_common_query(
party_type,
party,
party_account,
default_advance_account,
limit,
condition,
)
payment_ref = frappe.qb.DocType("Payment Entry Reference")
q = q.inner_join(payment_ref).on(payment_entry.name == payment_ref.parent)
q = q.select(
(payment_ref.allocated_amount).as_("amount"),
(payment_ref.name).as_("reference_row"),
(payment_ref.reference_name).as_("against_order"),
(payment_entry.book_advance_payments_in_separate_party_account),
)
q = q.where(payment_ref.reference_doctype == order_doctype)
if order_list:
q = q.where(payment_ref.reference_name.isin(order_list))
allocated = list(q.run(as_dict=True))
payment_entries += allocated
if include_unallocated:
q = get_common_query(
party_type,
party,
party_account,
default_advance_account,
limit,
condition,
)
q = q.select((payment_entry.unallocated_amount).as_("amount"))
q = q.where(payment_entry.unallocated_amount > 0)
unallocated = list(q.run(as_dict=True))
payment_entries += unallocated
return payment_entries
def get_common_query(
party_type,
party,
party_account,
default_advance_account,
limit,
condition,
):
account_type = frappe.db.get_value("Party Type", party_type, "account_type")
payment_type = "Receive" if account_type == "Receivable" else "Pay"
payment_entry = frappe.qb.DocType("Payment Entry")
q = (
frappe.qb.from_(payment_entry)
.select(
ConstantColumn("Payment Entry").as_("reference_type"),
(payment_entry.name).as_("reference_name"),
payment_entry.posting_date,
(payment_entry.remarks).as_("remarks"),
(payment_entry.book_advance_payments_in_separate_party_account),
)
.where(payment_entry.payment_type == payment_type)
.where(payment_entry.party_type == party_type)
.where(payment_entry.party == party)
.where(payment_entry.docstatus == 1)
)
field = "paid_from" if payment_type == "Receive" else "paid_to"
q = q.select((payment_entry[f"{field}_account_currency"]).as_("currency"))
q = q.select(payment_entry[field])
account_condition = payment_entry[field].isin(party_account)
if default_advance_account:
q = q.where(
account_condition
| (
(payment_entry[field] == default_advance_account)
& (payment_entry.book_advance_payments_in_separate_party_account == 1)
>>>>>>> b2c3da135e (refactor: only apply configuration on normal payments)
)
.where(
(pe[party_account_field] == party_account)

View File

@@ -368,5 +368,16 @@ erpnext.patches.v14_0.remove_cancelled_asset_capitalization_from_asset
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter
erpnext.patches.v14_0.update_stock_uom_in_work_order_item
<<<<<<< HEAD
erpnext.patches.v14_0.disable_add_row_in_gross_profit
=======
erpnext.patches.v15_0.enable_allow_existing_serial_no
erpnext.patches.v15_0.update_cc_in_process_statement_of_accounts
erpnext.patches.v15_0.refactor_closing_stock_balance #5
erpnext.patches.v15_0.update_asset_status_to_work_in_progress
erpnext.patches.v15_0.rename_manufacturing_settings_field
erpnext.patches.v15_0.migrate_checkbox_to_select_for_reconciliation_effect
erpnext.patches.v15_0.sync_auto_reconcile_config
execute:frappe.db.set_single_value("Accounts Settings", "exchange_gain_loss_posting_date", "Payment")
>>>>>>> b2c3da135e (refactor: only apply configuration on normal payments)