From f60cca97e6b0e1829a1246b3927ada45a596298d Mon Sep 17 00:00:00 2001 From: Tanshu Date: Wed, 28 Nov 2012 13:28:16 +0530 Subject: [PATCH] Added salary deductions model / route. Updated import queries to support deductions. Added esi_pf expense and payable ledgers to LedgerBase. --- brewman/brewman/__init__.py | 2 + brewman/brewman/models/master.py | 8 + brewman/brewman/models/voucher.py | 107 ++++++++---- .../static/partial/employee-functions.html | 9 - ...edit-esi-pf.html => salary-deduction.html} | 17 +- .../static/scripts/employee-functions.js | 165 +++++++++++++++++- brewman/brewman/static/scripts/overlord.js | 3 + brewman/brewman/templates/angular_base.mako | 1 + brewman/brewman/views/employee.py | 18 +- brewman/brewman/views/reports/daybook.py | 2 +- brewman/brewman/views/reports/ledger.py | 2 +- .../brewman/views/reports/product_ledger.py | 2 +- .../brewman/views/reports/purchase_entries.py | 2 +- brewman/brewman/views/reports/unposted.py | 2 +- brewman/brewman/views/services/login.py | 11 -- .../views/services/voucher/__init__.py | 64 +++++++ .../views/services/voucher/empty_voucher.py | 5 + .../services/voucher/salary_deduction.py | 109 ++++++++++++ .../views/services/voucher/save_voucher.py | 7 + .../views/services/voucher/update_voucher.py | 7 + brewman/brewman/views/transactions.py | 47 ----- 21 files changed, 459 insertions(+), 131 deletions(-) rename brewman/brewman/static/partial/{credit-esi-pf.html => salary-deduction.html} (85%) create mode 100644 brewman/brewman/views/services/voucher/salary_deduction.py delete mode 100644 brewman/brewman/views/transactions.py diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py index 548c04bd..d742a32d 100644 --- a/brewman/brewman/__init__.py +++ b/brewman/brewman/__init__.py @@ -92,6 +92,8 @@ def main(global_config, **settings): config.add_route('issue_id', '/Issue/{id}') config.add_route('issue', '/Issue') config.add_route('issues_grid', '/Issues/Services/{date}') + config.add_route('salary_deduction_id', '/SalaryDeduction/{id}') + config.add_route('salary_deduction', '/SalaryDeduction') config.add_route('voucher', '/Voucher/{id}') config.add_route('voucher_new', '/Voucher') diff --git a/brewman/brewman/models/master.py b/brewman/brewman/models/master.py index 265e28ad..6a0d415a 100644 --- a/brewman/brewman/models/master.py +++ b/brewman/brewman/models/master.py @@ -227,6 +227,14 @@ class LedgerBase(Base): def salary(cls): return {'LedgerID': '5c2b54d0-c174-004d-a0d5-92cdaadcefa7', 'Name': 'salary staff'} + @classmethod + def esi_pf_expense(cls): + return uuid.UUID('d2a1a286-e900-764b-a1a5-9f4b00dbb940') + + @classmethod + def esi_pf_payable(cls): + return uuid.UUID('42277912-cc18-854b-b134-9f4b00dba419') + class Employee(LedgerBase): __tablename__ = 'entities_employees' diff --git a/brewman/brewman/models/voucher.py b/brewman/brewman/models/voucher.py index 8469b6a6..4baa1730 100644 --- a/brewman/brewman/models/voucher.py +++ b/brewman/brewman/models/voucher.py @@ -6,11 +6,49 @@ from brewman.models.guidtype import GUID from sqlalchemy import Column, Integer, Boolean, Unicode, DateTime, Numeric, ForeignKey, func -from sqlalchemy.orm import relationship, synonym +from sqlalchemy.orm import relationship, synonym, backref from brewman.models import Base, DBSession from brewman.models.master import Product +class VoucherType: + def __init__(self, id, name): + self.id = id + self.name = name + + @classmethod + def list(cls): + list = [] + list.append(VoucherType(1, 'Journal')) + list.append(VoucherType(2, 'Purchase')) + list.append(VoucherType(3, 'Issue')) + list.append(VoucherType(4, 'Payment')) + list.append(VoucherType(5, 'Receipt')) + list.append(VoucherType(6, 'Purchase Return')) + list.append(VoucherType(7, 'Opening Ledgers')) + list.append(VoucherType(8, 'Opening Inventories')) + list.append(VoucherType(9, 'Verification')) + list.append(VoucherType(10, 'Opening Balance')) + list.append(VoucherType(11, 'Closing Balance')) + list.append(VoucherType(12, 'Salary Deductions')) + return list + + @classmethod + def by_name(cls, name): + list = cls.list() + for item in list: + if item.name == name: + return item + + + @classmethod + def by_id(cls, id): + list = cls.list() + for item in list: + if item.id == id: + return item + + class Voucher(Base): __tablename__ = 'entities_vouchers' @@ -30,6 +68,8 @@ class Voucher(Base): journals = relationship('Journal', backref='voucher', cascade="delete, delete-orphan", cascade_backrefs=False) inventories = relationship('Inventory', backref='voucher', cascade="delete, delete-orphan", cascade_backrefs=False) + salary_deductions = relationship('SalaryDeduction', backref='voucher', cascade="delete, delete-orphan", + cascade_backrefs=False) def _get_type(self): return self._type @@ -50,7 +90,8 @@ class Voucher(Base): def __name__(self): return self.name - def __init__(self, date=None, reconcilliation_date=None, narration=None, posted=False, creation_date=None, last_edit_date=None, type=None, user_id=None, poster_id=None): + def __init__(self, date=None, reconcilliation_date=None, narration='', posted=False, creation_date=None, + last_edit_date=None, type=None, user_id=None, poster_id=None): self.date = date self.reconcilliation_date = reconcilliation_date self.narration = narration @@ -113,42 +154,34 @@ class Journal(Base): return DBSession.query(cls) -class VoucherType: - def __init__(self, id, name): +class SalaryDeduction(Base): + __tablename__ = 'entities_salarydeductions' + id = Column('SalaryDeductionID', GUID(), primary_key=True, default=uuid.uuid4) + voucher_id = Column('VoucherID', GUID(), ForeignKey('entities_vouchers.VoucherID')) + journal_id = Column('JournalID', GUID(), ForeignKey('entities_journals.JournalID')) + gross_salary = Column('GrossSalary', Integer) + days_worked = Column('DaysWorked', Integer) + esi_ee = Column('EsiEmployee', Integer) + pf_ee = Column('PfEmployee', Integer) + esi_er = Column('EsiEmployer', Integer) + pf_er = Column('PfEmployer', Integer) + + journal = relationship(Journal, backref=backref('salary_deduction', uselist=False), cascade=None, + cascade_backrefs=False) + + def __init__(self, id=None, voucher_id=None, journal_id=None, journal=None, gross_salary=None, days_worked=None, + esi_ee=None, pf_ee=None, esi_er=None, pf_er=None): self.id = id - self.name = name - - @classmethod - def list(cls): - list = [] - list.append(VoucherType(1, 'Journal')) - list.append(VoucherType(2, 'Purchase')) - list.append(VoucherType(3, 'Issue')) - list.append(VoucherType(4, 'Payment')) - list.append(VoucherType(5, 'Receipt')) - list.append(VoucherType(6, 'Purchase Return')) - list.append(VoucherType(7, 'Opening Ledgers')) - list.append(VoucherType(8, 'Opening Inventories')) - list.append(VoucherType(9, 'Verification')) - list.append(VoucherType(10, 'Opening Balance')) - list.append(VoucherType(11, 'Closing Balance')) - list.append(VoucherType(12, 'Salary Deductions')) - return list - - @classmethod - def by_name(cls, name): - list = cls.list() - for item in list: - if item.name == name: - return item - - - @classmethod - def by_id(cls, id): - list = cls.list() - for item in list: - if item.id == id: - return item + self.voucher_id = voucher_id + self.journal_id = journal_id + self.gross_salary = gross_salary + self.days_worked = days_worked + self.esi_ee = esi_ee + self.pf_ee = pf_ee + self.esi_er = esi_er + self.pf_er = pf_er + if journal_id is None and journal is not None: + self.journal = journal class Inventory(Base): diff --git a/brewman/brewman/static/partial/employee-functions.html b/brewman/brewman/static/partial/employee-functions.html index c7f113c9..277f9dad 100644 --- a/brewman/brewman/static/partial/employee-functions.html +++ b/brewman/brewman/static/partial/employee-functions.html @@ -18,15 +18,6 @@ Download - Credit Esi / Pf -
- - -
- - -
-
Upload Fingerprints
diff --git a/brewman/brewman/static/partial/credit-esi-pf.html b/brewman/brewman/static/partial/salary-deduction.html similarity index 85% rename from brewman/brewman/static/partial/credit-esi-pf.html rename to brewman/brewman/static/partial/salary-deduction.html index e3d182ae..19d98f2f 100644 --- a/brewman/brewman/static/partial/credit-esi-pf.html +++ b/brewman/brewman/static/partial/salary-deduction.html @@ -1,5 +1,5 @@
- Credit Esi Pf + Credit Esi / Pf
@@ -35,14 +35,13 @@ Esi ER Pf ER Delete - Delete - {{deduction.Employee.Name}} - {{deduction.Employee.Designation}} - {{deduction.Employee.Department}} + {{deduction.Journal.Ledger.Name}} + {{deduction.Journal.Ledger.Designation}} + {{deduction.Journal.Ledger.CostCenter.Name}} {{deduction.GrossSalary}} {{deduction.DaysWorked}} {{deduction.EsiEmployee}} @@ -61,14 +60,6 @@
-
- - -
- -
-