From da6997afc69fe9053c6fac3f0f0f6268cf269f7f Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Tue, 12 Aug 2014 13:17:41 +0530 Subject: [PATCH] Fix: Unable to change Employee Cost Center Fix: Do not add 0 amount Journals to Salary Voucher --- brewman/views/employee.py | 2 +- brewman/views/services/voucher/credit_salary.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/brewman/views/employee.py b/brewman/views/employee.py index f0a0478d..1f3830e8 100644 --- a/brewman/views/employee.py +++ b/brewman/views/employee.py @@ -83,7 +83,7 @@ def update(request): if item.name == '': raise ValidationError('Name cannot be blank') - item.cost_center_id = uuid.UUID(request.json_body['CostCenter']['CostCenterID']) + item.costcenter_id = uuid.UUID(request.json_body['CostCenter']['CostCenterID']) item.designation = request.json_body.get('Designation', '').strip() try: diff --git a/brewman/views/services/voucher/credit_salary.py b/brewman/views/services/voucher/credit_salary.py index d41974c3..56c386bd 100644 --- a/brewman/views/services/voucher/credit_salary.py +++ b/brewman/views/services/voucher/credit_salary.py @@ -51,8 +51,9 @@ def salary_journals(start_date, finish_date): .all() att = sum(map(lambda x: AttendanceType.by_id(x.attendance_type).value, att)) att = round(att * employee.salary / days) - amount += att - journals.append(Journal(amount=att, debit=-1, ledger_id=employee.id, cost_center_id=employee.costcenter_id)) + if att != 0: + amount += att + journals.append(Journal(amount=att, debit=-1, ledger_id=employee.id, cost_center_id=employee.costcenter_id)) salary = Ledger.salary() salary = Ledger.by_id(uuid.UUID(salary['LedgerID'])) journals.append(Journal(amount=amount, debit=1, ledger_id=salary.id, cost_center_id=salary.costcenter_id))