Set company address while making invoice from SO, don't show taxes in print if amount is zero, fixed state code

This commit is contained in:
Nabin Hait 2017-07-12 15:45:32 +05:30
parent c1a1e62c0d
commit 0a32b7a6eb
7 changed files with 33 additions and 15 deletions

View File

@ -8,9 +8,10 @@ import datetime
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 @@ def set_address_details(out, party, party_type, doctype=None, company=None):
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)

View File

@ -559,7 +559,7 @@ class calculate_taxes_and_totals(object):
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

View File

@ -675,7 +675,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
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]);

View File

@ -6,7 +6,7 @@ states = [
'Assam',
'Bihar',
'Chandigarh',
'Chattisgarh',
'Chhattisgarh',
'Dadra and Nagar Haveli',
'Daman and Diu',
'Delhi',
@ -45,7 +45,7 @@ state_numbers = {
"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 @@ state_numbers = {
"Mizoram": "15",
"Nagaland": "13",
"Odisha": "21",
"Other Territory": "98",
"Pondicherry": "34",
"Punjab": "03",
"Rajasthan": "08",
@ -74,5 +75,5 @@ state_numbers = {
"Tripura": "16",
"Uttar Pradesh": "09",
"Uttarakhand": "05",
"West Bengal": "19"
"West Bengal": "19",
}

View File

@ -7,11 +7,12 @@ import json
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 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
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)

View File

@ -8,10 +8,12 @@ from frappe.utils import flt, cint
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 get_invoiced_qty_map(delivery_note):
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 @@ def make_sales_invoice(source_name, target_doc=None):
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 @@ def make_sales_invoice(source_name, target_doc=None):
},
"add_if_empty": True
}
}, target_doc, update_accounts)
}, target_doc, set_missing_values)
return doc

View File

@ -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>