Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple port from v11 hotfix #18954

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions erpnext/assets/doctype/asset/asset.py
Expand Up @@ -292,12 +292,6 @@ def validate_cancellation(self):
if self.status not in ("Submitted", "Partially Depreciated", "Fully Depreciated"):
frappe.throw(_("Asset cannot be cancelled, as it is already {0}").format(self.status))

if self.purchase_invoice:
frappe.throw(_("Please cancel Purchase Invoice {0} first").format(self.purchase_invoice))

if self.purchase_receipt:
frappe.throw(_("Please cancel Purchase Receipt {0} first").format(self.purchase_receipt))

def delete_depreciation_entries(self):
for d in self.get("schedules"):
if d.journal_entry:
Expand Down
14 changes: 7 additions & 7 deletions erpnext/regional/italy/e-invoice.xml
@@ -1,5 +1,5 @@
{%- macro format_float(value) -%}
{{ "%.2f" % value|abs }}
{%- macro format_float(value, precision=2) -%}
{{ value|round(frappe.utils.cint(precision)) }}
{%- endmacro -%}

{%- macro render_address(address) %}
Expand Down Expand Up @@ -182,10 +182,10 @@
<Descrizione>{{ html2text(item.description or '') or item.item_name }}</Descrizione>
<Quantita>{{ format_float(item.qty) }}</Quantita>
<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, item_meta.get_field("rate").precision) }}</PrezzoUnitario>
{{ render_discount_or_margin(item) }}
<PrezzoTotale>{{ format_float(item.amount) }}</PrezzoTotale>
<AliquotaIVA>{{ format_float(item.tax_rate) }}</AliquotaIVA>
<PrezzoTotale>{{ format_float(item.amount, item_meta.get_field("amount").precision) }}</PrezzoTotale>
<AliquotaIVA>{{ format_float(item.tax_rate, item_meta.get_field("tax_rate").precision) }}</AliquotaIVA>
{%- if item.tax_exemption_reason %}
<Natura>{{ item.tax_exemption_reason.split("-")[0] }}</Natura>
{%- endif %}
Expand All @@ -197,8 +197,8 @@
{%- if data.tax_exemption_reason %}
<Natura>{{ data.tax_exemption_reason.split("-")[0] }}</Natura>
{%- endif %}
<ImponibileImporto>{{ format_float(data.taxable_amount) }}</ImponibileImporto>
<Imposta>{{ format_float(data.tax_amount) }}</Imposta>
<ImponibileImporto>{{ format_float(data.taxable_amount, item_meta.get_field("tax_amount").precision) }}</ImponibileImporto>
<Imposta>{{ format_float(data.tax_amount, item_meta.get_field("tax_amount").precision) }}</Imposta>
<EsigibilitaIVA>{{ doc.vat_collectability.split("-")[0] }}</EsigibilitaIVA>
{%- if data.tax_exemption_law %}
<RiferimentoNormativo>{{ data.tax_exemption_law }}</RiferimentoNormativo>
Expand Down
9 changes: 7 additions & 2 deletions erpnext/regional/italy/utils.py
Expand Up @@ -151,7 +151,8 @@ def get_invoice_summary(items, taxes):
tax_rate=tax.rate,
tax_amount=(reference_row.tax_amount * tax.rate) / 100,
net_amount=reference_row.tax_amount,
taxable_amount=reference_row.tax_amount,
taxable_amount=(reference_row.tax_amount if tax.charge_type == 'On Previous Row Amount'
else reference_row.total),
item_tax_rate={tax.account_head: tax.rate},
charges=True
)
Expand Down Expand Up @@ -278,7 +279,11 @@ def prepare_and_attach_invoice(doc, replace=False):
progressive_name, progressive_number = get_progressive_name_and_number(doc, replace)

invoice = prepare_invoice(doc, progressive_number)
invoice_xml = frappe.render_template('erpnext/regional/italy/e-invoice.xml', context={"doc": invoice}, is_path=True)
item_meta = frappe.get_meta("Sales Invoice Item")

invoice_xml = frappe.render_template('erpnext/regional/italy/e-invoice.xml',
context={"doc": invoice, "item_meta": item_meta}, is_path=True)

invoice_xml = invoice_xml.replace("&", "&amp;")

xml_filename = progressive_name + ".xml"
Expand Down