fix: reposting patch fixes (#24775)

This commit is contained in:
Nabin Hait 2021-03-02 13:37:45 +05:30 committed by GitHub
parent f45756d821
commit bd10d7c028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -1,13 +1,24 @@
import frappe
from frappe import _
from frappe.utils import getdate, get_time
from frappe.utils import getdate, get_time, today
from erpnext.stock.stock_ledger import update_entries_after
from erpnext.accounts.utils import update_gl_entries_after
def execute():
frappe.reload_doc('stock', 'doctype', 'repost_item_valuation')
for doctype in ('repost_item_valuation', 'stock_entry_detail', 'purchase_receipt_item',
'purchase_invoice_item', 'delivery_note_item', 'sales_invoice_item', 'packed_item'):
frappe.reload_doc('stock', 'doctype', doctype)
frappe.reload_doc('buying', 'doctype', 'purchase_receipt_item_supplied')
reposting_project_deployed_on = get_creation_time()
posting_date = getdate(reposting_project_deployed_on)
posting_time = get_time(reposting_project_deployed_on)
if posting_date == today():
return
frappe.clear_cache()
frappe.flags.warehouse_account_map = {}
data = frappe.db.sql('''
SELECT
@ -41,8 +52,6 @@ def execute():
print("Reposting General Ledger Entries...")
posting_date = getdate(reposting_project_deployed_on)
posting_time = get_time(reposting_project_deployed_on)
for row in frappe.get_all('Company', filters= {'enable_perpetual_inventory': 1}):
update_gl_entries_after(posting_date, posting_time, company=row.name)

View File

@ -324,10 +324,12 @@ class PurchaseReceipt(BuyingController):
else:
loss_account = self.get_company_default("default_expense_account")
cost_center = d.cost_center or frappe.get_cached_value("Company", self.company, "cost_center")
gl_entries.append(self.get_gl_dict({
"account": loss_account,
"against": warehouse_account[d.warehouse]["account"],
"cost_center": d.cost_center,
"cost_center": cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": divisional_loss,
"project": d.project