[fix][#1769] Add disable option to Sales/Purchase Tax Master with validation

This commit is contained in:
ankitjavalkarwork 2014-10-06 13:20:53 +05:30
parent 803cd11f68
commit 6c29d8789a
3 changed files with 44 additions and 3 deletions

View File

@ -2,7 +2,7 @@
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:title",
"creation": "2013-01-10 16:34:08.000000",
"creation": "2013-01-10 16:34:08",
"description": "Standard tax template that can be applied to all Purchase Transactions. This template can contain list of tax heads and also other expense heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Consider Tax or Charge for: In this section you can specify if the tax / charge is only for valuation (not a part of total) or only for total (does not add value to the item) or for both.\n10. Add or Deduct: Whether you want to add or deduct the tax.",
"docstatus": 0,
"doctype": "DocType",
@ -12,6 +12,7 @@
"fieldname": "title",
"fieldtype": "Data",
"in_filter": 1,
"in_list_view": 1,
"label": "Title",
"oldfieldname": "title",
"oldfieldtype": "Data",
@ -22,18 +23,42 @@
{
"fieldname": "is_default",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Default",
"permlevel": 0
},
{
"fieldname": "disabled",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Disabled",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "column_break4",
"fieldtype": "Column Break",
"label": "",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "Company",
"options": "Company",
"permlevel": 0,
"reqd": 1
},
{
"fieldname": "section_break6",
"fieldtype": "Section Break",
"label": "",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "other_charges",
"fieldtype": "Table",
@ -46,7 +71,7 @@
],
"icon": "icon-money",
"idx": 1,
"modified": "2014-01-29 12:26:38.000000",
"modified": "2014-10-07 12:40:17.165882",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Taxes and Charges Master",

View File

@ -27,6 +27,14 @@
"label": "Default",
"permlevel": 0
},
{
"fieldname": "disabled",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Disabled",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break",
@ -72,7 +80,7 @@
],
"icon": "icon-money",
"idx": 1,
"modified": "2014-05-27 03:49:19.023941",
"modified": "2014-10-06 13:11:18.616789",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Taxes and Charges Master",

View File

@ -26,6 +26,9 @@ class AccountsController(TransactionBase):
if self.meta.get_field("is_recurring"):
validate_recurring_document(self)
if self.meta.get_field("taxes_and_charges"):
self.validate_enabled_taxes_and_charges()
def on_submit(self):
if self.meta.get_field("is_recurring"):
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
@ -342,6 +345,11 @@ class AccountsController(TransactionBase):
self.precision(base_field, item))
item.set(base_field, value_in_company_currency)
def validate_enabled_taxes_and_charges(self):
taxes_and_charges_doctype = self.meta.get_options("taxes_and_charges")
if frappe.db.get_value(taxes_and_charges_doctype, self.taxes_and_charges, "disabled"):
frappe.throw(_("{0} '{1}' is disabled").format(taxes_and_charges_doctype, self.taxes_and_charges))
def calculate_total_advance(self, parenttype, advance_parentfield):
if self.doctype == parenttype and self.docstatus < 2:
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))