fix: add LCV flag to determine negative expenses

(cherry picked from commit baa3fee1bf)

# Conflicts:
#	erpnext/controllers/stock_controller.py
This commit is contained in:
Gursheen Anand
2024-02-29 09:04:24 +05:30
committed by Mergify
parent f9a7bb0544
commit 20b8ee1e90
3 changed files with 45 additions and 16 deletions

View File

@@ -51,7 +51,37 @@ class StockController(AccountsController):
self.validate_internal_transfer()
self.validate_putaway_capacity()
<<<<<<< HEAD
def make_gl_entries(self, gl_entries=None, from_repost=False):
=======
def validate_duplicate_serial_and_batch_bundle(self):
if sbb_list := [
item.get("serial_and_batch_bundle")
for item in self.items
if item.get("serial_and_batch_bundle")
]:
SLE = frappe.qb.DocType("Stock Ledger Entry")
data = (
frappe.qb.from_(SLE)
.select(SLE.voucher_type, SLE.voucher_no, SLE.serial_and_batch_bundle)
.where(
(SLE.docstatus == 1)
& (SLE.serial_and_batch_bundle.notnull())
& (SLE.serial_and_batch_bundle.isin(sbb_list))
)
.limit(1)
).run(as_dict=True)
if data:
data = data[0]
frappe.throw(
_("Serial and Batch Bundle {0} is already used in {1} {2}.").format(
frappe.bold(data.serial_and_batch_bundle), data.voucher_type, data.voucher_no
)
)
def make_gl_entries(self, gl_entries=None, from_repost=False, via_landed_cost_voucher=False):
>>>>>>> baa3fee1bf (fix: add LCV flag to determine negative expenses)
if self.docstatus == 2:
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
@@ -72,7 +102,7 @@ class StockController(AccountsController):
if self.docstatus == 1:
if not gl_entries:
gl_entries = self.get_gl_entries(warehouse_account)
gl_entries = self.get_gl_entries(warehouse_account, via_landed_cost_voucher)
make_gl_entries(gl_entries, from_repost=from_repost)
def validate_serialized_batch(self):