[fix] missing gl entries warnings
This commit is contained in:
parent
d97200cb5a
commit
6465711ca6
@ -276,12 +276,18 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for
|
|||||||
def compare_existing_and_expected_gle(existing_gle, expected_gle):
|
def compare_existing_and_expected_gle(existing_gle, expected_gle):
|
||||||
matched = True
|
matched = True
|
||||||
for entry in expected_gle:
|
for entry in expected_gle:
|
||||||
|
account_existed = False
|
||||||
for e in existing_gle:
|
for e in existing_gle:
|
||||||
if entry.account==e.account and entry.against_account==e.against_account \
|
if entry.account == e.account:
|
||||||
and (not entry.cost_center or not e.cost_center or entry.cost_center==e.cost_center) \
|
account_existed = True
|
||||||
|
if entry.account == e.account and entry.against_account == e.against_account \
|
||||||
|
and (not entry.cost_center or not e.cost_center or entry.cost_center == e.cost_center) \
|
||||||
and (entry.debit != e.debit or entry.credit != e.credit):
|
and (entry.debit != e.debit or entry.credit != e.credit):
|
||||||
matched = False
|
matched = False
|
||||||
break
|
break
|
||||||
|
if not account_existed:
|
||||||
|
matched = False
|
||||||
|
break
|
||||||
return matched
|
return matched
|
||||||
|
|
||||||
def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, for_items=None):
|
def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, for_items=None):
|
||||||
|
@ -36,6 +36,7 @@ class StockEntry(StockController):
|
|||||||
self.pro_doc = frappe.get_doc('Production Order', self.production_order)
|
self.pro_doc = frappe.get_doc('Production Order', self.production_order)
|
||||||
|
|
||||||
self.validate_posting_time()
|
self.validate_posting_time()
|
||||||
|
self.validate_posting_date()
|
||||||
self.validate_purpose()
|
self.validate_purpose()
|
||||||
self.validate_item()
|
self.validate_item()
|
||||||
self.set_transfer_qty()
|
self.set_transfer_qty()
|
||||||
@ -65,6 +66,38 @@ class StockEntry(StockController):
|
|||||||
self.update_production_order()
|
self.update_production_order()
|
||||||
self.make_gl_entries_on_cancel()
|
self.make_gl_entries_on_cancel()
|
||||||
|
|
||||||
|
def validate_posting_date(self):
|
||||||
|
allow_negative_stock = cint(frappe.db.get_value("Stock Settings", None, "allow_negative_stock"))
|
||||||
|
items, warehouses = self.get_items_and_warehouses()
|
||||||
|
previous_stock_vouchers = self.get_previous_stock_vouchers(self.posting_date, self.posting_time, warehouses,
|
||||||
|
items)
|
||||||
|
|
||||||
|
if allow_negative_stock and previous_stock_vouchers:
|
||||||
|
for voucher_type, voucher_no in previous_stock_vouchers:
|
||||||
|
frappe.msgprint(
|
||||||
|
_("The posting date is after {0}: {1}, this will cause missing data in the General Ledger").format(
|
||||||
|
voucher_type, voucher_no))
|
||||||
|
|
||||||
|
def get_previous_stock_vouchers(self, posting_date, posting_time, for_warehouses=None, for_items=None):
|
||||||
|
previous_stock_vouchers = []
|
||||||
|
|
||||||
|
values = []
|
||||||
|
condition = ""
|
||||||
|
|
||||||
|
if for_items:
|
||||||
|
condition += " and item_code in ({})".format(", ".join(["%s"] * len(for_items)))
|
||||||
|
values += for_items
|
||||||
|
|
||||||
|
for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
|
||||||
|
from `tabStock Ledger Entry` sle
|
||||||
|
where timestamp(sle.posting_date, sle.posting_time) <= timestamp(%s, %s) {condition}
|
||||||
|
and warehouse = "Finished Goods - IAG"
|
||||||
|
order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""".format(condition=condition),
|
||||||
|
tuple([posting_date, posting_time] + values), as_dict=True):
|
||||||
|
previous_stock_vouchers.append([d.voucher_type, d.voucher_no])
|
||||||
|
|
||||||
|
return previous_stock_vouchers
|
||||||
|
|
||||||
def validate_purpose(self):
|
def validate_purpose(self):
|
||||||
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture",
|
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture",
|
||||||
"Manufacture", "Repack", "Subcontract"]
|
"Manufacture", "Repack", "Subcontract"]
|
||||||
|
Loading…
Reference in New Issue
Block a user