fix(e-invoicing): minor calculation fixes (#24282)
This commit is contained in:
parent
adb8bbe958
commit
60460a6d23
@ -328,6 +328,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
target_doc.po_detail = source_doc.po_detail
|
target_doc.po_detail = source_doc.po_detail
|
||||||
target_doc.pr_detail = source_doc.pr_detail
|
target_doc.pr_detail = source_doc.pr_detail
|
||||||
target_doc.purchase_invoice_item = source_doc.name
|
target_doc.purchase_invoice_item = source_doc.name
|
||||||
|
target_doc.price_list_rate = 0
|
||||||
|
|
||||||
elif doctype == "Delivery Note":
|
elif doctype == "Delivery Note":
|
||||||
returned_qty_map = get_returned_qty_map_for_row(source_doc.name, doctype)
|
returned_qty_map = get_returned_qty_map_for_row(source_doc.name, doctype)
|
||||||
@ -353,6 +354,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
target_doc.dn_detail = source_doc.dn_detail
|
target_doc.dn_detail = source_doc.dn_detail
|
||||||
target_doc.expense_account = source_doc.expense_account
|
target_doc.expense_account = source_doc.expense_account
|
||||||
target_doc.sales_invoice_item = source_doc.name
|
target_doc.sales_invoice_item = source_doc.name
|
||||||
|
target_doc.price_list_rate = 0
|
||||||
if default_warehouse_for_sales_return:
|
if default_warehouse_for_sales_return:
|
||||||
target_doc.warehouse = default_warehouse_for_sales_return
|
target_doc.warehouse = default_warehouse_for_sales_return
|
||||||
|
|
||||||
|
@ -543,6 +543,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
company: me.frm.doc.company,
|
company: me.frm.doc.company,
|
||||||
order_type: me.frm.doc.order_type,
|
order_type: me.frm.doc.order_type,
|
||||||
is_pos: cint(me.frm.doc.is_pos),
|
is_pos: cint(me.frm.doc.is_pos),
|
||||||
|
is_return: cint(me.frm.doc.is_return),
|
||||||
is_subcontracted: me.frm.doc.is_subcontracted,
|
is_subcontracted: me.frm.doc.is_subcontracted,
|
||||||
transaction_date: me.frm.doc.transaction_date || me.frm.doc.posting_date,
|
transaction_date: me.frm.doc.transaction_date || me.frm.doc.posting_date,
|
||||||
ignore_pricing_rule: me.frm.doc.ignore_pricing_rule,
|
ignore_pricing_rule: me.frm.doc.ignore_pricing_rule,
|
||||||
|
@ -92,21 +92,18 @@ def get_party_details(address_name):
|
|||||||
location = gstin_details.get('AddrLoc') or address.get('city')
|
location = gstin_details.get('AddrLoc') or address.get('city')
|
||||||
state_code = gstin_details.get('StateCode')
|
state_code = gstin_details.get('StateCode')
|
||||||
pincode = gstin_details.get('AddrPncd')
|
pincode = gstin_details.get('AddrPncd')
|
||||||
address_line1 = '{} {}'.format(gstin_details.get('AddrBno'), gstin_details.get('AddrFlno'))
|
address_line1 = '{} {}'.format(gstin_details.get('AddrBno') or "", gstin_details.get('AddrFlno') or "")
|
||||||
address_line2 = '{} {}'.format(gstin_details.get('AddrBnm'), gstin_details.get('AddrSt'))
|
address_line2 = '{} {}'.format(gstin_details.get('AddrBnm') or "", gstin_details.get('AddrSt') or "")
|
||||||
email_id = address.get('email_id')
|
|
||||||
phone = address.get('phone')
|
|
||||||
# get last 10 digit
|
|
||||||
phone = phone.replace(" ", "")[-10:] if phone else ''
|
|
||||||
|
|
||||||
if state_code == 97:
|
if state_code == 97:
|
||||||
# according to einvoice standard
|
# according to einvoice standard
|
||||||
pincode = 999999
|
pincode = 999999
|
||||||
|
|
||||||
return frappe._dict(dict(
|
return frappe._dict(dict(
|
||||||
gstin=gstin, legal_name=legal_name, location=location,
|
gstin=gstin, legal_name=legal_name,
|
||||||
pincode=pincode, state_code=state_code, address_line1=address_line1,
|
location=location, pincode=pincode,
|
||||||
address_line2=address_line2, email=email_id, phone=phone
|
state_code=state_code, address_line1=address_line1,
|
||||||
|
address_line2=address_line2
|
||||||
))
|
))
|
||||||
|
|
||||||
def get_gstin_details(gstin):
|
def get_gstin_details(gstin):
|
||||||
@ -146,9 +143,10 @@ def get_item_list(invoice):
|
|||||||
item.update(d.as_dict())
|
item.update(d.as_dict())
|
||||||
|
|
||||||
item.sr_no = d.idx
|
item.sr_no = d.idx
|
||||||
item.discount_amount = abs(item.discount_amount * item.qty)
|
item.description = d.item_name.replace('"', '\\"')
|
||||||
item.description = d.item_name
|
|
||||||
item.qty = abs(item.qty)
|
item.qty = abs(item.qty)
|
||||||
|
item.discount_amount = abs(item.discount_amount * item.qty)
|
||||||
item.unit_rate = abs(item.base_amount / item.qty)
|
item.unit_rate = abs(item.base_amount / item.qty)
|
||||||
item.gross_amount = abs(item.base_amount)
|
item.gross_amount = abs(item.base_amount)
|
||||||
item.taxable_value = abs(item.base_amount)
|
item.taxable_value = abs(item.base_amount)
|
||||||
@ -156,6 +154,7 @@ def get_item_list(invoice):
|
|||||||
item.batch_expiry_date = frappe.db.get_value('Batch', d.batch_no, 'expiry_date') if d.batch_no else None
|
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.batch_expiry_date = format_date(item.batch_expiry_date, 'dd/mm/yyyy') if item.batch_expiry_date else None
|
||||||
item.is_service_item = 'N' if frappe.db.get_value('Item', d.item_code, 'is_stock_item') else 'Y'
|
item.is_service_item = 'N' if frappe.db.get_value('Item', d.item_code, 'is_stock_item') else 'Y'
|
||||||
|
item.serial_no = ""
|
||||||
|
|
||||||
item = update_item_taxes(invoice, item)
|
item = update_item_taxes(invoice, item)
|
||||||
|
|
||||||
@ -272,7 +271,25 @@ def get_eway_bill_details(invoice):
|
|||||||
vehicle_type=vehicle_type[invoice.gst_vehicle_type]
|
vehicle_type=vehicle_type[invoice.gst_vehicle_type]
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def validate_mandatory_fields(invoice):
|
||||||
|
if not invoice.company_address:
|
||||||
|
frappe.throw(_('Company Address is mandatory to fetch company GSTIN details.'), title=_('Missing Fields'))
|
||||||
|
if not invoice.customer_address:
|
||||||
|
frappe.throw(_('Customer Address is mandatory to fetch customer GSTIN details.'), title=_('Missing Fields'))
|
||||||
|
if not frappe.db.get_value('Address', invoice.company_address, 'gstin'):
|
||||||
|
frappe.throw(
|
||||||
|
_('GSTIN is mandatory to fetch company GSTIN details. Please enter GSTIN in selected company address.'),
|
||||||
|
title=_('Missing Fields')
|
||||||
|
)
|
||||||
|
if not frappe.db.get_value('Address', invoice.customer_address, 'gstin'):
|
||||||
|
frappe.throw(
|
||||||
|
_('GSTIN is mandatory to fetch customer GSTIN details. Please enter GSTIN in selected customer address.'),
|
||||||
|
title=_('Missing Fields')
|
||||||
|
)
|
||||||
|
|
||||||
def make_einvoice(invoice):
|
def make_einvoice(invoice):
|
||||||
|
validate_mandatory_fields(invoice)
|
||||||
|
|
||||||
schema = read_json('einv_template')
|
schema = read_json('einv_template')
|
||||||
|
|
||||||
transaction_details = get_transaction_details(invoice)
|
transaction_details = get_transaction_details(invoice)
|
||||||
@ -351,7 +368,7 @@ def validate_einvoice(validations, einvoice, errors=[]):
|
|||||||
# remove empty dicts
|
# remove empty dicts
|
||||||
einvoice.pop(fieldname, None)
|
einvoice.pop(fieldname, None)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# convert to int or str
|
# convert to int or str
|
||||||
if value_type == 'string':
|
if value_type == 'string':
|
||||||
einvoice[fieldname] = str(value)
|
einvoice[fieldname] = str(value)
|
||||||
|
@ -74,7 +74,9 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru
|
|||||||
|
|
||||||
update_party_blanket_order(args, out)
|
update_party_blanket_order(args, out)
|
||||||
|
|
||||||
get_price_list_rate(args, item, out)
|
if not doc or cint(doc.get('is_return')) == 0:
|
||||||
|
# get price list rate only if the invoice is not a credit or debit note
|
||||||
|
get_price_list_rate(args, item, out)
|
||||||
|
|
||||||
if args.customer and cint(args.is_pos):
|
if args.customer and cint(args.is_pos):
|
||||||
out.update(get_pos_profile_item_details(args.company, args))
|
out.update(get_pos_profile_item_details(args.company, args))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user