mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 08:05:00 +00:00
fix: add patch to update base_outstanding and base_paid_amount
This commit is contained in:
@@ -408,3 +408,4 @@ erpnext.patches.v15_0.rename_sla_fields
|
||||
erpnext.stock.doctype.stock_ledger_entry.patches.ensure_sle_indexes
|
||||
erpnext.patches.v15_0.update_query_report
|
||||
erpnext.patches.v15_0.set_purchase_receipt_row_item_to_capitalization_stock_item
|
||||
erpnext.patches.v15_0.update_payment_schedule_fields_in_invoices
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import frappe
|
||||
from frappe.query_builder import DocType
|
||||
|
||||
|
||||
def execute():
|
||||
invoice_types = ["Sales Invoice", "Purchase Invoice"]
|
||||
for invoice_type in invoice_types:
|
||||
invoice = DocType(invoice_type)
|
||||
invoice_details = frappe.qb.from_(invoice).select(invoice.conversion_rate, invoice.name)
|
||||
update_payment_schedule(invoice_details)
|
||||
|
||||
|
||||
def update_payment_schedule(invoice_details):
|
||||
ps = DocType("Payment Schedule")
|
||||
|
||||
frappe.qb.update(ps).join(invoice_details).on(ps.parent == invoice_details.name).set(
|
||||
ps.base_paid_amount, ps.paid_amount * invoice_details.conversion_rate
|
||||
).set(ps.base_outstanding, ps.outstanding * invoice_details.conversion_rate).run()
|
||||
Reference in New Issue
Block a user