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, 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): 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 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(self.company) if self.docstatus == 1: if not gl_entries: gl_entries = self.get_gl_entries(warehouse_account) make_gl_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, company=self.company) elif self.doctype in ['Purchase Receipt', 'Purchase Invoice' ] and self.docstatus == 1: gl_entries = [] gl_entries = self.get_asset_gl_entry(gl_entries) make_gl_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 on_cancel(doc,method): #Update the expense claim amount cleared so that no new JV can be made for i in doc.earnings: if i.expense_claim: ec = frappe.get_doc("Expense Claim", i.expense_claim) frappe.db.set_value("Expense Claim", i.expense_claim, "total_amount_reimbursed", 0) frappe.db.set_value("Expense Claim", i.expense_claim, "status", "Unpaid") delete_gl_entries(None, 'Salary Slip', doc.name)
def on_cancel(self): delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) self.set_status() if frappe.db.get_single_value( 'Selling Settings', 'sales_update_frequency') == "Each Transaction": update_company_current_month_sales(self.company) update_company_current_month_purchase(self.company)
def make_gl_entries(self, repost_future_gle=True): if self.docstatus == 2: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): warehouse_account = get_warehouse_account() if self.docstatus == 1: gl_entries = self.get_gl_entries(warehouse_account) make_gl_entries(gl_entries) 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)
def make_gl_entries(self, repost_future_gle=True): if self.docstatus == 2: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): warehouse_account = get_warehouse_account() if self.docstatus==1: gl_entries = self.get_gl_entries(warehouse_account) make_gl_entries(gl_entries) 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)
def make_gl_entries(self, update_gl_entries_after=True): if self.doc.docstatus == 2: delete_gl_entries(voucher_type=self.doc.doctype, voucher_no=self.doc.name) if cint(frappe.defaults.get_global_default( "auto_accounting_for_stock")): warehouse_account = self.get_warehouse_account() if self.doc.docstatus == 1: gl_entries = self.get_gl_entries(warehouse_account) make_gl_entries(gl_entries) if update_gl_entries_after: self.update_gl_entries_after(warehouse_account)
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 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==1: if not gl_entries: gl_entries = self.get_gl_entries(warehouse_account) make_gl_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)
def execute(): for name in frappe.db.sql(""" SELECT name FROM `tabIndent Invoice` WHERE docstatus = 1; """): name = name[0] if cint(name) < 1000: continue invoice = frappe.get_doc("Indent Invoice", name) gl_entries = invoice.get_gl_entries() delete_gl_entries(voucher_type="Indent Invoice", voucher_no=name) make_gl_entries(gl_entries)
def on_cancel(self): delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if (self.employment_type == 'Bus Supplier'): to_clr_count = frappe.db.sql( """update `tabTrip Order` set driver_clearance_status = "No" where name in (select trip_order from `tabClearance Bus Orders` where parent = %s) """, (self.name), as_dict=True) else: to_clr_count = frappe.db.sql( """update `tabTrip Order` set driver_clearance_status = "No" where name in (select trip_order from `tabClearance Trips Orders` where parent = %s) """, (self.name), as_dict=True)
def convert_all_interests_till(loan, posting_date=today(), disable_make_interest=False, cancel=0, recalculate=0): from frappe.utils import cint, get_first_day, get_last_day, add_months from frappe.permissions import get_roles if 'Loan Manager' not in get_roles(frappe.session.user): frappe.throw('Insufficient permission') if cint(cancel): return delete_gl_entries(voucher_type='Loan', voucher_no=loan) if cint(recalculate): delete_gl_entries(voucher_type='Loan', voucher_no=loan) loan = frappe.get_doc('Loan', loan) def get_dates(start_date, end_date): from_date = getdate(start_date) to_date = getdate(end_date) while from_date <= to_date: yield from_date from_date = add_months(from_date, 1) effective_date = getdate('2017-08-01') start_date = get_first_day( add_months( loan.posting_date \ if loan.posting_date > effective_date else effective_date, 1 ) ) def generate(d): amount = loan.convert_interest_to_principal(d) loan.make_interest(d, amount) return d return map(generate, get_dates(start_date, posting_date))
def update_billed_amount(self, amount): self.billed_amount = amount self.save() interest_income_account = frappe.get_value( "Microfinance Loan", self.loan, "interest_income_account" ) cur_billed = frappe.db.sql( """ SELECT SUM(credit - debit) FROM `tabGL Entry` WHERE account = '{account}' AND voucher_no = '{voucher_no}' """.format( account=interest_income_account, voucher_no=self.name ) )[0][0] if cur_billed != self.billed_amount: delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) self.make_gl_entries( self.billed_amount, remarks="Interest for {}".format(self.period) )
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)
def on_cancel(self): delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def on_cancel(self): from erpnext.accounts.general_ledger import delete_gl_entries delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def on_cancel(self): self.validate_cancellation() self.delete_depreciation_entries() self.set_status() delete_gl_entries(voucher_type='Asset', voucher_no=self.name) self.db_set('booked_fixed_asset', 0)
def on_cancel(self): self.title = self.workflow_state + "-" + self.origination_place + "-" + self.final_destination frappe.db.set_value("Trip Order", self.name, "title", self.title) delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def on_cancel(self): delete_gl_entries(None, 'Employee Advance', self.name)