Ejemplo n.º 1
0
def running_balance(line_item):
    from efms.utils import to_money
    if line_item.type == 'C':
        running_balance.amount += line_item.amount
    else:
        running_balance.amount -= line_item.amount
    return to_money(running_balance.amount)
Ejemplo n.º 2
0
def new_allocations(txn_amt, ancestor):
    allocs = ([], [], [])
    totals = [Decimal(0), Decimal(0)]
    ancestor_allocations = ancestor.allocations.all()
    for prj_item in ancestor_allocations:
        allocs[0].append(prj_item.account_id)
        percent = prj_item.cost / ancestor.cost
        cost = utils.to_money((ancestor.cost + txn_amt) * percent)
        amt = utils.to_money(txn_amt * percent)
        totals[0] += amt
        totals[1] += cost
        allocs[1].append(amt)
        allocs[2].append(cost)
    if ancestor.unallocated_amt == 0 and totals[0] != txn_amt:
        utils.adjust_pennies([(txn_amt, allocs[1]), (ancestor.cost + txn_amt, allocs[2])])
    return [Allocation(acct, amt, cost) for acct, amt, cost in zip(allocs[0], allocs[1], allocs[2])]
Ejemplo n.º 3
0
def build_data(db_data):
    data = []
    prev_balance = 0
    for rec in db_data:
        item = dict()
        item['fyqseq'] = rec.fyqseq
        item['item_type'] = rec.item_type
        item['po_nbr'] = rec.po_nbr
        item['date'] = rec.date
        item['description'] = rec.description
        item['amount'] = to_money(rec.amount)
        item['cost'] = '' if rec.cost is None else to_money(rec.cost)
        if rec.item_type == 'C':
            prev_balance += rec.amount
        else:
            prev_balance -= rec.amount
        item['balance'] = to_money(prev_balance)
        data.append(item)
    return data
Ejemplo n.º 4
0
    def test_get_efforts_by_month(self):
        employee = Employee()
        employee.id = 1
        employee.project_id = 1
        employee.salary = 89752

        assignment = Assignment()
        assignment.start_date =  date(2013, 12, 1)
        assignment.end_date = date(2014, 4, 30)
        assignment.effort = 25
        assignment.project_id = 1
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date =  date(2014, 3, 1)
        assignment.end_date = date(2014, 6, 30)
        assignment.effort = 50
        assignment.project_id = 2
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date =  date(2014, 1, 1)
        assignment.end_date = date(2014, 3, 31)
        assignment.effort = 10
        assignment.project_id = 3
        assignment.role_id = 1
        employee.assignments.add(assignment)

        efforts = employee.get_efforts_by_month()
        self.assertEqual(7, len(efforts))
        self.assertEqual(EffortCost(25, to_money(1869.83)), efforts[EffortMonth(2013, 12)])
        self.assertEqual(EffortCost(35, to_money(2617.76)), efforts[EffortMonth(2014, 1)])
        self.assertEqual(EffortCost(35, to_money(2617.76)), efforts[EffortMonth(2014, 2)])
        self.assertEqual(EffortCost(85, to_money(6357.43)), efforts[EffortMonth(2014, 3)])
        self.assertEqual(EffortCost(75, to_money(5609.50)), efforts[EffortMonth(2014, 4)])
        self.assertEqual(EffortCost(50, to_money(3739.67)), efforts[EffortMonth(2014, 5)])
        self.assertEqual(EffortCost(50, to_money(3739.67)), efforts[EffortMonth(2014, 6)])
Ejemplo n.º 5
0
 def render_unallocated_amt(self, value):
     return to_money(Decimal(value))
Ejemplo n.º 6
0
 def render_unobl_bal(self, value):
     return to_money(Decimal(value))
Ejemplo n.º 7
0
 def render_obl_amt(self, value):
     return to_money(Decimal(value))
Ejemplo n.º 8
0
 def _calculate_cost_per_month(self, effort):
     return to_money(self.gross_pay * effort * Decimal(.01) / 12)