diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 866a94d04b1..46e2c50e40b 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -169,21 +169,18 @@ class PeriodClosingVoucher(AccountsController): return frappe.db.sql( """ select - t2.account_currency, + t1.account_currency, {dimension_fields}, sum(t1.debit_in_account_currency) - sum(t1.credit_in_account_currency) as bal_in_account_currency, sum(t1.debit) - sum(t1.credit) as bal_in_company_currency - from `tabGL Entry` t1, `tabAccount` t2 + from `tabGL Entry` t1 where t1.is_cancelled = 0 - and t1.account = t2.name - and t2.report_type = 'Profit and Loss' - and t2.docstatus < 2 - and t2.company = %s + and t1.account in (select name from `tabAccount` where report_type = 'Profit and Loss' and docstatus < 2 and company = %s) and t1.posting_date between %s and %s group by {dimension_fields} """.format( - dimension_fields=", ".join(dimension_fields) + dimension_fields=", ".join(dimension_fields), ), (self.company, self.get("year_start_date"), self.posting_date), as_dict=1, diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 38a66e470cf..d6de519d232 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -432,7 +432,7 @@ class Asset(AccountsController): ) skip_row = True - if depreciation_amount > 0: + if flt(depreciation_amount, self.precision("gross_purchase_amount")) > 0: self.append( "schedules", { @@ -1281,9 +1281,11 @@ def get_straight_line_or_manual_depr_amount(asset, row): ) # if the Depreciation Schedule is being prepared for the first time else: - return (flt(asset.gross_purchase_amount) - flt(row.expected_value_after_useful_life)) / flt( - row.total_number_of_depreciations - ) + return ( + flt(asset.gross_purchase_amount) + - flt(asset.opening_accumulated_depreciation) + - flt(row.expected_value_after_useful_life) + ) / flt(row.total_number_of_depreciations - asset.number_of_depreciations_booked) def get_wdv_or_dd_depr_amount( diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 0cf4d5b603a..55154385947 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -569,7 +569,7 @@ class TestDepreciationMethods(AssetSetup): ) self.assertEqual(asset.status, "Draft") - expected_schedules = [["2032-12-31", 30000.0, 77095.89], ["2033-06-06", 12904.11, 90000.0]] + expected_schedules = [["2032-12-31", 42904.11, 90000.0]] schedules = [ [cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount] for d in asset.get("schedules") diff --git a/erpnext/hr/doctype/leave_policy_assignment/leave_policy_assignment.py b/erpnext/hr/doctype/leave_policy_assignment/leave_policy_assignment.py index bb19ffa9d1e..2330541813e 100644 --- a/erpnext/hr/doctype/leave_policy_assignment/leave_policy_assignment.py +++ b/erpnext/hr/doctype/leave_policy_assignment/leave_policy_assignment.py @@ -192,9 +192,9 @@ def add_current_month_if_applicable(months_passed, date_of_joining, based_on_doj date = getdate(frappe.flags.current_date) or getdate() if based_on_doj: - # if leave type allocation is based on DOJ, and the date of assignment creation is same as DOJ, + # if leave type allocation is based on DOJ, and the date of assignment creation is after DOJ, # then the month should be considered - if date.day == date_of_joining.day: + if date.day >= date_of_joining.day: months_passed += 1 else: last_day_of_month = get_last_day(date) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index ae0b26222ee..0c2e52cfbb2 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -48,7 +48,8 @@ frappe.ui.form.on("BOM", { return { query: "erpnext.manufacturing.doctype.bom.bom.item_query", filters: { - "item_code": doc.item + "include_item_in_manufacturing": 1, + "is_fixed_asset": 0 } }; }); diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 9ae9b1a4af2..1a56116718d 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -1346,8 +1346,9 @@ def item_query(doctype, txt, searchfield, start, page_len, filters): if not has_variants: query_filters["has_variants"] = 0 - if filters and filters.get("is_stock_item"): - query_filters["is_stock_item"] = 1 + if filters: + for fieldname, value in filters.items(): + query_filters[fieldname] = value return frappe.get_list( "Item", diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 16280fc8106..6425769cf38 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -605,6 +605,45 @@ class TestBOM(FrappeTestCase): bom.update_cost() self.assertFalse(bom.flags.cost_updated) + def test_do_not_include_manufacturing_and_fixed_items(self): + from erpnext.manufacturing.doctype.bom.bom import item_query + + if not frappe.db.exists("Asset Category", "Computers-Test"): + doc = frappe.get_doc({"doctype": "Asset Category", "asset_category_name": "Computers-Test"}) + doc.flags.ignore_mandatory = True + doc.insert() + + for item_code, properties in { + "_Test RM Item 1 Do Not Include In Manufacture": { + "is_stock_item": 1, + "include_item_in_manufacturing": 0, + }, + "_Test RM Item 2 Fixed Asset Item": { + "is_fixed_asset": 1, + "is_stock_item": 0, + "asset_category": "Computers-Test", + }, + "_Test RM Item 3 Manufacture Item": {"is_stock_item": 1, "include_item_in_manufacturing": 1}, + }.items(): + make_item(item_code, properties) + + data = item_query( + "Item", + txt="_Test RM Item", + searchfield="name", + start=0, + page_len=20000, + filters={"include_item_in_manufacturing": 1, "is_fixed_asset": 0}, + ) + + items = [] + for row in data: + items.append(row[0]) + + self.assertTrue("_Test RM Item 1 Do Not Include In Manufacture" not in items) + self.assertTrue("_Test RM Item 2 Fixed Asset Item" not in items) + self.assertTrue("_Test RM Item 3 Manufacture Item" in items) + def get_default_bom(item_code="_Test FG Item 2"): return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1}) diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json index dd5bb89bee3..43dc5c0b7be 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.json +++ b/erpnext/manufacturing/doctype/job_card/job_card.json @@ -420,7 +420,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2021-11-12 10:15:06.572401", + "modified": "2023-05-22 23:26:57.589331", "modified_by": "Administrator", "module": "Manufacturing", "name": "Job Card", diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index 092ad1ffe83..f9ffc3529dc 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -657,7 +657,7 @@ class JobCard(Document): self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0] if self.docstatus < 2: - if self.for_quantity <= self.transferred_qty: + if flt(self.for_quantity) <= flt(self.transferred_qty): self.status = "Material Transferred" if self.time_logs: diff --git a/erpnext/patches/v13_0/update_amt_in_work_order_required_items.py b/erpnext/patches/v13_0/update_amt_in_work_order_required_items.py index e37f291233e..64170edb718 100644 --- a/erpnext/patches/v13_0/update_amt_in_work_order_required_items.py +++ b/erpnext/patches/v13_0/update_amt_in_work_order_required_items.py @@ -7,4 +7,6 @@ def execute(): frappe.reload_doc("manufacturing", "doctype", "work_order") frappe.reload_doc("manufacturing", "doctype", "work_order_item") - frappe.db.sql("""UPDATE `tabWork Order Item` SET amount = rate * required_qty""") + frappe.db.sql( + """UPDATE `tabWork Order Item` SET amount = ifnull(rate, 0.0) * ifnull(required_qty, 0.0)""" + ) diff --git a/erpnext/payroll/report/salary_register/salary_register.py b/erpnext/payroll/report/salary_register/salary_register.py index 94369e4a468..8ee971e8d38 100644 --- a/erpnext/payroll/report/salary_register/salary_register.py +++ b/erpnext/payroll/report/salary_register/salary_register.py @@ -183,13 +183,6 @@ def get_columns(earning_types, ded_types): "fieldtype": "Float", "width": 120, }, - { - "label": _("Currency"), - "fieldname": "currency", - "fieldtype": "Link", - "options": "Currency", - "hidden": 1, - }, ] for earning in earning_types: @@ -247,6 +240,13 @@ def get_columns(earning_types, ded_types): "options": "currency", "width": 120, }, + { + "label": _("Currency"), + "fieldname": "currency", + "fieldtype": "Data", + "options": "Currency", + "hidden": 1, + }, ] ) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 483c79bbdbb..af2a4460eee 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -656,11 +656,15 @@ def get_credit_limit(customer, company): if not credit_limit: customer_group = frappe.get_cached_value("Customer", customer, "customer_group") - credit_limit = frappe.db.get_value( + + result = frappe.db.get_values( "Customer Credit Limit", {"parent": customer_group, "parenttype": "Customer Group", "company": company}, - "credit_limit", + fieldname=["credit_limit", "bypass_credit_limit_check"], + as_dict=True, ) + if result and not result[0].bypass_credit_limit_check: + credit_limit = result[0].credit_limit if not credit_limit: credit_limit = frappe.get_cached_value("Company", company, "credit_limit") diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index dd88b6c498f..3d7c33401ac 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -235,7 +235,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } } // payment request - if(flt(doc.per_billed)<100) { + if(flt(doc.per_billed, precision('per_billed', doc)) < 100 + frappe.boot.sysdefaults.over_billing_allowance) { this.frm.add_custom_button(__('Payment Request'), () => this.make_payment_request(), __('Create')); this.frm.add_custom_button(__('Payment'), () => this.make_payment_entry(), __('Create')); } diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 9790d995477..1949fa7e8fe 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -22,6 +22,10 @@ def boot_session(bootinfo): bootinfo.sysdefaults.allow_stale = cint( frappe.db.get_single_value("Accounts Settings", "allow_stale") ) + bootinfo.sysdefaults.over_billing_allowance = frappe.db.get_single_value( + "Accounts Settings", "over_billing_allowance" + ) + bootinfo.sysdefaults.quotation_valid_till = cint( frappe.db.get_single_value("Selling Settings", "default_valid_till") ) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index effba8e579b..e88b132e02b 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -292,7 +292,7 @@ def get_items_with_location_and_quantity(item_doc, item_location_map, docstatus) item_doc.qty if (docstatus == 1 and item_doc.stock_qty == 0) else item_doc.stock_qty ) - while remaining_stock_qty > 0 and available_locations: + while flt(remaining_stock_qty) > 0 and available_locations: item_location = available_locations.pop(0) item_location = frappe._dict(item_location)