From 38b7f941d5f9570e6715b4495fd1af403a56ecc8 Mon Sep 17 00:00:00 2001 From: Tanshu Date: Wed, 28 Nov 2012 16:11:00 +0530 Subject: [PATCH] Fixed minor errors in SalaryDeduction --- brewman/brewman/models/voucher.py | 2 +- brewman/brewman/views/services/voucher/__init__.py | 4 +++- brewman/brewman/views/services/voucher/salary_deduction.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/brewman/brewman/models/voucher.py b/brewman/brewman/models/voucher.py index 4baa1730..a176f5bc 100644 --- a/brewman/brewman/models/voucher.py +++ b/brewman/brewman/models/voucher.py @@ -30,7 +30,7 @@ class VoucherType: list.append(VoucherType(9, 'Verification')) list.append(VoucherType(10, 'Opening Balance')) list.append(VoucherType(11, 'Closing Balance')) - list.append(VoucherType(12, 'Salary Deductions')) + list.append(VoucherType(12, 'Salary Deduction')) return list @classmethod diff --git a/brewman/brewman/views/services/voucher/__init__.py b/brewman/brewman/views/services/voucher/__init__.py index 3986eeac..4c07dca3 100644 --- a/brewman/brewman/views/services/voucher/__init__.py +++ b/brewman/brewman/views/services/voucher/__init__.py @@ -137,6 +137,7 @@ def voucher_info(voucher): 'Narration': voucher.narration, 'Journals': [], 'Inventories': [], + 'SalaryDeductions': [], 'CreationDate': voucher.creation_date.strftime('%d-%b-%Y %H:%M'), 'LastEditDate': voucher.last_edit_date.strftime('%d-%b-%Y %H:%M'), 'User': {'UserID': voucher.user.id, 'Name': voucher.user.name}, @@ -148,7 +149,6 @@ def voucher_info(voucher): 'Ledger': {'LedgerID': item.ledger.id, 'Name': item.ledger.name}, 'CostCenter': {'CostCenterID': item.cost_center_id}}) for item in voucher.salary_deductions: - json_voucher['SalaryDeductions'] = [] json_voucher['SalaryDeductions'].append( {'GrossSalary': item.gross_salary, 'DaysWorked': item.days_worked, @@ -236,6 +236,8 @@ def get_edit_url(request, voucher): return request.route_url('payment_id', id=voucher.id) elif voucher.type == 5: return request.route_url('receipt_id', id=voucher.id) + elif voucher.type == 12: + return request.route_url('salary_deduction_id', id=voucher.id) else: return '#' diff --git a/brewman/brewman/views/services/voucher/salary_deduction.py b/brewman/brewman/views/services/voucher/salary_deduction.py index 8b760f87..75bac6f2 100644 --- a/brewman/brewman/views/services/voucher/salary_deduction.py +++ b/brewman/brewman/views/services/voucher/salary_deduction.py @@ -36,7 +36,7 @@ def salary_deduction_create_voucher(json, user): def salary_deduction_update_voucher(voucher, json, user): dt = get_last_day(datetime.datetime.strptime(json['Date'], '%d-%b-%Y')) - if dt != voucher.date: + if dt != voucher.date.date(): raise ValidationError("Date Cannot be changed for Salary Deduction voucher!") days_in_month = voucher.date.day voucher.user_id = user.id