diff --git a/ohrms_loan_accounting/README.md b/ohrms_loan_accounting/README.md new file mode 100644 index 000000000..e4647ca8a --- /dev/null +++ b/ohrms_loan_accounting/README.md @@ -0,0 +1,36 @@ +OHRMS Loan Management +===================== + +Manage Loan Requests. + + +Installation +============ +- www.odoo.com/documentation/10.0/setup/install.html +- Install our custom addon + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developers: Anusha P P + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. + diff --git a/ohrms_loan_accounting/RELEASE_NOTES.md b/ohrms_loan_accounting/RELEASE_NOTES.md new file mode 100644 index 000000000..8ca74dc80 --- /dev/null +++ b/ohrms_loan_accounting/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module ohrms_loan_accounting + +#### 30.03.2018 +#### Version 10.0.1.0.0 +##### ADD +- Initial commit for OpenHrms Project diff --git a/ohrms_loan_accounting/__init__.py b/ohrms_loan_accounting/__init__.py new file mode 100644 index 000000000..89d26e2f5 --- /dev/null +++ b/ohrms_loan_accounting/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import models diff --git a/ohrms_loan_accounting/__manifest__.py b/ohrms_loan_accounting/__manifest__.py new file mode 100644 index 000000000..3757e79d4 --- /dev/null +++ b/ohrms_loan_accounting/__manifest__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Anusha P P () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +{ + 'name': 'OHRMS Loan Accounting', + 'version': '10.0.1.0.0', + 'summary': 'HR Loan Accounting', + 'description': """ + Create accounting entries for loan requests. + """, + 'category': 'Generic Modules/Human Resources', + 'author': "Cybrosys Techno Solutions", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.openhrms.com", + 'depends': [ + 'hr_payroll', 'hr', 'account', 'ohrms_loan', + ], + 'data': [ + 'views/hr_loan_config.xml', + 'views/hr_loan_acc.xml', + + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/ohrms_loan_accounting/models/__init__.py b/ohrms_loan_accounting/models/__init__.py new file mode 100644 index 000000000..0bc44dcad --- /dev/null +++ b/ohrms_loan_accounting/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +import hr_loan_config +import hr_loan_acc + diff --git a/ohrms_loan_accounting/models/hr_loan_acc.py b/ohrms_loan_accounting/models/hr_loan_acc.py new file mode 100644 index 000000000..1ab56e43e --- /dev/null +++ b/ohrms_loan_accounting/models/hr_loan_acc.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +import time +from odoo import models, fields, api +from odoo.exceptions import except_orm + + +class HrLoanAcc(models.Model): + _inherit = 'hr.loan' + + @api.multi + def action_approve(self): + """This create account move for request. + """ + loan_approve = self.env['ir.values'].get_default('account.config.settings', 'loan_approve') + contract_obj = self.env['hr.contract'].search([('employee_id', '=', self.employee_id.id)]) + if not contract_obj: + raise except_orm('Warning', 'You must Define a contract for employee') + if not self.loan_line_ids: + raise except_orm('Warning', 'You must compute Loan Request before Approved') + if loan_approve: + self.write({'state': 'waiting_approval_2'}) + else: + raise except_orm('Warning', 'Enable the option for loan approval from accounting department') + + @api.multi + def action_double_approve(self): + """This create account move for request in case of double approval. + """ + if not self.emp_account_id or not self.treasury_account_id or not self.journal_id: + raise except_orm('Warning', "You must enter employee account & Treasury account and journal to approve ") + if not self.loan_line_ids: + raise except_orm('Warning', 'You must compute Loan Request before Approved') + move_obj = self.env['account.move'] + timenow = time.strftime('%Y-%m-%d') + line_ids = [] + debit_sum = 0.0 + credit_sum = 0.0 + for loan in self: + amount = loan.loan_amount + loan_name = loan.employee_id.name + reference = loan.name + journal_id = loan.journal_id.id + move = { + 'name': 'Loan For' + ' ' + loan_name, + 'narration': loan_name, + 'ref': reference, + 'journal_id': journal_id, + 'date': timenow, + 'state': 'posted', + } + + debit_account_id = loan.treasury_account_id.id + credit_account_id = loan.emp_account_id.id + if debit_account_id: + debit_line = (0, 0, { + 'name': loan_name, + 'account_id': debit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount > 0.0 and amount or 0.0, + 'credit': amount < 0.0 and -amount or 0.0, + 'loan_id': loan.id, + }) + line_ids.append(debit_line) + debit_sum += debit_line[2]['debit'] - debit_line[2]['credit'] + + if credit_account_id: + credit_line = (0, 0, { + 'name': loan_name, + 'account_id': credit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount < 0.0 and -amount or 0.0, + 'credit': amount > 0.0 and amount or 0.0, + 'loan_id': loan.id, + }) + line_ids.append(credit_line) + credit_sum += credit_line[2]['credit'] - credit_line[2]['debit'] + + move.update({'line_ids': line_ids}) + move_id = move_obj.create(move) + self.move_id = move_id.id + self.write({'state': 'approve'}) + return self.write({'move_id': move_id.id}) + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + loan_id = fields.Many2one('hr.loan', string="Loan") + + +class HrLoanLineAcc(models.Model): + _inherit = "hr.loan.line" + + @api.one + def action_paid_amount(self): + """This create the account move line for payment of each installment. + """ + result = super(HrLoanLineAcc, self).action_paid_amount() + move_obj = self.env['account.move'] + timenow = time.strftime('%Y-%m-%d') + line_ids = [] + debit_sum = 0.0 + credit_sum = 0.0 + + for line in self: + if line.loan_id.state != 'approve': + raise except_orm('Warning', "Loan Request must be approved") + amount = line.paid_amount + loan_name = line.employee_id.name + print "loan_name",loan_name + reference = line.loan_id.name + journal_id = line.loan_id.journal_id.id + move = { + 'name': 'Loan For' + ' ' + loan_name, + 'narration': loan_name, + 'ref': reference, + 'journal_id': journal_id, + 'date': timenow, + 'state': 'posted', + } + + debit_account_id = line.loan_id.emp_account_id.id + credit_account_id = line.loan_id.treasury_account_id.id + + if debit_account_id: + debit_line = (0, 0, { + 'name': loan_name, + 'account_id': debit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount > 0.0 and amount or 0.0, + 'credit': amount < 0.0 and -amount or 0.0, + 'loan_id': line.loan_id.id, + }) + line_ids.append(debit_line) + debit_sum += debit_line[2]['debit'] - debit_line[2]['credit'] + + if credit_account_id: + credit_line = (0, 0, { + 'name': loan_name, + 'account_id': credit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount < 0.0 and -amount or 0.0, + 'credit': amount > 0.0 and amount or 0.0, + 'loan_id': line.loan_id.id, + }) + line_ids.append(credit_line) + credit_sum += credit_line[2]['credit'] - credit_line[2]['debit'] + + move.update({'line_ids': line_ids}) + move_id = move_obj.create(move) + return result + return True + + +class HrPayslipAcc(models.Model): + _inherit = 'hr.payslip' + + @api.multi + def action_payslip_done(self): + rules = [] + for line in self.loan_ids: + if line.paid: + if self.struct_id: + for line_id in self.struct_id.rule_ids: + rules.append(line_id.code) + if self.struct_id.parent_id: + for line_ids in self.struct_id.parent_id.rule_ids: + rules.append(line_ids.code) + if 'LO' in rules: + line.action_paid_amount() + else: + raise except_orm('Warning', "Add Salary rule for loan in salary structure") + return super(HrPayslipAcc, self).action_payslip_done() diff --git a/ohrms_loan_accounting/models/hr_loan_config.py b/ohrms_loan_accounting/models/hr_loan_config.py new file mode 100644 index 000000000..a46dcca3d --- /dev/null +++ b/ohrms_loan_accounting/models/hr_loan_config.py @@ -0,0 +1,13 @@ +from odoo import models, fields, api, _ + + +class AccConfig(models.TransientModel): + _inherit = 'account.config.settings' + + loan_approve = fields.Boolean(default=False, string="Approval from Accounting Department", + help="Loan Approval from account manager") + + @api.multi + def set_loan_approve(self): + return self.env['ir.values'].sudo().set_default( + 'account.config.settings', 'loan_approve', self.loan_approve) diff --git a/ohrms_loan_accounting/static/description/HRMS-BUTTON.png b/ohrms_loan_accounting/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/ohrms_loan_accounting/static/description/HRMS-BUTTON.png differ diff --git a/ohrms_loan_accounting/static/description/accounting_validation.png b/ohrms_loan_accounting/static/description/accounting_validation.png new file mode 100644 index 000000000..1f8537f24 Binary files /dev/null and b/ohrms_loan_accounting/static/description/accounting_validation.png differ diff --git a/ohrms_loan_accounting/static/description/banner.jpg b/ohrms_loan_accounting/static/description/banner.jpg new file mode 100644 index 000000000..85265f48d Binary files /dev/null and b/ohrms_loan_accounting/static/description/banner.jpg differ diff --git a/ohrms_loan_accounting/static/description/cybro-service.png b/ohrms_loan_accounting/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/ohrms_loan_accounting/static/description/cybro-service.png differ diff --git a/ohrms_loan_accounting/static/description/icon.png b/ohrms_loan_accounting/static/description/icon.png new file mode 100644 index 000000000..e90809a0f Binary files /dev/null and b/ohrms_loan_accounting/static/description/icon.png differ diff --git a/ohrms_loan_accounting/static/description/index.html b/ohrms_loan_accounting/static/description/index.html new file mode 100644 index 000000000..cb9ea109b --- /dev/null +++ b/ohrms_loan_accounting/static/description/index.html @@ -0,0 +1,159 @@ +
+
+

OpenHRMS

+

Most advanced open source HR management software

+
+
+ +
+
+
+
+ + + + +
+
+ +
+
+ +
+
+

HR Loan

+

Manage Loan request of employees

+

Cybrosys Technologies

+
+
+

Features:

+
+ Employee can create loan request.
+ Double layer approval, from Accounting & HR Department.
+ Loan amount is deducted from the salary.
+
+
+
+ +
+
+
+
+

Overview

+

+ HR Loan is a component of Open HRMS suit. + HR Loan module helps the user to configure different loan policies, assign approval authority, conduct the verification process and sanction loan for employees. +

+
+
+
+
+ +
+
+
+

Configuration

+
+
+

Install the Module "HR Loan Accounting" in order to enable Accounting Entries. + Enable the option "Loan Approval From Accounting Department" In accounting settings

+
+
+ +
+
+
+
+

Add the deduction rule for loan in Salary Structure

+
+
+ +
+
+
+
+
+ +
+
+
+

Loan Request

+

Employee can create loan request

+
+
+ +
+
+
+
+
+ +
+
+
+

Loan Approval

+

Once the HR department has given the Approval, the accounts department take the decision

+
+
+ +
+
+
+
+
+ +
+
+
+

Employee Payslip

+

When we create the payslip, all the pending installments will be listed there, + we can manually select the installments that have to be deducted from the salary

+
+
+ +
+
+
+
+
+ +
+
+
+

Loan Amount Deduction

+

When we check the Loan request again, + the deducted installments will be changed to paid state.

+
+
+ +
+
+
+
+
+ +
+
+

Our Odoo Services

+
+
+ + +
+

Need Any Help?

+ +
diff --git a/ohrms_loan_accounting/static/description/loan_amount_deduction.png b/ohrms_loan_accounting/static/description/loan_amount_deduction.png new file mode 100644 index 000000000..b1896e2b7 Binary files /dev/null and b/ohrms_loan_accounting/static/description/loan_amount_deduction.png differ diff --git a/ohrms_loan_accounting/static/description/loan_approval.png b/ohrms_loan_accounting/static/description/loan_approval.png new file mode 100644 index 000000000..d34b799e9 Binary files /dev/null and b/ohrms_loan_accounting/static/description/loan_approval.png differ diff --git a/ohrms_loan_accounting/static/description/loan_request.png b/ohrms_loan_accounting/static/description/loan_request.png new file mode 100644 index 000000000..191d47adc Binary files /dev/null and b/ohrms_loan_accounting/static/description/loan_request.png differ diff --git a/ohrms_loan_accounting/static/description/loan_rule.png b/ohrms_loan_accounting/static/description/loan_rule.png new file mode 100644 index 000000000..3b3f78c7f Binary files /dev/null and b/ohrms_loan_accounting/static/description/loan_rule.png differ diff --git a/ohrms_loan_accounting/static/description/payslip.png b/ohrms_loan_accounting/static/description/payslip.png new file mode 100644 index 000000000..e58613b86 Binary files /dev/null and b/ohrms_loan_accounting/static/description/payslip.png differ diff --git a/ohrms_loan_accounting/views/hr_loan_acc.xml b/ohrms_loan_accounting/views/hr_loan_acc.xml new file mode 100644 index 000000000..52eb6123f --- /dev/null +++ b/ohrms_loan_accounting/views/hr_loan_acc.xml @@ -0,0 +1,43 @@ + + + + Loans + ir.actions.act_window + account.move.line + hr.loan + form + tree,form + {'search_default_loan_id': [active_id], 'default_loan_id': active_id} + [('loan_id','=',active_id)] + + + + HR LOAN + hr.loan + + + + 0 + + + 0 + + + 0 + + + + + + view.move.line.form.inherit + account.move.line + + + + + + + + + + diff --git a/ohrms_loan_accounting/views/hr_loan_config.xml b/ohrms_loan_accounting/views/hr_loan_config.xml new file mode 100644 index 000000000..a5d01e5d0 --- /dev/null +++ b/ohrms_loan_accounting/views/hr_loan_config.xml @@ -0,0 +1,21 @@ + + + + + Accounting settings + account.config.settings + + + + + + + + + + \ No newline at end of file