mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 00:55:02 +00:00
fix: Add cost center in loan document
(cherry picked from commit 5d66cc4c4a)
# Conflicts:
# erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py
# erpnext/patches.txt
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
"monthly_repayment_amount",
|
||||
"repayment_start_date",
|
||||
"is_term_loan",
|
||||
"accounting_dimensions_section",
|
||||
"cost_center",
|
||||
"account_info",
|
||||
"mode_of_payment",
|
||||
"disbursement_account",
|
||||
@@ -366,12 +368,23 @@
|
||||
"options": "Account",
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "accounting_dimensions_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Accounting Dimensions"
|
||||
},
|
||||
{
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"options": "Cost Center"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-01-25 16:29:16.325501",
|
||||
"modified": "2022-03-10 11:50:31.957360",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Loan Management",
|
||||
"name": "Loan",
|
||||
|
||||
@@ -26,6 +26,7 @@ class Loan(AccountsController):
|
||||
self.set_loan_amount()
|
||||
self.validate_loan_amount()
|
||||
self.set_missing_fields()
|
||||
self.validate_cost_center()
|
||||
self.validate_accounts()
|
||||
self.check_sanctioned_amount_limit()
|
||||
self.validate_repay_from_salary()
|
||||
@@ -59,6 +60,13 @@ class Loan(AccountsController):
|
||||
)
|
||||
)
|
||||
|
||||
def validate_cost_center(self):
|
||||
if not self.cost_center and self.rate_of_interest != 0:
|
||||
self.cost_center = frappe.db.get_value('Company', self.company, 'cost_center')
|
||||
|
||||
if not self.cost_center:
|
||||
frappe.throw(_('Cost center is mandatory for loans having rate of interest greater than 0'))
|
||||
|
||||
def on_submit(self):
|
||||
self.link_loan_security_pledge()
|
||||
# Interest accrual for backdated term loans
|
||||
|
||||
@@ -6,7 +6,6 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import add_days, cint, date_diff, flt, get_datetime, getdate, nowdate
|
||||
|
||||
import erpnext
|
||||
from erpnext.accounts.general_ledger import make_gl_entries
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
|
||||
@@ -41,8 +40,11 @@ class LoanInterestAccrual(AccountsController):
|
||||
def make_gl_entries(self, cancel=0, adv_adj=0):
|
||||
gle_map = []
|
||||
|
||||
cost_center = frappe.db.get_value('Loan', self.loan, 'cost_center')
|
||||
|
||||
if self.interest_amount:
|
||||
gle_map.append(
|
||||
<<<<<<< HEAD
|
||||
self.get_gl_dict(
|
||||
{
|
||||
"account": self.loan_account,
|
||||
@@ -78,6 +80,37 @@ class LoanInterestAccrual(AccountsController):
|
||||
"posting_date": self.posting_date,
|
||||
}
|
||||
)
|
||||
=======
|
||||
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": cost_center,
|
||||
"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": cost_center,
|
||||
"posting_date": self.posting_date
|
||||
})
|
||||
>>>>>>> 5d66cc4c4a (fix: Add cost center in loan document)
|
||||
)
|
||||
|
||||
if gle_map:
|
||||
|
||||
@@ -352,6 +352,7 @@ erpnext.patches.v13_0.amazon_mws_deprecation_warning
|
||||
erpnext.patches.v13_0.datev_deprecation_warning
|
||||
erpnext.patches.v13_0.set_work_order_qty_in_so_from_mr
|
||||
erpnext.patches.v13_0.update_accounts_in_loan_docs
|
||||
<<<<<<< HEAD
|
||||
erpnext.patches.v13_0.remove_unknown_links_to_prod_plan_items # 24-03-2022
|
||||
erpnext.patches.v13_0.rename_non_profit_fields
|
||||
erpnext.patches.v13_0.enable_ksa_vat_docs #1
|
||||
@@ -367,3 +368,9 @@ erpnext.patches.v13_0.create_accounting_dimensions_in_orders
|
||||
erpnext.patches.v13_0.set_per_billed_in_return_delivery_note
|
||||
erpnext.patches.v13_0.update_employee_advance_status
|
||||
erpnext.patches.v13_0.job_card_status_on_hold
|
||||
=======
|
||||
erpnext.patches.v14_0.update_batch_valuation_flag
|
||||
erpnext.patches.v14_0.delete_non_profit_doctypes
|
||||
erpnext.patches.v14_0.update_employee_advance_status
|
||||
erpnext.patches.v13_0.add_cost_center_in_loans
|
||||
>>>>>>> 5d66cc4c4a (fix: Add cost center in loan document)
|
||||
|
||||
16
erpnext/patches/v13_0/add_cost_center_in_loans.py
Normal file
16
erpnext/patches/v13_0/add_cost_center_in_loans.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('loan_management', 'doctype', 'loan')
|
||||
loan = frappe.qb.DocType('Loan')
|
||||
|
||||
for company in frappe.get_all('Company', pluck='name'):
|
||||
default_cost_center = frappe.db.get_value('Company', company, 'cost_center')
|
||||
frappe.qb.update(
|
||||
loan
|
||||
).set(
|
||||
loan.cost_center, default_cost_center
|
||||
).where(
|
||||
loan.company == company
|
||||
).run()
|
||||
Reference in New Issue
Block a user