From 8b4228d61635d43fcab182870e32d9028991b07f Mon Sep 17 00:00:00 2001 From: Ritvik Sardana Date: Mon, 24 Jul 2023 13:59:24 +0530 Subject: [PATCH] fix: removed duplicate code --- .../doctype/pos_invoice/test_pos_invoice.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index fa59003231..00c402f97b 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -986,19 +986,23 @@ def create_pos_invoice(**args): msg = f"Serial No {args.serial_no} not available for Item {args.item}" frappe.throw(_(msg)) + pos_invoice_item = { + "warehouse": args.warehouse or "_Test Warehouse - _TC", + "qty": args.qty or 1, + "rate": args.rate if args.get("rate") is not None else 100, + "income_account": args.income_account or "Sales - _TC", + "expense_account": args.expense_account or "Cost of Goods Sold - _TC", + "cost_center": args.cost_center or "_Test Cost Center - _TC", + "serial_and_batch_bundle": bundle_id, + } # append in pos invoice items without item_code by checking flag without_item_code if args.without_item_code: pos_inv.append( "items", { + **pos_invoice_item, "item_name": args.item_name or "_Test Item", "description": args.item_name or "_Test Item", - "warehouse": args.warehouse or "_Test Warehouse - _TC", - "qty": args.qty or 1, - "rate": args.rate if args.get("rate") is not None else 100, - "income_account": args.income_account or "Sales - _TC", - "expense_account": args.expense_account or "Cost of Goods Sold - _TC", - "cost_center": args.cost_center or "_Test Cost Center - _TC", }, ) @@ -1006,14 +1010,8 @@ def create_pos_invoice(**args): pos_inv.append( "items", { + **pos_invoice_item, "item_code": args.item or args.item_code or "_Test Item", - "warehouse": args.warehouse or "_Test Warehouse - _TC", - "qty": args.qty or 1, - "rate": args.rate if args.get("rate") is not None else 100, - "income_account": args.income_account or "Sales - _TC", - "expense_account": args.expense_account or "Cost of Goods Sold - _TC", - "cost_center": args.cost_center or "_Test Cost Center - _TC", - "serial_and_batch_bundle": bundle_id, }, )