Merge pull request #36238 from RitvikSardana/develop-ritvik-pos-dark

fix: POS closing with item name
This commit is contained in:
Deepesh Garg 2023-07-26 15:33:44 +05:30 committed by GitHub
commit f368894d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 20 deletions

View File

@ -49,6 +49,24 @@ class TestPOSClosingEntry(unittest.TestCase):
self.assertEqual(pcv_doc.total_quantity, 2)
self.assertEqual(pcv_doc.net_total, 6700)
def test_pos_closing_without_item_code(self):
"""
Test if POS Closing Entry is created without item code
"""
test_user, pos_profile = init_user_and_profile()
opening_entry = create_opening_entry(pos_profile, test_user.name)
pos_inv = create_pos_invoice(
rate=3500, do_not_submit=1, item_name="Test Item", without_item_code=1
)
pos_inv.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 3500})
pos_inv.submit()
pcv_doc = make_closing_entry_from_opening(opening_entry)
pcv_doc.submit()
self.assertTrue(pcv_doc.name)
def test_cancelling_of_pos_closing_entry(self):
test_user, pos_profile = init_user_and_profile()
opening_entry = create_opening_entry(pos_profile, test_user.name)

View File

@ -986,19 +986,34 @@ def create_pos_invoice(**args):
msg = f"Serial No {args.serial_no} not available for Item {args.item}"
frappe.throw(_(msg))
pos_inv.append(
"items",
{
"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,
},
)
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",
},
)
else:
pos_inv.append(
"items",
{
**pos_invoice_item,
"item_code": args.item or args.item_code or "_Test Item",
},
)
if not args.do_not_save:
pos_inv.insert()

View File

@ -776,7 +776,6 @@ frappe.ui.form.on('Sales Invoice', {
update_stock: function(frm, dt, dn) {
frm.events.hide_fields(frm);
frm.fields_dict.items.grid.toggle_reqd("item_code", frm.doc.update_stock);
frm.trigger('reset_posting_time');
},

View File

@ -113,7 +113,6 @@ class SalesInvoice(SellingController):
if cint(self.update_stock):
self.validate_dropship_item()
self.validate_item_code()
self.validate_warehouse()
self.update_current_stock()
self.validate_delivery_note()
@ -854,11 +853,6 @@ class SalesInvoice(SellingController):
):
frappe.throw(_("Paid amount + Write Off Amount can not be greater than Grand Total"))
def validate_item_code(self):
for d in self.get("items"):
if not d.item_code and self.is_opening == "No":
msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True)
def validate_warehouse(self):
super(SalesInvoice, self).validate_warehouse()