diff --git a/suppliers_portal/patches/move_invoices_to_erpnext.py b/suppliers_portal/patches/move_invoices_to_erpnext.py index f2ef869..d11724d 100644 --- a/suppliers_portal/patches/move_invoices_to_erpnext.py +++ b/suppliers_portal/patches/move_invoices_to_erpnext.py @@ -8,7 +8,7 @@ from frappe.desk.page.setup_wizard.setup_wizard import setup_complete from frappe.utils import getdate, update_progress_bar ######################## PATCH PREREQUISITES ######################## -# - This patch should be run on a fresh site with ERPNext installed +# - This patch should be run on a fresh site with ERPNext installed (`suppliers_portal` should be installed after `erpnext`) # - The following files (containing exported doctype records) must be setup in the # site's private backups folder: # - users.json (the 'send_welcome_email' field should be set to 0 otherwise it'll @@ -220,23 +220,19 @@ def import_invoices(): if frappe.db.exists("Purchase Invoice", {"name": invoice.get("name")}): continue - remarks = "" - if invoice.get("site_code"): - remarks += f"Site Code: {invoice.get('site_code')}\n" - if invoice.get("notes"): - remarks += f"Notes: {invoice.get('notes')}\n" - invoice_doc = frappe.new_doc("Purchase Invoice") invoice_doc.update( { "supplier": invoice.get("supplier"), "bill_no": invoice.get("supplier_invoice_number"), - "bill_date": getdate(invoice.get("invoice_date")), + "site_code": invoice.get("site_code"), "set_posting_time": True, + "bill_date": getdate(invoice.get("invoice_date")), "posting_date": getdate(invoice.get("invoice_date")), + "service_date": getdate(invoice.get("service_date")), "due_date": getdate(invoice.get("due_date")), "payment_terms_template": invoice.get("invoice_terms"), - "remarks": remarks, + "remarks": invoice.get("notes"), "owner": invoice.get("owner"), "creation": invoice.get("creation"), } diff --git a/suppliers_portal/suppliers_portal/custom/purchase_invoice.json b/suppliers_portal/suppliers_portal/custom/purchase_invoice.json new file mode 100644 index 0000000..3bddbcb --- /dev/null +++ b/suppliers_portal/suppliers_portal/custom/purchase_invoice.json @@ -0,0 +1,137 @@ +{ + "custom_fields": [ + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2025-05-19 02:22:24.828657", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Purchase Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "service_date", + "fieldtype": "Date", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 12, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "due_date", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Service Date", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-05-19 02:22:24.828657", + "modified_by": "Administrator", + "module": null, + "name": "Purchase Invoice-service_date", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "Administrator", + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2025-05-19 02:22:24.721092", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Purchase Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "site_code", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 6, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "company", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Site Code", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-05-19 02:22:24.721092", + "modified_by": "Administrator", + "module": null, + "name": "Purchase Invoice-site_code", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "Administrator", + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 1, + "unique": 0, + "width": null + } + ], + "custom_perms": [], + "doctype": "Purchase Invoice", + "links": [], + "property_setters": [], + "sync_on_migrate": 1 +}