diff --git a/README.md b/README.md index 65e4c86..32c8adf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,71 @@ ## Thai Tax -Thailand Taxation - VAT, WHT +Additional tax functionality to comply with Thailand Tax regulation. +### 1. Tax Point on both Invoice and Payment + +Tax Point determine when tax is recorded in general ledger. And on tax point, with Sales Tax Invoice or Purchase Tax Invoice will be created. + +Trading of stockable product, tax point occur when deliver product and invoice is issued. The selling party will issue out document called "Delivery Note / Tax Invoice". And so Tax Invoice doctype got created when submit sales/purchase invoice. + +For service, tax point occur when service is done and payment is made. When submit sales/purchase invoice, account ledger will record Undue Tax. Until when the seller get paid, it will then create Tax Invoice doctype on payment submission, in which account ledger will clear Undue Tax into Tax. The document issued from seller is called "Receipt / Tax Invoice" + +### 2. Withholding Tax and Certificate + +When a company purchase service from a supplier, when making payment, it is responsible to withhold (deduct) a tax amount (i.e., 3%) of invoice amount and issue out the Withholding Tax Certificate (pdf) to supplier. + +### 3. Reports that require for submission to RD, i.e., + +- Purchase Tax Report, Sales Tax Report +- Withholding Tax Report (PND or ภงด) + +### TODO: + +- Thailand e-Tax Invoice, e-Withholding Tax + +## Features + +- Sales Tax and Undue Sales Tax +- Purchase Tax and Undue Purchase Tax +- Sales and Purchase Tax Report +- Withholding Tax on Payment (based on invoice amount before tax) and Withholding Tax Cert (pdf) +- Withholding Tax Report (PND3, PND53) +- Get Address by Tax ID + +## Setup + +### Installation + +``` +$ cd frappe-bench +$ bench get-app https://github.com/kittiu/thai_tax +$ bench install-app thai_tax +``` + +### Configurations + +#### For Tax Invoice setup + +1. In chart of account, make sure to have with Rate, i.e, 7% for Thailand Tax (Tax) + - Sales Tax, Undue Sales Tax + - Purchase Tax, Undue Purchase Tax +2. Open Tax Invoice Settings, and setup above taxes +3. Setup Sales / Purchase Taxes and Charges Template, we just want to make sure that, + - When buy/sell product, Sales/Purchase Tax is record on invoice + - When buy/sell service, Undue Sales/Purchase Tax is record on invoice, then on payment, clear Undue Tax and record Tax +4. Make sure you have setup Company's Billing Address, as it will be used for Tax Invoice +5. Make sure all Supplier/Customer have setup Billing Address, they will be used for Tax Invoice + +Whenever Tax is recorded (with Tax Invoice and Tax Date), Sales/Purchase Tax Invoice will be created. + +#### For Withholding Tax setup + +1. In chart of account, make sure to have Withholding Tax Account +2. Create Withholding Tax Types (1%, 2%, 3% and 5%) + +During payment, user will manually choose to deduct with one of these Withholding Tax Type, and then click button Create Withholding Tax cert with the deducted amount plus some additional deduction information. + +----------------------- #### License MIT \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1243fdf..8d35e81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -# frappe -- https://github.com/frappe/frappe is installed via 'bench init' zeep \ No newline at end of file diff --git a/thai_tax/custom/custom_api.py b/thai_tax/custom/custom_api.py index 81da90a..8fd2e0b 100644 --- a/thai_tax/custom/custom_api.py +++ b/thai_tax/custom/custom_api.py @@ -179,11 +179,7 @@ def make_clear_vat_journal_entry(dt, dn): 'voucher_type': ref.reference_doctype, 'voucher_no': ref.reference_name, }, - fields=[ - 'name', 'account', - 'debit_in_account_currency', - 'credit_in_account_currency', - ]) + fields=["*"]) for gl in gl_entries: (undue_tax, base_amount, account_undue, account) = get_undue_tax(doc, ref, gl, tax) if ref.reference_doctype in ('Purchase Invoice', 'Expense Claim'): @@ -196,7 +192,6 @@ def make_clear_vat_journal_entry(dt, dn): 'account': account_undue, 'credit_in_account_currency': undue_tax > 0 and undue_tax, 'debit_in_account_currency': undue_tax < 0 and abs(undue_tax), - 'against_gl_entry': gl['name'], }, ) tax_total += undue_tax @@ -242,11 +237,7 @@ def clear_invoice_undue_tax(doc, method): 'voucher_type': ref.reference_doctype, 'voucher_no': ref.reference_name, }, - fields=[ - 'name', 'account', - 'debit_in_account_currency', - 'credit_in_account_currency', - ]) + fields=["*"]) for gl in gl_entries: (undue_tax, base_amount, account_undue, account) = get_undue_tax(doc, ref, gl, tax) if ref.reference_doctype in ('Purchase Invoice', 'Expense Claim'): @@ -256,21 +247,24 @@ def clear_invoice_undue_tax(doc, method): if undue_tax: doc.append('taxes', { - 'add_deduct_tax': undue_tax > 0 and 'Deduct' or 'Add', + # 'add_deduct_tax': undue_tax > 0 and 'Deduct' or 'Add', + 'add_deduct_tax': 'Add', 'description': 'Clear Undue Tax', 'charge_type': 'Actual', 'account_head': account_undue, - 'tax_amount': undue_tax, - 'against_gl_entry': gl['name'], + 'tax_amount': -undue_tax, }, ) tax_total += undue_tax if not tax_total: + if doc.has_purchase_tax_invoice: + frappe.throw(_("No undue tax amount to clear. Please uncheck 'Has Purchase Tax Invoice'")) return # To due tax doc.append('taxes', { - 'add_deduct_tax': tax_total > 0 and 'Add' or 'Deduct', + # 'add_deduct_tax': tax_total > 0 and 'Add' or 'Deduct', + 'add_deduct_tax': 'Add', 'description': 'Clear Undue Tax', 'charge_type': 'Actual', 'account_head': account, @@ -289,8 +283,8 @@ def get_undue_tax(doc, ref, gl, tax): if ref.reference_doctype in ('Purchase Invoice', 'Expense Claim'): tax_account_undue = tax.purchase_tax_account_undue tax_account = tax.purchase_tax_account - credit = gl['credit_in_account_currency'] - debit = gl['debit_in_account_currency'] + credit = gl['credit'] + debit = gl['debit'] alloc_percent = ref.allocated_amount / ref.total_amount # Find Base report_type = frappe.get_cached_value('Account', gl['account'], 'report_type') @@ -306,29 +300,12 @@ def get_undue_tax(doc, ref, gl, tax): undue_tax = undue_tax if undue_tax < undue_remain else undue_remain return (undue_tax, base_amount, tax_account_undue, tax_account) -def update_against_gl_entry_on_invoice_return(doc, method): - # For return invoice with undue tax, mark against_gl_entry to origin - if doc.voucher_type in ['Sales Invoice', 'Purchase Invoice']: - tax = frappe.get_single('Tax Invoice Settings') - if doc.account in [tax.purchase_tax_account_undue, tax.sales_tax_account_undue]: - invoice = frappe.get_doc(doc.voucher_type, doc.voucher_no) - if not invoice.is_return or not invoice.return_against: - return - gl = frappe.db.get_all( - 'GL Entry', - filters={'voucher_type': invoice.doctype, 'voucher_no': invoice.return_against, 'account': doc.account}, - fields=['name'], - ) - doc.against_gl_entry = gl[0]['name'] - def get_uncleared_tax_amount(gl, payment_type): - uncleared_gl = frappe.db.get_all( - 'GL Entry', - filters={'account': gl['account']}, - or_filters={'name': gl['name'], 'against_gl_entry': gl['name']}, - fields=['debit_in_account_currency', 'credit_in_account_currency'], - ) - uncleared_tax = sum([x.debit_in_account_currency - x.credit_in_account_currency for x in uncleared_gl]) + # If module bs_reconcile is installed, uncleared_tax = residual amount + # else uncleared_tax is the debit - credit amount + uncleared_tax = gl.debit - gl.credit + if gl.get("is_reconcile"): + uncleared_tax = gl.get("residual") if payment_type == 'Receive': uncleared_tax = -uncleared_tax return uncleared_tax @@ -376,13 +353,13 @@ def get_withholding_tax(filters, doc): }, fields=[ 'name', 'account', - 'debit_in_account_currency', - 'credit_in_account_currency', + 'debit', + 'credit', ]) base_amount = 0 for gl in gl_entries: - credit = gl['credit_in_account_currency'] - debit = gl['debit_in_account_currency'] + credit = gl['credit'] + debit = gl['debit'] alloc_percent = ref['allocated_amount'] / ref['total_amount'] report_type = frappe.get_cached_value('Account', gl['account'], 'report_type') if report_type == 'Profit and Loss': diff --git a/thai_tax/custom/general_ledger.py b/thai_tax/custom/general_ledger.py deleted file mode 100644 index e795863..0000000 --- a/thai_tax/custom/general_ledger.py +++ /dev/null @@ -1,33 +0,0 @@ -from frappe.utils import cstr - - -def check_if_in_list(gle, gl_map, dimensions=None): - - account_head_fieldnames = [ - "voucher_detail_no", - "party", - "against_voucher", - "cost_center", - "against_voucher_type", - "party_type", - "project", - "finance_book", - "against_gl_entry" # Additional column - ] - - if dimensions: - account_head_fieldnames = account_head_fieldnames + dimensions - - for e in gl_map: - same_head = True - if e.account != gle.account: - same_head = False - continue - - for fieldname in account_head_fieldnames: - if cstr(e.get(fieldname)) != cstr(gle.get(fieldname)): - same_head = False - break - - if same_head: - return e diff --git a/thai_tax/custom/journal_entry.py b/thai_tax/custom/journal_entry.py deleted file mode 100644 index c7a292d..0000000 --- a/thai_tax/custom/journal_entry.py +++ /dev/null @@ -1,46 +0,0 @@ -from frappe.utils import flt -from erpnext.accounts.doctype.journal_entry.journal_entry import JournalEntry - - -class ThaiTaxJournalEntry(JournalEntry): - - def build_gl_map(self): - gl_map = [] - for d in self.get("accounts"): - if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"): - r = [d.user_remark, self.remark] - r = [x for x in r if x] - remarks = "\n".join(r) - - gl_map.append( - self.get_gl_dict( - { - "account": d.account, - "party_type": d.party_type, - "due_date": self.due_date, - "party": d.party, - "against": d.against_account, - "debit": flt(d.debit, d.precision("debit")), - "credit": flt(d.credit, d.precision("credit")), - "account_currency": d.account_currency, - "debit_in_account_currency": flt( - d.debit_in_account_currency, d.precision("debit_in_account_currency") - ), - "credit_in_account_currency": flt( - d.credit_in_account_currency, d.precision("credit_in_account_currency") - ), - "against_voucher_type": d.reference_type, - "against_voucher": d.reference_name, - "remarks": remarks, - "voucher_detail_no": d.reference_detail_no, - "cost_center": d.cost_center, - "project": d.project, - "finance_book": self.finance_book, - # Add clear tax entry - "against_gl_entry": d.against_gl_entry, - # -- - }, - item=d, - ) - ) - return gl_map \ No newline at end of file diff --git a/thai_tax/custom/payment_entry.py b/thai_tax/custom/payment_entry.py deleted file mode 100644 index 45b6b4d..0000000 --- a/thai_tax/custom/payment_entry.py +++ /dev/null @@ -1,74 +0,0 @@ -import frappe -from frappe.utils import flt -from erpnext.accounts.utils import get_account_currency -from hrms.overrides.employee_payment_entry import EmployeePaymentEntry - - -class ThaiTaxPaymentEntry(EmployeePaymentEntry): - - def add_tax_gl_entries(self, gl_entries): - for d in self.get("taxes"): - account_currency = get_account_currency(d.account_head) - if account_currency != self.company_currency: - frappe.throw(_("Currency for {0} must be {1}").format(d.account_head, self.company_currency)) - - if self.payment_type in ("Pay", "Internal Transfer"): - dr_or_cr = "debit" if d.add_deduct_tax == "Add" else "credit" - rev_dr_or_cr = "credit" if dr_or_cr == "debit" else "debit" - against = self.party or self.paid_from - elif self.payment_type == "Receive": - dr_or_cr = "credit" if d.add_deduct_tax == "Add" else "debit" - rev_dr_or_cr = "credit" if dr_or_cr == "debit" else "debit" - against = self.party or self.paid_to - - payment_account = self.get_party_account_for_taxes() - tax_amount = d.tax_amount - base_tax_amount = d.base_tax_amount - - gl_entries.append( - self.get_gl_dict( - { - "account": d.account_head, - "against": against, - dr_or_cr: tax_amount, - dr_or_cr + "_in_account_currency": base_tax_amount - if account_currency == self.company_currency - else d.tax_amount, - "cost_center": d.cost_center, - "post_net_value": True, - # Add clear tax entry - "against_gl_entry": d.against_gl_entry, - # -- - }, - account_currency, - item=d, - ) - ) - - if not d.included_in_paid_amount: - if get_account_currency(payment_account) != self.company_currency: - if self.payment_type == "Receive": - exchange_rate = self.target_exchange_rate - elif self.payment_type in ["Pay", "Internal Transfer"]: - exchange_rate = self.source_exchange_rate - base_tax_amount = flt((tax_amount / exchange_rate), self.precision("paid_amount")) - - gl_entries.append( - self.get_gl_dict( - { - "account": payment_account, - "against": against, - rev_dr_or_cr: tax_amount, - rev_dr_or_cr + "_in_account_currency": base_tax_amount - if account_currency == self.company_currency - else d.tax_amount, - "cost_center": self.cost_center, - "post_net_value": True, - # Add clear tax entry - "against_gl_entry": d.against_gl_entry, - # -- - }, - account_currency, - item=d, - ) - ) diff --git a/thai_tax/fixtures/custom_field.json b/thai_tax/fixtures/custom_field.json index 5937c1c..d5a4a77 100644 --- a/thai_tax/fixtures/custom_field.json +++ b/thai_tax/fixtures/custom_field.json @@ -1,57 +1,4 @@ [ - { - "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": "GL Entry", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "against_gl_entry", - "fieldtype": "Link", - "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": "branch", - "is_system_generated": 0, - "is_virtual": 0, - "label": "Against GL Entry", - "length": 0, - "mandatory_depends_on": null, - "modified": "2023-03-26 10:24:45.288706", - "module": null, - "name": "GL Entry-against_gl_entry", - "no_copy": 0, - "non_negative": 0, - "options": "GL Entry", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 1, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 0, - "unique": 0, - "width": null - }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -101,59 +48,7 @@ "report_hide": 0, "reqd": 0, "search_index": 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": "Advance Taxes and Charges", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "against_gl_entry", - "fieldtype": "Link", - "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": "base_total", - "is_system_generated": 0, - "is_virtual": 0, - "label": "Against GL Entry", - "length": 0, - "mandatory_depends_on": null, - "modified": "2023-03-27 21:42:14.428999", - "module": null, - "name": "Advance Taxes and Charges-against_gl_entry", - "no_copy": 0, - "non_negative": 0, - "options": "GL Entry", - "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 @@ -207,59 +102,7 @@ "report_hide": 0, "reqd": 0, "search_index": 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": "Journal Entry Account", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "against_gl_entry", - "fieldtype": "Link", - "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": "against_account", - "is_system_generated": 0, - "is_virtual": 0, - "label": "Against GL Entry", - "length": 0, - "mandatory_depends_on": null, - "modified": "2023-03-26 10:25:30.958495", - "module": null, - "name": "Journal Entry Account-against_gl_entry", - "no_copy": 0, - "non_negative": 0, - "options": "GL Entry", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 1, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -313,6 +156,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -366,6 +210,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -419,6 +264,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -472,6 +318,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -525,6 +372,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -578,27 +426,28 @@ "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": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": null, + "depends_on": "eval:doc.docstatus==0", "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Expense Claim", + "dt": "Payment Entry", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "tax_invoice_number", - "fieldtype": "Data", + "fieldname": "deduct_withholding_tax", + "fieldtype": "Button", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -608,17 +457,17 @@ "in_global_search": 0, "in_list_view": 0, "in_preview": 0, - "in_standard_filter": 1, - "insert_after": "section_break_uodhb", + "in_standard_filter": 0, + "insert_after": "set_exchange_gain_loss", "is_system_generated": 0, "is_virtual": 0, - "label": "Tax Invoice Number", + "label": "Deduct Withholding Tax", "length": 0, - "mandatory_depends_on": "", - "modified": "2023-03-04 13:10:02.762509", + "mandatory_depends_on": null, + "modified": "2023-03-04 12:36:57.731438", "module": null, - "name": "Expense Claim-tax_invoice_number", - "no_copy": 1, + "name": "Payment Entry-deduct_withholding_tax", + "no_copy": 0, "non_negative": 0, "options": null, "permlevel": 0, @@ -627,31 +476,32 @@ "print_hide_if_no_value": 0, "print_width": null, "read_only": 0, - "read_only_depends_on": "eval:doc.docstatus!=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, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": "eval:doc.docstatus==0", + "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Payment Entry", + "dt": "Expense Claim", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "deduct_withholding_tax", - "fieldtype": "Button", + "fieldname": "tax_invoice_number", + "fieldtype": "Data", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -661,17 +511,17 @@ "in_global_search": 0, "in_list_view": 0, "in_preview": 0, - "in_standard_filter": 0, - "insert_after": "set_exchange_gain_loss", + "in_standard_filter": 1, + "insert_after": "section_break_uodhb", "is_system_generated": 0, "is_virtual": 0, - "label": "Deduct Withholding Tax", + "label": "Tax Invoice Number", "length": 0, - "mandatory_depends_on": null, - "modified": "2023-03-04 12:36:57.731438", + "mandatory_depends_on": "", + "modified": "2023-03-04 13:10:02.762509", "module": null, - "name": "Payment Entry-deduct_withholding_tax", - "no_copy": 0, + "name": "Expense Claim-tax_invoice_number", + "no_copy": 1, "non_negative": 0, "options": null, "permlevel": 0, @@ -680,10 +530,11 @@ "print_hide_if_no_value": 0, "print_width": null, "read_only": 0, - "read_only_depends_on": null, + "read_only_depends_on": "eval:doc.docstatus!=0", "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -737,6 +588,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -790,6 +642,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -843,6 +696,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -896,6 +750,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 1, "unique": 0, "width": null @@ -949,6 +804,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1002,6 +858,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1055,6 +912,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1108,6 +966,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1161,6 +1020,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1214,6 +1074,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1267,6 +1128,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1320,6 +1182,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1373,6 +1236,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1426,6 +1290,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1479,6 +1344,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 1, "unique": 0, "width": null @@ -1491,7 +1357,7 @@ "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": null, + "depends_on": "", "description": null, "docstatus": 0, "doctype": "Custom Field", @@ -1532,6 +1398,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1585,6 +1452,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1638,6 +1506,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1691,6 +1560,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1744,6 +1614,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1797,6 +1668,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1850,6 +1722,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1903,6 +1776,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -1956,27 +1830,28 @@ "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, + "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, @@ -1987,18 +1862,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, @@ -2009,27 +1884,28 @@ "report_hide": 0, "reqd": 0, "search_index": 0, - "translatable": 0, + "sort_options": 0, + "translatable": 1, "unique": 0, "width": null }, { "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, @@ -2040,18 +1916,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, @@ -2062,7 +1938,8 @@ "report_hide": 0, "reqd": 0, "search_index": 0, - "translatable": 1, + "sort_options": 0, + "translatable": 0, "unique": 0, "width": null }, @@ -2115,6 +1992,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2168,6 +2046,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2221,6 +2100,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2274,6 +2154,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2327,6 +2208,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2380,6 +2262,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null @@ -2433,6 +2316,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null diff --git a/thai_tax/fixtures/scheduled_job_type.json b/thai_tax/fixtures/scheduled_job_type.json deleted file mode 100644 index 430b93d..0000000 --- a/thai_tax/fixtures/scheduled_job_type.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "create_log": 1, - "cron_format": "30 * * * *", - "docstatus": 0, - "doctype": "Scheduled Job Type", - "frequency": "Cron", - "last_execution": "2023-03-26 12:30:24.729830", - "method": "erpnext.accounts.doctype.gl_entry.gl_entry.rename_gle_sle_docs", - "modified": "2023-03-26 12:52:32.269274", - "name": "gl_entry.rename_gle_sle_docs", - "next_execution": "2023-03-26 13:30:00", - "server_script": null, - "stopped": 1 - } -] \ No newline at end of file diff --git a/thai_tax/hooks.py b/thai_tax/hooks.py index 60cfbba..90e8a2f 100644 --- a/thai_tax/hooks.py +++ b/thai_tax/hooks.py @@ -3,9 +3,10 @@ app_name = "thai_tax" app_title = "Thai Tax" app_publisher = "Kitti U." -app_description = "Thailand Taxation - VAT, WHT" +app_description = "Thailand Taxation Compliance" app_email = "kittiu@gmail.com" app_license = "MIT" +required_apps = ["erpnext", "hrms"] fixtures = [ { @@ -52,13 +53,10 @@ "Journal Entry-column_break_3djv9", "Journal Entry-for_payment", "Journal Entry-supplier_name", - "Journal Entry-supplier", - "Journal Entry Account-against_gl_entry", + "Journal Entry-supplier", "Journal Entry-tax_base_amount", - "GL Entry-against_gl_entry", "Expense Claim-column_break_rqacr", "Expense Claim-base_amount_overwrite", - "Advance Taxes and Charges-against_gl_entry", "Payment Entry-column_break_bqyze", "Payment Entry-tax_base_amount", "Payment Entry-has_purchase_tax_invoice", @@ -83,18 +81,6 @@ ] ] }, - { - "doctype": "Scheduled Job Type", - "filters": [ - [ - "name", - "in", - ( - "gl_entry.rename_gle_sle_docs", # Stop it - ) - ] - ] - } ] @@ -122,13 +108,6 @@ # include js in doctype views # doctype_js = {"doctype" : "public/js/doctype.js"} -# Monkey patching -# ------------------ -import erpnext.accounts.general_ledger -import thai_tax.custom.general_ledger - -erpnext.accounts.general_ledger.check_if_in_list = thai_tax.custom.general_ledger.check_if_in_list - doctype_js = { "Journal Entry" : "public/js/journal_entry.js", "Payment Entry" : "public/js/payment_entry.js", @@ -180,7 +159,7 @@ # ------------ # before_install = "thai_tax.install.before_install" -# after_install = "thai_tax.install.after_install" +after_install = "thai_tax.install.after_install" # Uninstallation # ------------ @@ -210,8 +189,6 @@ # --------------- # Override standard doctype classes override_doctype_class = { - "Journal Entry": "thai_tax.custom.journal_entry.ThaiTaxJournalEntry", - "Payment Entry": "thai_tax.custom.payment_entry.ThaiTaxPaymentEntry", "Employee Advance": "thai_tax.custom.employee_advance.ThaiTaxEmployeeAdvance", } @@ -230,7 +207,6 @@ doc_events = { "GL Entry": { "after_insert": "thai_tax.custom.custom_api.create_tax_invoice_on_gl_tax", - "before_insert": "thai_tax.custom.custom_api.update_against_gl_entry_on_invoice_return", }, "Payment Entry": { "validate": "thai_tax.custom.custom_api.validate_company_address", diff --git a/thai_tax/install.py b/thai_tax/install.py new file mode 100644 index 0000000..4c368fa --- /dev/null +++ b/thai_tax/install.py @@ -0,0 +1,18 @@ +import click + + +def after_install(): + try: + print("Setting up Thai Tax...") + + click.secho("Thank you for installing Thai Tax!", fg="green") + + except Exception as e: + BUG_REPORT_URL = "https://github.com/kittiu/thai_tax/issues/new" + click.secho( + "Installation for Thai Tax app failed due to an error." + " Please try re-installing the app or" + f" report the issue on {BUG_REPORT_URL} if not resolved.", + fg="bright_red", + ) + raise e diff --git a/thai_tax/public/js/payment_entry.js b/thai_tax/public/js/payment_entry.js index 7931e2b..0d16768 100644 --- a/thai_tax/public/js/payment_entry.js +++ b/thai_tax/public/js/payment_entry.js @@ -67,10 +67,6 @@ frappe.ui.form.on('Payment Entry', { frm.add_custom_button(__('Clear Undue Tax'), function () { frm.trigger("make_clear_vat_journal_entry"); }); - // Add yellow comment - frm.dashboard.add_comment( - __("Pending tax invoice. Please clear undue tax when ready."), "yellow", true - ); } } }); diff --git a/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.js b/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.js index 885aa9e..1337a64 100644 --- a/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.js +++ b/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.js @@ -2,7 +2,26 @@ // For license information, please see license.txt frappe.ui.form.on('Tax Invoice Settings', { - // refresh: function(frm) { + onload: function(frm) { + for (let field of ['sales_tax_account', + 'sales_tax_account_undue', + 'purchase_tax_account', + 'purchase_tax_account_undue']) { + frm.set_query(field, function(doc) { + return { + filters: { + "account_type": "Tax", + "company": doc.company + } + }; + }); + } + }, - // } + company: function(frm) { + frm.set_value("sales_tax_account", null) + frm.set_value("sales_tax_account_undue", null) + frm.set_value("purchase_tax_account", null) + frm.set_value("purchase_tax_account_undue", null) + } }); diff --git a/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.json b/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.json index ea82384..706767a 100644 --- a/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.json +++ b/thai_tax/thai_tax/doctype/tax_invoice_settings/tax_invoice_settings.json @@ -65,7 +65,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-03-25 14:26:27.834806", + "modified": "2023-06-22 09:27:29.366931", "modified_by": "Administrator", "module": "Thai Tax", "name": "Tax Invoice Settings", @@ -73,13 +73,17 @@ "permissions": [ { "create": 1, - "delete": 1, - "email": 1, - "print": 1, "read": 1, - "role": "System Manager", - "share": 1, + "role": "Accounts Manager", "write": 1 + }, + { + "read": 1, + "role": "Sales User" + }, + { + "read": 1, + "role": "Purchase User" } ], "sort_field": "modified", diff --git a/thai_tax/thai_tax/form_tour/tax_invoice_settings/tax_invoice_settings.json b/thai_tax/thai_tax/form_tour/tax_invoice_settings/tax_invoice_settings.json new file mode 100644 index 0000000..9edf73c --- /dev/null +++ b/thai_tax/thai_tax/form_tour/tax_invoice_settings/tax_invoice_settings.json @@ -0,0 +1,110 @@ +{ + "creation": "2023-06-22 13:05:27.078306", + "docstatus": 0, + "doctype": "Form Tour", + "first_document": 0, + "idx": 0, + "include_name_field": 0, + "is_standard": 1, + "list_name": "List", + "modified": "2023-06-22 13:35:18.914103", + "modified_by": "Administrator", + "module": "Thai Tax", + "name": "Tax Invoice Settings", + "new_document_form": 0, + "owner": "Administrator", + "reference_doctype": "Tax Invoice Settings", + "report_name": "", + "save_on_complete": 0, + "steps": [ + { + "description": "Select your current company", + "fieldname": "company", + "fieldtype": "Link", + "has_next_condition": 0, + "hide_buttons": 0, + "is_table_field": 0, + "label": "Company", + "modal_trigger": 0, + "next_on_click": 0, + "offset_x": 0, + "offset_y": 0, + "popover_element": 0, + "position": "Bottom", + "title": "Company", + "ui_tour": 0 + }, + { + "description": "Select Sales Tax Account", + "fieldname": "sales_tax_account", + "fieldtype": "Link", + "has_next_condition": 0, + "hide_buttons": 0, + "is_table_field": 0, + "label": "Sales Tax Account", + "modal_trigger": 0, + "next_on_click": 0, + "offset_x": 0, + "offset_y": 0, + "popover_element": 0, + "position": "Bottom", + "title": "Sales Tax Account", + "ui_tour": 0 + }, + { + "description": "Select Undue Sales Tax Account", + "fieldname": "sales_tax_account_undue", + "fieldtype": "Link", + "has_next_condition": 0, + "hide_buttons": 0, + "is_table_field": 0, + "label": "Sales Tax Account Undue", + "modal_trigger": 0, + "next_on_click": 0, + "offset_x": 0, + "offset_y": 0, + "popover_element": 0, + "position": "Bottom", + "title": "Select Undue Sales Tax Account", + "ui_tour": 0 + }, + { + "description": "Select Purchase Tax Account", + "fieldname": "purchase_tax_account", + "fieldtype": "Link", + "has_next_condition": 0, + "hide_buttons": 0, + "is_table_field": 0, + "label": "Purchase Tax Account", + "modal_trigger": 0, + "next_on_click": 0, + "offset_x": 0, + "offset_y": 0, + "popover_element": 0, + "position": "Bottom", + "title": "Select Purchase Tax Account", + "ui_tour": 0 + }, + { + "description": "Select Undue Purchase Tax Account", + "fieldname": "purchase_tax_account_undue", + "fieldtype": "Link", + "has_next_condition": 0, + "hide_buttons": 0, + "is_table_field": 0, + "label": "Purchase Tax Account Undue", + "modal_trigger": 0, + "next_on_click": 0, + "offset_x": 0, + "offset_y": 0, + "popover_element": 0, + "position": "Bottom", + "title": "Select Undue Purchase Tax Account", + "ui_tour": 0 + } + ], + "title": "Tax Invoice Settings", + "track_steps": 0, + "ui_tour": 0, + "view_name": "Workspaces" +} \ No newline at end of file diff --git a/thai_tax/thai_tax/module_onboarding/thai_tax/thai_tax.json b/thai_tax/thai_tax/module_onboarding/thai_tax/thai_tax.json new file mode 100644 index 0000000..cb1d543 --- /dev/null +++ b/thai_tax/thai_tax/module_onboarding/thai_tax/thai_tax.json @@ -0,0 +1,50 @@ +{ + "allow_roles": [ + { + "role": "Accounts Manager" + }, + { + "role": "Accounts User" + } + ], + "creation": "2023-06-22 11:58:50.650153", + "docstatus": 0, + "doctype": "Module Onboarding", + "documentation_url": "https://github.com/kittiu/thai_tax/blob/main/README.md", + "idx": 0, + "is_complete": 0, + "modified": "2023-06-23 11:59:08.144024", + "modified_by": "Administrator", + "module": "Thai Tax", + "name": "Thai Tax", + "owner": "Administrator", + "steps": [ + { + "step": "Add Thai Tax Accounts" + }, + { + "step": "Tax Invoice Setting" + }, + { + "step": "Add Withholding Tax Type" + }, + { + "step": "Browse Sales Tax Invoices" + }, + { + "step": "Browse Purchase Tax Invoices" + }, + { + "step": "Tax Report" + }, + { + "step": "Browse Withholding Tax Cert" + }, + { + "step": "Withholding Tax Report (PND)" + } + ], + "subtitle": "Tax Account Setup, Withholding Tax Type", + "success_message": "The Thai Tax Module is all set up!", + "title": "Setup Thai Tax" +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/add_taxes_to_chart_of_account/add_taxes_to_chart_of_account.json b/thai_tax/thai_tax/onboarding_step/add_taxes_to_chart_of_account/add_taxes_to_chart_of_account.json new file mode 100644 index 0000000..ec20928 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/add_taxes_to_chart_of_account/add_taxes_to_chart_of_account.json @@ -0,0 +1,20 @@ +{ + "action": "Create Entry", + "creation": "2023-06-22 12:02:29.107120", + "description": "YYY", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-22 12:02:29.107120", + "modified_by": "Administrator", + "name": "Add Taxes to Chart of Account", + "owner": "Administrator", + "reference_document": "Account", + "show_form_tour": 0, + "show_full_form": 0, + "title": "XXX", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/add_thai_tax_accounts/add_thai_tax_accounts.json b/thai_tax/thai_tax/onboarding_step/add_thai_tax_accounts/add_thai_tax_accounts.json new file mode 100644 index 0000000..625e745 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/add_thai_tax_accounts/add_thai_tax_accounts.json @@ -0,0 +1,24 @@ +{ + "action": "Go to Page", + "action_label": "Let's create tax accounts", + "callback_message": "", + "callback_title": "", + "creation": "2023-06-22 12:36:13.122910", + "description": "# Add Thai Tax Accounts\n\nPlease make sure you have all required Tax Accounts, you can name it as you want.\n1. Purchase Tax -- Current Asset, Rate = 7\n2. Undue Purchase Tax -- Currency Asset, Rate = 7\n3. Sales Tax -- Current Liability, Rate = 7\n4. Undue Sales Tax -- Current Liability, Rate = 7\n5. Withholding Tax -- Current Liability\n\n", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:20:25.502674", + "modified_by": "Administrator", + "name": "Add Thai Tax Accounts", + "owner": "Administrator", + "path": "account/view/tree", + "reference_document": "Account", + "show_form_tour": 0, + "show_full_form": 1, + "title": "Add Thai Tax Accounts", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/add_withholding_tax_type/add_withholding_tax_type.json b/thai_tax/thai_tax/onboarding_step/add_withholding_tax_type/add_withholding_tax_type.json new file mode 100644 index 0000000..7e4cdb3 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/add_withholding_tax_type/add_withholding_tax_type.json @@ -0,0 +1,20 @@ +{ + "action": "Create Entry", + "creation": "2023-06-23 10:43:23.606425", + "description": "To withhold tax, you need to create Withholding Tyes, i.e., 1%, 2%, 3% and 5%", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:59:02.378631", + "modified_by": "Administrator", + "name": "Add Withholding Tax Type", + "owner": "Administrator", + "reference_document": "Withholding Tax Type", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Add Withholding Tax Type", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/asset_item/asset_item.json b/thai_tax/thai_tax/onboarding_step/asset_item/asset_item.json new file mode 100644 index 0000000..13e3e2e --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/asset_item/asset_item.json @@ -0,0 +1,22 @@ +{ + "action": "Create Entry", + "action_label": "Let's create a new Asset item", + "creation": "2021-08-13 14:27:07.277167", + "description": "# Asset Item\n\nAsset items are created based on Asset Category. You can create one or multiple items against once Asset Category. The sales and purchase transaction for Asset is done via Asset Item. ", + "docstatus": 0, + "doctype": "Onboarding Step", + "form_tour": "Item", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2021-12-02 11:23:48.158504", + "modified_by": "Administrator", + "name": "Asset Item", + "owner": "Administrator", + "reference_document": "Item", + "show_form_tour": 1, + "show_full_form": 1, + "title": "Create an Asset Item", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/browse_purchase_tax_invoices/browse_purchase_tax_invoices.json b/thai_tax/thai_tax/onboarding_step/browse_purchase_tax_invoices/browse_purchase_tax_invoices.json new file mode 100644 index 0000000..b799741 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/browse_purchase_tax_invoices/browse_purchase_tax_invoices.json @@ -0,0 +1,22 @@ +{ + "action": "Go to Page", + "callback_message": "", + "callback_title": "Purchase Tax Invoices are created after you have record tax.", + "creation": "2023-06-23 11:16:19.993908", + "description": "Purchase Tax Invoice is created when tax ledger is recorded, which could be,\n1. On Purchase Invoice for case buying product\n2. On Payment for case buying service and can record tax on payment\n3. On Journal Entry for case buying service and record tax afterward", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:17:34.911128", + "modified_by": "Administrator", + "name": "Browse Purchase Tax Invoices", + "owner": "Administrator", + "path": "List/Purchase Tax Invoice", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Browse Purchase Tax Invoices", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/browse_sales_tax_invoices/browse_sales_tax_invoices.json b/thai_tax/thai_tax/onboarding_step/browse_sales_tax_invoices/browse_sales_tax_invoices.json new file mode 100644 index 0000000..856ab4b --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/browse_sales_tax_invoices/browse_sales_tax_invoices.json @@ -0,0 +1,22 @@ +{ + "action": "Go to Page", + "callback_message": "", + "callback_title": "Sales Tax Invoices are created after you have record tax.", + "creation": "2023-06-23 11:11:48.094053", + "description": "Sales Tax Invoice is created when tax ledger is recorded, which could be,\n1. On Sales Invoice for case selling product\n2. On Payment for case selling service", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:17:45.307520", + "modified_by": "Administrator", + "name": "Browse Sales Tax Invoices", + "owner": "Administrator", + "path": "List/Sales Tax Invoice", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Browse Sales Tax Invoices", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/browse_withholding_tax_cert/browse_withholding_tax_cert.json b/thai_tax/thai_tax/onboarding_step/browse_withholding_tax_cert/browse_withholding_tax_cert.json new file mode 100644 index 0000000..44a805e --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/browse_withholding_tax_cert/browse_withholding_tax_cert.json @@ -0,0 +1,21 @@ +{ + "action": "Go to Page", + "action_label": "Browse Withholding Tax Certs", + "creation": "2023-06-23 11:22:48.027326", + "description": "On Payment Entry with withholding tax deduction, button Create Withholing Tax Cert will be visible.\nThese are all Withholding Tax Certs created during payments.", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:26:09.219232", + "modified_by": "Administrator", + "name": "Browse Withholding Tax Cert", + "owner": "Administrator", + "path": "List/Withholding Tax Cert", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Browse Withholding Tax Cert", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/company_set_up/company_set_up.json b/thai_tax/thai_tax/onboarding_step/company_set_up/company_set_up.json new file mode 100644 index 0000000..fae2de0 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/company_set_up/company_set_up.json @@ -0,0 +1,21 @@ +{ + "action": "Create Entry", + "action_label": "Let's review your Company", + "creation": "2021-11-22 11:55:48.931427", + "description": "# Set Up a Company\n\nA company is a legal entity for which you will set up your books of account and create accounting transactions. In ERPNext, you can create multiple companies, and establish relationships (group/subsidiary) among them.\n\nWithin the company master, you can capture various default accounts for that Company and set crucial settings related to the accounting methodology followed for a company.\n", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 1, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-05-15 09:18:42.895537", + "modified_by": "Administrator", + "name": "Company Set Up", + "owner": "Administrator", + "reference_document": "Company", + "show_form_tour": 1, + "show_full_form": 1, + "title": "Set Up a Company", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/tax_invoice_setting/tax_invoice_setting.json b/thai_tax/thai_tax/onboarding_step/tax_invoice_setting/tax_invoice_setting.json new file mode 100644 index 0000000..63f352e --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/tax_invoice_setting/tax_invoice_setting.json @@ -0,0 +1,22 @@ +{ + "action": "Show Form Tour", + "creation": "2023-06-22 12:59:15.255686", + "description": "#Tax Invoice Settings\n\nAfter you have created all required tax account, please map them in the settings.", + "docstatus": 0, + "doctype": "Onboarding Step", + "field": "sales_tax_account", + "idx": 0, + "is_complete": 0, + "is_single": 1, + "is_skipped": 0, + "modified": "2023-06-22 14:00:33.605362", + "modified_by": "Administrator", + "name": "Tax Invoice Setting", + "owner": "Administrator", + "reference_document": "Tax Invoice Settings", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Tax Invoice Setting", + "validate_action": 1, + "value_to_validate": "%" +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/tax_report/tax_report.json b/thai_tax/thai_tax/onboarding_step/tax_report/tax_report.json new file mode 100644 index 0000000..678a635 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/tax_report/tax_report.json @@ -0,0 +1,23 @@ +{ + "action": "View Report", + "creation": "2023-06-23 11:18:50.186869", + "description": "Sales Tax Report and Purchase Tax Repot can be found in separated menu.", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:32:45.317640", + "modified_by": "Administrator", + "name": "Tax Report", + "owner": "Administrator", + "reference_report": "Sales Tax Report", + "report_description": "You can also go to Purchase Tax Report for the same", + "report_reference_doctype": "Sales Tax Invoice", + "report_type": "Script Report", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Sales / Purchase Tax Report", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/onboarding_step/withholding_tax_report_(pnd)/withholding_tax_report_(pnd).json b/thai_tax/thai_tax/onboarding_step/withholding_tax_report_(pnd)/withholding_tax_report_(pnd).json new file mode 100644 index 0000000..082deb4 --- /dev/null +++ b/thai_tax/thai_tax/onboarding_step/withholding_tax_report_(pnd)/withholding_tax_report_(pnd).json @@ -0,0 +1,27 @@ +{ + "action": "Go to Page", + "action_label": "View PND Report", + "callback_message": "PND53 can be found in separated menu.", + "callback_title": "PND3 Report", + "creation": "2023-06-23 11:27:09.437734", + "description": "PND3 and PND53 reports are summay of Withholding Ta Certs", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2023-06-23 11:32:29.566442", + "modified_by": "Administrator", + "name": "Withholding Tax Report (PND)", + "owner": "Administrator", + "path": "query-report/PND3", + "reference_report": "PND3", + "report_description": "PND53 can also be found in separated menu.", + "report_reference_doctype": "Withholding Tax Cert", + "report_type": "Script Report", + "show_form_tour": 0, + "show_full_form": 0, + "title": "Withholding Tax Report (PND)", + "validate_action": 1 +} \ No newline at end of file diff --git a/thai_tax/thai_tax/report/open_undue_tax_report/__init__.py b/thai_tax/thai_tax/report/open_undue_tax_report/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.js b/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.js deleted file mode 100644 index 8f5985a..0000000 --- a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2023, Kitti U. and contributors -// For license information, please see license.txt -/* eslint-disable */ - -frappe.query_reports["Open Undue Tax Report"] = { - "filters": [ - { - "fieldname": "account", - "label": __("Undue Tax Account"), - "fieldtype": "Link", - "options": "Account", - get_query: () => { - return { - query: "thai_tax.custom.queries.undue_tax_query", - }; - }, - "width": "800px", - "reqd": 1, - }, - { - "fieldname": "voucher_type", - "label": __("Voucher Type"), - "fieldtype": "Select", - "options": "\nPurchase Invoice\nSales Invoice\nJournal Entry", - }, - - { - "fieldname": "voucher_no", - "label": __("Voucher No"), - "fieldtype": "Data", - }, - { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - }, - { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - }, - { - "fieldname": "is_open", - "label": __("Is Open Only"), - "fieldtype": "Check", - }, - ] -}; \ No newline at end of file diff --git a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.json b/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.json deleted file mode 100644 index 61bb4de..0000000 --- a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "add_total_row": 0, - "columns": [], - "creation": "2023-03-28 10:40:02.602287", - "disable_prepared_report": 0, - "disabled": 0, - "docstatus": 0, - "doctype": "Report", - "filters": [], - "idx": 0, - "is_standard": "Yes", - "modified": "2023-03-28 10:42:47.365913", - "modified_by": "Administrator", - "module": "Thai Tax", - "name": "Open Undue Tax Report", - "owner": "Administrator", - "prepared_report": 0, - "ref_doctype": "GL Entry", - "report_name": "Open Undue Tax Report", - "report_type": "Script Report", - "roles": [ - { - "role": "Accounts User" - }, - { - "role": "Accounts Manager" - }, - { - "role": "Auditor" - } - ] -} \ No newline at end of file diff --git a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.py b/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.py deleted file mode 100644 index 92daff3..0000000 --- a/thai_tax/thai_tax/report/open_undue_tax_report/open_undue_tax_report.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright (c) 2023, Kitti U. and contributors -# For license information, please see license.txt - -import frappe -from frappe import _ -from frappe.query_builder import CustomFunction, Case -from frappe.query_builder.functions import Sum, Avg, GroupConcat, Coalesce - -def execute(filters=None): - columns = get_columns() - data = get_data(filters) - return columns, data, None, None, None - - -def get_columns(): - return [ - { - "label": _("Undue Tax"), - "fieldname": "account", - "fieldtype": "Link", - "options": "Account", - "width": 0, - }, - { - "label": _("Voucher Type"), - "fieldname": "voucher_type", - "fieldtype": "Data", - "width": 0, - }, - { - "label": _("Voucher No"), - "fieldname": "voucher_no", - "fieldtype": "Dynamic Link", - "options": "voucher_type", - "width": 0, - }, - { - "label": _("Posting Date"), - "fieldname": "posting_date", - "fieldtype": "Date", - "width": 0, - }, - { - "label": _("Undue Tax Amount"), - "fieldname": "undue_tax_amount", - "fieldtype": "Float", - "width": 0, - }, - { - "label": _("Clear Tax Amount"), - "fieldname": "clear_tax_amount", - "fieldtype": "Float", - "width": 0, - }, - { - "label": _("Open Tax Amount"), - "fieldname": "open_tax_amount", - "fieldtype": "Float", - "width": 0, - }, - { - "label": _("Clearing Vouchers"), - "fieldname": "clearing_vouchers", - "fieldtype": "Data", - "width": 300, - }, - ] - - -def get_data(filters): - - undue = frappe.qb.DocType("GL Entry") - clear = frappe.qb.DocType("GL Entry") - round = CustomFunction("round", ["value", "digit"]) - setting = frappe.get_doc('Tax Invoice Settings') - purchase_tax = setting.purchase_tax_account_undue - avg_undue = Coalesce(Avg(undue.debit-undue.credit), 0) - sum_clear = Coalesce(Sum(clear.debit-clear.credit), 0) - - query = ( - frappe.qb.from_(undue) - .left_outer_join(clear) - .on( - (undue.name == clear.against_gl_entry) - & (clear.account == undue.account) - ) - .select( - undue.account, - undue.voucher_type, - undue.voucher_no, - undue.posting_date, - Case().when(undue.account == purchase_tax, avg_undue).else_(-avg_undue).as_("undue_tax_amount"), - Case().when(undue.account == purchase_tax, -sum_clear).else_(sum_clear).as_("clear_tax_amount"), - Case().when(undue.account == purchase_tax, avg_undue + sum_clear).else_(-avg_undue-sum_clear).as_("open_tax_amount"), - GroupConcat(clear.voucher_no).distinct().as_("clearing_vouchers") - ) - .where(undue.against_gl_entry.isnull()) - .where(undue.account == filters["account"]) - .groupby(undue.account, undue.voucher_type, undue.voucher_no, undue.posting_date) - .orderby(undue.account, undue.voucher_type, undue.voucher_no, undue.posting_date) - ) - - if filters.get("voucher_type"): - query = query.where(undue.voucher_type == filters["voucher_type"]) - if filters.get("voucher_no"): - query = query.where(undue.voucher_no.like("%{0}%".format(filters["voucher_no"]))) - if filters.get("from_date"): - query = query.where(undue.posting_date >= filters["from_date"]) - if filters.get("to_date"): - query = query.where(undue.posting_date <= filters["to_date"]) - - query2 = frappe.qb.from_(query).select("*") - - if filters.get("is_open") == 1: - query2 = query2.where(round(query.open_tax_amount, 3) != 0) - - result = query2.run(as_dict=True) - - return result diff --git a/thai_tax/thai_tax/report/to_clear_purchase_tax/__init__.py b/thai_tax/thai_tax/report/to_clear_purchase_tax/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/thai_tax/thai_tax/report/to_clear_purchase_tax/to_clear_purchase_tax.json b/thai_tax/thai_tax/report/to_clear_purchase_tax/to_clear_purchase_tax.json deleted file mode 100644 index ba51880..0000000 --- a/thai_tax/thai_tax/report/to_clear_purchase_tax/to_clear_purchase_tax.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "add_total_row": 1, - "columns": [ - { - "fieldname": "name", - "fieldtype": "Data", - "label": "GL Entry", - "width": 0 - }, - { - "fieldname": "voucher_type", - "fieldtype": "Link", - "label": "DocType", - "options": "DocType", - "width": 0 - }, - { - "fieldname": "voucher_no", - "fieldtype": "Dynamic Link", - "label": "Document", - "options": "voucher_type", - "width": 0 - }, - { - "fieldname": "amount", - "fieldtype": "Currency", - "label": "Remaining", - "width": 0 - } - ], - "creation": "2023-03-26 22:46:50.223662", - "disable_prepared_report": 0, - "disabled": 0, - "docstatus": 0, - "doctype": "Report", - "filters": [ - { - "fieldname": "year", - "fieldtype": "Link", - "label": "Year", - "mandatory": 1, - "options": "Fiscal Year", - "wildcard_filter": 0 - }, - { - "fieldname": "month", - "fieldtype": "Select", - "label": "Month", - "mandatory": 1, - "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12", - "wildcard_filter": 0 - } - ], - "idx": 0, - "is_standard": "Yes", - "letter_head": "", - "modified": "2023-03-26 22:50:10.773756", - "modified_by": "Administrator", - "module": "Thai Tax", - "name": "To Clear Purchase Tax", - "owner": "Administrator", - "prepared_report": 0, - "query": "select gl.name, gl.voucher_type, gl.voucher_no, rm.amount from\n(select name, sum(debit-credit) amount\nfrom (\n(\n select name, debit, credit\n from `tabGL Entry`\n where account = 'Undue VAT - TH'\n and against_gl_entry is null\n)\nunion all\n(\n select against_gl_entry name, debit, credit\n from `tabGL Entry`\n where account = 'Undue VAT - TH'\n and against_gl_entry is not null\n)\n) a\ngroup by name) rm\njoin `tabGL Entry` gl on gl.name = rm.name\nwhere rm.amount !=0 \nand month(gl.posting_date) = %(month)s\nand year(gl.posting_date) = %(year)s", - "ref_doctype": "GL Entry", - "report_name": "To Clear Purchase Tax", - "report_script": "", - "report_type": "Query Report", - "roles": [ - { - "role": "Accounts Manager" - }, - { - "role": "Accounts User" - } - ] -} \ No newline at end of file diff --git a/thai_tax/thai_tax/workspace/thai_tax/thai_tax.json b/thai_tax/thai_tax/workspace/thai_tax/thai_tax.json new file mode 100644 index 0000000..153530c --- /dev/null +++ b/thai_tax/thai_tax/workspace/thai_tax/thai_tax.json @@ -0,0 +1,140 @@ +{ + "charts": [], + "content": "[{\"id\":\"Uty0KUCJZZ\",\"type\":\"onboarding\",\"data\":{\"onboarding_name\":\"Thai Tax\",\"col\":12}},{\"id\":\"0xFTodMRF1\",\"type\":\"card\",\"data\":{\"card_name\":\"Tax Invoices\",\"col\":4}},{\"id\":\"MOY2MzVVaE\",\"type\":\"card\",\"data\":{\"card_name\":\"Reports\",\"col\":4}},{\"id\":\"NLSyjJJigj\",\"type\":\"card\",\"data\":{\"card_name\":\"Settings\",\"col\":4}}]", + "creation": "2023-06-22 11:35:38.341907", + "custom_blocks": [], + "docstatus": 0, + "doctype": "Workspace", + "for_user": "", + "hide_custom": 0, + "icon": "milestone", + "idx": 0, + "is_hidden": 0, + "label": "Thai Tax", + "links": [ + { + "hidden": 0, + "is_query_report": 0, + "label": "Settings", + "link_count": 2, + "onboard": 0, + "type": "Card Break" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Tax Invoice Setting", + "link_count": 0, + "link_to": "Tax Invoice Settings", + "link_type": "DocType", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Withholding Tax Type", + "link_count": 0, + "link_to": "Withholding Tax Type", + "link_type": "DocType", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Tax Invoices", + "link_count": 2, + "onboard": 0, + "type": "Card Break" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Sales Tax Invoice", + "link_count": 0, + "link_to": "Sales Tax Invoice", + "link_type": "DocType", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Purchase Tax Invoice", + "link_count": 0, + "link_to": "Purchase Tax Invoice", + "link_type": "DocType", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Reports", + "link_count": 4, + "onboard": 0, + "type": "Card Break" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Sales Tax Report", + "link_count": 0, + "link_to": "Sales Tax Report", + "link_type": "Report", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Purchase Tax Report", + "link_count": 0, + "link_to": "Purchase Tax Report", + "link_type": "Report", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "PND3", + "link_count": 0, + "link_to": "PND3", + "link_type": "Report", + "onboard": 0, + "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "PND53", + "link_count": 0, + "link_to": "PND53", + "link_type": "Report", + "onboard": 0, + "type": "Link" + } + ], + "modified": "2023-06-22 12:53:31.947656", + "modified_by": "Administrator", + "module": "Thai Tax", + "name": "Thai Tax", + "number_cards": [], + "owner": "Administrator", + "parent_page": "Accounting", + "public": 1, + "quick_lists": [], + "roles": [ + { + "role": "Accounts User" + }, + { + "role": "Accounts Manager" + } + ], + "sequence_id": 39.0, + "shortcuts": [], + "title": "Thai Tax" +} \ No newline at end of file