fix: ImponibileImporto calculation

This commit is contained in:
Rohit Waghchaure 2019-03-12 17:44:29 +05:30
parent 22ebaf1b11
commit 1b7059b867
6 changed files with 55 additions and 24 deletions

View File

@ -587,5 +587,5 @@ erpnext.patches.v11_1.setup_guardian_role
execute:frappe.delete_doc('DocType', 'Notification Control') execute:frappe.delete_doc('DocType', 'Notification Control')
erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants
erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
erpnext.patches.v11_0.make_italian_localization_fields # 07-03-2019 erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019
erpnext.patches.v11_1.make_job_card_time_logs erpnext.patches.v11_1.make_job_card_time_logs

View File

@ -28,3 +28,10 @@ def execute():
from `tabCountry` where name = `tabAddress`.country), '')) from `tabCountry` where name = `tabAddress`.country), ''))
where country_code is null and state_code is null where country_code is null and state_code is null
""".format(condition=condition)) """.format(condition=condition))
frappe.db.sql("""
UPDATE `tabSales Invoice Item` si, `tabSales Order` so
set si.customer_po_no = so.po_no, si.customer_po_date = so.po_date
WHERE
si.sales_order = so.name and so.po_no is not null
""")

View File

@ -143,15 +143,11 @@
<ImportoTotaleDocumento>{{ format_float(doc.rounded_total or doc.grand_total) }}</ImportoTotaleDocumento> <ImportoTotaleDocumento>{{ format_float(doc.rounded_total or doc.grand_total) }}</ImportoTotaleDocumento>
<Causale>VENDITA</Causale> <Causale>VENDITA</Causale>
</DatiGeneraliDocumento> </DatiGeneraliDocumento>
{%- for row in doc.e_invoice_items %} {%- for po_no, po_date in doc.customer_po_data.items() %}
{%- if row.customer_po_no %} <DatiOrdineAcquisto>
<DatiOrdineAcquisto> <IdDocumento>{{ po_no }}</IdDocumento>
<IdDocumento>{{ row.customer_po_no }}</IdDocumento> <Data>{{ po_date }}</Data>
{%- if row.customer_po_date %} </DatiOrdineAcquisto>
<Data>{{ row.customer_po_date }}</Data>
{%- endif %}
</DatiOrdineAcquisto>
{%- endif %}
{%- endfor %} {%- endfor %}
{%- if doc.is_return and doc.return_against_unamended %} {%- if doc.is_return and doc.return_against_unamended %}
<DatiFattureCollegate> <DatiFattureCollegate>
@ -188,7 +184,11 @@
<UnitaMisura>{{ item.stock_uom }}</UnitaMisura> <UnitaMisura>{{ item.stock_uom }}</UnitaMisura>
<PrezzoUnitario>{{ format_float(item.price_list_rate or item.rate) }}</PrezzoUnitario> <PrezzoUnitario>{{ format_float(item.price_list_rate or item.rate) }}</PrezzoUnitario>
{{ render_discount_or_margin(item) }} {{ render_discount_or_margin(item) }}
<PrezzoTotale>{{ format_float(item.amount) }}</PrezzoTotale> {%- if (item.discount_amount or item.rate_with_margin) %}
<PrezzoTotale>{{ format_float(item.net_amount) }}</PrezzoTotale>
{%- else %}
<PrezzoTotale>{{ format_float(item.amount) }}</PrezzoTotale>
{%- endif %}
<AliquotaIVA>{{ format_float(item.tax_rate) }}</AliquotaIVA> <AliquotaIVA>{{ format_float(item.tax_rate) }}</AliquotaIVA>
{%- if item.tax_exemption_reason %} {%- if item.tax_exemption_reason %}
<Natura>{{ item.tax_exemption_reason.split("-")[0] }}</Natura> <Natura>{{ item.tax_exemption_reason.split("-")[0] }}</Natura>

View File

@ -3,15 +3,26 @@ erpnext.setup_e_invoice_button = (doctype) => {
refresh: (frm) => { refresh: (frm) => {
if(frm.doc.docstatus == 1) { if(frm.doc.docstatus == 1) {
frm.add_custom_button('Generate E-Invoice', () => { frm.add_custom_button('Generate E-Invoice', () => {
var w = window.open( frm.call({
frappe.urllib.get_full_url( method: "erpnext.regional.italy.utils.generate_single_invoice",
"/api/method/erpnext.regional.italy.utils.generate_single_invoice?" args: {
+ "docname=" + frm.doc.name docname: frm.doc.name
) },
) callback: function(r) {
if (!w) { frm.reload_doc();
frappe.msgprint(__("Please enable pop-ups")); return; if(r.message) {
} var w = window.open(
frappe.urllib.get_full_url(
"/api/method/erpnext.regional.italy.utils.download_e_invoice_file?"
+ "file_name=" + r.message
)
)
if (!w) {
frappe.msgprint(__("Please enable pop-ups")); return;
}
}
}
});
}); });
} }
} }

View File

@ -32,14 +32,14 @@ def make_custom_fields(update=True):
dict(fieldname='customer_po_no', label='Customer PO No', dict(fieldname='customer_po_no', label='Customer PO No',
fieldtype='Data', insert_after='customer_po_details', fieldtype='Data', insert_after='customer_po_details',
fetch_from = 'sales_order.po_no', fetch_from = 'sales_order.po_no',
print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1), print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1, no_copy=1),
dict(fieldname='customer_po_clm_brk', label='', dict(fieldname='customer_po_clm_brk', label='',
fieldtype='Column Break', insert_after='customer_po_no', fieldtype='Column Break', insert_after='customer_po_no',
print_hide=1, read_only=1), print_hide=1, read_only=1),
dict(fieldname='customer_po_date', label='Customer PO Date', dict(fieldname='customer_po_date', label='Customer PO Date',
fieldtype='Date', insert_after='customer_po_clm_brk', fieldtype='Date', insert_after='customer_po_clm_brk',
fetch_from = 'sales_order.po_date', fetch_from = 'sales_order.po_date',
print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1) print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1, no_copy=1)
] ]
custom_fields = { custom_fields = {

View File

@ -82,6 +82,14 @@ def prepare_invoice(invoice, progressive_number):
if item.tax_rate == 0.0 and item.tax_amount == 0.0: if item.tax_rate == 0.0 and item.tax_amount == 0.0:
item.tax_exemption_reason = tax_data["0.0"]["tax_exemption_reason"] item.tax_exemption_reason = tax_data["0.0"]["tax_exemption_reason"]
customer_po_data = {}
for d in invoice.e_invoice_items:
if (d.customer_po_no and d.customer_po_date
and d.customer_po_no not in customer_po_data):
customer_po_data[d.customer_po_no] = d.customer_po_date
invoice.customer_po_data = customer_po_data
return invoice return invoice
def get_conditions(filters): def get_conditions(filters):
@ -267,13 +275,18 @@ def prepare_and_attach_invoice(doc, replace=False):
def generate_single_invoice(docname): def generate_single_invoice(docname):
doc = frappe.get_doc("Sales Invoice", docname) doc = frappe.get_doc("Sales Invoice", docname)
e_invoice = prepare_and_attach_invoice(doc, True) e_invoice = prepare_and_attach_invoice(doc, True)
return e_invoice.file_name
@frappe.whitelist()
def download_e_invoice_file(file_name):
content = None content = None
with open(frappe.get_site_path('private', 'files', e_invoice.file_name), "r") as f: with open(frappe.get_site_path('private', 'files', file_name), "r") as f:
content = f.read() content = f.read()
frappe.local.response.filename = e_invoice.file_name frappe.local.response.filename = file_name
frappe.local.response.filecontent = content frappe.local.response.filecontent = content
frappe.local.response.type = "download" frappe.local.response.type = "download"