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.total_quantity, 2)
self.assertEqual(pcv_doc.net_total, 6700) 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): def test_cancelling_of_pos_closing_entry(self):
test_user, pos_profile = init_user_and_profile() test_user, pos_profile = init_user_and_profile()
opening_entry = create_opening_entry(pos_profile, test_user.name) opening_entry = create_opening_entry(pos_profile, test_user.name)

View File

@ -986,10 +986,7 @@ def create_pos_invoice(**args):
msg = f"Serial No {args.serial_no} not available for Item {args.item}" msg = f"Serial No {args.serial_no} not available for Item {args.item}"
frappe.throw(_(msg)) frappe.throw(_(msg))
pos_inv.append( pos_invoice_item = {
"items",
{
"item_code": args.item or args.item_code or "_Test Item",
"warehouse": args.warehouse or "_Test Warehouse - _TC", "warehouse": args.warehouse or "_Test Warehouse - _TC",
"qty": args.qty or 1, "qty": args.qty or 1,
"rate": args.rate if args.get("rate") is not None else 100, "rate": args.rate if args.get("rate") is not None else 100,
@ -997,6 +994,24 @@ def create_pos_invoice(**args):
"expense_account": args.expense_account or "Cost of Goods Sold - _TC", "expense_account": args.expense_account or "Cost of Goods Sold - _TC",
"cost_center": args.cost_center or "_Test Cost Center - _TC", "cost_center": args.cost_center or "_Test Cost Center - _TC",
"serial_and_batch_bundle": bundle_id, "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",
}, },
) )

View File

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

View File

@ -113,7 +113,6 @@ class SalesInvoice(SellingController):
if cint(self.update_stock): if cint(self.update_stock):
self.validate_dropship_item() self.validate_dropship_item()
self.validate_item_code()
self.validate_warehouse() self.validate_warehouse()
self.update_current_stock() self.update_current_stock()
self.validate_delivery_note() 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")) 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): def validate_warehouse(self):
super(SalesInvoice, self).validate_warehouse() super(SalesInvoice, self).validate_warehouse()