Merge branch 'develop' into membership-enhancements-2
This commit is contained in:
commit
7a21e40527
@ -1861,23 +1861,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def test_einvoice_json(self):
|
def test_einvoice_json(self):
|
||||||
from erpnext.regional.india.e_invoice.utils import make_einvoice
|
from erpnext.regional.india.e_invoice.utils import make_einvoice
|
||||||
|
|
||||||
customer_gstin = '27AACCM7806M1Z3'
|
|
||||||
customer_gstin_dtls = {
|
|
||||||
'LegalName': '_Test Customer', 'TradeName': '_Test Customer', 'AddrLoc': '_Test City',
|
|
||||||
'StateCode': '27', 'AddrPncd': '410038', 'AddrBno': '_Test Bldg',
|
|
||||||
'AddrBnm': '100', 'AddrFlno': '200', 'AddrSt': '_Test Street'
|
|
||||||
}
|
|
||||||
company_gstin = '27AAECE4835E1ZR'
|
|
||||||
company_gstin_dtls = {
|
|
||||||
'LegalName': '_Test Company', 'TradeName': '_Test Company', 'AddrLoc': '_Test City',
|
|
||||||
'StateCode': '27', 'AddrPncd': '401108', 'AddrBno': '_Test Bldg',
|
|
||||||
'AddrBnm': '100', 'AddrFlno': '200', 'AddrSt': '_Test Street'
|
|
||||||
}
|
|
||||||
# set cache gstin details to avoid fetching details which will require connection to GSP servers
|
|
||||||
frappe.local.gstin_cache = {}
|
|
||||||
frappe.local.gstin_cache[customer_gstin] = customer_gstin_dtls
|
|
||||||
frappe.local.gstin_cache[company_gstin] = company_gstin_dtls
|
|
||||||
|
|
||||||
si = make_sales_invoice_for_ewaybill()
|
si = make_sales_invoice_for_ewaybill()
|
||||||
si.naming_series = 'INV-2020-.#####'
|
si.naming_series = 'INV-2020-.#####'
|
||||||
si.items = []
|
si.items = []
|
||||||
@ -1930,12 +1913,12 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(value_details['SgstVal'], total_item_sgst_value)
|
self.assertEqual(value_details['SgstVal'], total_item_sgst_value)
|
||||||
self.assertEqual(value_details['IgstVal'], total_item_igst_value)
|
self.assertEqual(value_details['IgstVal'], total_item_igst_value)
|
||||||
|
|
||||||
self.assertEqual(
|
calculated_invoice_value = \
|
||||||
value_details['TotInvVal'],
|
value_details['AssVal'] + value_details['CgstVal'] \
|
||||||
value_details['AssVal'] + value_details['CgstVal']
|
+ value_details['SgstVal'] + value_details['IgstVal'] \
|
||||||
+ value_details['SgstVal'] + value_details['IgstVal']
|
|
||||||
+ value_details['OthChrg'] - value_details['Discount']
|
+ value_details['OthChrg'] - value_details['Discount']
|
||||||
)
|
|
||||||
|
self.assertTrue(value_details['TotInvVal'] - calculated_invoice_value < 0.1)
|
||||||
|
|
||||||
self.assertEqual(value_details['TotInvVal'], si.base_grand_total)
|
self.assertEqual(value_details['TotInvVal'], si.base_grand_total)
|
||||||
self.assertTrue(einvoice['EwbDtls'])
|
self.assertTrue(einvoice['EwbDtls'])
|
||||||
|
@ -217,11 +217,14 @@ def update_item_taxes(invoice, item):
|
|||||||
|
|
||||||
def get_invoice_value_details(invoice):
|
def get_invoice_value_details(invoice):
|
||||||
invoice_value_details = frappe._dict(dict())
|
invoice_value_details = frappe._dict(dict())
|
||||||
|
|
||||||
if invoice.apply_discount_on == 'Net Total' and invoice.discount_amount:
|
if invoice.apply_discount_on == 'Net Total' and invoice.discount_amount:
|
||||||
invoice_value_details.base_total = abs(invoice.base_total)
|
invoice_value_details.base_total = abs(invoice.base_total)
|
||||||
else:
|
else:
|
||||||
invoice_value_details.base_total = abs(invoice.base_net_total)
|
invoice_value_details.base_total = abs(invoice.base_net_total)
|
||||||
invoice_value_details.invoice_discount_amt = invoice.base_discount_amount
|
|
||||||
|
# since tax already considers discount amount
|
||||||
|
invoice_value_details.invoice_discount_amt = 0 # invoice.base_discount_amount
|
||||||
invoice_value_details.round_off = invoice.base_rounding_adjustment
|
invoice_value_details.round_off = invoice.base_rounding_adjustment
|
||||||
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(invoice.base_grand_total)
|
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(invoice.base_grand_total)
|
||||||
invoice_value_details.grand_total = abs(invoice.rounded_total) or abs(invoice.grand_total)
|
invoice_value_details.grand_total = abs(invoice.rounded_total) or abs(invoice.grand_total)
|
||||||
@ -247,9 +250,9 @@ def update_invoice_taxes(invoice, invoice_value_details):
|
|||||||
|
|
||||||
for tax_type in ['igst', 'cgst', 'sgst']:
|
for tax_type in ['igst', 'cgst', 'sgst']:
|
||||||
if t.account_head in gst_accounts[f'{tax_type}_account']:
|
if t.account_head in gst_accounts[f'{tax_type}_account']:
|
||||||
invoice_value_details[f'total_{tax_type}_amt'] += abs(t.base_tax_amount)
|
invoice_value_details[f'total_{tax_type}_amt'] += abs(t.base_tax_amount_after_discount_amount)
|
||||||
else:
|
else:
|
||||||
invoice_value_details.total_other_charges += abs(t.base_tax_amount)
|
invoice_value_details.total_other_charges += abs(t.base_tax_amount_after_discount_amount)
|
||||||
|
|
||||||
return invoice_value_details
|
return invoice_value_details
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user