def test_till_close_final_cash_amount(self): station = self.create_station() till = Till(store=self.store, branch=self.current_branch, station=station) till.open_till(self.current_user) # There is no cash amount yet self.assertEqual(till.get_cash_amount(), 0) # Add a card payment. Cash amount is still at zero payment = self.create_card_payment(provider_id='VISA') TillEntry(description=u'test', value=payment.value, till=till, station=station, branch=till.station.branch, payment=payment, store=self.store) self.assertEqual(till.get_cash_amount(), 0) # Add a cash payment. cash amount increases payment = self.create_payment() TillEntry(description=u'test', value=payment.value, till=till, station=self.current_station, branch=till.station.branch, payment=payment, store=self.store) self.assertEqual(till.get_cash_amount(), 10) # Final cash amount should consider only CASH payments till.close_till(self.current_user) self.assertEqual(till.final_cash_amount, 10)
def testGetCashAmount(self): till = Till(store=self.store, station=self.create_station()) till.open_till() old = till.get_cash_amount() # money operations till.add_credit_entry(currency(10), u"") self.assertEqual(till.get_cash_amount(), old + 10) till.add_debit_entry(currency(5), u"") self.assertEqual(till.get_cash_amount(), old + 5) # non-money operations payment1 = self._create_inpayment() till.add_entry(payment1) self.assertEqual(till.get_cash_amount(), old + 5) payment2 = self._create_outpayment() till.add_entry(payment2) self.assertEqual(till.get_cash_amount(), old + 5) # money payment method operation payment = self.create_payment() payment.due_date = till.opening_date payment.till = till payment.set_pending() TillEntry(description=u'test', value=payment.value, till=till, branch=till.station.branch, payment=payment, store=self.store) payment.pay() self.assertEqual(till.get_cash_amount(), old + 5 + payment.value)
def test_get_cash_amount(self): till = Till(store=self.store, station=self.create_station()) till.open_till() old = till.get_cash_amount() # money operations till.add_credit_entry(currency(10), u"") self.assertEqual(till.get_cash_amount(), old + 10) till.add_debit_entry(currency(5), u"") self.assertEqual(till.get_cash_amount(), old + 5) # non-money operations payment1 = self._create_inpayment() till.add_entry(payment1) self.assertEqual(till.get_cash_amount(), old + 5) payment2 = self._create_outpayment() till.add_entry(payment2) self.assertEqual(till.get_cash_amount(), old + 5) # money payment method operation payment = self.create_payment() payment.due_date = till.opening_date payment.set_pending() TillEntry(description=u'test', value=payment.value, till=till, branch=till.station.branch, payment=payment, store=self.store) payment.pay() self.assertEqual(till.get_cash_amount(), old + 5 + payment.value)