added patches and field modifcations
This commit is contained in:
parent
f668698c25
commit
e08e6306df
5 changed files with 54 additions and 33 deletions
|
|
@ -2,6 +2,10 @@ import frappe
|
|||
|
||||
|
||||
def execute():
|
||||
update_supplier_invoices()
|
||||
|
||||
|
||||
def update_supplier_invoices():
|
||||
suppliers = frappe.get_list("Supplier", pluck="name")
|
||||
|
||||
for supplier in suppliers:
|
||||
|
|
@ -19,3 +23,13 @@ def execute():
|
|||
supplier_doc.save()
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
def update_invoice_status():
|
||||
invoices = frappe.get_list("Invoices", pluck="name")
|
||||
|
||||
for invoice in invoices:
|
||||
invoice_doc = frappe.get_doc("Invoices", invoice)
|
||||
invoice_doc.update_status()
|
||||
|
||||
frappe.db.commit()
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
{
|
||||
"fieldname": "payment_reference_number",
|
||||
"fieldtype": "Data",
|
||||
"label": "Payment Reference Number"
|
||||
"label": "Reference Number"
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_reference_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Payment Reference Date"
|
||||
"label": "Payment Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_nukw",
|
||||
|
|
@ -29,13 +29,13 @@
|
|||
{
|
||||
"fieldname": "paid_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Paid Amount"
|
||||
"label": "Amount"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-10-09 16:29:15.297375",
|
||||
"modified": "2024-10-12 07:16:26.416034",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Invoice Payment References",
|
||||
|
|
|
|||
|
|
@ -21,10 +21,9 @@
|
|||
"payment_references",
|
||||
"section_break_ajbe",
|
||||
"paid_amount",
|
||||
"amount_due",
|
||||
"total_amount",
|
||||
"column_break_quxe",
|
||||
"payment_reference_no",
|
||||
"payment_reference_date",
|
||||
"section_break_olmx",
|
||||
"service_address",
|
||||
"site_code",
|
||||
|
|
@ -79,7 +78,7 @@
|
|||
"fieldtype": "Select",
|
||||
"hidden": 1,
|
||||
"label": "Status",
|
||||
"options": "Paid\nUnpaid\nOverdue\nPartially Paid"
|
||||
"options": "Paid\nUnpaid\nOverdue\nPartially Paid\nPartially Paid and Overdue"
|
||||
},
|
||||
{
|
||||
"fieldname": "service_date",
|
||||
|
|
@ -121,16 +120,6 @@
|
|||
"label": "Total Amount",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_reference_no",
|
||||
"fieldtype": "Data",
|
||||
"label": "Payment Reference No."
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_reference_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Payment Reference Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_quxe",
|
||||
"fieldtype": "Column Break"
|
||||
|
|
@ -191,11 +180,17 @@
|
|||
"fieldtype": "Currency",
|
||||
"label": "Paid Amount",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amount_due",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Amount Due",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-10-09 18:12:49.160847",
|
||||
"modified": "2024-10-12 08:12:37.273898",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Invoices",
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class Invoices(Document):
|
|||
self.set_total_amount()
|
||||
self.set_due_date()
|
||||
self.set_total_paid()
|
||||
self.update_amount_due()
|
||||
self.update_status()
|
||||
|
||||
def on_update(self):
|
||||
|
|
@ -44,20 +45,23 @@ class Invoices(Document):
|
|||
self.db_set("paid_amount", total_paid)
|
||||
|
||||
def update_status(self):
|
||||
if (
|
||||
self.payment_reference_no and self.payment_reference_date
|
||||
) or self.paid_amount == self.total_amount:
|
||||
self.status = "Paid"
|
||||
elif self.paid_amount != self.total_amount and nowdate() > self.due_date:
|
||||
self.status = "Overdue"
|
||||
else:
|
||||
if self.paid_amount == 0:
|
||||
self.status = "Unpaid"
|
||||
|
||||
if self.paid_amount != self.total_amount and self.status not in (
|
||||
"Paid",
|
||||
"Overdue",
|
||||
):
|
||||
elif self.paid_amount < self.total_amount and self.paid_amount > 0:
|
||||
self.status = "Partially Paid"
|
||||
elif self.paid_amount == self.total_amount:
|
||||
self.status = "Paid"
|
||||
|
||||
if getdate(nowdate()) > getdate(self.due_date):
|
||||
if self.paid_amount == 0:
|
||||
self.status = "Overdue"
|
||||
elif self.paid_amount < self.total_amount:
|
||||
self.status = "Partially Paid and Overdue"
|
||||
|
||||
self.db_set("status", self.status, update_modified=False, commit=True)
|
||||
|
||||
def update_amount_due(self):
|
||||
self.amount_due = self.total_amount - self.paid_amount
|
||||
|
||||
def update_suppliers_invoice(self):
|
||||
supplier = frappe.get_doc("Supplier", self.supplier)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"app": "suppliers_portal",
|
||||
"app": "supplier_portal",
|
||||
"charts": [],
|
||||
"content": "[{\"id\":\"AyiOTTupgl\",\"type\":\"paragraph\",\"data\":{\"text\":\"Documents\",\"col\":12}},{\"id\":\"64VHemT3p8\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Suppliers\",\"col\":4}},{\"id\":\"_vl927eRbo\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Invoices\",\"col\":4}},{\"id\":\"j428xL5Lje\",\"type\":\"paragraph\",\"data\":{\"text\":\"Reports\",\"col\":12}},{\"id\":\"CDzGMPClRq\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Supplier Invoices Report\",\"col\":4}}]",
|
||||
"creation": "2024-10-02 17:23:06.804441",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"is_hidden": 0,
|
||||
"label": "Supplier Portal",
|
||||
"links": [],
|
||||
"modified": "2024-10-09 15:49:04.735953",
|
||||
"modified": "2024-10-12 07:25:56.798875",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Supplier Portal",
|
||||
|
|
@ -23,7 +23,15 @@
|
|||
"parent_page": "",
|
||||
"public": 1,
|
||||
"quick_lists": [],
|
||||
"roles": [],
|
||||
"restrict_to_domain": "",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Portal Supplier"
|
||||
},
|
||||
{
|
||||
"role": "Portal User"
|
||||
}
|
||||
],
|
||||
"sequence_id": 2.0,
|
||||
"shortcuts": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue