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)
def test_add_credit_entry(self): till = Till(store=self.store, station=self.create_station()) till.open_till() self.assertEqual(till.get_balance(), 0) till.add_credit_entry(10) self.assertEqual(till.get_balance(), 10)
def test_get_balance(self): till = Till(store=self.store, station=self.create_station()) till.open_till() old = till.get_balance() till.add_credit_entry(currency(10), u"") self.assertEqual(till.get_balance(), old + 10) till.add_debit_entry(currency(5), u"") self.assertEqual(till.get_balance(), old + 5)
def test_get_debits_total(self): till = Till(store=self.store, station=self.create_station()) till.open_till() old = till.get_debits_total() till.add_debit_entry(currency(10), u"") self.assertEqual(till.get_debits_total(), old - 10) # This should not affect the debit till.add_credit_entry(currency(5), u"") self.assertEqual(till.get_debits_total(), old - 10)
def test_till_open_previously_opened(self): yesterday = localnow() - datetime.timedelta(1) # Open a till, set the opening_date to yesterday till = Till(station=get_current_station(self.store), store=self.store) till.open_till() till.opening_date = yesterday till.add_credit_entry(currency(10), u"") till.close_till() till.closing_date = yesterday new_till = Till(station=get_current_station(self.store), store=self.store) self.failUnless(new_till._get_last_closed_till()) new_till.open_till() self.assertEquals(new_till.initial_cash_amount, till.final_cash_amount)
def test_till_open_previously_opened(self): yesterday = localnow() - datetime.timedelta(1) # Open a till, set the opening_date to yesterday till = Till(station=get_current_station(self.store), store=self.store) till.open_till() till.opening_date = yesterday till.add_credit_entry(currency(10), u"") till.close_till() till.closing_date = yesterday new_till = Till(station=get_current_station(self.store), store=self.store) self.assertTrue(new_till._get_last_closed_till()) new_till.open_till() self.assertEqual(new_till.initial_cash_amount, till.final_cash_amount)