[patch] delete gl entries for cancelled vouchers
This commit is contained in:
parent
cf8ae7c3d9
commit
145e5e26fa
@ -12,18 +12,17 @@ from accounts.general_ledger import make_gl_entries, delete_gl_entries
|
|||||||
|
|
||||||
class StockController(AccountsController):
|
class StockController(AccountsController):
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
|
if self.doc.docstatus == 2:
|
||||||
return
|
|
||||||
|
|
||||||
warehouse_account = self.get_warehouse_account()
|
|
||||||
|
|
||||||
if self.doc.docstatus==1:
|
|
||||||
gl_entries = self.get_gl_entries_for_stock(warehouse_account)
|
|
||||||
make_gl_entries(gl_entries)
|
|
||||||
else:
|
|
||||||
delete_gl_entries(voucher_type=self.doc.doctype, voucher_no=self.doc.name)
|
delete_gl_entries(voucher_type=self.doc.doctype, voucher_no=self.doc.name)
|
||||||
|
|
||||||
|
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
|
||||||
|
warehouse_account = self.get_warehouse_account()
|
||||||
|
|
||||||
self.update_gl_entries_after(warehouse_account)
|
if self.doc.docstatus==1:
|
||||||
|
gl_entries = self.get_gl_entries_for_stock(warehouse_account)
|
||||||
|
make_gl_entries(gl_entries)
|
||||||
|
|
||||||
|
self.update_gl_entries_after(warehouse_account)
|
||||||
|
|
||||||
def get_gl_entries_for_stock(self, warehouse_account=None, default_expense_account=None,
|
def get_gl_entries_for_stock(self, warehouse_account=None, default_expense_account=None,
|
||||||
default_cost_center=None):
|
default_cost_center=None):
|
||||||
@ -96,7 +95,6 @@ class StockController(AccountsController):
|
|||||||
return warehouse_account
|
return warehouse_account
|
||||||
|
|
||||||
def update_gl_entries_after(self, warehouse_account=None):
|
def update_gl_entries_after(self, warehouse_account=None):
|
||||||
from accounts.utils import get_stock_and_account_difference
|
|
||||||
future_stock_vouchers = self.get_future_stock_vouchers()
|
future_stock_vouchers = self.get_future_stock_vouchers()
|
||||||
gle = self.get_voucherwise_gl_entries(future_stock_vouchers)
|
gle = self.get_voucherwise_gl_entries(future_stock_vouchers)
|
||||||
if not warehouse_account:
|
if not warehouse_account:
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
entries = webnotes.conn.sql("""select voucher_type, voucher_no
|
||||||
|
from `tabGL Entry` group by voucher_type, voucher_no""", as_dict=1)
|
||||||
|
for entry in entries:
|
||||||
|
try:
|
||||||
|
cancelled_voucher = webnotes.conn.sql("""select name from `tab%s` where name = %s
|
||||||
|
and docstatus=2""" % (entry['voucher_type'], "%s"), entry['voucher_no'])
|
||||||
|
if cancelled_voucher:
|
||||||
|
print entry
|
||||||
|
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type = %s and
|
||||||
|
voucher_no = %s""", (entry['voucher_type'], entry['voucher_no']))
|
||||||
|
except:
|
||||||
|
pass
|
@ -226,4 +226,5 @@ patch_list = [
|
|||||||
"execute:webnotes.delete_doc('Report', 'Item-wise Price List')",
|
"execute:webnotes.delete_doc('Report', 'Item-wise Price List')",
|
||||||
"patches.october_2013.p03_remove_sales_and_purchase_return_tool",
|
"patches.october_2013.p03_remove_sales_and_purchase_return_tool",
|
||||||
"patches.october_2013.p04_update_report_permission",
|
"patches.october_2013.p04_update_report_permission",
|
||||||
|
"patches.october_2013.p05_delete_gl_entries_for_cancelled_vouchers",
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user