From 28d405bf736c8d402ea4ca12f84b47cb4b951f96 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 9 Dec 2014 11:35:20 +0700 Subject: [PATCH] labor cost --- netforce_clinic/models/labor_cost_entry.py | 11 ++++++++--- netforce_clinic/models/labor_cost_entry_line.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/models/labor_cost_entry.py b/netforce_clinic/models/labor_cost_entry.py index 07303ce..6ec1a92 100644 --- a/netforce_clinic/models/labor_cost_entry.py +++ b/netforce_clinic/models/labor_cost_entry.py @@ -68,12 +68,17 @@ class LaborCostEntry(Model): lines=[] timenow=time.strftime("%Y-%m-%d") for staff_id, vals in staffs.items(): + qty=vals['qty'] or 0 + amt=vals['amt'] or 0.0 + rate=0.0 + if qty: + rate=amt/qty # average lines.append(('create',{ 'staff_id': staff_id, - 'qty': vals['qty'] or 0, - 'amount': vals['amt'] or 0.0, + 'qty': qty, + 'amount': amt, 'date': timenow, - 'rate': vals['amt'], + 'rate': rate, })) for line in obj.lines: diff --git a/netforce_clinic/models/labor_cost_entry_line.py b/netforce_clinic/models/labor_cost_entry_line.py index d0d9d0f..1f9545a 100644 --- a/netforce_clinic/models/labor_cost_entry_line.py +++ b/netforce_clinic/models/labor_cost_entry_line.py @@ -14,7 +14,7 @@ class LaborCostEntryLine(Model): 'date': fields.Date("Date"), 'staff_id': fields.Many2One("clinic.staff","Staff"), 'qty': fields.Integer("Qty"), - 'rate': fields.Float("Rate"), + 'rate': fields.Float("Rate Avg."), 'amount': fields.Float("Amount"), 'company_id': fields.Many2One("company","Company"), }