oct 10 tasks update
This commit is contained in:
parent
77b2f66190
commit
491dc2be9d
17 changed files with 421 additions and 12 deletions
|
|
@ -193,6 +193,19 @@
|
|||
data-bs-parent="#service-address-accordion"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="row mb-1">
|
||||
<label for="site_code" class="col-sm-3 col-form-label"
|
||||
>Site Code</label
|
||||
>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="site_code"
|
||||
v-model="invoiceData.site_code"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label for="street" class="col-sm-3 col-form-label"
|
||||
>Street</label
|
||||
|
|
@ -505,6 +518,7 @@ const invoiceData = reactive({
|
|||
supplier_name: sessionSupplierName(),
|
||||
invoice_terms: '',
|
||||
total_amount: 0,
|
||||
site_code: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
|
|
@ -554,6 +568,7 @@ const saveInvoice = () => {
|
|||
invoice_date: invoiceData.invoice_date,
|
||||
supplier_name: invoiceData.supplier_name,
|
||||
invoice_terms: invoiceData.invoice_terms,
|
||||
site_code: invoiceData.site_code,
|
||||
street: invoiceData.street,
|
||||
city: invoiceData.city,
|
||||
state: invoiceData.state,
|
||||
|
|
|
|||
|
|
@ -161,6 +161,20 @@
|
|||
data-bs-parent="#service-address-accordion"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="row mb-1">
|
||||
<label for="site_code" class="col-sm-3 col-form-label"
|
||||
>Sitee Code</label
|
||||
>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="text"
|
||||
readonly
|
||||
class="form-control-plaintext"
|
||||
id="site_code"
|
||||
:value="invoice.doc.site_code"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label for="street" class="col-sm-3 col-form-label"
|
||||
>Street</label
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2024-10-09 16:28:25.879209",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"payment_reference_number",
|
||||
"payment_reference_date",
|
||||
"column_break_nukw",
|
||||
"paid_amount"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "payment_reference_number",
|
||||
"fieldtype": "Data",
|
||||
"label": "Payment Reference Number"
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_reference_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Payment Reference Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_nukw",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "paid_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Paid Amount"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-10-09 16:29:15.297375",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Invoice Payment References",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2024, jeowsome15@gmail.com and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class InvoicePaymentReferences(Document):
|
||||
pass
|
||||
|
|
@ -17,13 +17,17 @@
|
|||
"status",
|
||||
"section_break_swkm",
|
||||
"supplier_invoice_items",
|
||||
"section_break_slsq",
|
||||
"payment_references",
|
||||
"section_break_ajbe",
|
||||
"paid_amount",
|
||||
"total_amount",
|
||||
"column_break_quxe",
|
||||
"payment_reference_no",
|
||||
"payment_reference_date",
|
||||
"section_break_olmx",
|
||||
"service_address",
|
||||
"site_code",
|
||||
"street",
|
||||
"city",
|
||||
"state",
|
||||
|
|
@ -35,7 +39,7 @@
|
|||
{
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"label": "Supplier ID",
|
||||
"label": "Supplier",
|
||||
"options": "Supplier"
|
||||
},
|
||||
{
|
||||
|
|
@ -75,7 +79,7 @@
|
|||
"fieldtype": "Select",
|
||||
"hidden": 1,
|
||||
"label": "Status",
|
||||
"options": "Paid\nUnpaid\nOverdue"
|
||||
"options": "Paid\nUnpaid\nOverdue\nPartially Paid"
|
||||
},
|
||||
{
|
||||
"fieldname": "service_date",
|
||||
|
|
@ -97,7 +101,9 @@
|
|||
"fetch_from": "supplier.company_name",
|
||||
"fieldname": "supplier_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Supplier Name"
|
||||
"hidden": 1,
|
||||
"label": "Supplier Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "service_address",
|
||||
|
|
@ -122,7 +128,7 @@
|
|||
},
|
||||
{
|
||||
"fieldname": "payment_reference_date",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Date",
|
||||
"label": "Payment Reference Date"
|
||||
},
|
||||
{
|
||||
|
|
@ -164,11 +170,32 @@
|
|||
"fieldname": "due_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Due Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "site_code",
|
||||
"fieldtype": "Data",
|
||||
"label": "Site Code"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_slsq",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_references",
|
||||
"fieldtype": "Table",
|
||||
"label": "Payment References",
|
||||
"options": "Invoice Payment References"
|
||||
},
|
||||
{
|
||||
"fieldname": "paid_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Paid Amount",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-10-05 02:26:32.725807",
|
||||
"modified": "2024-10-09 18:12:49.160847",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Invoices",
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
# Copyright (c) 2024, jeowsome15@gmail.com and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import add_days, flt, nowdate
|
||||
from frappe.utils import add_days, flt, getdate, nowdate
|
||||
|
||||
|
||||
class Invoices(Document):
|
||||
def validate(self):
|
||||
self.set_total_amount()
|
||||
self.set_due_date()
|
||||
self.set_total_paid()
|
||||
self.update_status()
|
||||
|
||||
def on_update(self):
|
||||
self.update_suppliers_invoice()
|
||||
|
||||
def set_total_amount(self):
|
||||
if self.get("supplier_invoice_items"):
|
||||
total_amount = 0
|
||||
|
|
@ -33,10 +37,45 @@ class Invoices(Document):
|
|||
elif self.invoice_terms == "NET 60":
|
||||
self.due_date = add_days(self.invoice_date, 60)
|
||||
|
||||
def set_total_paid(self):
|
||||
total_paid = 0
|
||||
for item in self.payment_references:
|
||||
total_paid += item.paid_amount
|
||||
self.db_set("paid_amount", total_paid)
|
||||
|
||||
def update_status(self):
|
||||
if self.payment_reference_no and self.payment_reference_date:
|
||||
if (
|
||||
self.payment_reference_no and self.payment_reference_date
|
||||
) or self.paid_amount == self.total_amount:
|
||||
self.status = "Paid"
|
||||
elif self.status == "Unpaid" and nowdate() > self.due_date:
|
||||
elif self.paid_amount != self.total_amount and nowdate() > self.due_date:
|
||||
self.status = "Overdue"
|
||||
else:
|
||||
self.status = "Unpaid"
|
||||
|
||||
if self.paid_amount != self.total_amount and self.status not in (
|
||||
"Paid",
|
||||
"Overdue",
|
||||
):
|
||||
self.status = "Partially Paid"
|
||||
|
||||
def update_suppliers_invoice(self):
|
||||
supplier = frappe.get_doc("Supplier", self.supplier)
|
||||
|
||||
# check if invoice already exists
|
||||
for invoice in supplier.invoices:
|
||||
if invoice.invoice_number == self.name:
|
||||
if invoice.total_due != self.total_amount:
|
||||
invoice.total_amount = self.total_amount
|
||||
if invoice.invoice_date != self.invoice_date:
|
||||
invoice.invoice_date = self.invoice_date
|
||||
if invoice.status != self.status:
|
||||
invoice.status = self.status
|
||||
supplier.save()
|
||||
return
|
||||
|
||||
supplier.append(
|
||||
"invoices",
|
||||
{"invoice_number": self.name},
|
||||
)
|
||||
supplier.save()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
"street",
|
||||
"city",
|
||||
"state",
|
||||
"zip_code"
|
||||
"zip_code",
|
||||
"section_break_svzz",
|
||||
"invoices"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -56,10 +58,21 @@
|
|||
"fieldname": "zip_code",
|
||||
"fieldtype": "Data",
|
||||
"label": "Zip Code"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_svzz",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "invoices",
|
||||
"fieldtype": "Table",
|
||||
"label": "Invoices",
|
||||
"options": "Supplier Invoices",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2024-09-28 02:13:04.095973",
|
||||
"modified": "2024-10-09 18:09:28.675273",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Supplier",
|
||||
|
|
@ -78,7 +91,10 @@
|
|||
"write": 1
|
||||
}
|
||||
],
|
||||
"search_fields": "company_name",
|
||||
"show_title_field_in_link": 1,
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
"states": [],
|
||||
"title_field": "company_name"
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2024-10-09 16:59:58.079331",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"invoice_number",
|
||||
"status",
|
||||
"column_break_mprs",
|
||||
"invoice_date",
|
||||
"terms",
|
||||
"total_due"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "invoice_number",
|
||||
"fieldtype": "Link",
|
||||
"label": "Invoice Number",
|
||||
"options": "Invoices",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "invoice_number.invoice_date",
|
||||
"fieldname": "invoice_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Invoice Date",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "invoice_number.invoice_terms",
|
||||
"fieldname": "terms",
|
||||
"fieldtype": "Data",
|
||||
"label": "Term",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "invoice_number.total_amount",
|
||||
"fieldname": "total_due",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Total Due",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "invoice_number.status",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Data",
|
||||
"label": "Status",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_mprs",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-10-09 17:33:59.785852",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Supplier Invoices",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2024, jeowsome15@gmail.com and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class SupplierInvoices(Document):
|
||||
pass
|
||||
0
suppliers_portal/suppliers_portal/report/__init__.py
Normal file
0
suppliers_portal/suppliers_portal/report/__init__.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
frappe.query_reports["Supplier Invoices"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname": "invoice_date_from",
|
||||
"label": __("Invoice Date From"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), // Default to last month
|
||||
"placeholder": __("Invoice Date From")
|
||||
},
|
||||
{
|
||||
"fieldname": "invoice_date_to",
|
||||
"label": __("Invoice Date To"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.get_today(), // Default to today
|
||||
},
|
||||
{
|
||||
"fieldname": "supplier",
|
||||
"label": __("Supplier"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Supplier"
|
||||
},
|
||||
{
|
||||
"fieldname": "status",
|
||||
"label": __("Status"),
|
||||
"fieldtype": "Select",
|
||||
"options": "All\nPaid\nUnpaid\nOverdue",
|
||||
"default": "All",
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"add_total_row": 1,
|
||||
"columns": [],
|
||||
"creation": "2024-10-09 15:22:34.256149",
|
||||
"disabled": 1,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"filters": [],
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"letterhead": null,
|
||||
"modified": "2024-10-09 17:03:58.993246",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Supplier Invoices",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"ref_doctype": "Invoices",
|
||||
"report_name": "Supplier Invoices",
|
||||
"report_type": "Script Report",
|
||||
"roles": [
|
||||
{
|
||||
"role": "System Manager"
|
||||
},
|
||||
{
|
||||
"role": "Portal Supplier"
|
||||
}
|
||||
],
|
||||
"timeout": 0
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
import frappe
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
columns = [
|
||||
{
|
||||
"fieldname": "invoice_number",
|
||||
"label": "Invoice Number",
|
||||
"fieldtype": "Link",
|
||||
"options": "Invoices",
|
||||
},
|
||||
{
|
||||
"fieldname": "supplier_name",
|
||||
"label": "Supplier Name",
|
||||
"fieldtype": "Data",
|
||||
"width": 200,
|
||||
},
|
||||
{"fieldname": "status", "label": "Status", "fieldtype": "Data", "width": 100},
|
||||
{"fieldname": "invoice_date", "label": "Invoice Date", "fieldtype": "Date"},
|
||||
{"fieldname": "due_date", "label": "Due Date", "fieldtype": "Date"},
|
||||
{"fieldname": "total_amount", "label": "Total Amount", "fieldtype": "Currency"},
|
||||
]
|
||||
|
||||
conditions = ""
|
||||
if filters.get("invoice_date_from"):
|
||||
conditions += " AND invoice_date >= %(invoice_date_from)s"
|
||||
if filters.get("invoice_date_to"):
|
||||
conditions += " AND invoice_date <= %(invoice_date_to)s"
|
||||
if filters.get("supplier"):
|
||||
conditions += " AND supplier = %(supplier)s"
|
||||
if filters.get("status"):
|
||||
if not filters.get("status") == "All":
|
||||
conditions += " AND status = %(status)s"
|
||||
|
||||
query = f"""
|
||||
SELECT
|
||||
name as invoice_number,
|
||||
supplier_name,
|
||||
status,
|
||||
invoice_date,
|
||||
due_date,
|
||||
total_amount
|
||||
FROM
|
||||
`tabInvoices`
|
||||
WHERE
|
||||
docstatus = 0 {conditions}
|
||||
"""
|
||||
data = frappe.db.sql(query, filters, as_dict=True)
|
||||
return columns, data
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"app": "suppliers_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",
|
||||
"custom_blocks": [],
|
||||
"docstatus": 0,
|
||||
"doctype": "Workspace",
|
||||
"for_user": "",
|
||||
"hide_custom": 0,
|
||||
"icon": "clipboard",
|
||||
"idx": 0,
|
||||
"indicator_color": "green",
|
||||
"is_hidden": 0,
|
||||
"label": "Supplier Portal",
|
||||
"links": [],
|
||||
"modified": "2024-10-09 15:49:04.735953",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Suppliers Portal",
|
||||
"name": "Supplier Portal",
|
||||
"number_cards": [],
|
||||
"owner": "Administrator",
|
||||
"parent_page": "",
|
||||
"public": 1,
|
||||
"quick_lists": [],
|
||||
"roles": [],
|
||||
"sequence_id": 2.0,
|
||||
"shortcuts": [
|
||||
{
|
||||
"color": "Grey",
|
||||
"doc_view": "List",
|
||||
"label": "Supplier Invoices Report",
|
||||
"link_to": "Supplier Invoices",
|
||||
"type": "Report"
|
||||
},
|
||||
{
|
||||
"color": "Grey",
|
||||
"doc_view": "List",
|
||||
"label": "Suppliers",
|
||||
"link_to": "Supplier",
|
||||
"stats_filter": "[]",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"color": "Grey",
|
||||
"doc_view": "List",
|
||||
"label": "Invoices",
|
||||
"link_to": "Invoices",
|
||||
"stats_filter": "[]",
|
||||
"type": "DocType"
|
||||
}
|
||||
],
|
||||
"title": "Supplier Portal",
|
||||
"type": "Workspace"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue