mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
fixup! feat(payment): add advance payment status to advance payment doctypes to better track advance payments
This commit is contained in:
@@ -1272,7 +1272,6 @@
|
|||||||
"show_dashboard": 1
|
"show_dashboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "Not Initiated",
|
|
||||||
"fieldname": "advance_payment_status",
|
"fieldname": "advance_payment_status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
|||||||
@@ -344,5 +344,6 @@ erpnext.patches.v15_0.delete_woocommerce_settings_doctype
|
|||||||
erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults
|
erpnext.patches.v14_0.migrate_deferred_accounts_to_item_defaults
|
||||||
erpnext.patches.v14_0.update_invoicing_period_in_subscription
|
erpnext.patches.v14_0.update_invoicing_period_in_subscription
|
||||||
execute:frappe.delete_doc("Page", "welcome-to-erpnext")
|
execute:frappe.delete_doc("Page", "welcome-to-erpnext")
|
||||||
|
erpnext.patches.v15_0.create_advance_payment_status
|
||||||
# below migration patch should always run last
|
# below migration patch should always run last
|
||||||
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
||||||
|
|||||||
54
erpnext/patches/v15_0/create_advance_payment_status.py
Normal file
54
erpnext/patches/v15_0/create_advance_payment_status.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
Description:
|
||||||
|
Calculate the new Advance Payment Statuse column in SO & PO
|
||||||
|
"""
|
||||||
|
|
||||||
|
if frappe.reload_doc("selling", "doctype", "Sales Order"):
|
||||||
|
so = frappe.qb.DocType("Sales Order")
|
||||||
|
frappe.qb.update(so).set(so.advance_payment_status, "Not Requested").where(
|
||||||
|
so.docstatus == 1
|
||||||
|
).where(so.advance_paid == 0.0).run()
|
||||||
|
|
||||||
|
frappe.qb.update(so).set(so.advance_payment_status, "Partially Paid").where(
|
||||||
|
so.docstatus == 1
|
||||||
|
).where(so.advance_payment_status.isnull()).where(
|
||||||
|
so.advance_paid < (so.rounded_total or so.grand_total)
|
||||||
|
).run()
|
||||||
|
|
||||||
|
frappe.qb.update(so).set(so.advance_payment_status, "Paid").where(so.docstatus == 1).where(
|
||||||
|
so.advance_payment_status.isnull()
|
||||||
|
).where(so.advance_paid == (so.rounded_total or so.grand_total)).run()
|
||||||
|
|
||||||
|
pr = frappe.qb.DocType("Payment Request")
|
||||||
|
frappe.qb.update(so).join(pr).on(so.name == pr.reference_name).set(
|
||||||
|
so.advance_payment_status, "Requested"
|
||||||
|
).where(so.docstatus == 1).where(pr.docstatus == 1).where(
|
||||||
|
so.advance_payment_status == "Not Requested"
|
||||||
|
).run()
|
||||||
|
|
||||||
|
if frappe.reload_doc("buying", "doctype", "Purchase Order"):
|
||||||
|
po = frappe.qb.DocType("Purchase Order")
|
||||||
|
frappe.qb.update(po).set(po.advance_payment_status, "Not Initiated").where(
|
||||||
|
po.docstatus == 1
|
||||||
|
).where(po.advance_paid == 0.0).run()
|
||||||
|
|
||||||
|
frappe.qb.update(po).set(po.advance_payment_status, "Partially Paid").where(
|
||||||
|
po.docstatus == 1
|
||||||
|
).where(po.advance_payment_status.isnull()).where(
|
||||||
|
po.advance_paid < (po.rounded_total or po.grand_total)
|
||||||
|
).run()
|
||||||
|
|
||||||
|
frappe.qb.update(po).set(po.advance_payment_status, "Paid").where(po.docstatus == 1).where(
|
||||||
|
po.advance_payment_status.isnull()
|
||||||
|
).where(po.advance_paid == (po.rounded_total or po.grand_total)).run()
|
||||||
|
|
||||||
|
pr = frappe.qb.DocType("Payment Request")
|
||||||
|
frappe.qb.update(po).join(pr).on(po.name == pr.reference_name).set(
|
||||||
|
po.advance_payment_status, "Initiated"
|
||||||
|
).where(po.docstatus == 1).where(pr.docstatus == 1).where(
|
||||||
|
po.advance_payment_status == "Not Initiated"
|
||||||
|
).run()
|
||||||
@@ -1642,7 +1642,6 @@
|
|||||||
"report_hide": 1
|
"report_hide": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "Not Requested",
|
|
||||||
"fieldname": "advance_payment_status",
|
"fieldname": "advance_payment_status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user