def get_pricing_rule_discount(self): from erpnext.accounts.doctype.pricing_rule.utils import get_pricing_rules, filter_pricing_rules from erpnext.stock.get_item_details import process_args parent_dict = {} for fieldname in self.meta.get_valid_columns(): parent_dict[fieldname] = self.get(fieldname) parent_dict.update({"document_type": "Sales Order Item"}) for item in self.get("items"): if not item.original_discount: if item.get("item_code"): args = parent_dict.copy() args.update(item.as_dict()) args["doctype"] = self.doctype args["name"] = self.name if not args.get("transaction_date"): args["transaction_date"] = args.get("posting_date") if self.get("is_subcontracted"): args["is_subcontracted"] = self.is_subcontracted args = process_args(args) pricing_rules = get_pricing_rules(args) pricing_rule = filter_pricing_rules(args, pricing_rules) if pricing_rule: item.original_discount = pricing_rule.discount_percentage
def get_serial_no(args): if isinstance(args, basestring): args = json.loads(args) args = frappe._dict(args) if args.get('warehouse'): if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1: args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')}) args = process_args(args) serial_no = get_serial_nos_by_fifo(args) return serial_no
def get_serial_no(args): if isinstance(args, basestring): args = json.loads(args) args = frappe._dict(args) if args.get('warehouse'): if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1: args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')}) args = process_args(args) serial_no = get_serial_nos_by_fifo(args) return serial_no
def test_price_in_a_qty(self): # Check correct price at this quantity doc = frappe.copy_doc(test_records[2]) args = { "price_list": doc.price_list, "customer": doc.customer, "uom": "_Test UOM", "transaction_date": '2017-04-18', "qty": 10 } price = get_price_list_rate_for(process_args(args), doc.item_code) self.assertEqual(price, 20.0)
def test_price_in_a_qty(self): # Check correct price at this quantity doc = frappe.copy_doc(test_records[2]) args = { "price_list": doc.price_list, "min_qty": doc.min_qty, "customer": doc.customer, "uom": "_Test UOM", "transaction_date": '2017-04-18', "qty": 10 } price = get_price_list_rate_for(process_args(args), doc.item_code) self.assertEqual(price, 20.0)
def get_item_details(args): args = process_args(args) print(args) item = frappe.get_cached_doc("Item", args.item_code) _validate_item_details(args, item) return _get_basic_details(args, item)