Merge pull request #26471 from deepeshgarg007/payment_entry_taxes_unallocated_amount
fix: Unallocated amount in Payment Entry after taxes
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index c27a878..6dc2767 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -2118,9 +2118,9 @@
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()
@@ -2137,7 +2137,7 @@
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
@@ -2145,7 +2145,7 @@
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
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index e724e9b..1759fa3 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -55,9 +55,11 @@
if not account_details.get(account):
frappe.throw(_("Account {0} does not exists").format(account))
- if (filters.get("account") and filters.get("group_by") == _('Group by Account')
- and account_details[filters.account].is_group == 0):
- frappe.throw(_("Can not filter based on Account, if grouped by Account"))
+ if (filters.get("account") and filters.get("group_by") == _('Group by Account')):
+ filters.account = frappe.parse_json(filters.get('account'))
+ for account in filters.account:
+ if account_details[account].is_group == 0:
+ frappe.throw(_("Can not filter based on Child Account, if grouped by Account"))
if (filters.get("voucher_no")
and filters.get("group_by") in [_('Group by Voucher')]):
diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
index e15715d..6b9df41 100644
--- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
+++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
@@ -75,7 +75,8 @@
select voucher_no, credit
from `tabGL Entry`
where party in (%s) and credit > 0
- and company=%s and posting_date between %s and %s
+ and company=%s and is_cancelled = 0
+ and posting_date between %s and %s
""", (supplier, company, from_date, to_date), as_dict=1)
supplier_credit_amount = flt(sum(d.credit for d in entries))
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index a8e4b15..1cdbd8d 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -788,7 +788,7 @@
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:
diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py
index 3c2e59a..b0e662d 100644
--- a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py
+++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py
@@ -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")
@@ -47,7 +52,6 @@
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")
@@ -90,7 +94,6 @@
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")
@@ -141,7 +144,6 @@
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")
@@ -202,6 +204,7 @@
doc = frappe.get_doc(dict( #nosec
doctype="Mpesa Settings",
+ sandbox=1,
payment_gateway_name=payment_gateway_name,
consumer_key="5sMu9LVI1oS3oBGPJfh3JyvLHwZOdTKn",
consumer_secret="VI1oS3oBGPJfh3JyvLHw",
diff --git a/erpnext/erpnext_integrations/utils.py b/erpnext/erpnext_integrations/utils.py
index 3840e78..a5e162f 100644
--- a/erpnext/erpnext_integrations/utils.py
+++ b/erpnext/erpnext_integrations/utils.py
@@ -52,7 +52,8 @@
"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,
@@ -66,6 +67,10 @@
})
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 = ''
diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
index 578eccf..96ea686 100644
--- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
@@ -72,7 +72,8 @@
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
@@ -82,7 +83,7 @@
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]
])
@@ -145,7 +146,7 @@
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,
diff --git a/erpnext/portal/product_configurator/utils.py b/erpnext/portal/product_configurator/utils.py
index d77eb2c..211b94a 100644
--- a/erpnext/portal/product_configurator/utils.py
+++ b/erpnext/portal/product_configurator/utils.py
@@ -2,6 +2,7 @@
from frappe.utils import cint
from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager
from erpnext.shopping_cart.product_info import get_product_info_for_website
+from erpnext.setup.doctype.item_group.item_group import get_child_groups
def get_field_filter_data():
product_settings = get_product_settings()
@@ -89,6 +90,7 @@
def get_products_html_for_website(field_filters=None, attribute_filters=None):
field_filters = frappe.parse_json(field_filters)
attribute_filters = frappe.parse_json(attribute_filters)
+ set_item_group_filters(field_filters)
items = get_products_for_website(field_filters, attribute_filters)
html = ''.join(get_html_for_items(items))
@@ -98,6 +100,10 @@
return html
+def set_item_group_filters(field_filters):
+ if 'item_group' in field_filters:
+ field_filters['item_group'] = [ig[0] for ig in get_child_groups(field_filters['item_group'])]
+
def get_item_codes_by_attributes(attribute_filters, template_item_code=None):
items = []
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 39a6024..5976e01 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -77,9 +77,6 @@
if flt(self.progress or 0) > 100:
frappe.throw(_("Progress % for a task cannot be more than 100."))
- if flt(self.progress) == 100:
- self.status = 'Completed'
-
if self.status == 'Completed':
self.progress = 100
diff --git a/erpnext/public/js/help_links.js b/erpnext/public/js/help_links.js
index 5c9a453..d0c935f 100644
--- a/erpnext/public/js/help_links.js
+++ b/erpnext/public/js/help_links.js
@@ -54,7 +54,7 @@
frappe.help.help_links["Form/System Settings"] = [
{
- label: "Naming Series",
+ label: "System Settings",
url: docsUrl + "user/manual/en/setting-up/settings/system-settings",
},
];
@@ -206,7 +206,7 @@
label: "PayPal Settings",
url:
docsUrl +
- "user/manual/en/setting-up/integrations/paypal-integration",
+ "user/manual/en/erpnext_integration/paypal-integration",
},
];
@@ -215,14 +215,14 @@
label: "Razorpay Settings",
url:
docsUrl +
- "user/manual/en/setting-up/integrations/razorpay-integration",
+ "user/manual/en/erpnext_integration/razorpay-integration",
},
];
frappe.help.help_links["Form/Dropbox Settings"] = [
{
label: "Dropbox Settings",
- url: docsUrl + "user/manual/en/setting-up/integrations/dropbox-backup",
+ url: docsUrl + "user/manual/en/erpnext_integration/dropbox-backup",
},
];
@@ -230,7 +230,7 @@
{
label: "LDAP Settings",
url:
- docsUrl + "user/manual/en/setting-up/integrations/ldap-integration",
+ docsUrl + "user/manual/en/erpnext_integration/ldap-integration",
},
];
@@ -239,7 +239,7 @@
label: "Stripe Settings",
url:
docsUrl +
- "user/manual/en/setting-up/integrations/stripe-integration",
+ "user/manual/en/erpnext_integration/stripe-integration",
},
];
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index ef03b01..6f5d67c 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -147,7 +147,7 @@
}
// 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",
diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.py b/erpnext/regional/doctype/gst_settings/gst_settings.py
index bc956e9..af3d92e 100644
--- a/erpnext/regional/doctype/gst_settings/gst_settings.py
+++ b/erpnext/regional/doctype/gst_settings/gst_settings.py
@@ -19,6 +19,21 @@
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)
diff --git a/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
index 3857ce1..065f80d 100644
--- a/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
+++ b/erpnext/regional/doctype/gstr_3b_report/test_gstr_3b_report.py
@@ -46,14 +46,14 @@
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()
@@ -89,7 +89,7 @@
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
@@ -117,7 +117,7 @@
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
@@ -138,7 +138,7 @@
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
@@ -159,7 +159,7 @@
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
@@ -195,7 +195,7 @@
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
@@ -203,7 +203,7 @@
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
@@ -410,10 +410,10 @@
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",
@@ -444,9 +444,9 @@
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()
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index 3e0b9b7..5f9d5ed 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -25,6 +25,7 @@
frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
create_gratuity_rule()
add_print_formats()
+ update_accounts_settings_for_taxes()
def add_hsn_sac_codes():
if frappe.flags.in_test and frappe.flags.created_hsn_codes:
@@ -680,7 +681,7 @@
def make_fixtures(company=None):
docs = []
- company = company.name if company else frappe.db.get_value("Global Defaults", None, "default_company")
+ company = company or frappe.db.get_value("Global Defaults", None, "default_company")
set_salary_components(docs)
set_tds_account(docs, company)
@@ -698,6 +699,53 @@
# create records for Tax Withholding Category
set_tax_withholding_category(company)
+def update_regional_tax_settings(country, company):
+ # Will only add default GST accounts if present
+ input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
+ output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
+ rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
+ gst_settings = frappe.get_single('GST Settings')
+ existing_account_list = []
+
+ for account in gst_settings.get('gst_accounts'):
+ for key in ['cgst_account', 'sgst_account', 'igst_account']:
+ existing_account_list.append(account.get(key))
+
+ gst_accounts = frappe._dict(frappe.get_all("Account",
+ {'company': company, 'account_name': ('in', input_account_names +
+ output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
+
+ add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
+ existing_account_list, gst_settings)
+ add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
+ existing_account_list, gst_settings)
+ add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
+ existing_account_list, gst_settings, is_reverse_charge=1)
+
+ gst_settings.save()
+
+def add_accounts_in_gst_settings(company, account_names, gst_accounts,
+ existing_account_list, gst_settings, is_reverse_charge=0):
+ accounts_not_added = 1
+
+ for account in account_names:
+ # Default Account Added does not exists
+ if not gst_accounts.get(account):
+ accounts_not_added = 0
+
+ # Check if already added in GST Settings
+ if gst_accounts.get(account) in existing_account_list:
+ accounts_not_added = 0
+
+ if accounts_not_added:
+ gst_settings.append('gst_accounts', {
+ 'company': company,
+ 'cgst_account': gst_accounts.get(account_names[0]),
+ 'sgst_account': gst_accounts.get(account_names[1]),
+ 'igst_account': gst_accounts.get(account_names[2]),
+ 'is_reverse_charge_account': is_reverse_charge
+ })
+
def set_salary_components(docs):
docs.extend([
{'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
@@ -731,12 +779,13 @@
docs = get_tds_details(accounts, fiscal_year)
for d in docs:
- try:
+ if not frappe.db.exists("Tax Withholding Category", d.get("name")):
doc = frappe.get_doc(d)
+ doc.flags.ignore_validate = True
doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True
doc.insert()
- except frappe.DuplicateEntryError:
+ else:
doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
if accounts:
@@ -749,11 +798,12 @@
doc.append("rates", d.get('rates')[0])
doc.flags.ignore_permissions = True
+ doc.flags.ignore_validate = True
doc.flags.ignore_mandatory = True
+ doc.flags.ignore_links = True
doc.save()
def set_tds_account(docs, company):
- abbr = frappe.get_value("Company", company, "abbr")
parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
if parent_account:
docs.extend([
@@ -912,7 +962,6 @@
]
def create_gratuity_rule():
-
# Standard Indain Gratuity Rule
if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
rule = frappe.new_doc("Gratuity Rule")
@@ -930,3 +979,7 @@
rule.flags.ignore_mandatory = True
rule.save()
+
+def update_accounts_settings_for_taxes():
+ if frappe.db.count('Company') == 1:
+ frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)
\ No newline at end of file
diff --git a/erpnext/regional/report/e_invoice_summary/e_invoice_summary.json b/erpnext/regional/report/e_invoice_summary/e_invoice_summary.json
index 4deb073..d0000ad 100644
--- a/erpnext/regional/report/e_invoice_summary/e_invoice_summary.json
+++ b/erpnext/regional/report/e_invoice_summary/e_invoice_summary.json
@@ -11,7 +11,7 @@
"is_standard": "Yes",
"json": "{}",
"letter_head": "Logo",
- "modified": "2021-03-12 12:36:48.689413",
+ "modified": "2021-03-13 12:36:48.689413",
"modified_by": "Administrator",
"module": "Regional",
"name": "E-Invoice Summary",
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 8fd905d..36a7d20 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -110,7 +110,7 @@
self.create_default_warehouses()
if frappe.flags.country_change:
- install_country_fixtures(self.name)
+ install_country_fixtures(self.name, self.country)
self.create_default_tax_template()
if not frappe.db.get_value("Department", {"company": self.name}):
@@ -440,16 +440,15 @@
return " - ".join(parts)
-def install_country_fixtures(company):
- company_doc = frappe.get_doc("Company", company)
- path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(company_doc.country))
+def install_country_fixtures(company, country):
+ path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(country))
if os.path.exists(path.encode("utf-8")):
try:
- module_name = "erpnext.regional.{0}.setup.setup".format(frappe.scrub(company_doc.country))
- frappe.get_attr(module_name)(company_doc, False)
+ module_name = "erpnext.regional.{0}.setup.setup".format(frappe.scrub(country))
+ frappe.get_attr(module_name)(company, False)
except Exception as e:
frappe.log_error()
- frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(company_doc.country)))
+ frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(country)))
def update_company_current_month_sales(company):
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index 1a83cb6..c46b6cc 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -87,8 +87,8 @@
if not field_filters:
field_filters = {}
- # Ensure the query remains within current item group
- field_filters['item_group'] = self.name
+ # Ensure the query remains within current item group & sub group
+ field_filters['item_group'] = [ig[0] for ig in get_child_groups(self.name)]
engine = ProductQuery()
context.items = engine.query(attribute_filters, field_filters, search, start, item_group=self.name)
diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json
index daaa626..34af093 100644
--- a/erpnext/setup/setup_wizard/data/country_wise_tax.json
+++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json
@@ -1164,33 +1164,292 @@
},
"India": {
+ "tax_categories": [
+ {
+ "title": "In-State",
+ "is_inter_state": 0,
+ "gst_state": ""
+ },
+ {
+ "title": "Out-State",
+ "is_inter_state": 1,
+ "gst_state": ""
+ },
+ {
+ "title": "Reverse Charge In-State",
+ "is_inter_state": 0,
+ "gst_state": ""
+ },
+ {
+ "title": "Reverse Charge Out-State",
+ "is_inter_state": 1,
+ "gst_state": ""
+ },
+ {
+ "title": "Registered Composition",
+ "is_inter_state": 0,
+ "gst_state": ""
+ }
+ ],
"chart_of_accounts": {
"*": {
"item_tax_templates": [
{
- "title": "In State GST",
+ "title": "GST 9%",
"taxes": [
{
"tax_type": {
- "account_name": "SGST",
+ "account_name": "Output Tax SGST",
"tax_rate": 9.00
}
},
{
"tax_type": {
- "account_name": "CGST",
+ "account_name": "Output Tax CGST",
"tax_rate": 9.00
}
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax IGST",
+ "tax_rate": 18.00
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST",
+ "tax_rate": 9.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST",
+ "tax_rate": 9.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST",
+ "tax_rate": 18.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST RCM",
+ "tax_rate": 9.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST RCM",
+ "tax_rate": 9.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST RCM",
+ "tax_rate": 18.00,
+ "root_type": "Asset"
+ }
}
]
},
{
- "title": "Out of State GST",
+ "title": "GST 5%",
"taxes": [
{
"tax_type": {
- "account_name": "IGST",
- "tax_rate": 18.00
+ "account_name": "Output Tax SGST",
+ "tax_rate": 2.5
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax CGST",
+ "tax_rate": 2.5
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax IGST",
+ "tax_rate": 5.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST",
+ "tax_rate": 2.5,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST",
+ "tax_rate": 2.5,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST",
+ "tax_rate": 5.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST RCM",
+ "tax_rate": 2.50,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST RCM",
+ "tax_rate": 2.50,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST RCM",
+ "tax_rate": 5.00,
+ "root_type": "Asset"
+ }
+ }
+ ]
+ },
+ {
+ "title": "GST 12%",
+ "taxes": [
+ {
+ "tax_type": {
+ "account_name": "Output Tax SGST",
+ "tax_rate": 6.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax CGST",
+ "tax_rate": 6.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax IGST",
+ "tax_rate": 12.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST",
+ "tax_rate": 6.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST",
+ "tax_rate": 6.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST",
+ "tax_rate": 12.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST RCM",
+ "tax_rate": 6.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST RCM",
+ "tax_rate": 6.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST RCM",
+ "tax_rate": 12.00,
+ "root_type": "Asset"
+ }
+ }
+ ]
+ },
+ {
+ "title": "GST 28%",
+ "taxes": [
+ {
+ "tax_type": {
+ "account_name": "Output Tax SGST",
+ "tax_rate": 14.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax CGST",
+ "tax_rate": 14.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Output Tax IGST",
+ "tax_rate": 28.0
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST",
+ "tax_rate": 14.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST",
+ "tax_rate": 14.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST",
+ "tax_rate": 28.0,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax SGST RCM",
+ "tax_rate": 14.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax CGST RCM",
+ "tax_rate": 14.00,
+ "root_type": "Asset"
+ }
+ },
+ {
+ "tax_type": {
+ "account_name": "Input Tax IGST RCM",
+ "tax_rate": 28.00,
+ "root_type": "Asset"
}
}
]
@@ -1229,36 +1488,117 @@
]
}
],
- "*": [
+ "sales_tax_templates": [
{
- "title": "In State GST",
+ "title": "Output GST In-state",
"taxes": [
{
"account_head": {
- "account_name": "SGST",
- "tax_rate": 9.00
+ "account_name": "Output Tax SGST",
+ "tax_rate": 9.00,
+ "account_type": "Tax"
}
},
{
"account_head": {
- "account_name": "CGST",
- "tax_rate": 9.00
+ "account_name": "Output Tax CGST",
+ "tax_rate": 9.00,
+ "account_type": "Tax"
}
}
- ]
+ ],
+ "tax_category": "In-State"
},
{
- "title": "Out of State GST",
+ "title": "Output GST Out-state",
"taxes": [
{
"account_head": {
- "account_name": "IGST",
- "tax_rate": 18.00
+ "account_name": "Output Tax IGST",
+ "tax_rate": 18.00,
+ "account_type": "Tax"
}
}
- ]
+ ],
+ "tax_category": "Out-State"
+ }
+ ],
+ "purchase_tax_templates": [
+ {
+ "title": "Input GST In-state",
+ "taxes": [
+ {
+ "account_head": {
+ "account_name": "Input Tax SGST",
+ "tax_rate": 9.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ },
+ {
+ "account_head": {
+ "account_name": "Input Tax CGST",
+ "tax_rate": 9.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ }
+ ],
+ "tax_category": "In-State"
},
{
+ "title": "Input GST Out-state",
+ "taxes": [
+ {
+ "account_head": {
+ "account_name": "Input Tax IGST",
+ "tax_rate": 18.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ }
+ ],
+ "tax_category": "Out-State"
+ },
+ {
+ "title": "Input GST RCM In-state",
+ "taxes": [
+ {
+ "account_head": {
+ "account_name": "Input Tax SGST RCM",
+ "tax_rate": 9.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ },
+ {
+ "account_head": {
+ "account_name": "Input Tax CGST RCM",
+ "tax_rate": 9.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ }
+ ],
+ "tax_category": "Reverse Charge In-State"
+ },
+ {
+ "title": "Input GST RCM Out-state",
+ "taxes": [
+ {
+ "account_head": {
+ "account_name": "Input Tax IGST RCM",
+ "tax_rate": 18.00,
+ "root_type": "Asset",
+ "account_type": "Tax"
+ }
+ }
+ ],
+ "tax_category": "Reverse Charge Out-State"
+ }
+ ],
+ "*": [
+ {
"title": "VAT 5%",
"taxes": [
{
@@ -1349,7 +1689,7 @@
"Italy VAT 4%":{
"account_name": "IVA 4%",
"tax_rate": 4.00
- }
+ }
},
"Ivory Coast": {
diff --git a/erpnext/setup/setup_wizard/operations/company_setup.py b/erpnext/setup/setup_wizard/operations/company_setup.py
index 3f0bb14..4edf948 100644
--- a/erpnext/setup/setup_wizard/operations/company_setup.py
+++ b/erpnext/setup/setup_wizard/operations/company_setup.py
@@ -42,29 +42,6 @@
'quotation_series': "QTN-",
}).insert()
-def create_bank_account(args):
- if args.get("bank_account"):
- company_name = args.get('company_name')
- bank_account_group = frappe.db.get_value("Account",
- {"account_type": "Bank", "is_group": 1, "root_type": "Asset",
- "company": company_name})
- if bank_account_group:
- bank_account = frappe.get_doc({
- "doctype": "Account",
- 'account_name': args.get("bank_account"),
- 'parent_account': bank_account_group,
- 'is_group':0,
- 'company': company_name,
- "account_type": "Bank",
- })
- try:
- return bank_account.insert()
- except RootNotEditable:
- frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
- except frappe.DuplicateEntryError:
- # bank account same as a CoA entry
- pass
-
def create_email_digest():
from frappe.utils.user import get_system_managers
system_managers = get_system_managers(only_name=True)
diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py
index 7ae81d7..cd49a18 100644
--- a/erpnext/setup/setup_wizard/operations/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py
@@ -448,6 +448,8 @@
set_active_domains(args)
update_stock_settings()
update_shopping_cart_settings(args)
+
+ args.update({"set_default": 1})
create_bank_account(args)
def set_global_defaults(args):
@@ -479,17 +481,17 @@
stock_settings.save()
def create_bank_account(args):
- if not args.bank_account:
+ if not args.get('bank_account'):
return
- company_name = args.company_name
+ company_name = args.get('company_name')
bank_account_group = frappe.db.get_value("Account",
{"account_type": "Bank", "is_group": 1, "root_type": "Asset",
"company": company_name})
if bank_account_group:
bank_account = frappe.get_doc({
"doctype": "Account",
- 'account_name': args.bank_account,
+ 'account_name': args.get('bank_account'),
'parent_account': bank_account_group,
'is_group':0,
'company': company_name,
@@ -498,10 +500,13 @@
try:
doc = bank_account.insert()
- frappe.db.set_value("Company", args.company_name, "default_bank_account", bank_account.name, update_modified=False)
+ if args.get('set_default'):
+ frappe.db.set_value("Company", args.get('company_name'), "default_bank_account", bank_account.name, update_modified=False)
+
+ return doc
except RootNotEditable:
- frappe.throw(_("Bank account cannot be named as {0}").format(args.bank_account))
+ frappe.throw(_("Bank account cannot be named as {0}").format(args.get('bank_account')))
except frappe.DuplicateEntryError:
# bank account same as a CoA entry
pass
diff --git a/erpnext/setup/setup_wizard/operations/taxes_setup.py b/erpnext/setup/setup_wizard/operations/taxes_setup.py
index f4fe18e..6ea0ca4 100644
--- a/erpnext/setup/setup_wizard/operations/taxes_setup.py
+++ b/erpnext/setup/setup_wizard/operations/taxes_setup.py
@@ -26,7 +26,8 @@
if 'chart_of_accounts' not in country_wise_tax:
country_wise_tax = simple_to_detailed(country_wise_tax)
- from_detailed_data(company_name, country_wise_tax)
+ from_detailed_data(company_name, country_wise_tax.get('chart_of_accounts'))
+ update_regional_tax_settings(country, company_name)
def simple_to_detailed(templates):
@@ -77,16 +78,15 @@
def from_detailed_data(company_name, data):
"""Create Taxes and Charges Templates from detailed data."""
coa_name = frappe.db.get_value('Company', company_name, 'chart_of_accounts')
- coa_data = data.get('chart_of_accounts', {})
- tax_templates = coa_data.get(coa_name) or coa_data.get('*', {})
- tax_categories = data.get('tax_categories')
- sales_tax_templates = tax_templates.get('sales_tax_templates') or tax_templates.get('*', {})
- purchase_tax_templates = tax_templates.get('purchase_tax_templates') or tax_templates.get('*', {})
- item_tax_templates = tax_templates.get('item_tax_templates') or tax_templates.get('*', {})
+ tax_templates = data.get(coa_name) or data.get('*')
+ sales_tax_templates = tax_templates.get('sales_tax_templates') or tax_templates.get('*')
+ purchase_tax_templates = tax_templates.get('purchase_tax_templates') or tax_templates.get('*')
+ item_tax_templates = tax_templates.get('item_tax_templates') or tax_templates.get('*')
+ tax_categories = tax_templates.get('tax_categories')
if tax_categories:
for tax_category in tax_categories:
- make_tax_catgory(tax_category)
+ make_tax_category(tax_category)
if sales_tax_templates:
for template in sales_tax_templates:
@@ -101,6 +101,17 @@
make_item_tax_template(company_name, template)
+def update_regional_tax_settings(country, company):
+ path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(country))
+ if os.path.exists(path.encode("utf-8")):
+ try:
+ module_name = "erpnext.regional.{0}.setup.update_regional_tax_settings".format(frappe.scrub(country))
+ frappe.get_attr(module_name)(country, company)
+ except Exception as e:
+ # Log error and ignore if failed to setup regional tax settings
+ frappe.log_error()
+ pass
+
def make_taxes_and_charges_template(company_name, doctype, template):
template['company'] = company_name
template['doctype'] = doctype
@@ -130,8 +141,14 @@
if fieldname not in tax_row:
tax_row[fieldname] = default_value
- return frappe.get_doc(template).insert(ignore_permissions=True)
+ doc = frappe.get_doc(template)
+ # Data in country wise json is already pre validated, hence validations can be ignored
+ # Ingone validations to make doctypes faster
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
+ return doc
def make_item_tax_template(company_name, template):
"""Create an Item Tax Template.
@@ -156,8 +173,24 @@
if 'tax_rate' not in tax_row:
tax_row['tax_rate'] = account_data.get('tax_rate')
- return frappe.get_doc(template).insert(ignore_permissions=True)
+ doc = frappe.get_doc(template)
+ # Data in country wise json is already pre validated, hence validations can be ignored
+ # Ingone validations to make doctypes faster
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
+ return doc
+
+def make_tax_category(tax_category):
+ """ Make tax category based on title if not already created """
+ doctype = 'Tax Category'
+ if not frappe.db.exists(doctype, tax_category['title']):
+ tax_category['doctype'] = doctype
+ doc = frappe.get_doc(tax_category)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
def get_or_create_account(company_name, account):
"""
@@ -175,8 +208,7 @@
or_filters={
'account_name': account.get('account_name'),
'account_number': account.get('account_number')
- }
- )
+ })
if existing_accounts:
return frappe.get_doc('Account', existing_accounts[0].name)
@@ -191,8 +223,11 @@
account['root_type'] = root_type
account['is_group'] = 0
- return frappe.get_doc(account).insert(ignore_permissions=True, ignore_mandatory=True)
-
+ doc = frappe.get_doc(account)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True, ignore_mandatory=True)
+ return doc
def get_or_create_tax_group(company_name, root_type):
# Look for a group account of type 'Tax'
@@ -237,7 +272,11 @@
'account_type': 'Tax',
'account_name': account_name,
'parent_account': root_account.name
- }).insert(ignore_permissions=True)
+ })
+
+ tax_group_account.flags.ignore_links = True
+ tax_group_account.flags.ignore_validate = True
+ tax_group_account.insert(ignore_permissions=True)
tax_group_name = tax_group_account.name
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index cb939e6..93482e8 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -89,17 +89,16 @@
if item_det.is_stock_item != 1:
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
- # check if batch number is required
- if self.voucher_type != 'Stock Reconciliation':
- if item_det.has_batch_no == 1:
- batch_item = self.item_code if self.item_code == item_det.item_name else self.item_code + ":" + item_det.item_name
- if not self.batch_no:
- frappe.throw(_("Batch number is mandatory for Item {0}").format(batch_item))
- elif not frappe.db.get_value("Batch",{"item": self.item_code, "name": self.batch_no}):
- frappe.throw(_("{0} is not a valid Batch Number for Item {1}").format(self.batch_no, batch_item))
+ # check if batch number is valid
+ if item_det.has_batch_no == 1:
+ batch_item = self.item_code if self.item_code == item_det.item_name else self.item_code + ":" + item_det.item_name
+ if not self.batch_no:
+ frappe.throw(_("Batch number is mandatory for Item {0}").format(batch_item))
+ elif not frappe.db.get_value("Batch",{"item": self.item_code, "name": self.batch_no}):
+ frappe.throw(_("{0} is not a valid Batch Number for Item {1}").format(self.batch_no, batch_item))
- elif item_det.has_batch_no == 0 and self.batch_no and self.is_cancelled == 0:
- frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))
+ elif item_det.has_batch_no == 0 and self.batch_no and self.is_cancelled == 0:
+ frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))
if item_det.has_variants:
frappe.throw(_("Stock cannot exist for Item {0} since has variants").format(self.item_code),
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 76a3f1a..4540954 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -17,6 +17,14 @@
}
}
});
+ frm.set_query("batch_no", "items", function(doc, cdt, cdn) {
+ var item = locals[cdt][cdn];
+ return {
+ filters: {
+ 'item': item.item_code
+ }
+ };
+ });
if (frm.doc.company) {
erpnext.queries.setup_queries(frm, "Warehouse", function() {
diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
index 7b98c7b..cbe413b 100644
--- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
@@ -16,6 +16,7 @@
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
+
class TestStockReconciliation(unittest.TestCase):
@classmethod
def setUpClass(self):
@@ -316,6 +317,26 @@
dn2.cancel()
pr1.cancel()
+ def test_valid_batch(self):
+ create_batch_item_with_batch("Testing Batch Item 1", "001")
+ create_batch_item_with_batch("Testing Batch Item 2", "002")
+ sr = create_stock_reconciliation(item_code="Testing Batch Item 1", qty=1, rate=100, batch_no="002"
+ , do_not_submit=True)
+ self.assertRaises(frappe.ValidationError, sr.submit)
+
+def create_batch_item_with_batch(item_name, batch_id):
+ batch_item_doc = create_item(item_name, is_stock_item=1)
+ if not batch_item_doc.has_batch_no:
+ batch_item_doc.has_batch_no = 1
+ batch_item_doc.create_new_batch = 1
+ batch_item_doc.save(ignore_permissions=True)
+
+ if not frappe.db.exists('Batch', batch_id):
+ b = frappe.new_doc('Batch')
+ b.item = item_name
+ b.batch_id = batch_id
+ b.save()
+
def insert_existing_sle(warehouse):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html
index 393c3a4..9050cc3 100644
--- a/erpnext/templates/generators/item_group.html
+++ b/erpnext/templates/generators/item_group.html
@@ -9,7 +9,7 @@
{% endblock %}
{% block page_content %}
-<div class="item-group-content" itemscope itemtype="http://schema.org/Product">
+<div class="item-group-content" itemscope itemtype="http://schema.org/Product" data-item-group="{{ name }}">
<div class="item-group-slideshow">
{% if slideshow %}<!-- slideshow -->
{{ web_block(
@@ -127,15 +127,36 @@
</script>
</div>
</div>
- <div class="row">
- <div class="col-12">
+ <div class="row mt-6">
+ <div class="col-3">
+ </div>
+ <div class="col-9">
{% if frappe.form_dict.start|int > 0 %}
- <button class="btn btn-outline-secondary btn-prev" data-start="{{ frappe.form_dict.start|int - page_length }}">{{ _("Prev") }}</button>
+ <button class="btn btn-outline-secondary btn-prev" data-start="{{ frappe.form_dict.start|int - page_length }}">
+ {{ _("Prev") }}
+ </button>
{% endif %}
{% if items|length >= page_length %}
- <button class="btn btn-outline-secondary btn-next" data-start="{{ frappe.form_dict.start|int + page_length }}">{{ _("Next") }}</button>
+ <button class="btn btn-outline-secondary btn-next" data-start="{{ frappe.form_dict.start|int + page_length }}"
+ style="float: right;">
+ {{ _("Next") }}
+ </button>
{% endif %}
</div>
</div>
</div>
+
+<script>
+ frappe.ready(() => {
+ $('.btn-prev, .btn-next').click((e) => {
+ const $btn = $(e.target);
+ $btn.prop('disabled', true);
+ const start = $btn.data('start');
+ let query_params = frappe.utils.get_query_params();
+ query_params.start = start;
+ let path = window.location.pathname + '?' + frappe.utils.get_url_from_dict(query_params);
+ window.location.href = path;
+ });
+ });
+</script>
{% endblock %}
\ No newline at end of file
diff --git a/erpnext/www/all-products/index.js b/erpnext/www/all-products/index.js
index 0721056..1c641b5 100644
--- a/erpnext/www/all-products/index.js
+++ b/erpnext/www/all-products/index.js
@@ -124,6 +124,10 @@
attribute_filters: if_key_exists(attribute_filters)
};
+ const item_group = $(".item-group-content").data('item-group');
+ if (item_group) {
+ Object.assign(field_filters, { item_group });
+ }
return new Promise((resolve, reject) => {
frappe.call('erpnext.portal.product_configurator.utils.get_products_html_for_website', args)
.then(r => {