chore: Test case for adance TDS allocation

This commit is contained in:
Deepesh Garg 2021-05-19 18:38:35 +05:30
parent a23aaf43f4
commit c9da1fc568
6 changed files with 233 additions and 334 deletions

View File

@ -97,9 +97,7 @@
{ {
"fieldname": "type_of_payment", "fieldname": "type_of_payment",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Type of Payment", "label": "Type of Payment"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -109,9 +107,7 @@
"options": "ACC-PAY-.YYYY.-", "options": "ACC-PAY-.YYYY.-",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1,
"set_only_once": 1, "set_only_once": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -122,15 +118,11 @@
"label": "Payment Type", "label": "Payment Type",
"options": "Receive\nPay\nInternal Transfer", "options": "Receive\nPay\nInternal Transfer",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_5", "fieldname": "column_break_5",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -139,9 +131,7 @@
"fieldtype": "Date", "fieldtype": "Date",
"in_list_view": 1, "in_list_view": 1,
"label": "Posting Date", "label": "Posting Date",
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "company", "fieldname": "company",
@ -150,34 +140,26 @@
"options": "Company", "options": "Company",
"print_hide": 1, "print_hide": 1,
"remember_last_selected_value": 1, "remember_last_selected_value": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Cost Center", "label": "Cost Center",
"options": "Cost Center", "options": "Cost Center"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "mode_of_payment", "fieldname": "mode_of_payment",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "Mode of Payment", "label": "Mode of Payment",
"options": "Mode of Payment", "options": "Mode of Payment"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)", "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)",
"fieldname": "party_section", "fieldname": "party_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Payment From / To", "label": "Payment From / To"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.docstatus==0", "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.docstatus==0",
@ -187,9 +169,7 @@
"label": "Party Type", "label": "Party Type",
"options": "DocType", "options": "DocType",
"print_hide": 1, "print_hide": 1,
"search_index": 1, "search_index": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -198,9 +178,7 @@
"fieldtype": "Dynamic Link", "fieldtype": "Dynamic Link",
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Party", "label": "Party",
"options": "party_type", "options": "party_type"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
@ -208,24 +186,18 @@
"fieldname": "party_name", "fieldname": "party_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_global_search": 1, "in_global_search": 1,
"label": "Party Name", "label": "Party Name"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_11", "fieldname": "column_break_11",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "party", "depends_on": "party",
"fieldname": "contact_person", "fieldname": "contact_person",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Contact", "label": "Contact",
"options": "Contact", "options": "Contact"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "contact_person", "depends_on": "contact_person",
@ -233,17 +205,13 @@
"fieldtype": "Data", "fieldtype": "Data",
"label": "Email", "label": "Email",
"options": "Email", "options": "Email",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
"fieldname": "payment_accounts_section", "fieldname": "payment_accounts_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Accounts", "label": "Accounts"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "party", "depends_on": "party",
@ -251,9 +219,7 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Party Balance", "label": "Party Balance",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -264,9 +230,7 @@
"label": "Account Paid From", "label": "Account Paid From",
"options": "Account", "options": "Account",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "paid_from", "depends_on": "paid_from",
@ -276,9 +240,7 @@
"options": "Currency", "options": "Currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "paid_from", "depends_on": "paid_from",
@ -287,15 +249,11 @@
"label": "Account Balance", "label": "Account Balance",
"options": "paid_from_account_currency", "options": "paid_from_account_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_18", "fieldname": "column_break_18",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:(in_list([\"Internal Transfer\", \"Receive\"], doc.payment_type) || doc.party)", "depends_on": "eval:(in_list([\"Internal Transfer\", \"Receive\"], doc.payment_type) || doc.party)",
@ -305,9 +263,7 @@
"label": "Account Paid To", "label": "Account Paid To",
"options": "Account", "options": "Account",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "paid_to", "depends_on": "paid_to",
@ -317,9 +273,7 @@
"options": "Currency", "options": "Currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "paid_to", "depends_on": "paid_to",
@ -328,17 +282,13 @@
"label": "Account Balance", "label": "Account Balance",
"options": "paid_to_account_currency", "options": "paid_to_account_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:(doc.paid_to && doc.paid_from)", "depends_on": "eval:(doc.paid_to && doc.paid_from)",
"fieldname": "payment_amounts_section", "fieldname": "payment_amounts_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Amount", "label": "Amount"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -346,18 +296,14 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Paid Amount", "label": "Paid Amount",
"options": "paid_from_account_currency", "options": "paid_from_account_currency",
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "source_exchange_rate", "fieldname": "source_exchange_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Exchange Rate", "label": "Exchange Rate",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_paid_amount", "fieldname": "base_paid_amount",
@ -366,15 +312,11 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_21", "fieldname": "column_break_21",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -383,18 +325,14 @@
"label": "Received Amount", "label": "Received Amount",
"options": "paid_to_account_currency", "options": "paid_to_account_currency",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "target_exchange_rate", "fieldname": "target_exchange_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Exchange Rate", "label": "Exchange Rate",
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_received_amount", "fieldname": "base_received_amount",
@ -403,40 +341,30 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:(doc.party && doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)", "depends_on": "eval:(doc.party && doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)",
"fieldname": "section_break_14", "fieldname": "section_break_14",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Reference", "label": "Reference"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:doc.docstatus==0", "depends_on": "eval:doc.docstatus==0",
"fieldname": "get_outstanding_invoice", "fieldname": "get_outstanding_invoice",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Get Outstanding Invoice", "label": "Get Outstanding Invoice"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "references", "fieldname": "references",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Payment References", "label": "Payment References",
"options": "Payment Entry Reference", "options": "Payment Entry Reference"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "section_break_34", "fieldname": "section_break_34",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Writeoff", "label": "Writeoff"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -445,9 +373,7 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Total Allocated Amount", "label": "Total Allocated Amount",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_total_allocated_amount", "fieldname": "base_total_allocated_amount",
@ -455,31 +381,23 @@
"label": "Total Allocated Amount (Company Currency)", "label": "Total Allocated Amount (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "set_exchange_gain_loss", "fieldname": "set_exchange_gain_loss",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Set Exchange Gain / Loss", "label": "Set Exchange Gain / Loss"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_36", "fieldname": "column_break_36",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:(doc.paid_amount && doc.received_amount && doc.references)", "depends_on": "eval:(doc.paid_amount && doc.received_amount && doc.references)",
"fieldname": "unallocated_amount", "fieldname": "unallocated_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Unallocated Amount", "label": "Unallocated Amount",
"print_hide": 1, "print_hide": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -489,17 +407,13 @@
"label": "Difference Amount (Company Currency)", "label": "Difference Amount (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "difference_amount", "depends_on": "difference_amount",
"fieldname": "write_off_difference_amount", "fieldname": "write_off_difference_amount",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Write Off Difference Amount", "label": "Write Off Difference Amount"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
@ -507,39 +421,29 @@
"depends_on": "eval:(doc.paid_amount && doc.received_amount)", "depends_on": "eval:(doc.paid_amount && doc.received_amount)",
"fieldname": "deductions_or_loss_section", "fieldname": "deductions_or_loss_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Deductions or Loss", "label": "Deductions or Loss"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "deductions", "fieldname": "deductions",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Payment Deductions or Loss", "label": "Payment Deductions or Loss",
"options": "Payment Entry Deduction", "options": "Payment Entry Deduction"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "transaction_references", "fieldname": "transaction_references",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Transaction ID", "label": "Transaction ID"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
"depends_on": "eval:(doc.paid_from && doc.paid_to)", "depends_on": "eval:(doc.paid_from && doc.paid_to)",
"fieldname": "reference_no", "fieldname": "reference_no",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Cheque/Reference No", "label": "Cheque/Reference No"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_23", "fieldname": "column_break_23",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -547,9 +451,7 @@
"fieldname": "reference_date", "fieldname": "reference_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Cheque/Reference Date", "label": "Cheque/Reference Date",
"search_index": 1, "search_index": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:doc.docstatus==1", "depends_on": "eval:doc.docstatus==1",
@ -558,76 +460,58 @@
"label": "Clearance Date", "label": "Clearance Date",
"no_copy": 1, "no_copy": 1,
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
"depends_on": "eval:(doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)", "depends_on": "eval:(doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)",
"fieldname": "section_break_12", "fieldname": "section_break_12",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "More Information", "label": "More Information"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "project", "fieldname": "project",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Project", "label": "Project",
"options": "Project", "options": "Project",
"print_hide": 1, "print_hide": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "remarks", "fieldname": "remarks",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"label": "Remarks", "label": "Remarks",
"no_copy": 1, "no_copy": 1,
"read_only_depends_on": "eval:doc.custom_remarks == 0", "read_only_depends_on": "eval:doc.custom_remarks == 0"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_16", "fieldname": "column_break_16",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "letter_head", "fieldname": "letter_head",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Letter Head", "label": "Letter Head",
"options": "Letter Head", "options": "Letter Head",
"print_hide": 1, "print_hide": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "print_heading", "fieldname": "print_heading",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Print Heading", "label": "Print Heading",
"options": "Print Heading", "options": "Print Heading",
"print_hide": 1, "print_hide": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fetch_from": "bank_account.bank", "fetch_from": "bank_account.bank",
"fieldname": "bank", "fieldname": "bank",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"label": "Bank", "label": "Bank"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fetch_from": "bank_account.bank_account_no", "fetch_from": "bank_account.bank_account_no",
"fieldname": "bank_account_no", "fieldname": "bank_account_no",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"label": "Bank Account No", "label": "Bank Account No"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "payment_order", "fieldname": "payment_order",
@ -636,16 +520,12 @@
"no_copy": 1, "no_copy": 1,
"options": "Payment Order", "options": "Payment Order",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "subscription_section", "fieldname": "subscription_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Subscription Section", "label": "Subscription Section"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
@ -655,9 +535,7 @@
"no_copy": 1, "no_copy": 1,
"options": "Auto Repeat", "options": "Auto Repeat",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "amended_from", "fieldname": "amended_from",
@ -666,9 +544,7 @@
"no_copy": 1, "no_copy": 1,
"options": "Payment Entry", "options": "Payment Entry",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "title", "fieldname": "title",
@ -683,18 +559,14 @@
"fieldname": "bank_account", "fieldname": "bank_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Company Bank Account", "label": "Company Bank Account",
"options": "Bank Account", "options": "Bank Account"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "party", "depends_on": "party",
"fieldname": "party_bank_account", "fieldname": "party_bank_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Party Bank Account", "label": "Party Bank Account",
"options": "Bank Account", "options": "Bank Account"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "payment_order_status", "fieldname": "payment_order_status",
@ -702,23 +574,17 @@
"hidden": 1, "hidden": 1,
"label": "Payment Order Status", "label": "Payment Order Status",
"options": "Initiated\nPayment Ordered", "options": "Initiated\nPayment Ordered",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
"fieldname": "accounting_dimensions_section", "fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Accounting Dimensions", "label": "Accounting Dimensions"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "dimension_col_break", "fieldname": "dimension_col_break",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "Draft", "default": "Draft",
@ -739,70 +605,55 @@
"fieldname": "tax_withholding_category", "fieldname": "tax_withholding_category",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Tax Withholding Category", "label": "Tax Withholding Category",
"options": "Tax Withholding Category", "mandatory_depends_on": "eval:doc.apply_tax_withholding_amount",
"show_days": 1, "options": "Tax Withholding Category"
"show_seconds": 1
}, },
{ {
"default": "0", "default": "0",
"depends_on": "eval:doc.party_type == 'Supplier'", "depends_on": "eval:doc.party_type == 'Supplier'",
"fieldname": "apply_tax_withholding_amount", "fieldname": "apply_tax_withholding_amount",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Apply Tax Withholding Amount", "label": "Apply Tax Withholding Amount"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
"fieldname": "taxes_and_charges_section", "fieldname": "taxes_and_charges_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Taxes and Charges", "label": "Taxes and Charges"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:doc.party_type == 'Supplier'", "depends_on": "eval:doc.party_type == 'Supplier'",
"fieldname": "purchase_taxes_and_charges_template", "fieldname": "purchase_taxes_and_charges_template",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Taxes and Charges Template", "label": "Taxes and Charges Template",
"options": "Purchase Taxes and Charges Template", "options": "Purchase Taxes and Charges Template"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval: doc.party_type == 'Customer'", "depends_on": "eval: doc.party_type == 'Customer'",
"fieldname": "sales_taxes_and_charges_template", "fieldname": "sales_taxes_and_charges_template",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Taxes and Charges Template", "label": "Taxes and Charges Template",
"options": "Sales Taxes and Charges Template", "options": "Sales Taxes and Charges Template"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval: doc.party_type == 'Supplier' || doc.party_type == 'Customer'", "depends_on": "eval: doc.party_type == 'Supplier' || doc.party_type == 'Customer'",
"fieldname": "taxes", "fieldname": "taxes",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Advance Taxes and Charges", "label": "Advance Taxes and Charges",
"options": "Advance Taxes and Charges", "options": "Advance Taxes and Charges"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_total_taxes_and_charges", "fieldname": "base_total_taxes_and_charges",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Total Taxes and Charges (Company Currency)", "label": "Total Taxes and Charges (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "total_taxes_and_charges", "fieldname": "total_taxes_and_charges",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Total Taxes and Charges", "label": "Total Taxes and Charges",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "paid_amount_after_tax", "fieldname": "paid_amount_after_tax",
@ -810,61 +661,47 @@
"hidden": 1, "hidden": 1,
"label": "Paid Amount After Tax", "label": "Paid Amount After Tax",
"options": "paid_from_account_currency", "options": "paid_from_account_currency",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_paid_amount_after_tax", "fieldname": "base_paid_amount_after_tax",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Paid Amount After Tax (Company Currency)", "label": "Paid Amount After Tax (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_55", "fieldname": "column_break_55",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "section_break_56", "fieldname": "section_break_56",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hide_border": 1, "hide_border": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "advance_tax_account", "fieldname": "advance_tax_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Advance Tax Account", "label": "Advance Tax Account",
"options": "Account", "options": "Account"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "received_amount_after_tax", "fieldname": "received_amount_after_tax",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Received Amount After Tax", "label": "Received Amount After Tax",
"options": "paid_to_account_currency", "options": "paid_to_account_currency"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "base_received_amount_after_tax", "fieldname": "base_received_amount_after_tax",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Received Amount After Tax (Company Currency)", "label": "Received Amount After Tax (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency"
"show_days": 1,
"show_seconds": 1
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2021-05-15 13:05:16.958866", "modified": "2021-05-19 02:33:08.192932",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Entry", "name": "Payment Entry",
@ -908,4 +745,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "title", "title_field": "title",
"track_changes": 1 "track_changes": 1
} }

View File

@ -436,7 +436,10 @@ class PaymentEntry(AccountsController):
if not tax_withholding_details: if not tax_withholding_details:
return return
tax_withholding_details.update({'included_in_paid_amount': included_in_paid_amount}) tax_withholding_details.update({
'included_in_paid_amount': included_in_paid_amount,
'cost_center': self.cost_center or erpnext.get_default_cost_center(self.company)
})
accounts = [] accounts = []
for d in self.taxes: for d in self.taxes:
@ -1412,6 +1415,7 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
if doc.doctype == 'Purchase Order' and doc.apply_tds: if doc.doctype == 'Purchase Order' and doc.apply_tds:
pe.apply_tax_withholding_amount = 1 pe.apply_tax_withholding_amount = 1
pe.tax_withholding_category = doc.tax_withholding_category
return pe return pe

View File

@ -900,47 +900,6 @@ class PurchaseInvoice(BuyingController):
"cost_center": self.cost_center "cost_center": self.cost_center
}, account_currency, item=self)) }, account_currency, item=self))
def allocate_advance_taxes(self, gl_entries):
tax_map = self.get_tax_map()
for pe in self.get('advances'):
if pe.reference_type == 'Payment Entry':
pe = frappe.get_doc('Payment Entry', pe.reference_name)
for tax in pe.get('taxes'):
account_currency = get_account_currency(tax.account_head)
dr_or_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
rev_dr_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
unallocated_amount = tax.tax_amount - tax.allocated_amount
if tax_map.get(tax.account_head):
amount = tax_map.get(tax.account_head)
if amount < unallocated_amount:
unallocated_amount = amount
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": self.supplier,
dr_or_cr: unallocated_amount,
dr_or_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))
gl_entries.append(
self.get_gl_dict({
"account": pe.advance_tax_account,
"against": self.supplier,
rev_dr_cr: unallocated_amount,
rev_dr_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center or self.cost_center
}, account_currency, item=tax))
frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount', tax.allocated_amount + unallocated_amount)
tax_map[tax.account_head] -= unallocated_amount
def make_payment_gl_entries(self, gl_entries): def make_payment_gl_entries(self, gl_entries):
# Make Cash GL Entries # Make Cash GL Entries
if cint(self.is_paid) and self.cash_bank_account and self.paid_amount: if cint(self.is_paid) and self.cash_bank_account and self.paid_amount:

View File

@ -950,6 +950,96 @@ class TestPurchaseInvoice(unittest.TestCase):
acc_settings.submit_journal_entriessubmit_journal_entries = 0 acc_settings.submit_journal_entriessubmit_journal_entries = 0
acc_settings.save() acc_settings.save()
def test_purchase_invoice_advance_taxes(self):
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
from erpnext.buying.doctype.purchase_order.purchase_order import get_mapped_purchase_invoice
# Update tax withholding category with current fiscal year and rate details
update_tax_witholding_category('_Test Company', 'TDS Payable - _TC', nowdate())
# Create Purchase Order with TDS applied
po = create_purchase_order(do_not_save=1, rate=3000)
po.apply_tds = 1
po.tax_withholding_category = 'TDS - 194 - Dividends - Individual'
po.save()
po.submit()
# Update Unrealized Profit / Loss Account which is used as default advance tax account
frappe.db.set_value('Company', '_Test Company', 'unrealized_profit_loss_account', '_Test Account Excise Duty - _TC')
# Create Payment Entry Against the order
payment_entry = get_payment_entry(dt='Purchase Order', dn=po.name)
payment_entry.save()
payment_entry.submit()
# Check GLE for Payment Entry
expected_gle = [
['_Test Account Excise Duty - _TC', 6000, 0],
['Cash - _TC', 0, 24000],
['Creditors - _TC', 24000, 0],
['TDS Payable - _TC', 0, 6000],
]
gl_entries = frappe.db.sql("""select account, debit, credit
from `tabGL Entry`
where voucher_type='Payment Entry' and voucher_no=%s
order by account asc""", (payment_entry.name), as_dict=1)
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_gle[i][0], gle.account)
self.assertEqual(expected_gle[i][1], gle.debit)
self.assertEqual(expected_gle[i][2], gle.credit)
# Create Purchase Invoice against Purchase Order
purchase_invoice = get_mapped_purchase_invoice(po.name)
purchase_invoice.allocate_advances_automatically = 1
purchase_invoice.save()
purchase_invoice.submit()
# Check GLE for Purchase Invoice
# Zero net effect on final TDS Payable on invoice
expected_gle = [
['_Test Account Excise Duty - _TC', 0, 6000],
['Cost of Goods Sold - _TC', 30000, 0],
['Creditors - _TC', 0, 24000],
['TDS Payable - _TC', 6000, 6000],
]
gl_entries = frappe.db.sql("""select account, debit, credit
from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no=%s
order by account asc""", (purchase_invoice.name), as_dict=1)
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_gle[i][0], gle.account)
self.assertEqual(expected_gle[i][1], gle.debit)
self.assertEqual(expected_gle[i][2], gle.credit)
def update_tax_witholding_category(company, account, date):
from erpnext.accounts.utils import get_fiscal_year
fiscal_year = get_fiscal_year(date=date, company=company)
if not frappe.db.get_value('Tax Withholding Rate',
{'parent': 'TDS - 194 - Dividends - Individual', 'fiscal_year': fiscal_year[0]}):
tds_category = frappe.get_doc('Tax Withholding Category', 'TDS - 194 - Dividends - Individual')
tds_category.append('rates', {
'fiscal_year': fiscal_year[0],
'tax_withholding_rate': 20,
'single_threshold': 2500,
'cumulative_threshold': 0
})
tds_category.save()
if not frappe.db.get_value('Tax Withholding Account',
{'parent': 'TDS - 194 - Dividends - Individual', 'account': account}):
tds_category = frappe.get_doc('Tax Withholding Category', 'TDS - 194 - Dividends - Individual')
tds_category.append('accounts', {
'company': company,
'account': account
})
tds_category.save()
def unlink_payment_on_cancel_of_invoice(enable=1): def unlink_payment_on_cancel_of_invoice(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings") accounts_settings = frappe.get_doc("Accounts Settings")

View File

@ -913,47 +913,6 @@ class SalesInvoice(SellingController):
"cost_center": self.cost_center "cost_center": self.cost_center
}, account_currency, item=self)) }, account_currency, item=self))
def allocate_advance_taxes(self, gl_entries):
tax_map = self.get_tax_map()
for pe in self.get('advances'):
if pe.reference_type == 'Payment Entry':
pe = frappe.get_doc('Payment Entry', pe.reference_name)
for tax in pe.get('taxes'):
account_currency = get_account_currency(tax.account_head)
dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
rev_dr_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
unallocated_amount = tax.tax_amount - tax.allocated_amount
if tax_map.get(tax.account_head):
amount = tax_map.get(tax.account_head)
if amount < unallocated_amount:
unallocated_amount = amount
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": self.customer,
dr_or_cr: unallocated_amount,
dr_or_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))
gl_entries.append(
self.get_gl_dict({
"account": pe.advance_tax_account,
"against": self.customer,
rev_dr_cr: unallocated_amount,
rev_dr_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
'cost_center': tax.cost_center
}, account_currency, item=tax))
frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount', tax.allocated_amount + unallocated_amount)
tax_map[tax.account_head] -= unallocated_amount
def make_item_gl_entries(self, gl_entries): def make_item_gl_entries(self, gl_entries):
# income account gl entries # income account gl entries
for item in self.get("items"): for item in self.get("items"):

View File

@ -700,7 +700,7 @@ class AccountsController(TransactionBase):
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
if self.doctype in ["Sales Invoice", "Purchase Invoice"]: if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
self.update_allocated_advance_taxes() self.update_allocated_advance_taxes_on_cancel()
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'): if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
unlink_ref_doc_from_payment_entries(self) unlink_ref_doc_from_payment_entries(self)
@ -716,7 +716,7 @@ class AccountsController(TransactionBase):
return tax_map return tax_map
def update_allocated_advance_taxes(self): def update_allocated_advance_taxes_on_cancel(self):
if self.get('advances'): if self.get('advances'):
tax_accounts = [d.account_head for d in self.get('taxes')] tax_accounts = [d.account_head for d in self.get('taxes')]
allocated_tax_map = frappe._dict(frappe.get_all('GL Entry', fields=['account', 'sum(credit - debit)'], allocated_tax_map = frappe._dict(frappe.get_all('GL Entry', fields=['account', 'sum(credit - debit)'],
@ -734,10 +734,60 @@ class AccountsController(TransactionBase):
allocated_amount = tax.tax_amount allocated_amount = tax.tax_amount
if allocated_amount: if allocated_amount:
frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount', tax.allocated_amount - allocated_amount) frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount',
tax.allocated_amount - allocated_amount)
tax_map[tax.account_head] -= allocated_amount tax_map[tax.account_head] -= allocated_amount
allocated_tax_map[tax.account_head] -= allocated_amount allocated_tax_map[tax.account_head] -= allocated_amount
def allocate_advance_taxes(self, gl_entries):
tax_map = self.get_tax_map()
for pe in self.get("advances"):
if pe.reference_type == "Payment Entry":
pe = frappe.get_doc("Payment Entry", pe.reference_name)
for tax in pe.get("taxes"):
account_currency = get_account_currency(tax.account_head)
if self.doctype == "Purchase Invoice":
dr_or_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
rev_dr_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
else:
dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
rev_dr_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
party = self.supplier if self.doctype == "Purchase Invoice" else self.customer
unallocated_amount = tax.tax_amount - tax.allocated_amount
if tax_map.get(tax.account_head):
amount = tax_map.get(tax.account_head)
if amount < unallocated_amount:
unallocated_amount = amount
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": party,
dr_or_cr: unallocated_amount,
dr_or_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
"cost_center": tax.cost_center
}, account_currency, item=tax))
gl_entries.append(
self.get_gl_dict({
"account": pe.advance_tax_account,
"against": party,
rev_dr_cr: unallocated_amount,
rev_dr_cr + "_in_account_currency": unallocated_amount
if account_currency==self.company_currency
else unallocated_amount,
"cost_center": tax.cost_center
}, account_currency, item=tax))
frappe.db.set_value("Advance Taxes and Charges", tax.name, "allocated_amount",
tax.allocated_amount + unallocated_amount)
tax_map[tax.account_head] -= unallocated_amount
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield): def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
from erpnext.controllers.status_updater import get_allowance_for from erpnext.controllers.status_updater import get_allowance_for
item_allowance = {} item_allowance = {}