feat(payment): add advance payment status to advance payment doctypes to better track advance payments

This commit is contained in:
David Arnold 2023-10-10 20:40:50 +02:00
parent b495e5a5a1
commit c809e61103
No known key found for this signature in database
GPG Key ID: AB15A6AF1101390D
6 changed files with 54 additions and 4 deletions

View File

@ -115,6 +115,17 @@ class PaymentRequest(Document):
elif self.payment_channel == "Phone":
self.request_phone_payment()
if (
self.reference_doctype in ["Sales Order"] and ref_doc.advance_payment_status == "Not Requested"
):
ref_doc.db_set("advance_payment_status", "Requested")
if (
self.reference_doctype in ["Purchase Order"]
and ref_doc.advance_payment_status == "Not Initiated"
):
ref_doc.db_set("advance_payment_status", "Initiated")
def request_phone_payment(self):
controller = _get_payment_gateway_controller(self.payment_gateway)
request_amount = self.get_request_amount()

View File

@ -134,6 +134,7 @@
"more_info_tab",
"tracking_section",
"status",
"advance_payment_status",
"column_break_75",
"per_billed",
"per_received",
@ -1269,13 +1270,26 @@
"fieldtype": "Tab Break",
"label": "Connections",
"show_dashboard": 1
},
{
"default": "Not Initiated",
"fieldname": "advance_payment_status",
"fieldtype": "Select",
"hidden": 1,
"in_standard_filter": 1,
"label": "Advance Payment Status",
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
"options": "Not Initiated\nInitiated\nPartially Paid\nPaid",
"print_hide": 1
}
],
"icon": "fa fa-file-text",
"idx": 105,
"is_submittable": 1,
"links": [],
"modified": "2023-10-01 20:58:07.851037",
"modified": "2023-10-10 13:37:40.158761",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
@ -1330,4 +1344,4 @@
"timeline_field": "supplier",
"title_field": "supplier_name",
"track_changes": 1
}
}

View File

@ -349,6 +349,9 @@ class PurchaseOrder(BuyingController):
self.validate_budget()
self.update_reserved_qty_for_subcontract()
if not self.advance_payment_status:
self.advance_payment_status = "Not Initiated"
frappe.get_doc("Authorization Control").validate_approving_authority(
self.doctype, self.company, self.base_grand_total
)

View File

@ -1689,6 +1689,12 @@ class AccountsController(TransactionBase):
)
frappe.db.set_value(self.doctype, self.name, "advance_paid", advance_paid)
frappe.db.set_value(
self.doctype,
self.name,
"advance_payment_status",
"Partially Paid" if advance_paid < order_total else "Paid",
)
@property
def company_abbr(self):

View File

@ -131,6 +131,7 @@
"per_billed",
"per_picked",
"billing_status",
"advance_payment_status",
"sales_team_section_break",
"sales_partner",
"column_break7",
@ -1639,13 +1640,26 @@
"no_copy": 1,
"print_hide": 1,
"report_hide": 1
},
{
"default": "Not Requested",
"fieldname": "advance_payment_status",
"fieldtype": "Select",
"hidden": 1,
"hide_days": 1,
"hide_seconds": 1,
"in_standard_filter": 1,
"label": "Advance Payment Status",
"no_copy": 1,
"options": "Not Requested\nRequested\nPartially Paid\nPaid",
"print_hide": 1
}
],
"icon": "fa fa-file-text",
"idx": 105,
"is_submittable": 1,
"links": [],
"modified": "2023-07-24 08:59:11.599875",
"modified": "2023-10-10 13:36:07.526793",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
@ -1723,4 +1737,4 @@
"title_field": "customer_name",
"track_changes": 1,
"track_seen": 1
}
}

View File

@ -88,6 +88,8 @@ class SalesOrder(SellingController):
self.billing_status = "Not Billed"
if not self.delivery_status:
self.delivery_status = "Not Delivered"
if not self.advance_payment_status:
self.advance_payment_status = "Not Requested"
self.reset_default_field_value("set_warehouse", "items", "warehouse")