mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 22:49:19 +00:00
[minor] repost future gl entries only for current voucher items
This commit is contained in:
@@ -117,9 +117,6 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
"warehouse"))
|
||||
|
||||
self.assertEqual(webnotes.conn.get_value("Serial No", pr.doclist[1].serial_no,
|
||||
"status"), "Not Available")
|
||||
|
||||
def get_gl_entries(voucher_type, voucher_no):
|
||||
return webnotes.conn.sql("""select account, debit, credit
|
||||
|
||||
@@ -52,9 +52,7 @@ class DocType(StockController):
|
||||
webnotes.throw(_("Item Code cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
|
||||
if not self.via_stock_ledger and warehouse != self.doc.warehouse:
|
||||
webnotes.throw(_("Warehouse cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
|
||||
|
||||
if not self.doc.warehouse and self.doc.status=="Available":
|
||||
self.doc.status = "Not Available"
|
||||
|
||||
|
||||
def validate_item(self):
|
||||
"""
|
||||
@@ -94,4 +92,4 @@ class DocType(StockController):
|
||||
serial_nos = map(lambda i: i==old and new or i, item[1].split('\n'))
|
||||
webnotes.conn.sql("""update `tab%s` set serial_no = %s
|
||||
where name=%s""" % (dt[0], '%s', '%s'),
|
||||
('\n'.join(serial_nos), item[0]))
|
||||
('\n'.join(serial_nos), item[0]))
|
||||
|
||||
@@ -316,7 +316,7 @@ class DocType(StockController):
|
||||
def update_stock_ledger(self):
|
||||
sl_entries = []
|
||||
for d in getlist(self.doclist, 'mtn_details'):
|
||||
if cstr(d.s_warehouse):
|
||||
if cstr(d.s_warehouse) and self.doc.docstatus == 1:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"warehouse": cstr(d.s_warehouse),
|
||||
"actual_qty": -flt(d.transfer_qty),
|
||||
@@ -329,6 +329,16 @@ class DocType(StockController):
|
||||
"actual_qty": flt(d.transfer_qty),
|
||||
"incoming_rate": flt(d.incoming_rate)
|
||||
}))
|
||||
|
||||
# On cancellation, make stock ledger entry for
|
||||
# target warehouse first, to update serial no values properly
|
||||
|
||||
if cstr(d.s_warehouse) and self.doc.docstatus == 2:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"warehouse": cstr(d.s_warehouse),
|
||||
"actual_qty": -flt(d.transfer_qty),
|
||||
"incoming_rate": 0
|
||||
}))
|
||||
|
||||
self.make_sl_entries(sl_entries, self.doc.amended_from and 'Yes' or 'No')
|
||||
|
||||
|
||||
@@ -700,6 +700,9 @@ class TestStockEntry(unittest.TestCase):
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", "ABCD"))
|
||||
self.assertTrue(webnotes.conn.exists("Serial No", "EFGH"))
|
||||
|
||||
se.cancel()
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", "ABCD", "warehouse"))
|
||||
|
||||
def test_serial_no_not_exists(self):
|
||||
self._clear_stock_account_balance()
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
@@ -755,6 +758,9 @@ class TestStockEntry(unittest.TestCase):
|
||||
se.insert()
|
||||
se.submit()
|
||||
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse 1 - _TC")
|
||||
|
||||
se.cancel()
|
||||
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse - _TC")
|
||||
|
||||
def test_serial_warehouse_error(self):
|
||||
self._clear_stock_account_balance()
|
||||
@@ -778,7 +784,6 @@ class TestStockEntry(unittest.TestCase):
|
||||
|
||||
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_no, "warehouse"))
|
||||
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "status"), "Not Available")
|
||||
|
||||
def make_serialized_item():
|
||||
se = webnotes.bean(copy=test_records[0])
|
||||
|
||||
@@ -124,13 +124,14 @@ class DocType(DocListController):
|
||||
|
||||
if self.doc.actual_qty < 0:
|
||||
if sr.doc.warehouse!=self.doc.warehouse:
|
||||
webnotes.throw(_("Warehouse does not belong to Item") + \
|
||||
(": %s (%s)" % (self.doc.item_code, serial_no)), SerialNoWarehouseError)
|
||||
webnotes.throw(_("Serial No") + ": " + serial_no +
|
||||
_(" does not belong to Warehouse") + ": " + self.doc.warehouse,
|
||||
SerialNoWarehouseError)
|
||||
|
||||
if self.doc.voucher_type in ("Delivery Note", "Sales Invoice") \
|
||||
and sr.doc.status != "Available":
|
||||
webnotes.throw(_("Serial No status must be 'Available' to Deliver") + \
|
||||
": " + serial_no, SerialNoStatusError)
|
||||
webnotes.throw(_("Serial No status must be 'Available' to Deliver")
|
||||
+ ": " + serial_no, SerialNoStatusError)
|
||||
|
||||
|
||||
sr.doc.warehouse = None
|
||||
|
||||
Reference in New Issue
Block a user