def make_gl_entries_stock(self, gl_entries=None, repost_future_gle=True, from_repost=False): if self.docstatus == 2: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if cint(erpnext.is_perpetual_inventory_enabled(self.company)): warehouse_account = get_warehouse_account_map() if self.docstatus == 0: if not gl_entries: gl_entries = get_gl_entries_receipt(self, warehouse_account) frappe.throw(str(gl_entries)) make_gl2_entries(gl_entries, from_repost=from_repost) if repost_future_gle: items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items, warehouse_account) elif self.doctype in ['Purchase Receipt', 'Purchase Invoice' ] and self.docstatus == 0: gl_entries = [] gl_entries = self.get_asset_gl_entry(gl_entries) frappe.msgprint(str(gl_entries)) make_gl2_entries(gl_entries, from_repost=from_repost)
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False): if not self.grand_total: return if not gl_entries: gl_entries = self.get_gl_entries() if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries # if POS and amount is written off, updating outstanding amt after posting all gl entries update_outstanding = "No" if (cint(self.is_pos) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, "Customer", self.customer, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): from erpnext.accounts.general_ledger import delete_gl_entries delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, repost_future_gle=True, allow_negative_stock=False): gl_entries = self.get_gl_entries( allow_negative_stock=allow_negative_stock) if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries update_outstanding = cint(self.is_pos) and self.write_off_account \ and 'No' or 'Yes' make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, self.doctype, self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items)
def make_gl_entries(self, repost_future_gle=True): gl_entries = self.get_gl_entries() if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries # if POS and amount is written off, there's no outstanding and hence no need to update it update_outstanding = cint(self.is_pos) and self.write_off_account \ and 'No' or 'Yes' make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, "Customer", self.customer, self.doctype, self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): from erpnext.accounts.general_ledger import delete_gl_entries delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, repost_future_gle=True): if not self.grand_total: return gl_entries = self.get_gl_entries() if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries # if POS and amount is written off, updating outstanding amt after posting all gl entries update_outstanding = "No" if (cint(self.is_pos) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, "Customer", self.customer, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): from erpnext.accounts.general_ledger import delete_gl_entries delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False): if not self.grand_total: return if not gl_entries: gl_entries = self.get_gl_entries() if gl_entries: update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": update_outstanding_amt( self.credit_to, "Supplier", self.supplier, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint( self.update_stock) and self.auto_accounting_for_stock: from erpnext.controllers.stock_controller import update_gl_entries_after items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint( self.update_stock) and self.auto_accounting_for_stock: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, repost_future_gle=True): gl_entries = self.get_gl_entries() if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries # if POS and amount is written off, there's no outstanding and hence no need to update it update_outstanding = cint(self.is_pos) and self.write_off_account \ and 'No' or 'Yes' make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, "Customer", self.customer, self.doctype, self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): from erpnext.accounts.general_ledger import delete_gl_entries delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def repost_gle_for_stock_transactions(posting_date=None, posting_time=None, for_warehouses=None): frappe.db.auto_commit_on_many_writes = 1 if not posting_date: posting_date = "1900-01-01" if not posting_time: posting_time = "00:00" update_gl_entries_after(posting_date, posting_time, for_warehouses=for_warehouses) frappe.db.auto_commit_on_many_writes = 0
def execute(): if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): return wh_account = get_warehouse_account() for pi in frappe.get_all("Purchase Invoice", filters={"docstatus": 1, "update_stock": 1}): pi_doc = frappe.get_doc("Purchase Invoice", pi.name) items, warehouses = pi_doc.get_items_and_warehouses() update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account) frappe.db.commit()
def execute(): company_list = frappe.db.sql_list("""Select name from tabCompany where enable_perpetual_inventory = 1""") frappe.reload_doc('accounts', 'doctype', 'sales_invoice') frappe.reload_doctype("Purchase Invoice") wh_account = get_warehouse_account_map() for pi in frappe.get_all("Purchase Invoice", fields=["name", "company"], filters={"docstatus": 1, "update_stock": 1}): if pi.company in company_list: pi_doc = frappe.get_doc("Purchase Invoice", pi.name) items, warehouses = pi_doc.get_items_and_warehouses() update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account) frappe.db.commit()
def execute(): company_list = frappe.db.sql_list("""Select name from tabCompany where enable_perpetual_inventory = 1""") frappe.reload_doc('accounts', 'doctype', 'sales_invoice') frappe.reload_doctype("Purchase Invoice") wh_account = get_warehouse_account_map() for pi in frappe.get_all("Purchase Invoice", fields=["name", "company"], filters={"docstatus": 1, "update_stock": 1}): if pi.company in company_list: pi_doc = frappe.get_doc("Purchase Invoice", pi.name) items, warehouses = pi_doc.get_items_and_warehouses() update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account, company = pi.company) frappe.db.commit()
def make_gl_entries(self, repost_future_gle=True): if not self.grand_total: return self.auto_accounting_for_stock = \ cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) self.stock_received_but_not_billed = self.get_company_default( "stock_received_but_not_billed") self.expenses_included_in_valuation = self.get_company_default( "expenses_included_in_valuation") self.negative_expense_to_be_booked = 0.0 gl_entries = [] self.make_supplier_gl_entry(gl_entries) self.make_item_gl_entries(gl_entries) self.make_tax_gl_entries(gl_entries) gl_entries = merge_similar_entries(gl_entries) self.make_payment_gl_entries(gl_entries) self.make_write_off_gl_entry(gl_entries) if gl_entries: update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": update_outstanding_amt( self.credit_to, "Supplier", self.supplier, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint( self.update_stock) and self.auto_accounting_for_stock: from erpnext.controllers.stock_controller import update_gl_entries_after items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint( self.update_stock) and self.auto_accounting_for_stock: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, repost_future_gle=True, allow_negative_stock=False): gl_entries = self.get_gl_entries(allow_negative_stock=allow_negative_stock) if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries update_outstanding = cint(self.is_pos) and self.write_off_account \ and 'No' or 'Yes' make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt(self.debit_to, self.doctype, self.name) if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items)
def make_gl_entries_sales_invoice(doc, method): self = doc gl_entries = None repost_future_gle = True from_repost = False auto_accounting_for_stock = erpnext.is_perpetual_inventory_enabled( self.company) if not self.grand_total: return if not gl_entries: gl_entries = self.get_gl_entries() if gl_entries: # if POS and amount is written off, updating outstanding amt after posting all gl entries update_outstanding = "No" if (cint(self.is_pos) or self.write_off_account) else "Yes" make_gl2_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt update_outstanding_amt( self.debit_to, "Customer", self.customer, self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name) if repost_future_gle and cint(self.update_stock) \ and cint(auto_accounting_for_stock): items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) \ and cint(auto_accounting_for_stock): delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def execute(): if not cint( frappe.defaults.get_global_default("auto_accounting_for_stock")): return frappe.reload_doc('accounts', 'doctype', 'sales_invoice') frappe.reload_doctype("Purchase Invoice") wh_account = get_warehouse_account_map() for pi in frappe.get_all("Purchase Invoice", filters={ "docstatus": 1, "update_stock": 1 }): pi_doc = frappe.get_doc("Purchase Invoice", pi.name) items, warehouses = pi_doc.get_items_and_warehouses() update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account) frappe.db.commit()
def make_gl_entries(self, repost_future_gle=True): if not self.grand_total: return self.auto_accounting_for_stock = \ cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) self.stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed") self.expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation") self.negative_expense_to_be_booked = 0.0 gl_entries = [] self.make_supplier_gl_entry(gl_entries) self.make_item_gl_entries(gl_entries) self.make_tax_gl_entries(gl_entries) gl_entries = merge_similar_entries(gl_entries) self.make_payment_gl_entries(gl_entries) self.make_write_off_gl_entry(gl_entries) if gl_entries: update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": update_outstanding_amt(self.credit_to, "Supplier", self.supplier, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint(self.update_stock) and self.auto_accounting_for_stock: from erpnext.controllers.stock_controller import update_gl_entries_after items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) and self.auto_accounting_for_stock: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False): if not self.grand_total: return if not gl_entries: gl_entries = self.get_gl_entries() if gl_entries: update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) if update_outstanding == "No": update_outstanding_amt(self.credit_to, "Supplier", self.supplier, self.doctype, self.return_against if cint(self.is_return) else self.name) if repost_future_gle and cint(self.update_stock) and self.auto_accounting_for_stock: from erpnext.controllers.stock_controller import update_gl_entries_after items, warehouses = self.get_items_and_warehouses() update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items) elif self.docstatus == 2 and cint(self.update_stock) and self.auto_accounting_for_stock: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)