def create_disbursement_entry(self): je = frappe.new_doc("Journal Entry") je.voucher_type = 'Journal Entry' je.company = self.company je.remark = 'Loan Disbursement entry against Invoice Discounting: ' + self.name je.append( "accounts", { "account": self.bank_account, "debit_in_account_currency": flt(self.total_amount) - flt(self.bank_charges), "cost_center": erpbee.get_default_cost_center(self.company) }) if self.bank_charges: je.append( "accounts", { "account": self.bank_charges_account, "debit_in_account_currency": flt(self.bank_charges), "cost_center": erpbee.get_default_cost_center(self.company) }) je.append( "accounts", { "account": self.short_term_loan, "credit_in_account_currency": flt(self.total_amount), "cost_center": erpbee.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name }) for d in self.invoices: je.append( "accounts", { "account": self.accounts_receivable_discounted, "debit_in_account_currency": flt(d.outstanding_amount), "cost_center": erpbee.get_default_cost_center( self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", "party": d.customer }) je.append( "accounts", { "account": self.accounts_receivable_credit, "credit_in_account_currency": flt(d.outstanding_amount), "cost_center": erpbee.get_default_cost_center( self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", "party": d.customer }) return je
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 get_items_from_purchase_receipts(self): self.set("items", []) for pr in self.get("purchase_receipts"): if pr.receipt_document_type and pr.receipt_document: pr_items = frappe.db.sql( """select pr_item.item_code, pr_item.description, pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name, pr_item.cost_center, pr_item.is_fixed_asset from `tab{doctype} Item` pr_item where parent = %s and exists(select name from tabItem where name = pr_item.item_code and (is_stock_item = 1 or is_fixed_asset=1)) """.format(doctype=pr.receipt_document_type), pr.receipt_document, as_dict=True) for d in pr_items: item = self.append("items") item.item_code = d.item_code item.description = d.description item.qty = d.qty item.rate = d.base_rate item.cost_center = d.cost_center or \ erpbee.get_default_cost_center(self.company) item.amount = d.base_amount item.receipt_document_type = pr.receipt_document_type item.receipt_document = pr.receipt_document item.purchase_receipt_item = d.name item.is_fixed_asset = d.is_fixed_asset
def set_missing_values(self, amounts): precision = cint(frappe.db.get_default("currency_precision")) or 2 if not self.posting_date: self.posting_date = get_datetime() if not self.cost_center: self.cost_center = erpbee.get_default_cost_center(self.company) if not self.interest_payable: self.interest_payable = flt(amounts['interest_amount'], precision) if not self.penalty_amount: self.penalty_amount = flt(amounts['penalty_amount'], precision) if not self.pending_principal_amount: self.pending_principal_amount = flt( amounts['pending_principal_amount'], precision) if not self.payable_principal_amount and self.is_term_loan: self.payable_principal_amount = flt( amounts['payable_principal_amount'], precision) if not self.payable_amount: self.payable_amount = flt(amounts['payable_amount'], precision) if amounts.get('due_date'): self.due_date = amounts.get('due_date')
def make_bank_entry(dt, dn): from erpbee.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account expense_claim = frappe.get_doc(dt, dn) default_bank_cash_account = get_default_bank_cash_account( expense_claim.company, "Bank") if not default_bank_cash_account: default_bank_cash_account = get_default_bank_cash_account( expense_claim.company, "Cash") payable_amount = flt(expense_claim.total_sanctioned_amount) \ - flt(expense_claim.total_amount_reimbursed) - flt(expense_claim.total_advance_amount) je = frappe.new_doc("Journal Entry") je.voucher_type = 'Bank Entry' je.company = expense_claim.company je.remark = 'Payment against Expense Claim: ' + dn je.append( "accounts", { "account": expense_claim.payable_account, "debit_in_account_currency": payable_amount, "reference_type": "Expense Claim", "party_type": "Employee", "party": expense_claim.employee, "cost_center": erpbee.get_default_cost_center( expense_claim.company), "reference_name": expense_claim.name }) je.append( "accounts", { "account": default_bank_cash_account.account, "credit_in_account_currency": payable_amount, "reference_type": "Expense Claim", "reference_name": expense_claim.name, "balance": default_bank_cash_account.balance, "account_currency": default_bank_cash_account.account_currency, "cost_center": erpbee.get_default_cost_center( expense_claim.company), "account_type": default_bank_cash_account.account_type }) return je.as_dict()
def make_bank_entry(dt, dn): doc = frappe.get_doc(dt, dn) payment_account = get_default_bank_cash_account(doc.company, account_type="Cash", mode_of_payment=doc.mode_of_payment) if not payment_account: frappe.throw(_("Please set a Default Cash Account in Company defaults")) advance_account_currency = frappe.db.get_value('Account', doc.advance_account, 'account_currency') advance_amount, advance_exchange_rate = get_advance_amount_advance_exchange_rate(advance_account_currency,doc ) paying_amount, paying_exchange_rate = get_paying_amount_paying_exchange_rate(payment_account, doc) je = frappe.new_doc("Journal Entry") je.posting_date = nowdate() je.voucher_type = 'Bank Entry' je.company = doc.company je.remark = 'Payment against Employee Advance: ' + dn + '\n' + doc.purpose je.multi_currency = 1 if advance_account_currency != payment_account.account_currency else 0 je.append("accounts", { "account": doc.advance_account, "account_currency": advance_account_currency, "exchange_rate": flt(advance_exchange_rate), "debit_in_account_currency": flt(advance_amount), "reference_type": "Employee Advance", "reference_name": doc.name, "party_type": "Employee", "cost_center": erpbee.get_default_cost_center(doc.company), "party": doc.employee, "is_advance": "Yes" }) je.append("accounts", { "account": payment_account.account, "cost_center": erpbee.get_default_cost_center(doc.company), "credit_in_account_currency": flt(paying_amount), "account_currency": payment_account.account_currency, "account_type": payment_account.account_type, "exchange_rate": flt(paying_exchange_rate) }) return je.as_dict()
def set_missing_values(self): if not self.disbursement_date: self.disbursement_date = nowdate() if not self.cost_center: self.cost_center = erpbee.get_default_cost_center(self.company) if not self.posting_date: self.posting_date = self.disbursement_date or nowdate() if not self.bank_account and self.applicant_type == "Customer": self.bank_account = frappe.db.get_value("Customer", self.applicant, "default_bank_account")
def set_missing_values(self): if not self.cost_center: self.cost_center = erpbee.get_default_cost_center(self.company)
def get_expense_claim_account_and_cost_center(expense_claim_type, company): data = get_expense_claim_account(expense_claim_type, company) cost_center = erpbee.get_default_cost_center(company) return {"account": data.get("account"), "cost_center": cost_center}
def close_loan(self): je = frappe.new_doc("Journal Entry") je.voucher_type = 'Journal Entry' je.company = self.company je.remark = 'Loan Settlement entry against Invoice Discounting: ' + self.name je.append( "accounts", { "account": self.short_term_loan, "debit_in_account_currency": flt(self.total_amount), "cost_center": erpbee.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, }) je.append( "accounts", { "account": self.bank_account, "credit_in_account_currency": flt(self.total_amount), "cost_center": erpbee.get_default_cost_center(self.company) }) if getdate(self.loan_end_date) > getdate(nowdate()): for d in self.invoices: outstanding_amount = frappe.db.get_value( "Sales Invoice", d.sales_invoice, "outstanding_amount") if flt(outstanding_amount) > 0: je.append( "accounts", { "account": self.accounts_receivable_discounted, "credit_in_account_currency": flt(outstanding_amount), "cost_center": erpbee.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", "party": d.customer }) je.append( "accounts", { "account": self.accounts_receivable_unpaid, "debit_in_account_currency": flt(outstanding_amount), "cost_center": erpbee.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", "party": d.customer }) return je