From 5b2b76c4a7190433fbdf1b8c727bd990ca441e3c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 11:52:35 +0530 Subject: [PATCH 1/9] fix: dont fetch entire barcode table in get_item_details (#30131) (#30666) (cherry picked from commit 64905188c46b90452e30927323f892d8b210f14a) Co-authored-by: Ankush Menat --- erpnext/stock/get_item_details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index a8742eef81e..ca0386262e2 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -329,7 +329,7 @@ def get_basic_details(args, item, overwrite_warehouse=True): if not out[d[1]]: out[d[1]] = frappe.get_cached_value('Company', args.company, d[2]) if d[2] else None - for fieldname in ("item_name", "item_group", "barcodes", "brand", "stock_uom"): + for fieldname in ("item_name", "item_group", "brand", "stock_uom"): out[fieldname] = item.get(fieldname) if args.get("manufacturer"): From 68fd8a1dcf78654ea8037672cdbc52e3a493be17 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 19:48:22 +0530 Subject: [PATCH 2/9] fix(india): transporter name is null while generating e-way bill (backport #30736) --- erpnext/regional/india/e_invoice/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 69abfcfaac2..d5d4a526383 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -766,12 +766,13 @@ class GSPConnector(): headers = self.get_headers() eway_bill_details = get_eway_bill_details(args) + data = json.dumps({ 'Irn': args.irn, 'Distance': cint(eway_bill_details.distance), 'TransMode': eway_bill_details.mode_of_transport, 'TransId': eway_bill_details.gstin, - 'TransName': eway_bill_details.transporter, + 'TransName': eway_bill_details.name, 'TrnDocDt': eway_bill_details.document_date, 'TrnDocNo': eway_bill_details.document_name, 'VehNo': eway_bill_details.vehicle_no, From a92c53dd2b937e0a421dc2a85404685708b292e1 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 21 Apr 2022 11:40:39 +0530 Subject: [PATCH 3/9] chore: disable coverage coverage adds overhead which isn't necessary on v12 branch now [skip ci] --- .travis.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7968edc40ba..c33aeb37102 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,11 +16,11 @@ jobs: include: - name: "Python 2.7 Server Side Test" python: 2.7 - script: bench --site test_site run-tests --app erpnext --coverage + script: bench --site test_site run-tests --app erpnext - name: "Python 3.6 Server Side Test" python: 3.6 - script: bench --site test_site run-tests --app erpnext --coverage + script: bench --site test_site run-tests --app erpnext - name: "Python 2.7 Patch Test" python: 2.7 @@ -74,8 +74,3 @@ install: - bench get-app erpnext $TRAVIS_BUILD_DIR - bench start & - bench --site test_site reinstall --yes - -after_script: - - pip install coverage==4.5.4 - - pip install python-coveralls - - coveralls -b apps/erpnext -d ../../sites/.coverage From 2d7c678a9d5a88dc17ad50d7d2066bd15fae7087 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 12:04:25 +0530 Subject: [PATCH 4/9] fix: warehouse naming when suffix is present (#30621) (#30768) (cherry picked from commit be04eaf723804e72226462472884c38b0c0d26ff) Co-authored-by: Ankush Menat --- erpnext/stock/doctype/warehouse/test_warehouse.py | 9 +++++++++ erpnext/stock/doctype/warehouse/warehouse.py | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py index 4ba87ac5fb8..867f3c6c5cf 100644 --- a/erpnext/stock/doctype/warehouse/test_warehouse.py +++ b/erpnext/stock/doctype/warehouse/test_warehouse.py @@ -32,6 +32,15 @@ class TestWarehouse(unittest.TestCase): self.assertEqual(p_warehouse.name, child_warehouse.parent_warehouse) self.assertEqual(child_warehouse.is_group, 0) + def test_naming(self): + company = "Wind Power LLC" + warehouse_name = "Named Warehouse - WP" + wh = frappe.get_doc(doctype="Warehouse", warehouse_name=warehouse_name, company=company).insert() + self.assertEqual(wh.name, warehouse_name) + + warehouse_name = "Unnamed Warehouse" + wh = frappe.get_doc(doctype="Warehouse", warehouse_name=warehouse_name, company=company).insert() + self.assertIn(warehouse_name, wh.name) def create_warehouse(warehouse_name, properties=None, company=None): if not company: diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index f953083d62e..e631f017db2 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -19,8 +19,9 @@ class Warehouse(NestedSet): suffix = " - " + frappe.get_cached_value('Company', self.company, "abbr") if not self.warehouse_name.endswith(suffix): self.name = self.warehouse_name + suffix - else: - self.name = self.warehouse_name + return + + self.name = self.warehouse_name def onload(self): '''load account name for General Ledger Report''' From 836bfc603ae02334c9579932350041f7605064a1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 10:16:06 +0530 Subject: [PATCH 5/9] fix(stock_ledger): round off values near to zero (#30803) (cherry picked from commit 6a014d12c1594cfccb4c2713cba7f5936010e2cb) Co-authored-by: Ankush Menat --- erpnext/stock/stock_ledger.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 4fa080a2fd2..db2e37aaec8 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -368,7 +368,7 @@ class update_entries_after(object): batch = self.stock_queue[index] if qty_to_pop >= batch[0]: # consume current batch - qty_to_pop = qty_to_pop - batch[0] + qty_to_pop = _round_off_if_near_zero(qty_to_pop - batch[0]) self.stock_queue.pop(index) if not self.stock_queue and qty_to_pop: # stock finished, qty still remains to be withdrawn @@ -382,8 +382,8 @@ class update_entries_after(object): batch[0] = batch[0] - qty_to_pop qty_to_pop = 0 - stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in self.stock_queue)) - stock_qty = sum((flt(batch[0]) for batch in self.stock_queue)) + stock_value = _round_off_if_near_zero(sum((flt(batch[0]) * flt(batch[1]) for batch in self.stock_queue))) + stock_qty = _round_off_if_near_zero(sum((flt(batch[0]) for batch in self.stock_queue))) if stock_qty: self.valuation_rate = stock_value / flt(stock_qty) @@ -549,3 +549,12 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no, frappe.throw(msg=msg, title=_("Valuation Rate Missing")) return valuation_rate + +def _round_off_if_near_zero(number, precision = 7): + """Rounds off the number to zero only if number is close to zero for decimal + specified in precision. Precision defaults to 7. + """ + if abs(0.0 - flt(number)) < (1.0 / (10**precision)): + return 0.0 + + return flt(number) From 432210d13d9fc0386cf3854530c2d44f2614d9fd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 14:26:38 +0530 Subject: [PATCH 6/9] fix(india): minor e-invoicing fixes (backport #30553) (#31067) --- .../print_format/gst_e_invoice/gst_e_invoice.html | 11 +++++++++-- erpnext/regional/india/e_invoice/utils.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html index 66981763c12..4379795ce6d 100644 --- a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html +++ b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html @@ -1,7 +1,8 @@ {%- from "templates/print_formats/standard_macros.html" import add_header, render_field, print_value -%} -{%- set einvoice = json.loads(doc.signed_einvoice) -%}
+ {% if doc.signed_einvoice %} + {%- set einvoice = json.loads(doc.signed_einvoice) -%}
{% if letter_head and not no_letterhead %}
{{ letter_head }}
@@ -163,4 +164,10 @@
-
\ No newline at end of file + {% else %} +
+ You must generate IRN before you can preview GST E-Invoice. +
+ {% endif %} + + diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index d5d4a526383..7892a5003a8 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -306,7 +306,7 @@ def update_other_charges(tax_row, invoice_value_details, gst_accounts_list, invo def get_payment_details(invoice): payee_name = invoice.company - mode_of_payment = ', '.join([d.mode_of_payment for d in invoice.payments]) + mode_of_payment = "" paid_amount = invoice.base_paid_amount outstanding_amount = invoice.outstanding_amount From 1c25d7c6f2934cf2d59aff232825047314b4b2ad Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 14:28:40 +0530 Subject: [PATCH 7/9] fix(india): error while parsing e-invoice (backport #31053) (#31224) --- erpnext/regional/india/e_invoice/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 7892a5003a8..9605d1d67b5 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -457,6 +457,8 @@ def make_einvoice(invoice): try: einvoice = safe_json_load(einvoice) einvoice = santize_einvoice_fields(einvoice) + except json.JSONDecodeError: + raise except Exception: show_link_to_error_log(invoice, einvoice) @@ -536,7 +538,14 @@ def safe_json_load(json_string): pos = e.pos start, end = max(0, pos-20), min(len(json_string)-1, pos+20) snippet = json_string[start:end] - frappe.throw(_("Error in input data. Please check for any special characters near following input:
{}").format(snippet)) + frappe.throw( + _( + "Error in input data. Please check for any special characters near following input:
{}" + ).format(snippet), + title=_("Invalid JSON"), + exc=e, + ) + def throw_error_list(errors, title): if len(errors) > 1: From 73484ef1bc06221dc8d8ad66272ef28683a83c73 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 8 Jun 2022 12:55:16 +0530 Subject: [PATCH 8/9] fix(india): e-invoice eligibility if company gstin is not configured (#31276) --- erpnext/regional/india/e_invoice/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 9605d1d67b5..34b52e1d7ae 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -36,6 +36,7 @@ def validate_eligibility(doc): return False invalid_company = not frappe.db.get_value('E Invoice User', { 'company': doc.get('company') }) + invalid_company_gstin = not frappe.db.get_value('E Invoice User', {'gstin': doc.get('company_gstin')}) invalid_supply_type = doc.get('gst_category') not in ['Registered Regular', 'SEZ', 'Overseas', 'Deemed Export'] company_transaction = doc.get('billing_address_gstin') == doc.get('company_gstin') @@ -44,7 +45,7 @@ def validate_eligibility(doc): no_taxes_applied = not doc.get('taxes') and not doc.get('gst_category') == 'Overseas' has_non_gst_item = any(d for d in doc.get('items', []) if d.get('is_non_gst')) - if invalid_company or invalid_supply_type or company_transaction or no_taxes_applied or has_non_gst_item: + if invalid_company or invalid_company_gstin or invalid_supply_type or company_transaction or no_taxes_applied or has_non_gst_item: return False return True From 74748c03e2913aa7f93579bb65cceb9fe0bbd94b Mon Sep 17 00:00:00 2001 From: RJPvT <48353029+RJPvT@users.noreply.github.com> Date: Wed, 8 Jun 2022 10:55:15 +0200 Subject: [PATCH 9/9] fix: locale Currency and Float setting in update_employee In fieldtypes locale settings (example NL) . and , changes whereby the field is inproperly filled --- erpnext/hr/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index d87e3569f44..9636439c5b0 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -138,6 +138,8 @@ def update_employee(employee, details, date=None, cancel=False): new_data = getdate(new_data) elif fieldtype =="Datetime" and new_data: new_data = get_datetime(new_data) + elif fieldtype in ["Currency", "Float"] and new_data: + new_data = flt(new_data) setattr(employee, item.fieldname, new_data) if item.fieldname in ["department", "designation", "branch"]: internal_work_history[item.fieldname] = item.new