def test_allocate_cei(self): cp = create_cp_1382_12() cp.save() fms_line_items = fms_items_1382_12_1() cp.update_line_items(fms_line_items) request = self.factory.get('line_item_allocate') ien = '95871250' request.session = { 'RunningBalanceReport': RunningBalanceReport(cp.number, cp.fy, 1, fms_line_items) } request.method = 'POST' request.POST = { 'id_desc': 'CEI Allocation', 'unallocated_amt': Decimal(0), 'allocation_string': '1:85000,2:22345,3:50310' } response = line_item_allocate(request, ien) item = ControlPointLineItem.objects.get(fyqseq='1210038') self.assertEquals('CEI Allocation', item.description) self.assertEquals(0, item.unallocated_amt) self.assertEquals(None, item.cost) self.assertEquals(3, item.allocations.count()) allocs = item.allocations.all() alloc = allocs.get(id=1) self.assertEquals('CEI Allocation', alloc.description) self.assertEquals('95871250', alloc.ien) self.assertEquals('1210038', alloc.fyqseq) self.assertEquals('C', alloc.type) self.assertEquals('506FC9276', alloc.po_nbr) self.assertEquals('2011-12-06', str(alloc.date)) self.assertEquals(Decimal('85000'), alloc.amount) self.assertEquals(None, alloc.cost) self.assertEquals(1, alloc.account_id) self.assertEquals(item.id, alloc.control_point_line_item_id) alloc = allocs.get(id=2) self.assertEquals('CEI Allocation', alloc.description) self.assertEquals('95871250', alloc.ien) self.assertEquals('1210038', alloc.fyqseq) self.assertEquals('C', alloc.type) self.assertEquals('506FC9276', alloc.po_nbr) self.assertEquals('2011-12-06', str(alloc.date)) self.assertEquals(Decimal('22345'), alloc.amount) self.assertEquals(None, alloc.cost) self.assertEquals(2, alloc.account_id) self.assertEquals(item.id, alloc.control_point_line_item_id) alloc = allocs.get(id=3) self.assertEquals('CEI Allocation', alloc.description) self.assertEquals('95871250', alloc.ien) self.assertEquals('1210038', alloc.fyqseq) self.assertEquals('C', alloc.type) self.assertEquals('506FC9276', alloc.po_nbr) self.assertEquals('2011-12-06', str(alloc.date)) self.assertEquals(Decimal('50310'), alloc.amount) self.assertEquals(None, alloc.cost) self.assertEquals(3, alloc.account_id) self.assertEquals(item.id, alloc.control_point_line_item_id)
def test_allocate_obl(self): cp = create_cp_1382_12() cp.save() fms_line_items = fms_items_1382_12_1() cp.update_line_items(fms_line_items) request = self.factory.get('line_item_allocate') ien = '95958457' request.session = { 'RunningBalanceReport': RunningBalanceReport(cp.number, cp.fy, 1, fms_line_items) } request.method = 'POST' request.POST = { 'id_desc': 'Some description', 'unallocated_amt': Decimal(0), 'allocation_string': '1:186.67,2:186.67,3:186.66' } response = line_item_allocate(request, ien) # self.assertEquals(200, response.status_code) self.assertEquals(9, ProjectAccountLineItem.objects.count()) allocs = ProjectAccountLineItem.objects.all() alloc = allocs.get(id=1) self.assertEquals('Some description', alloc.description) self.assertEquals('95958457', alloc.ien) self.assertEquals('1210011', alloc.fyqseq) self.assertEquals('O', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-03', str(alloc.date)) self.assertEquals(Decimal('186.67'), alloc.amount) self.assertEquals(Decimal('186.67'), alloc.cost) self.assertEquals(1, alloc.account_id) self.assertEquals(4, alloc.control_point_line_item_id) alloc = allocs.get(id=2) self.assertEquals('Some description', alloc.description) self.assertEquals('95958457', alloc.ien) self.assertEquals('1210011', alloc.fyqseq) self.assertEquals('O', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-03', str(alloc.date)) self.assertEquals(Decimal('186.67'), alloc.amount) self.assertEquals(Decimal('186.67'), alloc.cost) self.assertEquals(2, alloc.account_id) self.assertEquals(4, alloc.control_point_line_item_id) alloc = allocs.get(id=3) self.assertEquals('Some description', alloc.description) self.assertEquals('95958457', alloc.ien) self.assertEquals('1210011', alloc.fyqseq) self.assertEquals('O', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-03', str(alloc.date)) self.assertEquals(Decimal('186.66'), alloc.amount) self.assertEquals(Decimal('186.66'), alloc.cost) self.assertEquals(3, alloc.account_id) self.assertEquals(4, alloc.control_point_line_item_id) alloc = allocs.get(id=4) self.assertEquals('Some description', alloc.description) self.assertEquals('95876936', alloc.ien) self.assertEquals('1210029', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-31', str(alloc.date)) self.assertEquals(Decimal('-13.33'), alloc.amount) self.assertEquals(Decimal('173.33'), alloc.cost) self.assertEquals(1, alloc.account_id) self.assertEquals(6, alloc.control_point_line_item_id) alloc = allocs.get(id=5) self.assertEquals('Some description', alloc.description) self.assertEquals('95876936', alloc.ien) self.assertEquals('1210029', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-31', str(alloc.date)) self.assertEquals(Decimal('-13.33'), alloc.amount) self.assertEquals(Decimal('173.34'), alloc.cost) self.assertEquals(2, alloc.account_id) self.assertEquals(6, alloc.control_point_line_item_id) alloc = allocs.get(id=6) self.assertEquals('Some description', alloc.description) self.assertEquals('95876936', alloc.ien) self.assertEquals('1210029', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-10-31', str(alloc.date)) self.assertEquals(Decimal('-13.34'), alloc.amount) self.assertEquals(Decimal('173.33'), alloc.cost) self.assertEquals(3, alloc.account_id) self.assertEquals(6, alloc.control_point_line_item_id) alloc = allocs.get(id=7) self.assertEquals('Some description', alloc.description) self.assertEquals('95873815', alloc.ien) self.assertEquals('1210033', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-11-25', str(alloc.date)) self.assertEquals(Decimal('-80'), alloc.amount) self.assertEquals(Decimal('93.33'), alloc.cost) self.assertEquals(1, alloc.account_id) self.assertEquals(7, alloc.control_point_line_item_id) alloc = allocs.get(id=8) self.assertEquals('Some description', alloc.description) self.assertEquals('95873815', alloc.ien) self.assertEquals('1210033', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-11-25', str(alloc.date)) self.assertEquals(Decimal('-80'), alloc.amount) self.assertEquals(Decimal('93.34'), alloc.cost) self.assertEquals(2, alloc.account_id) self.assertEquals(7, alloc.control_point_line_item_id) alloc = allocs.get(id=9) self.assertEquals('Some description', alloc.description) self.assertEquals('95873815', alloc.ien) self.assertEquals('1210033', alloc.fyqseq) self.assertEquals('A', alloc.type) self.assertEquals('D25011', alloc.po_nbr) self.assertEquals('2011-11-25', str(alloc.date)) self.assertEquals(Decimal('-80'), alloc.amount) self.assertEquals(Decimal('93.33'), alloc.cost) self.assertEquals(3, alloc.account_id) self.assertEquals(7, alloc.control_point_line_item_id)