mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-12 06:48:31 +00:00
fix: credit note einvoice
This commit is contained in:
@@ -339,16 +339,18 @@ def get_item_list(invoice):
|
||||
|
||||
for d in invoice.items:
|
||||
item_schema = read_json('einv_item_template')
|
||||
item = frappe._dict(dict())
|
||||
item = frappe._dict({})
|
||||
item.update(d.as_dict())
|
||||
item.sr_no = d.idx
|
||||
item.description = d.item_name
|
||||
item.is_service_item = 'N' if frappe.db.get_value('Item', d.item_code, 'is_stock_item') else 'Y'
|
||||
item.batch_expiry_date = frappe.db.get_value('Batch', d.batch_no, 'expiry_date') if d.batch_no else None
|
||||
item.batch_expiry_date = format_date(item.batch_expiry_date, 'dd/mm/yyyy') if item.batch_expiry_date else None
|
||||
item.unit_rate = item.base_price_list_rate if item.discount_amount else item.base_rate
|
||||
item.total_amount = item.unit_rate * item.qty
|
||||
item.discount_amount = item.discount_amount * item.qty
|
||||
item.qty = abs(item.qty)
|
||||
item.unit_rate = abs(item.base_price_list_rate) if item.discount_amount else abs(item.base_rate)
|
||||
item.total_amount = abs(item.unit_rate * item.qty)
|
||||
item.discount_amount = abs(item.discount_amount * item.qty)
|
||||
item.base_amount = abs(item.base_amount)
|
||||
item.tax_rate = 0
|
||||
item.igst_amount = 0
|
||||
item.cgst_amount = 0
|
||||
@@ -360,18 +362,18 @@ def get_item_list(invoice):
|
||||
item_tax_detail = json.loads(t.item_wise_tax_detail).get(item.item_code)
|
||||
if t.account_head in gst_accounts.cess_account:
|
||||
item.cess_rate += item_tax_detail[0]
|
||||
item.cess_amount += item_tax_detail[1]
|
||||
item.cess_amount += abs(item_tax_detail[1])
|
||||
elif t.account_head in gst_accounts.igst_account:
|
||||
item.tax_rate += item_tax_detail[0]
|
||||
item.igst_amount += item_tax_detail[1]
|
||||
item.igst_amount += abs(item_tax_detail[1])
|
||||
elif t.account_head in gst_accounts.sgst_account:
|
||||
item.tax_rate += item_tax_detail[0]
|
||||
item.sgst_amount += item_tax_detail[1]
|
||||
item.sgst_amount += abs(item_tax_detail[1])
|
||||
elif t.account_head in gst_accounts.cgst_account:
|
||||
item.tax_rate += item_tax_detail[0]
|
||||
item.cgst_amount += item_tax_detail[1]
|
||||
item.cgst_amount += abs(item_tax_detail[1])
|
||||
|
||||
item.total_value = item.base_amount + item.igst_amount + item.sgst_amount + item.cgst_amount + item.cess_amount
|
||||
item.total_value = abs(item.base_amount + item.igst_amount + item.sgst_amount + item.cgst_amount + item.cess_amount)
|
||||
einv_item = item_schema.format(item=item)
|
||||
item_list.append(einv_item)
|
||||
|
||||
@@ -382,11 +384,11 @@ def get_value_details(invoice):
|
||||
gst_accounts_list = [d for accounts in gst_accounts.values() for d in accounts if d]
|
||||
|
||||
value_details = frappe._dict(dict())
|
||||
value_details.base_net_total = invoice.base_net_total
|
||||
value_details.invoice_discount_amt = invoice.discount_amount
|
||||
value_details.round_off = invoice.base_rounding_adjustment
|
||||
value_details.base_grand_total = invoice.base_rounded_total
|
||||
value_details.grand_total = invoice.rounded_total
|
||||
value_details.base_net_total = abs(invoice.base_net_total)
|
||||
value_details.invoice_discount_amt = abs(invoice.discount_amount)
|
||||
value_details.round_off = abs(invoice.base_rounding_adjustment)
|
||||
value_details.base_grand_total = abs(invoice.base_rounded_total)
|
||||
value_details.grand_total = abs(invoice.rounded_total)
|
||||
value_details.total_cgst_amt = 0
|
||||
value_details.total_sgst_amt = 0
|
||||
value_details.total_igst_amt = 0
|
||||
@@ -394,13 +396,13 @@ def get_value_details(invoice):
|
||||
for t in invoice.taxes:
|
||||
if t.account_head in gst_accounts_list:
|
||||
if t.account_head in gst_accounts.cess_account:
|
||||
value_details.total_cess_amt += t.base_tax_amount
|
||||
value_details.total_cess_amt += abs(t.base_tax_amount)
|
||||
elif t.account_head in gst_accounts.igst_account:
|
||||
value_details.total_igst_amt += t.base_tax_amount
|
||||
value_details.total_igst_amt += abs(t.base_tax_amount)
|
||||
elif t.account_head in gst_accounts.sgst_account:
|
||||
value_details.total_sgst_amt += t.base_tax_amount
|
||||
value_details.total_sgst_amt += abs(t.base_tax_amount)
|
||||
elif t.account_head in gst_accounts.cgst_account:
|
||||
value_details.total_cgst_amt += t.base_tax_amount
|
||||
value_details.total_cgst_amt += abs(t.base_tax_amount)
|
||||
|
||||
return value_details
|
||||
|
||||
@@ -520,7 +522,7 @@ def validate_einvoice(validations, einvoice, errors=[]):
|
||||
if value_type == 'string':
|
||||
einvoice[fieldname] = str(value)
|
||||
elif value_type == 'number':
|
||||
einvoice[fieldname] = flt(value, 2)
|
||||
einvoice[fieldname] = flt(value, 2) if fieldname != 'Pin' else int(value)
|
||||
|
||||
max_length = field_validation.get('maxLength')
|
||||
minimum = flt(field_validation.get('minimum'))
|
||||
|
||||
@@ -83,10 +83,10 @@
|
||||
"InvStDt": "{period_details.start_date}",
|
||||
"InvEndDt": "{period_details.end_date}"
|
||||
}},
|
||||
"PrecDocDtls": {{
|
||||
"PrecDocDtls": [{{
|
||||
"InvNo": "{prev_doc_details.invoice_name}",
|
||||
"InvDt": "{prev_doc_details.invoice_date}"
|
||||
}}
|
||||
}}]
|
||||
}},
|
||||
"ExpDtls": {{
|
||||
"ShipBNo": "{export_details.bill_no}",
|
||||
|
||||
Reference in New Issue
Block a user