Skip to content

Commit

Permalink
test: Updated test case for Eway bill
Browse files Browse the repository at this point in the history
  • Loading branch information
Subin Tom authored and Subin Tom committed Jul 19, 2021
1 parent 5265ba3 commit b24a149
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,8 @@ def test_eway_bill_json(self):
self.assertEqual(data['billLists'][0]['sgstValue'], 5400)
self.assertEqual(data['billLists'][0]['vehicleNo'], 'KA12KA1234')
self.assertEqual(data['billLists'][0]['itemList'][0]['taxableAmount'], 60000)
self.assertEqual(data['billLists'][0]['actualFromStateCode'],7)
self.assertEqual(data['billLists'][0]['fromStateCode'],27)

def test_einvoice_submission_without_irn(self):
# init
Expand Down Expand Up @@ -2061,6 +2063,30 @@ def make_test_address_for_ewaybill():

address.save()

if not frappe.db.exists('Address', '_Test Dispatch-Address for Eway bill-Shipping'):
address = frappe.get_doc({
"address_line1": "_Test Dispatch Address Line 1",
"address_title": "_Test Dispatch-Address for Eway bill",
"address_type": "Shipping",
"city": "_Test City",
"state": "Test State",
"country": "India",
"doctype": "Address",
"is_primary_address": 0,
"phone": "+910000000000",
"gstin": "07AAACC1206D1ZI",
"gst_state": "Delhi",
"gst_state_number": "07",
"pincode": "1100101"
}).insert()

address.append("links", {
"link_doctype": "Company",
"link_name": "_Test Company"
})

address.save()

def make_test_transporter_for_ewaybill():
if not frappe.db.exists('Supplier', '_Test Transporter'):
frappe.get_doc({
Expand Down Expand Up @@ -2099,6 +2125,7 @@ def make_sales_invoice_for_ewaybill():
si.distance = 2000
si.company_address = "_Test Address for Eway bill-Billing"
si.customer_address = "_Test Customer-Address for Eway bill-Shipping"
si.dispatch_address_name = "_Test Dispatch-Address for Eway bill-Shipping"
si.vehicle_no = "KA12KA1234"
si.gst_category = "Registered Regular"
si.mode_of_transport = 'Road'
Expand Down
4 changes: 2 additions & 2 deletions erpnext/regional/india/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def get_ewb_data(dt, dn):
billing_address = frappe.get_doc('Address', doc.customer_address)

#added dispatch address
dispatch_address = frappe.get_doc('Address', doc.dispatch_address_name)
dispatch_address = frappe.get_doc('Address', doc.dispatch_address_name) if doc.dispatch_address_name else company_address
shipping_address = frappe.get_doc('Address', doc.shipping_address_name)

data = get_address_details(data, doc, company_address, billing_address, dispatch_address)
Expand Down Expand Up @@ -524,7 +524,7 @@ def get_gstins_for_company(company):
def get_address_details(data, doc, company_address, billing_address, dispatch_address):
data.fromPincode = validate_pincode(company_address.pincode, 'Company Address')
data.fromStateCode = validate_state_code(company_address.gst_state_number, 'Company Address')
data.actualFromStateCode = validate_state_code(dispatch_address.gst_state_number, 'Company Address')
data.actualFromStateCode = validate_state_code(dispatch_address.gst_state_number, 'Dispatch Address')

if not doc.billing_address_gstin or len(doc.billing_address_gstin) < 15:
data.toGstin = 'URP'
Expand Down

0 comments on commit b24a149

Please sign in to comment.