feat: add test case for report output
diff --git a/erpnext/accounts/report/tax_detail/tax_detail.py b/erpnext/accounts/report/tax_detail/tax_detail.py
index 426e8d4..fb7791f 100644
--- a/erpnext/accounts/report/tax_detail/tax_detail.py
+++ b/erpnext/accounts/report/tax_detail/tax_detail.py
@@ -11,7 +11,7 @@
# field lists in multiple doctypes will be coalesced
required_sql_fields = {
("GL Entry", 1): ["posting_date"],
- ("Account",): ["account_type"],
+ ("Account",): ["root_type", "account_type"],
("GL Entry", 2): ["account", "voucher_type", "voucher_no", "debit", "credit"],
("Purchase Invoice Item", "Sales Invoice Item"): ["base_net_amount", "item_tax_rate", "item_tax_template", "item_group", "item_name"],
("Purchase Invoice", "Sales Invoice"): ["taxes_and_charges", "tax_category"],
diff --git a/erpnext/accounts/report/tax_detail/test_tax_detail.json b/erpnext/accounts/report/tax_detail/test_tax_detail.json
new file mode 100644
index 0000000..17248d0
--- /dev/null
+++ b/erpnext/accounts/report/tax_detail/test_tax_detail.json
@@ -0,0 +1,755 @@
+[
+ {
+ "abbr": "_T",
+ "company_name": "_T",
+ "country": "United Kingdom",
+ "default_currency": "GBP",
+ "doctype": "Company",
+ "name": "_T"
+ },{
+ "account_currency": "GBP",
+ "account_name": "Debtors",
+ "account_number": "",
+ "account_type": "Receivable",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 58,
+ "modified": "2021-03-26 04:44:19.955468",
+ "name": "Debtors - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Application of Funds (Assets) - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Balance Sheet",
+ "rgt": 59,
+ "root_type": "Asset",
+ "tax_rate": 0.0
+ },{
+ "account_currency": "GBP",
+ "account_name": "Sales",
+ "account_number": "",
+ "account_type": "Income Account",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 291,
+ "modified": "2021-03-26 04:50:21.697703",
+ "name": "Sales - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Income - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Profit and Loss",
+ "rgt": 292,
+ "root_type": "Income",
+ "tax_rate": 0.0
+ },{
+ "account_currency": "GBP",
+ "account_name": "VAT on Sales",
+ "account_number": "",
+ "account_type": "Tax",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 317,
+ "modified": "2021-03-26 04:50:21.697703",
+ "name": "VAT on Sales - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Source of Funds (Liabilities) - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Balance Sheet",
+ "rgt": 318,
+ "root_type": "Liability",
+ "tax_rate": 0.0
+ },{
+ "account_currency": "GBP",
+ "account_name": "Cost of Goods Sold",
+ "account_number": "",
+ "account_type": "Cost of Goods Sold",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 171,
+ "modified": "2021-03-26 04:44:19.994857",
+ "name": "Cost of Goods Sold - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Expenses - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Profit and Loss",
+ "rgt": 172,
+ "root_type": "Expense",
+ "tax_rate": 0.0
+ },{
+ "account_currency": "GBP",
+ "account_name": "VAT on Purchases",
+ "account_number": "",
+ "account_type": "Tax",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 80,
+ "modified": "2021-03-26 04:44:19.961983",
+ "name": "VAT on Purchases - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Application of Funds (Assets) - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Balance Sheet",
+ "rgt": 81,
+ "root_type": "Asset",
+ "tax_rate": 0.0
+ },{
+ "account_currency": "GBP",
+ "account_name": "Creditors",
+ "account_number": "",
+ "account_type": "Payable",
+ "balance_must_be": "",
+ "company": "_T",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Account",
+ "freeze_account": "No",
+ "include_in_gross": 0,
+ "inter_company_account": 0,
+ "is_group": 0,
+ "lft": 302,
+ "modified": "2021-03-26 04:50:21.697703",
+ "name": "Creditors - _T",
+ "old_parent": null,
+ "parent": null,
+ "parent_account": "Source of Funds (Liabilities) - _T",
+ "parentfield": null,
+ "parenttype": null,
+ "report_type": "Balance Sheet",
+ "rgt": 303,
+ "root_type": "Liability",
+ "tax_rate": 0.0
+ },{
+ "additional_discount_percentage": 0.0,
+ "address_display": null,
+ "adjust_advance_taxes": 0,
+ "advances": [],
+ "against_expense_account": "Cost of Goods Sold - _T",
+ "allocate_advances_automatically": 0,
+ "amended_from": null,
+ "apply_discount_on": "Grand Total",
+ "apply_tds": 0,
+ "auto_repeat": null,
+ "base_discount_amount": 0.0,
+ "base_grand_total": 511.68,
+ "base_in_words": "GBP Five Hundred And Eleven and Sixty Eight Pence only.",
+ "base_net_total": 426.4,
+ "base_paid_amount": 0.0,
+ "base_rounded_total": 511.68,
+ "base_rounding_adjustment": 0.0,
+ "base_taxes_and_charges_added": 85.28,
+ "base_taxes_and_charges_deducted": 0.0,
+ "base_total": 426.4,
+ "base_total_taxes_and_charges": 85.28,
+ "base_write_off_amount": 0.0,
+ "bill_date": null,
+ "bill_no": null,
+ "billing_address": null,
+ "billing_address_display": null,
+ "buying_price_list": "Standard Buying",
+ "cash_bank_account": null,
+ "clearance_date": null,
+ "company": "_T",
+ "contact_display": null,
+ "contact_email": null,
+ "contact_mobile": null,
+ "contact_person": null,
+ "conversion_rate": 1.0,
+ "cost_center": null,
+ "credit_to": "Creditors - _T",
+ "currency": "GBP",
+ "disable_rounded_total": 0,
+ "discount_amount": 0.0,
+ "docstatus": 0,
+ "doctype": "Purchase Invoice",
+ "due_date": "2021-04-30",
+ "from_date": null,
+ "grand_total": 511.68,
+ "group_same_items": 0,
+ "hold_comment": null,
+ "ignore_pricing_rule": 0,
+ "in_words": "GBP Five Hundred And Eleven and Sixty Eight Pence only.",
+ "inter_company_invoice_reference": null,
+ "is_internal_supplier": 0,
+ "is_opening": "No",
+ "is_paid": 0,
+ "is_return": 0,
+ "is_subcontracted": "No",
+ "items": [
+ {
+ "allow_zero_valuation_rate": 0,
+ "amount": 426.4,
+ "asset_category": null,
+ "asset_location": null,
+ "base_amount": 426.4,
+ "base_net_amount": 426.4,
+ "base_net_rate": 5.33,
+ "base_price_list_rate": 5.33,
+ "base_rate": 5.33,
+ "base_rate_with_margin": 0.0,
+ "batch_no": null,
+ "bom": null,
+ "brand": null,
+ "conversion_factor": 0.0,
+ "cost_center": "Main - _T",
+ "deferred_expense_account": null,
+ "description": "<div class=\"ql-editor read-mode\"><p>Fluid to make widgets</p></div>",
+ "discount_amount": 0.0,
+ "discount_percentage": 0.0,
+ "enable_deferred_expense": 0,
+ "expense_account": "Cost of Goods Sold - _T",
+ "from_warehouse": null,
+ "image": null,
+ "include_exploded_items": 0,
+ "is_fixed_asset": 0,
+ "is_free_item": 0,
+ "item_code": null,
+ "item_group": null,
+ "item_name": "Widget Fluid 1Litre",
+ "item_tax_amount": 0.0,
+ "item_tax_rate": "{\"VAT on Purchases - _T\": 20.0}",
+ "item_tax_template": "Purchase - Standard VAT",
+ "landed_cost_voucher_amount": 0.0,
+ "manufacturer": null,
+ "manufacturer_part_no": null,
+ "margin_rate_or_amount": 0.0,
+ "margin_type": "",
+ "net_amount": 426.4,
+ "net_rate": 5.33,
+ "page_break": 0,
+ "parent": null,
+ "parentfield": "items",
+ "parenttype": "Purchase Invoice",
+ "po_detail": null,
+ "pr_detail": null,
+ "price_list_rate": 5.33,
+ "pricing_rules": null,
+ "project": null,
+ "purchase_invoice_item": null,
+ "purchase_order": null,
+ "purchase_receipt": null,
+ "qty": 80.0,
+ "quality_inspection": null,
+ "rate": 5.33,
+ "rate_with_margin": 0.0,
+ "received_qty": 0.0,
+ "rejected_qty": 0.0,
+ "rejected_serial_no": null,
+ "rejected_warehouse": null,
+ "rm_supp_cost": 0.0,
+ "sales_invoice_item": null,
+ "serial_no": null,
+ "service_end_date": null,
+ "service_start_date": null,
+ "service_stop_date": null,
+ "stock_qty": 0.0,
+ "stock_uom": "Nos",
+ "stock_uom_rate": 0.0,
+ "total_weight": 0.0,
+ "uom": "Nos",
+ "valuation_rate": 0.0,
+ "warehouse": null,
+ "weight_per_unit": 0.0,
+ "weight_uom": null
+ }
+ ],
+ "language": "en",
+ "letter_head": null,
+ "mode_of_payment": null,
+ "modified": "2021-04-03 03:33:09.180453",
+ "name": null,
+ "naming_series": "ACC-PINV-.YYYY.-",
+ "net_total": 426.4,
+ "on_hold": 0,
+ "other_charges_calculation": "<div class=\"tax-break-up\" style=\"overflow-x: auto;\">\n\t<table class=\"table table-bordered table-hover\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-left\">Item</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-right\">Taxable Amount</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-right\">VAT on Purchases</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Widget Fluid 1Litre</td>\n\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\u00a3 426.40\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t(20.0%)\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\u00a3 85.28\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t</tbody>\n\t</table>\n</div>",
+ "outstanding_amount": 511.68,
+ "paid_amount": 0.0,
+ "parent": null,
+ "parentfield": null,
+ "parenttype": null,
+ "party_account_currency": "GBP",
+ "payment_schedule": [],
+ "payment_terms_template": null,
+ "plc_conversion_rate": 1.0,
+ "posting_date": null,
+ "posting_time": "16:59:56.789522",
+ "price_list_currency": "GBP",
+ "pricing_rules": [],
+ "project": null,
+ "rejected_warehouse": null,
+ "release_date": null,
+ "remarks": "No Remarks",
+ "represents_company": null,
+ "return_against": null,
+ "rounded_total": 511.68,
+ "rounding_adjustment": 0.0,
+ "scan_barcode": null,
+ "select_print_heading": null,
+ "set_from_warehouse": null,
+ "set_posting_time": 0,
+ "set_warehouse": null,
+ "shipping_address": null,
+ "shipping_address_display": "",
+ "shipping_rule": null,
+ "status": "Unpaid",
+ "supplied_items": [],
+ "supplier": "Raw Materials Inc",
+ "supplier_address": null,
+ "supplier_name": "Raw Materials Inc",
+ "supplier_warehouse": "Stores - _T",
+ "tax_category": "Other Supplier",
+ "tax_id": null,
+ "tax_withholding_category": null,
+ "taxes": [
+ {
+ "account_head": "VAT on Purchases - _T",
+ "add_deduct_tax": "Add",
+ "base_tax_amount": 85.28,
+ "base_tax_amount_after_discount_amount": 85.28,
+ "base_total": 511.68,
+ "category": "Total",
+ "charge_type": "On Net Total",
+ "cost_center": "Main - _T",
+ "description": "VAT on Purchases",
+ "included_in_print_rate": 0,
+ "item_wise_tax_detail": "{\"Widget Fluid 1Litre\":[20.0,85.28]}",
+ "parent": null,
+ "parentfield": "taxes",
+ "parenttype": "Purchase Invoice",
+ "rate": 0.0,
+ "row_id": null,
+ "tax_amount": 85.28,
+ "tax_amount_after_discount_amount": 85.28,
+ "total": 511.68
+ }
+ ],
+ "taxes_and_charges": null,
+ "taxes_and_charges_added": 85.28,
+ "taxes_and_charges_deducted": 0.0,
+ "tc_name": null,
+ "terms": null,
+ "title": "Raw Materials Inc",
+ "to_date": null,
+ "total": 426.4,
+ "total_advance": 0.0,
+ "total_net_weight": 0.0,
+ "total_qty": 80.0,
+ "total_taxes_and_charges": 85.28,
+ "unrealized_profit_loss_account": null,
+ "update_stock": 0,
+ "write_off_account": null,
+ "write_off_amount": 0.0,
+ "write_off_cost_center": null
+ },{
+ "account_for_change_amount": null,
+ "additional_discount_percentage": 0.0,
+ "address_display": null,
+ "advances": [],
+ "against_income_account": "Sales - _T",
+ "allocate_advances_automatically": 0,
+ "amended_from": null,
+ "apply_discount_on": "Grand Total",
+ "auto_repeat": null,
+ "base_change_amount": 0.0,
+ "base_discount_amount": 0.0,
+ "base_grand_total": 868.25,
+ "base_in_words": "GBP Eight Hundred And Sixty Eight and Twenty Five Pence only.",
+ "base_net_total": 825.0,
+ "base_paid_amount": 0.0,
+ "base_rounded_total": 868.25,
+ "base_rounding_adjustment": 0.0,
+ "base_total": 825.0,
+ "base_total_taxes_and_charges": 43.25,
+ "base_write_off_amount": 0.0,
+ "c_form_applicable": "No",
+ "c_form_no": null,
+ "campaign": null,
+ "cash_bank_account": null,
+ "change_amount": 0.0,
+ "commission_rate": 0.0,
+ "company": "_T",
+ "company_address": null,
+ "company_address_display": null,
+ "company_tax_id": null,
+ "contact_display": null,
+ "contact_email": null,
+ "contact_mobile": null,
+ "contact_person": null,
+ "conversion_rate": 1.0,
+ "cost_center": null,
+ "currency": "GBP",
+ "customer": "ABC Tyres",
+ "customer_address": null,
+ "customer_group": "All Customer Groups",
+ "customer_name": "ABC Tyres",
+ "debit_to": "Debtors - _T",
+ "discount_amount": 0.0,
+ "docstatus": 0,
+ "doctype": "Sales Invoice",
+ "due_date": "2021-03-31",
+ "from_date": null,
+ "grand_total": 868.25,
+ "group_same_items": 0,
+ "ignore_pricing_rule": 0,
+ "in_words": "GBP Eight Hundred And Sixty Eight and Twenty Five Pence only.",
+ "inter_company_invoice_reference": null,
+ "is_consolidated": 0,
+ "is_discounted": 0,
+ "is_internal_customer": 0,
+ "is_opening": "No",
+ "is_pos": 0,
+ "is_return": 0,
+ "items": [
+ {
+ "actual_batch_qty": 0.0,
+ "actual_qty": 0.0,
+ "allow_zero_valuation_rate": 0,
+ "amount": 200.0,
+ "asset": null,
+ "barcode": null,
+ "base_amount": 200.0,
+ "base_net_amount": 200.0,
+ "base_net_rate": 50.0,
+ "base_price_list_rate": 0.0,
+ "base_rate": 50.0,
+ "base_rate_with_margin": 0.0,
+ "batch_no": null,
+ "brand": null,
+ "conversion_factor": 1.0,
+ "cost_center": "Main - _T",
+ "customer_item_code": null,
+ "deferred_revenue_account": null,
+ "delivered_by_supplier": 0,
+ "delivered_qty": 0.0,
+ "delivery_note": null,
+ "description": "<div class=\"ql-editor read-mode\"><p>Used</p></div>",
+ "discount_amount": 0.0,
+ "discount_percentage": 0.0,
+ "dn_detail": null,
+ "enable_deferred_revenue": 0,
+ "expense_account": null,
+ "finance_book": null,
+ "image": null,
+ "income_account": "Sales - _T",
+ "incoming_rate": 0.0,
+ "is_fixed_asset": 0,
+ "is_free_item": 0,
+ "item_code": null,
+ "item_group": null,
+ "item_name": "Dunlop tyres",
+ "item_tax_rate": "{\"VAT on Sales - _T\": 20.0}",
+ "item_tax_template": "Sale - Standard VAT",
+ "margin_rate_or_amount": 0.0,
+ "margin_type": "",
+ "net_amount": 200.0,
+ "net_rate": 50.0,
+ "page_break": 0,
+ "parent": null,
+ "parentfield": "items",
+ "parenttype": "Sales Invoice",
+ "price_list_rate": 0.0,
+ "pricing_rules": null,
+ "project": null,
+ "qty": 4.0,
+ "quality_inspection": null,
+ "rate": 50.0,
+ "rate_with_margin": 0.0,
+ "sales_invoice_item": null,
+ "sales_order": null,
+ "serial_no": null,
+ "service_end_date": null,
+ "service_start_date": null,
+ "service_stop_date": null,
+ "so_detail": null,
+ "stock_qty": 4.0,
+ "stock_uom": "Nos",
+ "stock_uom_rate": 50.0,
+ "target_warehouse": null,
+ "total_weight": 0.0,
+ "uom": "Nos",
+ "warehouse": null,
+ "weight_per_unit": 0.0,
+ "weight_uom": null
+ },
+ {
+ "actual_batch_qty": 0.0,
+ "actual_qty": 0.0,
+ "allow_zero_valuation_rate": 0,
+ "amount": 65.0,
+ "asset": null,
+ "barcode": null,
+ "base_amount": 65.0,
+ "base_net_amount": 65.0,
+ "base_net_rate": 65.0,
+ "base_price_list_rate": 0.0,
+ "base_rate": 65.0,
+ "base_rate_with_margin": 0.0,
+ "batch_no": null,
+ "brand": null,
+ "conversion_factor": 1.0,
+ "cost_center": "Main - _T",
+ "customer_item_code": null,
+ "deferred_revenue_account": null,
+ "delivered_by_supplier": 0,
+ "delivered_qty": 0.0,
+ "delivery_note": null,
+ "description": "<div class=\"ql-editor read-mode\"><p>Used</p></div>",
+ "discount_amount": 0.0,
+ "discount_percentage": 0.0,
+ "dn_detail": null,
+ "enable_deferred_revenue": 0,
+ "expense_account": null,
+ "finance_book": null,
+ "image": null,
+ "income_account": "Sales - _T",
+ "incoming_rate": 0.0,
+ "is_fixed_asset": 0,
+ "is_free_item": 0,
+ "item_code": "",
+ "item_group": null,
+ "item_name": "Continental tyres",
+ "item_tax_rate": "{\"VAT on Sales - _T\": 5.0}",
+ "item_tax_template": "Sale - Reduced VAT",
+ "margin_rate_or_amount": 0.0,
+ "margin_type": "",
+ "net_amount": 65.0,
+ "net_rate": 65.0,
+ "page_break": 0,
+ "parent": null,
+ "parentfield": "items",
+ "parenttype": "Sales Invoice",
+ "price_list_rate": 0.0,
+ "pricing_rules": null,
+ "project": null,
+ "qty": 1.0,
+ "quality_inspection": null,
+ "rate": 65.0,
+ "rate_with_margin": 0.0,
+ "sales_invoice_item": null,
+ "sales_order": null,
+ "serial_no": null,
+ "service_end_date": null,
+ "service_start_date": null,
+ "service_stop_date": null,
+ "so_detail": null,
+ "stock_qty": 1.0,
+ "stock_uom": null,
+ "stock_uom_rate": 65.0,
+ "target_warehouse": null,
+ "total_weight": 0.0,
+ "uom": "Nos",
+ "warehouse": null,
+ "weight_per_unit": 0.0,
+ "weight_uom": null
+ },
+ {
+ "actual_batch_qty": 0.0,
+ "actual_qty": 0.0,
+ "allow_zero_valuation_rate": 0,
+ "amount": 560.0,
+ "asset": null,
+ "barcode": null,
+ "base_amount": 560.0,
+ "base_net_amount": 560.0,
+ "base_net_rate": 70.0,
+ "base_price_list_rate": 0.0,
+ "base_rate": 70.0,
+ "base_rate_with_margin": 0.0,
+ "batch_no": null,
+ "brand": null,
+ "conversion_factor": 1.0,
+ "cost_center": "Main - _T",
+ "customer_item_code": null,
+ "deferred_revenue_account": null,
+ "delivered_by_supplier": 0,
+ "delivered_qty": 0.0,
+ "delivery_note": null,
+ "description": "<div class=\"ql-editor read-mode\"><p>New</p></div>",
+ "discount_amount": 0.0,
+ "discount_percentage": 0.0,
+ "dn_detail": null,
+ "enable_deferred_revenue": 0,
+ "expense_account": null,
+ "finance_book": null,
+ "image": null,
+ "income_account": "Sales - _T",
+ "incoming_rate": 0.0,
+ "is_fixed_asset": 0,
+ "is_free_item": 0,
+ "item_code": null,
+ "item_group": null,
+ "item_name": "Toyo tyres",
+ "item_tax_rate": "{\"VAT on Sales - _T\": 0.0}",
+ "item_tax_template": "Sale - Zero VAT",
+ "margin_rate_or_amount": 0.0,
+ "margin_type": "",
+ "net_amount": 560.0,
+ "net_rate": 70.0,
+ "page_break": 0,
+ "parent": null,
+ "parentfield": "items",
+ "parenttype": "Sales Invoice",
+ "price_list_rate": 0.0,
+ "pricing_rules": null,
+ "project": null,
+ "qty": 8.0,
+ "quality_inspection": null,
+ "rate": 70.0,
+ "rate_with_margin": 0.0,
+ "sales_invoice_item": null,
+ "sales_order": null,
+ "serial_no": null,
+ "service_end_date": null,
+ "service_start_date": null,
+ "service_stop_date": null,
+ "so_detail": null,
+ "stock_qty": 8.0,
+ "stock_uom": null,
+ "stock_uom_rate": 70.0,
+ "target_warehouse": null,
+ "total_weight": 0.0,
+ "uom": "Nos",
+ "warehouse": null,
+ "weight_per_unit": 0.0,
+ "weight_uom": null
+ }
+ ],
+ "language": "en",
+ "letter_head": null,
+ "loyalty_amount": 0.0,
+ "loyalty_points": 0,
+ "loyalty_program": null,
+ "loyalty_redemption_account": null,
+ "loyalty_redemption_cost_center": null,
+ "modified": "2021-02-16 05:18:59.755144",
+ "name": null,
+ "naming_series": "ACC-SINV-.YYYY.-",
+ "net_total": 825.0,
+ "other_charges_calculation": "<div class=\"tax-break-up\" style=\"overflow-x: auto;\">\n\t<table class=\"table table-bordered table-hover\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-left\">Item</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-right\">Taxable Amount</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"text-right\">VAT on Sales</th>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Dunlop tyres</td>\n\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\u00a3 200.00\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t(20.0%)\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\u00a3 40.00\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Continental tyres</td>\n\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\u00a3 65.00\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t(5.0%)\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\u00a3 3.25\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Toyo tyres</td>\n\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\u00a3 560.00\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t<td class='text-right'>\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t(0.0%)\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\u00a3 0.00\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t</tbody>\n\t</table>\n</div>",
+ "outstanding_amount": 868.25,
+ "packed_items": [],
+ "paid_amount": 0.0,
+ "parent": null,
+ "parentfield": null,
+ "parenttype": null,
+ "party_account_currency": "GBP",
+ "payment_schedule": [],
+ "payment_terms_template": null,
+ "payments": [],
+ "plc_conversion_rate": 1.0,
+ "po_date": null,
+ "po_no": "",
+ "pos_profile": null,
+ "posting_date": null,
+ "posting_time": "5:19:02.994077",
+ "price_list_currency": "GBP",
+ "pricing_rules": [],
+ "project": null,
+ "redeem_loyalty_points": 0,
+ "remarks": "No Remarks",
+ "represents_company": "",
+ "return_against": null,
+ "rounded_total": 868.25,
+ "rounding_adjustment": 0.0,
+ "sales_partner": null,
+ "sales_team": [],
+ "scan_barcode": null,
+ "select_print_heading": null,
+ "selling_price_list": "Standard Selling",
+ "set_posting_time": 0,
+ "set_target_warehouse": null,
+ "set_warehouse": null,
+ "shipping_address": null,
+ "shipping_address_name": "",
+ "shipping_rule": null,
+ "source": null,
+ "status": "Overdue",
+ "tax_category": "",
+ "tax_id": null,
+ "taxes": [
+ {
+ "account_head": "VAT on Sales - _T",
+ "base_tax_amount": 43.25,
+ "base_tax_amount_after_discount_amount": 43.25,
+ "base_total": 868.25,
+ "charge_type": "On Net Total",
+ "cost_center": "Main - _T",
+ "description": "VAT on Sales",
+ "included_in_print_rate": 0,
+ "item_wise_tax_detail": "{\"Dunlop tyres\":[20.0,40.0],\"Continental tyres\":[5.0,3.25],\"Toyo tyres\":[0.0,0.0]}",
+ "parent": null,
+ "parentfield": "taxes",
+ "parenttype": "Sales Invoice",
+ "rate": 0.0,
+ "row_id": null,
+ "tax_amount": 43.25,
+ "tax_amount_after_discount_amount": 43.25,
+ "total": 868.25
+ }
+ ],
+ "taxes_and_charges": null,
+ "tc_name": null,
+ "terms": null,
+ "territory": "All Territories",
+ "timesheets": [],
+ "title": "ABC Tyres",
+ "to_date": null,
+ "total": 825.0,
+ "total_advance": 0.0,
+ "total_billing_amount": 0.0,
+ "total_commission": 0.0,
+ "total_net_weight": 0.0,
+ "total_qty": 13.0,
+ "total_taxes_and_charges": 43.25,
+ "unrealized_profit_loss_account": null,
+ "update_billed_amount_in_sales_order": 0,
+ "update_stock": 0,
+ "write_off_account": null,
+ "write_off_amount": 0.0,
+ "write_off_cost_center": null,
+ "write_off_outstanding_amount_automatically": 0
+ }
+]
\ No newline at end of file
diff --git a/erpnext/accounts/report/tax_detail/test_tax_detail.py b/erpnext/accounts/report/tax_detail/test_tax_detail.py
index dfd8d9e..c9b8e20 100644
--- a/erpnext/accounts/report/tax_detail/test_tax_detail.py
+++ b/erpnext/accounts/report/tax_detail/test_tax_detail.py
@@ -1,12 +1,98 @@
from __future__ import unicode_literals
-import frappe, unittest, datetime
-from frappe.utils import getdate
-from .tax_detail import execute, filter_match
+import frappe, unittest, datetime, json, os
+from frappe.utils import getdate, add_to_date, get_first_day, get_last_day
+from .tax_detail import filter_match, save_custom_report
class TestTaxDetail(unittest.TestCase):
- def setup(self):
- pass
+ def load_testdocs(self):
+ datapath, _ = os.path.splitext(os.path.realpath(__file__))
+ with open(datapath + '.json', 'r') as fp:
+ self.docs = json.load(fp)
+
+ def load_defcols(self):
+ custom_report = frappe.get_doc('Report', 'Tax Detail')
+ self.default_columns, _ = custom_report.run_query_report(
+ filters={
+ 'from_date': '2021-03-01',
+ 'to_date': '2021-03-31',
+ 'company': '_T',
+ 'mode': 'run',
+ 'report_name': 'Tax Detail'
+ }, user=frappe.session.user)
+
+ def setUp(self):
+ "Add Transactions in 01-03-2021 - 31-03-2021"
+ self.load_testdocs()
+ now = getdate()
+ self.from_date = get_first_day(now)
+ self.to_date = get_last_day(now)
+
+ for doc in self.docs:
+ try:
+ db_doc = frappe.get_doc(doc)
+ if 'Invoice' in db_doc.doctype:
+ db_doc.due_date = add_to_date(now, days=1)
+ db_doc.insert()
+ # Create GL Entries:
+ db_doc.submit()
+ else:
+ db_doc.insert()
+ except frappe.exceptions.DuplicateEntryError as e:
+ pass
+ #print(f'Duplicate Entry: {e}')
+ except:
+ print(f'\nError importing {doc["doctype"]}: {doc["name"]}')
+ raise
+
+ self.load_defcols()
+
+ def tearDown(self):
+ "Remove the Company and all data"
+ from erpnext.setup.doctype.company.delete_company_transactions import delete_company_transactions
+ for co in filter(lambda doc: doc['doctype'] == 'Company', self.docs):
+ delete_company_transactions(co['name'])
+ db_co = frappe.get_doc('Company', co['name'])
+ db_co.delete()
+
+ def test_report(self):
+ report_name = save_custom_report(
+ 'Tax Detail',
+ '_Test Tax Detail',
+ json.dumps({
+ 'columns': self.default_columns,
+ 'sections': {
+ 'Box1':{'Filter0':{'type':'filter','filters':{'4':'VAT on Sales'}}},
+ 'Box2':{'Filter0':{'type':'filter','filters':{'4':'Acquisition'}}},
+ 'Box3':{'Box1':{'type':'section'},'Box2':{'type':'section'}},
+ 'Box4':{'Filter0':{'type':'filter','filters':{'4':'VAT on Purchases'}}},
+ 'Box5':{'Box3':{'type':'section'},'Box4':{'type':'section'}},
+ 'Box6':{'Filter0':{'type':'filter','filters':{'3':'!=Tax','4':'Sales'}}},
+ 'Box7':{'Filter0':{'type':'filter','filters':{'2':'Expense','3':'!=Tax'}}},
+ 'Box8':{'Filter0':{'type':'filter','filters':{'3':'!=Tax','4':'Sales','12':'EU'}}},
+ 'Box9':{'Filter0':{'type':'filter','filters':{'2':'Expense','3':'!=Tax','12':'EU'}}}
+ },
+ 'show_detail': 1
+ }))
+ data = frappe.desk.query_report.run(report_name,
+ filters={
+ 'from_date': self.from_date,
+ 'to_date': self.to_date,
+ 'company': '_T',
+ 'mode': 'run',
+ 'report_name': report_name
+ }, user=frappe.session.user)
+
+ self.assertListEqual(data.get('columns'), self.default_columns)
+ expected = (('Box1', 43.25), ('Box2', 0.0), ('Box3', 43.25), ('Box4', -85.28), ('Box5', -42.03),
+ ('Box6', 825.0), ('Box7', -426.40), ('Box8', 0.0), ('Box9', 0.0))
+ exrow = iter(expected)
+ for row in data.get('result'):
+ if row.get('voucher_no') and not row.get('posting_date'):
+ label, value = next(exrow)
+ self.assertDictEqual(row, {'voucher_no': label, 'amount': value})
+ self.assertListEqual(data.get('report_summary'),
+ [{'label': label, 'datatype': 'Currency', 'value': value} for label, value in expected])
def test_filter_match(self):
# None - treated as -inf number except range