Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e379f08
feat(India): Separate Input and Output GST tax accounts
deepeshgarg007 Apr 20, 2021
3130ed5
fix: Item Tax templates for GST
deepeshgarg007 Apr 20, 2021
2acc66d
fix: Add tax categories on company setup
deepeshgarg007 Apr 21, 2021
5099770
fix: Update country-wise-tax JSON and tax setup
deepeshgarg007 Apr 21, 2021
66a71bd
fix: Issues on new company setup
deepeshgarg007 Apr 21, 2021
204ea10
fix: Ignore validations for Tax Setup
deepeshgarg007 Apr 30, 2021
a66184f
fix: Remove redundant get_doc
deepeshgarg007 May 2, 2021
f6610c9
fix: Gracefully handle duplicate bank account name to make setup faster
deepeshgarg007 May 2, 2021
72e602a
fix: Add validation for GST Settings
deepeshgarg007 May 2, 2021
1bac72b
fix: Add GST accounts to GST Settings
deepeshgarg007 May 2, 2021
0ae702a
Merge branch 'develop' of https://github.com/frappe/erpnext into boot…
deepeshgarg007 May 2, 2021
4311fdc
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext…
deepeshgarg007 May 27, 2021
48b1a82
fix: Add accounts and templates for reverse charge
deepeshgarg007 May 29, 2021
b3ed807
fix: Regional settings setup
deepeshgarg007 Jun 2, 2021
ca34eec
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext…
deepeshgarg007 Jun 2, 2021
7c7c084
fix: Check for tax category
deepeshgarg007 Jun 2, 2021
6734707
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext…
deepeshgarg007 Jun 23, 2021
40a4330
fix: Move tax categories up in country wise json
deepeshgarg007 Jun 23, 2021
208b5f9
chore: Add comments
deepeshgarg007 Jun 23, 2021
35e11fb
fix: Tests
deepeshgarg007 Jun 23, 2021
0bfffdd
fix: Test Cases
deepeshgarg007 Jun 23, 2021
1e5482c
fix: Revert Changes
deepeshgarg007 Jun 26, 2021
cf445eb
fix: Add validate bank account method back
deepeshgarg007 Jun 26, 2021
ebc46c1
fix: Update account heads in GST test cases
deepeshgarg007 Jun 28, 2021
6309601
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext…
deepeshgarg007 Jul 2, 2021
a0599e5
fix: Test cases for M-pesa
deepeshgarg007 Jul 5, 2021
db682d9
fix: Create mode of payment if doesn't exists
deepeshgarg007 Jul 5, 2021
15b336d
fix: Test cases
deepeshgarg007 Jul 5, 2021
9b6d9a4
fix: Test Cases
deepeshgarg007 Jul 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,33 @@ def test_einvoice_json(self):
einvoice = make_einvoice(si)
validate_totals(einvoice)

def test_item_tax_net_range(self):
item = create_item("T Shirt")

item.set('taxes', [])
item.append("taxes", {
"item_tax_template": "_Test Account Excise Duty @ 10 - _TC",
"minimum_net_rate": 0,
"maximum_net_rate": 500
})

item.append("taxes", {
"item_tax_template": "_Test Account Excise Duty @ 12 - _TC",
"minimum_net_rate": 501,
"maximum_net_rate": 1000
})

item.save()

sales_invoice = create_sales_invoice(item = "T Shirt", rate=700, do_not_submit=True)
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")

# Apply discount
sales_invoice.apply_discount_on = 'Net Total'
sales_invoice.discount_amount = 300
sales_invoice.save()
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")

def get_sales_invoice_for_e_invoice():
si = make_sales_invoice_for_ewaybill()
si.naming_series = 'INV-2020-.#####'
Expand Down Expand Up @@ -1985,32 +2012,6 @@ def get_sales_invoice_for_e_invoice():

return si

def test_item_tax_net_range(self):
item = create_item("T Shirt")

item.set('taxes', [])
item.append("taxes", {
"item_tax_template": "_Test Account Excise Duty @ 10 - _TC",
"minimum_net_rate": 0,
"maximum_net_rate": 500
})

item.append("taxes", {
"item_tax_template": "_Test Account Excise Duty @ 12 - _TC",
"minimum_net_rate": 501,
"maximum_net_rate": 1000
})

item.save()

sales_invoice = create_sales_invoice(item = "T Shirt", rate=700, do_not_submit=True)
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")

# Apply discount
sales_invoice.apply_discount_on = 'Net Total'
sales_invoice.discount_amount = 300
sales_invoice.save()
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")

def make_test_address_for_ewaybill():
if not frappe.db.exists('Address', '_Test Address for Eway bill-Billing'):
Expand Down Expand Up @@ -2087,9 +2088,9 @@ def make_sales_invoice_for_ewaybill():
if not gst_account:
gst_settings.append("gst_accounts", {
"company": "_Test Company",
"cgst_account": "CGST - _TC",
"sgst_account": "SGST - _TC",
"igst_account": "IGST - _TC",
"cgst_account": "Output Tax CGST - _TC",
"sgst_account": "Output Tax SGST - _TC",
"igst_account": "Output Tax IGST - _TC",
})

gst_settings.save()
Expand All @@ -2106,15 +2107,15 @@ def make_sales_invoice_for_ewaybill():

si.append("taxes", {
"charge_type": "On Net Total",
"account_head": "CGST - _TC",
"account_head": "Output Tax CGST - _TC",
"cost_center": "Main - _TC",
"description": "CGST @ 9.0",
"rate": 9
})

si.append("taxes", {
"charge_type": "On Net Total",
"account_head": "SGST - _TC",
"account_head": "Output Tax SGST - _TC",
"cost_center": "Main - _TC",
"description": "SGST @ 9.0",
"rate": 9
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def get_children(doctype, parent, company, is_root=False):
return acc

def create_payment_gateway_account(gateway, payment_channel="Email"):
from erpnext.setup.setup_wizard.operations.company_setup import create_bank_account
from erpnext.setup.setup_wizard.operations.install_fixtures import create_bank_account

company = frappe.db.get_value("Global Defaults", None, "default_company")
if not company:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
import unittest
from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_settings import process_balance_info, verify_transaction
from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice
from erpnext.erpnext_integrations.utils import create_mode_of_payment

class TestMpesaSettings(unittest.TestCase):
def setUp(self):
# create payment gateway in setup
create_mpesa_settings(payment_gateway_name="_Test")
create_mpesa_settings(payment_gateway_name="_Account Balance")
create_mpesa_settings(payment_gateway_name="Payment")

def tearDown(self):
frappe.db.sql('delete from `tabMpesa Settings`')
frappe.db.sql('delete from `tabIntegration Request` where integration_request_service = "Mpesa"')

def test_creation_of_payment_gateway(self):
create_mpesa_settings(payment_gateway_name="_Test")

mode_of_payment = frappe.get_doc("Mode of Payment", "Mpesa-_Test")
mode_of_payment = create_mode_of_payment('Mpesa-_Test', payment_type="Phone")
self.assertTrue(frappe.db.exists("Payment Gateway Account", {'payment_gateway': "Mpesa-_Test"}))
self.assertTrue(mode_of_payment.name)
self.assertEqual(mode_of_payment.type, "Phone")
Expand Down Expand Up @@ -47,7 +52,6 @@ def test_processing_of_account_balance(self):
integration_request.delete()

def test_processing_of_callback_payload(self):
create_mpesa_settings(payment_gateway_name="Payment")
mpesa_account = frappe.db.get_value("Payment Gateway Account", {"payment_gateway": 'Mpesa-Payment'}, "payment_account")
frappe.db.set_value("Account", mpesa_account, "account_currency", "KES")
frappe.db.set_value("Customer", "_Test Customer", "default_currency", "KES")
Expand Down Expand Up @@ -90,7 +94,6 @@ def test_processing_of_callback_payload(self):
pos_invoice.delete()

def test_processing_of_multiple_callback_payload(self):
create_mpesa_settings(payment_gateway_name="Payment")
mpesa_account = frappe.db.get_value("Payment Gateway Account", {"payment_gateway": 'Mpesa-Payment'}, "payment_account")
frappe.db.set_value("Account", mpesa_account, "account_currency", "KES")
frappe.db.set_value("Mpesa Settings", "Payment", "transaction_limit", "500")
Expand Down Expand Up @@ -141,7 +144,6 @@ def test_processing_of_multiple_callback_payload(self):
pos_invoice.delete()

def test_processing_of_only_one_succes_callback_payload(self):
create_mpesa_settings(payment_gateway_name="Payment")
mpesa_account = frappe.db.get_value("Payment Gateway Account", {"payment_gateway": 'Mpesa-Payment'}, "payment_account")
frappe.db.set_value("Account", mpesa_account, "account_currency", "KES")
frappe.db.set_value("Mpesa Settings", "Payment", "transaction_limit", "500")
Expand Down Expand Up @@ -202,6 +204,7 @@ def create_mpesa_settings(payment_gateway_name="Express"):

doc = frappe.get_doc(dict( #nosec
doctype="Mpesa Settings",
sandbox=1,
payment_gateway_name=payment_gateway_name,
consumer_key="5sMu9LVI1oS3oBGPJfh3JyvLHwZOdTKn",
consumer_secret="VI1oS3oBGPJfh3JyvLHw",
Expand Down
7 changes: 6 additions & 1 deletion erpnext/erpnext_integrations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def create_mode_of_payment(gateway, payment_type="General"):
"payment_gateway": gateway
}, ['payment_account'])

if not frappe.db.exists("Mode of Payment", gateway) and payment_gateway_account:
mode_of_payment = frappe.db.exists("Mode of Payment", gateway)
if not mode_of_payment and payment_gateway_account:
mode_of_payment = frappe.get_doc({
"doctype": "Mode of Payment",
"mode_of_payment": gateway,
Expand All @@ -66,6 +67,10 @@ def create_mode_of_payment(gateway, payment_type="General"):
})
mode_of_payment.insert(ignore_permissions=True)

return mode_of_payment
elif mode_of_payment:
return frappe.get_doc("Mode of Payment", mode_of_payment)

def get_tracking_url(carrier, tracking_number):
# Return the formatted Tracking URL.
tracking_url = ''
Expand Down
7 changes: 4 additions & 3 deletions erpnext/hr/doctype/expense_claim/test_expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def test_expense_claim_status(self):
def test_expense_claim_gl_entry(self):
payable_account = get_payable_account(company_name)
taxes = generate_taxes()
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", do_not_submit=True, taxes=taxes)
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4",
do_not_submit=True, taxes=taxes)
expense_claim.submit()

gl_entries = frappe.db.sql("""select account, debit, credit
Expand All @@ -82,7 +83,7 @@ def test_expense_claim_gl_entry(self):
self.assertTrue(gl_entries)

expected_values = dict((d[0], d) for d in [
['CGST - _TC4',18.0, 0.0],
['Output Tax CGST - _TC4',18.0, 0.0],
[payable_account, 0.0, 218.0],
["Travel Expenses - _TC4", 200.0, 0.0]
])
Expand Down Expand Up @@ -145,7 +146,7 @@ def generate_taxes():
parent_account = frappe.db.get_value('Account',
{'company': company_name, 'is_group':1, 'account_type': 'Tax'},
'name')
account = create_account(company=company_name, account_name="CGST", account_type="Tax", parent_account=parent_account)
account = create_account(company=company_name, account_name="Output Tax CGST", account_type="Tax", parent_account=parent_account)
return {'taxes':[{
"account_head": account,
"rate": 0,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/setup_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ erpnext.setup.slides_settings = [
}

// Validate bank name
if(me.values.bank_account){
if(me.values.bank_account) {
frappe.call({
async: false,
method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.validate_bank_account",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is removed? The code was there because many people enter just "Bank Accounts" in Bank field in Setup Wizard and it raises duplication error.

Expand Down
15 changes: 15 additions & 0 deletions erpnext/regional/doctype/gst_settings/gst_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ def onload(self):
from tabAddress where country = "India" and ifnull(gstin, '')!='' ''')
self.set_onload('data', data)

def validate(self):
# Validate duplicate accounts
self.validate_duplicate_accounts()

def validate_duplicate_accounts(self):
account_list = []
for account in self.get('gst_accounts'):
for fieldname in ['cgst_account', 'sgst_account', 'igst_account', 'cess_account']:
if account.get(fieldname) in account_list:
frappe.throw(_("Account {0} appears multiple times").format(
frappe.bold(account.get(fieldname))))

if account.get(fieldname):
account_list.append(account.get(fieldname))

@frappe.whitelist()
def send_reminder():
frappe.has_permission('GST Settings', throw=True)
Expand Down
28 changes: 14 additions & 14 deletions erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def test_gstr_3b_report(self):
make_sales_invoice()
create_purchase_invoices()

if frappe.db.exists("GSTR 3B Report", "GSTR3B-March-2019-_Test Address-Billing"):
report = frappe.get_doc("GSTR 3B Report", "GSTR3B-March-2019-_Test Address-Billing")
if frappe.db.exists("GSTR 3B Report", "GSTR3B-March-2019-_Test Address GST-Billing"):
report = frappe.get_doc("GSTR 3B Report", "GSTR3B-March-2019-_Test Address GST-Billing")
report.save()
else:
report = frappe.get_doc({
"doctype": "GSTR 3B Report",
"company": "_Test Company GST",
"company_address": "_Test Address-Billing",
"company_address": "_Test Address GST-Billing",
"year": getdate().year,
"month": month_number_mapping.get(getdate().month)
}).insert()
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_gst_rounding(self):

si.append("taxes", {
"charge_type": "On Net Total",
"account_head": "IGST - _GST",
"account_head": "Output Tax IGST - _GST",
"cost_center": "Main - _GST",
"description": "IGST @ 18.0",
"rate": 18
Expand Down Expand Up @@ -117,7 +117,7 @@ def make_sales_invoice():

si.append("taxes", {
"charge_type": "On Net Total",
"account_head": "IGST - _GST",
"account_head": "Output Tax IGST - _GST",
"cost_center": "Main - _GST",
"description": "IGST @ 18.0",
"rate": 18
Expand All @@ -138,7 +138,7 @@ def make_sales_invoice():

si1.append("taxes", {
"charge_type": "On Net Total",
"account_head": "IGST - _GST",
"account_head": "Output Tax IGST - _GST",
"cost_center": "Main - _GST",
"description": "IGST @ 18.0",
"rate": 18
Expand All @@ -159,7 +159,7 @@ def make_sales_invoice():

si2.append("taxes", {
"charge_type": "On Net Total",
"account_head": "IGST - _GST",
"account_head": "Output Tax IGST - _GST",
"cost_center": "Main - _GST",
"description": "IGST @ 18.0",
"rate": 18
Expand Down Expand Up @@ -195,15 +195,15 @@ def create_purchase_invoices():

pi.append("taxes", {
"charge_type": "On Net Total",
"account_head": "CGST - _GST",
"account_head": "Input Tax CGST - _GST",
"cost_center": "Main - _GST",
"description": "CGST @ 9.0",
"rate": 9
})

pi.append("taxes", {
"charge_type": "On Net Total",
"account_head": "SGST - _GST",
"account_head": "Input Tax SGST - _GST",
"cost_center": "Main - _GST",
"description": "SGST @ 9.0",
"rate": 9
Expand Down Expand Up @@ -410,10 +410,10 @@ def make_company():
company.country = "India"
company.insert()

if not frappe.db.exists('Address', '_Test Address-Billing'):
if not frappe.db.exists('Address', '_Test Address GST-Billing'):
address = frappe.get_doc({
"address_title": "_Test Address GST",
"address_line1": "_Test Address Line 1",
"address_title": "_Test Address",
"address_type": "Billing",
"city": "_Test City",
"state": "Test State",
Expand Down Expand Up @@ -444,9 +444,9 @@ def set_account_heads():
if not gst_account:
gst_settings.append("gst_accounts", {
"company": "_Test Company GST",
"cgst_account": "CGST - _GST",
"sgst_account": "SGST - _GST",
"igst_account": "IGST - _GST",
"cgst_account": "Output Tax CGST - _GST",
"sgst_account": "Output Tax SGST - _GST",
"igst_account": "Output Tax IGST - _GST"
})

gst_settings.save()
Loading