erpnext icon indicating copy to clipboard operation
erpnext copied to clipboard

POS: Unable to add item with price rule.

Open dj12djdjs opened this issue 2 years ago • 1 comments

Information about bug

Encountered while investigating: https://github.com/frappe/erpnext/issues/33277

Pricing Rule Document

{"name":"PRLE-0001","owner":"[email protected]","creation":"2022-12-13 23:22:17.989466","modified":"2022-12-13 23:22:17.989466","modified_by":"[email protected]","docstatus":0,"idx":0,"naming_series":"PRLE-.####","title":"test","disable":0,"apply_on":"Item Code","price_or_product_discount":"Product","mixed_conditions":0,"is_cumulative":0,"coupon_code_based":0,"apply_rule_on_other":"Item Code","other_item_code":"Demo Item","selling":1,"buying":0,"applicable_for":"","min_qty":2,"max_qty":0,"min_amt":0,"max_amt":0,"same_item":0,"free_item":"Demo Item","free_qty":1,"free_item_rate":500,"round_free_qty":0,"is_recursive":0,"recurse_for":1,"apply_recursion_over":0,"valid_from":"2022-12-12","company":"demo company","currency":"CAD","margin_type":"Percentage","margin_rate_or_amount":0,"rate_or_discount":"Discount Percentage","apply_discount_on":"Grand Total","rate":0,"discount_amount":0,"discount_percentage":0,"threshold_percentage":0,"priority":"","apply_multiple_pricing_rules":0,"apply_discount_on_rate":0,"validate_applied_rule":0,"doctype":"Pricing Rule","item_groups":[],"brands":[],"items":[{"name":"baf589e6d1","owner":"[email protected]","creation":"2022-12-13 23:22:17.989466","modified":"2022-12-13 23:22:17.989466","modified_by":"[email protected]","docstatus":0,"idx":1,"item_code":"Demo Item","parent":"PRLE-0001","parentfield":"items","parenttype":"Pricing Rule","doctype":"Pricing Rule Item Code"}],"__last_sync_on":"2022-12-14T04:24:49.676Z"}

App Versions

{
	"erpnext": "14.0.0-dev",
	"frappe": "14.0.0-dev",
	"payments": "0.0.1"
}

Route

point-of-sale

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 56, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 53, in handle
    return _RESTAPIHandler(call, doctype, name).get_response()
  File "apps/frappe/frappe/api.py", line 69, in get_response
    return self.handle_method()
  File "apps/frappe/frappe/api.py", line 79, in handle_method
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1586, in call
    return fn(*args, **newargs)
  File "apps/erpnext/erpnext/stock/get_item_details.py", line 116, in get_item_details
    data = get_pricing_rule_for_item(args, out.price_list_rate, doc, for_validate=for_validate)
  File "apps/erpnext/erpnext/accounts/doctype/pricing_rule/pricing_rule.py", line 340, in get_pricing_rule_for_item
    else get_pricing_rules(args, doc)
  File "apps/erpnext/erpnext/accounts/doctype/pricing_rule/utils.py", line 53, in get_pricing_rules
    pricing_rule = filter_pricing_rules(args, pricing_rules, doc)
  File "apps/erpnext/erpnext/accounts/doctype/pricing_rule/utils.py", line 283, in filter_pricing_rules
    pricing_rules = get_qty_and_rate_for_other_item(doc, pr_doc, pricing_rules, args) or []
  File "apps/erpnext/erpnext/accounts/doctype/pricing_rule/utils.py", line 479, in get_qty_and_rate_for_other_item
    amount = stock_qty * (row.get("price_list_rate") or row.get("rate"))
TypeError: can't multiply sequence by non-int of type 'float'

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"POS Invoice\",\"name\":\"new-pos-invoice-4\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"[email protected]\",\"naming_series\":\"ACC-PSINV-.YYYY.-\",\"is_pos\":1,\"is_return\":0,\"update_billed_amount_in_sales_order\":0,\"company\":\"demo company\",\"posting_date\":\"2022-12-13\",\"set_posting_time\":0,\"currency\":\"CAD\",\"selling_price_list\":\"Standard Selling\",\"price_list_currency\":\"CAD\",\"ignore_pricing_rule\":0,\"update_stock\":1,\"total_billing_amount\":0,\"redeem_loyalty_points\":0,\"apply_discount_on\":\"Grand Total\",\"allocate_advances_automatically\":0,\"write_off_outstanding_amount_automatically\":0,\"group_same_items\":0,\"is_discounted\":0,\"status\":\"Draft\",\"party_account_currency\":\"CAD\",\"is_opening\":\"No\",\"items\":[{\"docstatus\":0,\"doctype\":\"POS Invoice Item\",\"name\":\"new-pos-invoice-item-7\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"[email protected]\",\"has_item_scanned\":0,\"stock_uom\":\"Nos\",\"margin_type\":\"\",\"is_free_item\":0,\"grant_commission\":0,\"delivered_by_supplier\":0,\"is_fixed_asset\":0,\"enable_deferred_revenue\":0,\"allow_zero_valuation_rate\":0,\"cost_center\":\"Main - DC\",\"page_break\":0,\"parent\":\"new-pos-invoice-4\",\"parentfield\":\"items\",\"parenttype\":\"POS Invoice\",\"idx\":1,\"item_code\":\"Demo Item\",\"rate\":\"1000\",\"qty\":1,\"weight_per_unit\":0,\"weight_uom\":\"\",\"conversion_factor\":0,\"barcode\":null,\"pricing_rules\":\"\"}],\"pos_profile\":\"test\",\"idx\":0,\"conversion_rate\":1,\"plc_conversion_rate\":1,\"set_warehouse\":\"Stores - DC\",\"total_qty\":0,\"base_total\":0,\"base_net_total\":0,\"total\":0,\"net_total\":0,\"total_net_weight\":0,\"base_total_taxes_and_charges\":0,\"total_taxes_and_charges\":0,\"loyalty_points\":0,\"loyalty_amount\":0,\"base_discount_amount\":0,\"additional_discount_percentage\":0,\"discount_amount\":0,\"base_grand_total\":0,\"base_rounding_adjustment\":0,\"base_rounded_total\":0,\"grand_total\":0,\"rounding_adjustment\":0,\"rounded_total\":0,\"total_advance\":0,\"outstanding_amount\":0,\"base_paid_amount\":0,\"paid_amount\":0,\"base_change_amount\":0,\"change_amount\":0,\"account_for_change_amount\":\"Cash - DC\",\"write_off_amount\":0,\"base_write_off_amount\":0,\"write_off_account\":\"Write Off - DC\",\"write_off_cost_center\":\"Main - DC\",\"debit_to\":\"Debtors - DC\",\"amount_eligible_for_commission\":0,\"commission_rate\":0,\"total_commission\":0,\"pricing_rules\":[],\"payments\":[{\"docstatus\":0,\"idx\":1,\"default\":1,\"mode_of_payment\":\"Cash\",\"amount\":0,\"account\":\"Cash - DC\",\"type\":\"Cash\",\"base_amount\":0,\"parent\":\"new-pos-invoice-4\",\"parentfield\":\"payments\",\"parenttype\":\"POS Invoice\",\"doctype\":\"Sales Invoice Payment\",\"__islocal\":1,\"name\":\"new-sales-invoice-payment-4\"}],\"advances\":[],\"timesheets\":[],\"packed_items\":[],\"taxes\":[],\"sales_team\":[],\"payment_schedule\":[],\"campaign\":null,\"in_words\":\"\",\"base_in_words\":\"\",\"customer\":\"Counter sale\",\"customer_name\":\"Counter sale\",\"loyalty_program\":null,\"due_date\":\"2022-12-13\",\"customer_address\":null,\"address_display\":null,\"shipping_address_name\":\"\",\"shipping_address\":null,\"company_address\":null,\"company_address_display\":null,\"contact_person\":null,\"contact_display\":null,\"contact_email\":null,\"contact_mobile\":null,\"customer_group\":\"All Customer Groups\",\"territory\":\"All Territories\",\"language\":\"en\",\"tax_category\":\"\",\"payment_terms_template\":null,\"posting_time\":\"23:22:28\"}",
		"args": "{\"item_code\":\"Demo Item\",\"barcode\":null,\"set_warehouse\":\"Stores - DC\",\"customer\":\"Counter sale\",\"currency\":\"CAD\",\"update_stock\":0,\"conversion_rate\":1,\"price_list\":\"Standard Selling\",\"price_list_currency\":\"CAD\",\"plc_conversion_rate\":1,\"company\":\"demo company\",\"is_pos\":1,\"is_return\":0,\"ignore_pricing_rule\":0,\"doctype\":\"POS Invoice\",\"name\":\"new-pos-invoice-4\",\"qty\":1,\"net_rate\":\"1000\",\"conversion_factor\":0,\"weight_per_unit\":0,\"weight_uom\":\"\",\"stock_uom\":\"Nos\",\"pos_profile\":\"test\",\"cost_center\":\"Main - DC\",\"tax_category\":\"\",\"child_docname\":\"new-pos-invoice-item-7\"}"
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/erpnext.stock.get_item_details.get_item_details"
}

Response Data

{
	"exception": "TypeError: can't multiply sequence by non-int of type 'float'"
}

Module

selling

Version

develop

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No response

dj12djdjs avatar Dec 14 '22 04:12 dj12djdjs

Check weather the two variables (stock_qty and (row.get("price_list_rate") or row.get("rate")) are int or float datatype, I think in this two variable one variable in string datatype, check it...

Gokulnath17 avatar Dec 14 '22 14:12 Gokulnath17