Set company address while making invoice from SO, don't show taxes in print if amount is zero, fixed state code
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 355803b..ba0f0d3 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -8,9 +8,10 @@
from frappe import _, msgprint, scrub
from frappe.defaults import get_user_permissions
from frappe.model.utils import get_fetch_values
-from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, \
- add_years, get_timestamp, nowdate, flt
-from frappe.contacts.doctype.address.address import get_address_display, get_default_address
+from frappe.utils import (add_days, getdate, formatdate, get_first_day, date_diff,
+ add_years, get_timestamp, nowdate, flt)
+from frappe.contacts.doctype.address.address import (get_address_display,
+ get_default_address, get_company_address)
from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact
from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency
from erpnext.accounts.utils import get_fiscal_year
@@ -77,8 +78,10 @@
out.update(get_fetch_values(doctype, 'shipping_address_name', out.shipping_address_name))
if doctype and doctype in ['Sales Invoice']:
- out.company_address = get_default_address('Company', company)
- out.update(get_fetch_values(doctype, 'company_address', out.company_address))
+ out.update(get_company_address(company))
+ if out.company_address:
+ out.update(get_fetch_values(doctype, 'company_address', out.company_address))
+
def set_contact_details(out, party, party_type):
out.contact_person = get_default_contact(party_type, party.name)
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 72785da..8b96152 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -559,7 +559,7 @@
item_tax[item_code][tax.name] = [tax_rate, tax_amount]
else:
- item_tax[item_code][tax.name] = [cstr(flt(tax_data, tax_rate_precision)) + "%", ""]
+ item_tax[item_code][tax.name] = [cstr(flt(tax_data, tax_rate_precision)) + "%", "0.00"]
tax_accounts.append([tax.name, tax.account_head])
return item_tax, tax_accounts
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index e09925d..837097b 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -675,7 +675,7 @@
item_tax[item_code][tax.name] = [tax_rate, tax_amount];
} else {
- item_tax[item_code][tax.name] = [flt(tax_data, tax_rate_precision) + "%", ""];
+ item_tax[item_code][tax.name] = [flt(tax_data, tax_rate_precision) + "%", "0.00"];
}
});
tax_accounts.push([tax.name, tax.account_head]);
diff --git a/erpnext/regional/india/__init__.py b/erpnext/regional/india/__init__.py
index 3c0dd07..de5f1ab 100644
--- a/erpnext/regional/india/__init__.py
+++ b/erpnext/regional/india/__init__.py
@@ -6,7 +6,7 @@
'Assam',
'Bihar',
'Chandigarh',
- 'Chattisgarh',
+ 'Chhattisgarh',
'Dadra and Nagar Haveli',
'Daman and Diu',
'Delhi',
@@ -45,7 +45,7 @@
"Assam": "18",
"Bihar": "10",
"Chandigarh": "04",
- "Chattisgarh": "22",
+ "Chhattisgarh": "22",
"Dadra and Nagar Haveli": "26",
"Daman and Diu": "25",
"Delhi": "07",
@@ -65,6 +65,7 @@
"Mizoram": "15",
"Nagaland": "13",
"Odisha": "21",
+ "Other Territory": "98",
"Pondicherry": "34",
"Punjab": "03",
"Rajasthan": "08",
@@ -74,5 +75,5 @@
"Tripura": "16",
"Uttar Pradesh": "09",
"Uttarakhand": "05",
- "West Bengal": "19"
+ "West Bengal": "19",
}
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index ccaa07c..2df52ac 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -7,11 +7,12 @@
import frappe.utils
from frappe.utils import cstr, flt, getdate, comma_and, cint
from frappe import _
+from frappe.model.utils import get_fetch_values
from frappe.model.mapper import get_mapped_doc
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
from frappe.desk.notifications import clear_doctype_notifications
from erpnext.controllers.recurring_document import month_map, get_next_date
-
+from frappe.contacts.doctype.address.address import get_company_address
from erpnext.controllers.selling_controller import SellingController
form_grid_templates = {
@@ -503,7 +504,12 @@
target.flags.ignore_permissions = True
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
-
+
+ # set company address
+ target.update(get_company_address(target.company))
+ if target.company_address:
+ target.update(get_fetch_values("Sales Invoice", 'company_address', target.company_address))
+
def update_item(source, target, source_parent):
target.amount = flt(source.amount) - flt(source.billed_amt)
target.base_amount = target.amount * flt(source_parent.conversion_rate)
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 7523409..3bf0384 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -8,10 +8,12 @@
from frappe import msgprint, _
import frappe.defaults
+from frappe.model.utils import get_fetch_values
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.selling_controller import SellingController
from frappe.desk.notifications import clear_doctype_notifications
from erpnext.stock.doctype.batch.batch import set_batch_nos
+from frappe.contacts.doctype.address.address import get_company_address
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -371,7 +373,7 @@
def make_sales_invoice(source_name, target_doc=None):
invoiced_qty_map = get_invoiced_qty_map(source_name)
- def update_accounts(source, target):
+ def set_missing_values(source, target):
target.is_pos = 0
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
@@ -380,6 +382,12 @@
frappe.throw(_("All these items have already been invoiced"))
target.run_method("calculate_taxes_and_totals")
+
+ # set company address
+ target.update(get_company_address(target.company))
+ if target.company_address:
+ target.update(get_fetch_values("Sales Invoice", 'company_address', target.company_address))
+
def update_item(source_doc, target_doc, source_parent):
target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0)
@@ -415,7 +423,7 @@
},
"add_if_empty": True
}
- }, target_doc, update_accounts)
+ }, target_doc, set_missing_values)
return doc
diff --git a/erpnext/templates/print_formats/includes/taxes.html b/erpnext/templates/print_formats/includes/taxes.html
index b0bd1d4..b180c1c 100644
--- a/erpnext/templates/print_formats/includes/taxes.html
+++ b/erpnext/templates/print_formats/includes/taxes.html
@@ -17,7 +17,7 @@
{{ render_discount_amount(doc) }}
{%- endif -%}
{%- for charge in data -%}
- {%- if not charge.included_in_print_rate -%}
+ {%- if charge.tax_amount and not charge.included_in_print_rate -%}
<div class="row">
<div class="col-xs-5 {%- if not doc._align_labels_left %} text-right{%- endif -%}">
<label>{{ charge.get_formatted("description") }}</label></div>