diff --git a/thai_tax/fixtures/custom_field.json b/thai_tax/fixtures/custom_field.json index 3054662..46b1059 100644 --- a/thai_tax/fixtures/custom_field.json +++ b/thai_tax/fixtures/custom_field.json @@ -816,16 +816,16 @@ "collapsible": 0, "collapsible_depends_on": null, "columns": 0, - "default": "00000", + "default": null, "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Supplier", + "dt": "Journal Entry Account", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "branch_code", - "fieldtype": "Data", + "fieldname": "supplier", + "fieldtype": "Link", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -836,18 +836,18 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "tax_id", + "insert_after": "column_break_cun7x", "is_system_generated": 0, "is_virtual": 0, - "label": "Branch Code", + "label": "Supplier", "length": 0, "mandatory_depends_on": null, - "modified": "2023-03-04 14:39:42.726447", + "modified": "2023-07-30 14:29:09.467889", "module": null, - "name": "Supplier-branch_code", + "name": "Journal Entry Account-supplier", "no_copy": 0, "non_negative": 0, - "options": null, + "options": "Supplier", "permlevel": 0, "precision": "", "print_hide": 0, @@ -878,7 +878,7 @@ "dt": "Journal Entry Account", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "supplier", + "fieldname": "customer", "fieldtype": "Link", "hidden": 0, "hide_border": 0, @@ -890,18 +890,18 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "column_break_cun7x", + "insert_after": "supplier", "is_system_generated": 0, "is_virtual": 0, - "label": "Supplier", + "label": "Customer", "length": 0, "mandatory_depends_on": null, - "modified": "2023-07-30 14:29:09.467889", + "modified": "2023-07-30 14:58:34.278422", "module": null, - "name": "Journal Entry Account-supplier", + "name": "Journal Entry Account-customer", "no_copy": 0, "non_negative": 0, - "options": "Supplier", + "options": "Customer", "permlevel": 0, "precision": "", "print_hide": 0, @@ -924,16 +924,16 @@ "collapsible": 0, "collapsible_depends_on": null, "columns": 0, - "default": null, + "default": "00000", "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Journal Entry Account", + "dt": "Supplier", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "customer", - "fieldtype": "Link", + "fieldname": "branch_code", + "fieldtype": "Data", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -944,18 +944,18 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "supplier", + "insert_after": "irs_1099", "is_system_generated": 0, "is_virtual": 0, - "label": "Customer", + "label": "Branch Code", "length": 0, "mandatory_depends_on": null, - "modified": "2023-07-30 14:58:34.278422", + "modified": "2023-03-04 14:39:42.726447", "module": null, - "name": "Journal Entry Account-customer", + "name": "Supplier-branch_code", "no_copy": 0, "non_negative": 0, - "options": "Customer", + "options": null, "permlevel": 0, "precision": "", "print_hide": 0, @@ -1025,6 +1025,168 @@ "unique": 0, "width": null }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_wht", + "fieldtype": "Section Break", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "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": "tax_withholding_category", + "is_system_generated": 0, + "is_virtual": 0, + "label": "WHT", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-02-02 14:53:41.991210", + "module": null, + "name": "Supplier-custom_wht", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "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, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_default_income_tax_form", + "fieldtype": "Select", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "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": "custom_wht", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Default Income Tax Form", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-02-02 14:53:42.128406", + "module": null, + "name": "Supplier-custom_default_income_tax_form", + "no_copy": 0, + "non_negative": 0, + "options": "\nPND3\nPND53", + "permlevel": 0, + "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, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_column_break_7q1md", + "fieldtype": "Column Break", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "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": "custom_default_income_tax_form", + "is_system_generated": 0, + "is_virtual": 0, + "label": "", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-02-02 14:53:42.258839", + "module": null, + "name": "Supplier-custom_column_break_7q1md", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "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, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -1133,6 +1295,60 @@ "unique": 0, "width": null }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Payment Entry", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_wht_type", + "fieldtype": "Link", + "hidden": 1, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "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": "deduct_withholding_tax", + "is_system_generated": 0, + "is_virtual": 0, + "label": "WHT Type", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-02-02 22:56:25.792720", + "module": null, + "name": "Payment Entry-custom_wht_type", + "no_copy": 0, + "non_negative": 0, + "options": "Withholding Tax Type", + "permlevel": 0, + "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, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -1945,21 +2161,21 @@ }, { "allow_in_quick_entry": 0, - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": "eval:doc.party_type=='Employee'", + "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Payment Entry", - "fetch_from": "supplier.supplier_name", + "dt": "Sales Invoice", + "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "supplier_name", - "fieldtype": "Data", + "fieldname": "tax_invoice", + "fieldtype": "Tab Break", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -1970,18 +2186,18 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "tax_invoice_date", + "insert_after": "total_billing_amount", "is_system_generated": 0, "is_virtual": 0, - "label": "Supplier Name", + "label": "Tax Invoice", "length": 0, "mandatory_depends_on": null, - "modified": "2023-04-30 15:46:05.824582", + "modified": "2023-03-04 12:30:55.408440", "module": null, - "name": "Payment Entry-supplier_name", - "no_copy": 1, + "name": "Sales Invoice-tax_invoice", + "no_copy": 0, "non_negative": 0, - "options": "", + "options": null, "permlevel": 0, "precision": "", "print_hide": 0, @@ -1993,27 +2209,27 @@ "reqd": 0, "search_index": 0, "sort_options": 0, - "translatable": 1, + "translatable": 0, "unique": 0, "width": null }, { "allow_in_quick_entry": 0, - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": null, + "depends_on": "eval:doc.party_type=='Employee'", "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Sales Invoice", - "fetch_from": null, + "dt": "Payment Entry", + "fetch_from": "supplier.supplier_name", "fetch_if_empty": 0, - "fieldname": "tax_invoice", - "fieldtype": "Tab Break", + "fieldname": "supplier_name", + "fieldtype": "Data", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -2024,18 +2240,18 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "total_billing_amount", + "insert_after": "tax_invoice_date", "is_system_generated": 0, "is_virtual": 0, - "label": "Tax Invoice", + "label": "Supplier Name", "length": 0, "mandatory_depends_on": null, - "modified": "2023-03-04 12:30:55.408440", + "modified": "2023-04-30 15:46:05.824582", "module": null, - "name": "Sales Invoice-tax_invoice", - "no_copy": 0, + "name": "Payment Entry-supplier_name", + "no_copy": 1, "non_negative": 0, - "options": null, + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -2047,7 +2263,7 @@ "reqd": 0, "search_index": 0, "sort_options": 0, - "translatable": 0, + "translatable": 1, "unique": 0, "width": null }, diff --git a/thai_tax/hooks.py b/thai_tax/hooks.py index 53962e9..50d3ff9 100644 --- a/thai_tax/hooks.py +++ b/thai_tax/hooks.py @@ -64,6 +64,10 @@ "Payment Entry-has_purchase_tax_invoice", "Payment Entry-supplier", "Payment Entry-supplier_name", + "Supplier-custom_wht", + "Supplier-custom_default_income_tax_form", + "Supplier-custom_column_break_7q1md", + "Payment Entry-custom_wht_type", ), ] ], diff --git a/thai_tax/public/js/payment_entry.js b/thai_tax/public/js/payment_entry.js index 5d133c8..e429e8a 100644 --- a/thai_tax/public/js/payment_entry.js +++ b/thai_tax/public/js/payment_entry.js @@ -15,13 +15,19 @@ frappe.ui.form.on("Payment Entry", { frm.doc.payment_type == "Pay" && frm.doc.deductions.length > 0 ) { - frm.add_custom_button(__("Create Withholding Tax Cert"), function () { + frm.add_custom_button(__("Create Withholding Tax Cert"), async function () { + let income_tax_form = ( + await frappe.db.get_value( + frm.doc.party_type, frm.doc.party, "custom_default_income_tax_form" + ) + ).message.custom_default_income_tax_form; const fields = [ { fieldtype: "Link", label: __("WHT Type"), fieldname: "wht_type", options: "Withholding Tax Type", + default: frm.doc.custom_wht_type, reqd: 1, }, { @@ -35,6 +41,7 @@ frappe.ui.form.on("Payment Entry", { label: __("Income Tax Form"), fieldname: "income_tax_form", options: "PND3\nPND53", + default: income_tax_form }, { fieldtype: "Link", @@ -97,6 +104,7 @@ frappe.ui.form.on("Payment Entry", { fields, function (filters) { frm.events.add_withholding_tax_deduction(frm, filters); + frm.doc.custom_wht_type = filters.wht_type }, __("Deduct Withholding Tax"), __("Add Withholding Tax Deduction")