def make_gl_entries(self, cancel=0): gl_entries = [] loan_details = frappe.get_doc("Loan", self.loan) gl_entries.append( self.get_gl_dict({ "account": self.write_off_account, "against": loan_details.loan_account, "debit": self.write_off_amount, "debit_in_account_currency": self.write_off_amount, "against_voucher_type": "Loan", "against_voucher": self.loan, "remarks": _("Against Loan:") + self.loan, "cost_center": self.cost_center, "posting_date": getdate(self.posting_date) })) gl_entries.append( self.get_gl_dict({ "account": loan_details.loan_account, "party_type": loan_details.applicant_type, "party": loan_details.applicant, "against": self.write_off_account, "credit": self.write_off_amount, "credit_in_account_currency": self.write_off_amount, "against_voucher_type": "Loan", "against_voucher": self.loan, "remarks": _("Against Loan:") + self.loan, "cost_center": self.cost_center, "posting_date": getdate(self.posting_date) })) make_gl_entries(gl_entries, cancel=cancel, merge_entries=False)
def make_gl_entries(self): if not self.grand_total: return student_gl_entries = self.get_gl_dict( { "account": self.receivable_account, "party_type": "Student", "party": self.student, "against": self.income_account, "debit": self.grand_total, "debit_in_account_currency": self.grand_total, "against_voucher": self.name, "against_voucher_type": self.doctype }, item=self) fee_gl_entry = self.get_gl_dict( { "account": self.income_account, "against": self.student, "credit": self.grand_total, "credit_in_account_currency": self.grand_total, "cost_center": self.cost_center }, item=self) from erpbee.accounts.general_ledger import make_gl_entries make_gl_entries([student_gl_entries, fee_gl_entry], cancel=(self.docstatus == 2), update_outstanding="Yes", merge_entries=False)
def make_gl_entries(self): gl_entries = [] net_pl_balance = 0 dimension_fields = ['t1.cost_center'] accounting_dimensions = get_accounting_dimensions() for dimension in accounting_dimensions: dimension_fields.append('t1.{0}'.format(dimension)) dimension_filters, default_dimensions = get_dimension_filters() pl_accounts = self.get_pl_balances(dimension_fields) for acc in pl_accounts: if flt(acc.balance_in_company_currency): gl_entries.append(self.get_gl_dict({ "account": acc.account, "cost_center": acc.cost_center, "account_currency": acc.account_currency, "debit_in_account_currency": abs(flt(acc.balance_in_account_currency)) \ if flt(acc.balance_in_account_currency) < 0 else 0, "debit": abs(flt(acc.balance_in_company_currency)) \ if flt(acc.balance_in_company_currency) < 0 else 0, "credit_in_account_currency": abs(flt(acc.balance_in_account_currency)) \ if flt(acc.balance_in_account_currency) > 0 else 0, "credit": abs(flt(acc.balance_in_company_currency)) \ if flt(acc.balance_in_company_currency) > 0 else 0 }, item=acc)) net_pl_balance += flt(acc.balance_in_company_currency) if net_pl_balance: cost_center = frappe.db.get_value("Company", self.company, "cost_center") gl_entry = self.get_gl_dict({ "account": self.closing_account_head, "debit_in_account_currency": abs(net_pl_balance) if net_pl_balance > 0 else 0, "debit": abs(net_pl_balance) if net_pl_balance > 0 else 0, "credit_in_account_currency": abs(net_pl_balance) if net_pl_balance < 0 else 0, "credit": abs(net_pl_balance) if net_pl_balance < 0 else 0, "cost_center": cost_center }) for dimension in accounting_dimensions: gl_entry.update({ dimension: default_dimensions.get(self.company, {}).get(dimension) }) gl_entries.append(gl_entry) from erpbee.accounts.general_ledger import make_gl_entries make_gl_entries(gl_entries)
def make_gl_entries(self, cancel=0, adv_adj=0): gle_map = [] if self.interest_amount: gle_map.append( self.get_gl_dict({ "account": self.loan_account, "party_type": self.applicant_type, "party": self.applicant, "against": self.interest_income_account, "debit": self.interest_amount, "debit_in_account_currency": self.interest_amount, "against_voucher_type": "Loan", "against_voucher": self.loan, "remarks": _("Interest accrued from {0} to {1} against loan: {2}"). format(self.last_accrual_date, self.posting_date, self.loan), "cost_center": erpbee.get_default_cost_center(self.company), "posting_date": self.posting_date })) gle_map.append( self.get_gl_dict({ "account": self.interest_income_account, "against": self.loan_account, "credit": self.interest_amount, "credit_in_account_currency": self.interest_amount, "against_voucher_type": "Loan", "against_voucher": self.loan, "remarks": ("Interest accrued from {0} to {1} against loan: {2}" ).format(self.last_accrual_date, self.posting_date, self.loan), "cost_center": erpbee.get_default_cost_center(self.company), "posting_date": self.posting_date })) if gle_map: make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj)
def make_gl_entries(self): gl_entries = [] purchase_document = self.get_purchase_document() fixed_asset_account, cwip_account = self.get_fixed_asset_account( ), self.get_cwip_account() if (purchase_document and self.purchase_receipt_amount and self.available_for_use_date <= nowdate()): gl_entries.append( self.get_gl_dict( { "account": cwip_account, "against": fixed_asset_account, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "posting_date": self.available_for_use_date, "credit": self.purchase_receipt_amount, "credit_in_account_currency": self.purchase_receipt_amount, "cost_center": self.cost_center }, item=self)) gl_entries.append( self.get_gl_dict( { "account": fixed_asset_account, "against": cwip_account, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "posting_date": self.available_for_use_date, "debit": self.purchase_receipt_amount, "debit_in_account_currency": self.purchase_receipt_amount, "cost_center": self.cost_center }, item=self)) if gl_entries: from erpbee.accounts.general_ledger import make_gl_entries make_gl_entries(gl_entries) self.db_set('booked_fixed_asset', 1)
def make_gl_entries(self): company_currency = frappe.get_cached_value('Company', self.company, "default_currency") gl_entries = [] invoice_fields = [ "debit_to", "party_account_currency", "conversion_rate", "cost_center" ] accounting_dimensions = get_accounting_dimensions() invoice_fields.extend(accounting_dimensions) for d in self.invoices: inv = frappe.db.get_value("Sales Invoice", d.sales_invoice, invoice_fields, as_dict=1) if d.outstanding_amount: outstanding_in_company_currency = flt( d.outstanding_amount * inv.conversion_rate, d.precision("outstanding_amount")) ar_credit_account_currency = frappe.get_cached_value( "Account", self.accounts_receivable_credit, "currency") gl_entries.append(self.get_gl_dict({ "account": inv.debit_to, "party_type": "Customer", "party": d.customer, "against": self.accounts_receivable_credit, "credit": outstanding_in_company_currency, "credit_in_account_currency": outstanding_in_company_currency \ if inv.party_account_currency==company_currency else d.outstanding_amount, "cost_center": inv.cost_center, "against_voucher": d.sales_invoice, "against_voucher_type": "Sales Invoice" }, inv.party_account_currency, item=inv)) gl_entries.append(self.get_gl_dict({ "account": self.accounts_receivable_credit, "party_type": "Customer", "party": d.customer, "against": inv.debit_to, "debit": outstanding_in_company_currency, "debit_in_account_currency": outstanding_in_company_currency \ if ar_credit_account_currency==company_currency else d.outstanding_amount, "cost_center": inv.cost_center, "against_voucher": d.sales_invoice, "against_voucher_type": "Sales Invoice" }, ar_credit_account_currency, item=inv)) make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding='No')
def _book_deferred_revenue_or_expense(item, via_journal_entry, submit_journal_entry, book_deferred_entries_based_on): start_date, end_date, last_gl_entry = get_booking_dates( doc, item, posting_date=posting_date) if not (start_date and end_date): return account_currency = get_account_currency(item.expense_account) if doc.doctype == "Sales Invoice": against, project = doc.customer, doc.project credit_account, debit_account = item.income_account, item.deferred_revenue_account else: against, project = doc.supplier, item.project credit_account, debit_account = item.deferred_expense_account, item.expense_account total_days = date_diff(item.service_end_date, item.service_start_date) + 1 total_booking_days = date_diff(end_date, start_date) + 1 if book_deferred_entries_based_on == 'Months': amount, base_amount = calculate_monthly_amount( doc, item, last_gl_entry, start_date, end_date, total_days, total_booking_days, account_currency) else: amount, base_amount = calculate_amount(doc, item, last_gl_entry, total_days, total_booking_days, account_currency) if via_journal_entry: book_revenue_via_journal_entry(doc, credit_account, debit_account, against, amount, base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process, submit_journal_entry) else: make_gl_entries(doc, credit_account, debit_account, against, amount, base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process) # Returned in case of any errors because it tries to submit the same record again and again in case of errors if frappe.flags.deferred_accounting_error: return if getdate(end_date) < getdate(posting_date) and not last_gl_entry: _book_deferred_revenue_or_expense(item, via_journal_entry, submit_journal_entry, book_deferred_entries_based_on)
def make_gl_entries(self, gl_entries=None, from_repost=False): if self.docstatus == 2: make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if cint(erpbee.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) 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): if not self.dunning_amount: return gl_entries = [] invoice_fields = ["project", "cost_center", "debit_to", "party_account_currency", "conversion_rate", "cost_center"] inv = frappe.db.get_value("Sales Invoice", self.sales_invoice, invoice_fields, as_dict=1) accounting_dimensions = get_accounting_dimensions() invoice_fields.extend(accounting_dimensions) dunning_in_company_currency = flt(self.dunning_amount * inv.conversion_rate) default_cost_center = frappe.get_cached_value('Company', self.company, 'cost_center') gl_entries.append( self.get_gl_dict({ "account": inv.debit_to, "party_type": "Customer", "party": self.customer, "due_date": self.due_date, "against": self.income_account, "debit": dunning_in_company_currency, "debit_in_account_currency": self.dunning_amount, "against_voucher": self.name, "against_voucher_type": "Dunning", "cost_center": inv.cost_center or default_cost_center, "project": inv.project }, inv.party_account_currency, item=inv) ) gl_entries.append( self.get_gl_dict({ "account": self.income_account, "against": self.customer, "credit": dunning_in_company_currency, "cost_center": inv.cost_center or default_cost_center, "credit_in_account_currency": self.dunning_amount, "project": inv.project }, item=inv) ) make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding="No", merge_entries=False)
def make_gl_entries(self, cancel=0, adv_adj=0): gle_map = [] loan_details = frappe.get_doc("Loan", self.against_loan) gle_map.append( self.get_gl_dict({ "account": loan_details.loan_account, "against": loan_details.payment_account, "debit": self.disbursed_amount, "debit_in_account_currency": self.disbursed_amount, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Disbursement against loan:") + self.against_loan, "cost_center": self.cost_center, "party_type": self.applicant_type, "party": self.applicant, "posting_date": self.disbursement_date }) ) gle_map.append( self.get_gl_dict({ "account": loan_details.payment_account, "against": loan_details.loan_account, "credit": self.disbursed_amount, "credit_in_account_currency": self.disbursed_amount, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Disbursement against loan:") + self.against_loan, "cost_center": self.cost_center, "posting_date": self.disbursement_date }) ) if gle_map: make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj)
def make_gl_entries(doc, credit_account, debit_account, against, amount, base_amount, posting_date, project, account_currency, cost_center, item, deferred_process=None): # GL Entry for crediting the amount in the deferred expense from erpbee.accounts.general_ledger import make_gl_entries if amount == 0: return gl_entries = [] gl_entries.append( doc.get_gl_dict( { "account": credit_account, "against": against, "credit": base_amount, "credit_in_account_currency": amount, "cost_center": cost_center, "voucher_detail_no": item.name, 'posting_date': posting_date, 'project': project, 'against_voucher_type': 'Process Deferred Accounting', 'against_voucher': deferred_process }, account_currency, item=item)) # GL Entry to debit the amount from the expense gl_entries.append( doc.get_gl_dict( { "account": debit_account, "against": against, "debit": base_amount, "debit_in_account_currency": amount, "cost_center": cost_center, "voucher_detail_no": item.name, 'posting_date': posting_date, 'project': project, 'against_voucher_type': 'Process Deferred Accounting', 'against_voucher': deferred_process }, account_currency, item=item)) if gl_entries: try: make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True) frappe.db.commit() except: frappe.db.rollback() traceback = frappe.get_traceback() frappe.log_error(message=traceback) frappe.flags.deferred_accounting_error = True
def make_gl_entries(self, cancel=0, adv_adj=0): gle_map = [] loan_details = frappe.get_doc("Loan", self.against_loan) if self.penalty_amount: gle_map.append( self.get_gl_dict({ "account": loan_details.loan_account, "against": loan_details.payment_account, "debit": self.penalty_amount, "debit_in_account_currency": self.penalty_amount, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Penalty against loan:") + self.against_loan, "cost_center": self.cost_center, "party_type": self.applicant_type, "party": self.applicant, "posting_date": getdate(self.posting_date) })) gle_map.append( self.get_gl_dict({ "account": loan_details.penalty_income_account, "against": loan_details.payment_account, "credit": self.penalty_amount, "credit_in_account_currency": self.penalty_amount, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Penalty against loan:") + self.against_loan, "cost_center": self.cost_center, "posting_date": getdate(self.posting_date) })) gle_map.append( self.get_gl_dict({ "account": loan_details.payment_account, "against": loan_details.loan_account + ", " + loan_details.interest_income_account + ", " + loan_details.penalty_income_account, "debit": self.amount_paid, "debit_in_account_currency": self.amount_paid, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Repayment against Loan: ") + self.against_loan, "cost_center": self.cost_center, "posting_date": getdate(self.posting_date) })) gle_map.append( self.get_gl_dict({ "account": loan_details.loan_account, "party_type": loan_details.applicant_type, "party": loan_details.applicant, "against": loan_details.payment_account, "credit": self.amount_paid, "credit_in_account_currency": self.amount_paid, "against_voucher_type": "Loan", "against_voucher": self.against_loan, "remarks": _("Repayment against Loan: ") + self.against_loan, "cost_center": self.cost_center, "posting_date": getdate(self.posting_date) })) if gle_map: make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj, merge_entries=False)
def make_gl_entries(self, cancel=False): if flt(self.total_sanctioned_amount) > 0: gl_entries = self.get_gl_entries() make_gl_entries(gl_entries, cancel)