Пример #1
0
    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)
Пример #2
0
    def test_till_open_once(self):
        station = get_current_station(self.store)
        till = Till(store=self.store, station=station)

        till.open_till()
        till.close_till()

        self.assertRaises(TillError, till.open_till)
Пример #3
0
 def testTillClose(self):
     station = self.create_station()
     till = Till(store=self.store, station=station)
     till.open_till()
     self.assertEqual(till.status, Till.STATUS_OPEN)
     till.close_till()
     self.assertEqual(till.status, Till.STATUS_CLOSED)
     self.assertRaises(TillError, till.close_till)
Пример #4
0
 def test_till_close(self):
     station = self.create_station()
     till = Till(store=self.store, station=station)
     till.open_till()
     self.assertEqual(till.status, Till.STATUS_OPEN)
     till.close_till()
     self.assertEqual(till.status, Till.STATUS_CLOSED)
     self.assertRaises(TillError, till.close_till)
Пример #5
0
 def test_get_last_closed(self):
     till = Till(store=self.store,
                 branch=self.current_branch,
                 station=self.current_station)
     till.open_till(self.current_user)
     till.close_till(self.current_user)
     self.assertEqual(
         Till.get_last_closed(self.store, self.current_station), till)
Пример #6
0
    def testTillOpenOnce(self):
        station = get_current_station(self.store)
        till = Till(store=self.store, station=station)

        till.open_till()
        till.close_till()

        self.assertRaises(TillError, till.open_till)
Пример #7
0
 def test_needs_closing(self):
     till = Till(station=self.create_station(), store=self.store)
     self.failIf(till.needs_closing())
     till.open_till()
     self.failIf(till.needs_closing())
     till.opening_date = localnow() - datetime.timedelta(1)
     self.failUnless(till.needs_closing())
     till.close_till()
     self.failIf(till.needs_closing())
Пример #8
0
 def test_needs_closing(self):
     till = Till(station=self.create_station(), store=self.store)
     self.failIf(till.needs_closing())
     till.open_till()
     self.failIf(till.needs_closing())
     till.opening_date = localnow() - datetime.timedelta(1)
     self.failUnless(till.needs_closing())
     till.close_till()
     self.failIf(till.needs_closing())
Пример #9
0
    def testGetCurrentTillClose(self):
        station = get_current_station(self.store)
        self.assertEqual(Till.get_current(self.store), None)
        till = Till(store=self.store, station=station)
        till.open_till()

        self.assertEqual(Till.get_current(self.store), till)
        till.close_till()
        self.assertEqual(Till.get_current(self.store), None)
Пример #10
0
    def test_get_current_till_close(self):
        station = get_current_station(self.store)
        self.assertEqual(Till.get_current(self.store), None)
        till = Till(store=self.store, station=station)
        till.open_till()

        self.assertEqual(Till.get_current(self.store), till)
        till.close_till()
        self.assertEqual(Till.get_current(self.store), None)
Пример #11
0
 def test_till_close_more_than_balance(self):
     station = self.create_station()
     till = Till(store=self.store,
                 branch=self.current_branch,
                 station=station)
     till.open_till(self.current_user)
     till.add_debit_entry(currency(20), u"")
     with self.assertRaises(ValueError):
         till.close_till(self.current_user)
Пример #12
0
    def test_till_open_once(self):
        station = get_current_station(self.store)
        till = Till(store=self.store, station=station)

        till.open_till()
        till.close_till()

        with mock.patch.object(PluginManager, 'is_active') as is_active:
            is_active.return_value = True
            self.assertRaises(TillError, till.open_till)
Пример #13
0
    def test_till_open_previously_not_closed(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.close_till()
        till.closing_date = None

        self.assertRaises(TillError, till.open_till)
Пример #14
0
 def test_till_close(self):
     station = self.create_station()
     till = Till(store=self.store,
                 branch=self.current_branch,
                 station=station)
     till.open_till(self.current_user)
     self.assertEqual(till.status, Till.STATUS_OPEN)
     till.close_till(self.current_user)
     self.assertEqual(till.status, Till.STATUS_CLOSED)
     with self.assertRaises(TillError):
         till.close_till(self.current_user)
Пример #15
0
    def test_till_open_previously_not_closed(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.close_till()
        till.closing_date = None

        self.assertRaises(TillError, till.open_till)
Пример #16
0
    def test_till_open_once(self):
        till = Till(store=self.store,
                    branch=self.current_branch,
                    station=self.current_station)

        till.open_till(self.current_user)
        till.close_till(self.current_user)

        with mock.patch.object(PluginManager, 'is_active') as is_active:
            is_active.return_value = True
            with self.assertRaises(TillError):
                till.open_till(self.current_user)
Пример #17
0
    def testTillOpenPreviouslyNotClosed(self):
        yesterday = datetime.datetime.today() - 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.close_till()
        till.closing_date = None

        self.assertRaises(TillError, till.open_till)
Пример #18
0
    def test_till_open_previously_not_closed(self):
        yesterday = localnow() - datetime.timedelta(1)

        # Open a till, set the opening_date to yesterday
        till = Till(branch=self.current_branch,
                    station=self.current_station,
                    store=self.store)
        till.open_till(self.current_user)
        till.opening_date = yesterday
        till.close_till(self.current_user)
        till.closing_date = None

        with self.assertRaises(TillError):
            till.open_till(self.current_user)
Пример #19
0
    def test_till_open_yesterday(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

        self.assertRaises(TillError, Till.get_current, self.store)
        # This is used to close a till
        self.assertEqual(Till.get_last_opened(self.store), till)

        till.close_till()

        self.assertEqual(Till.get_current(self.store), None)
Пример #20
0
    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)
Пример #21
0
    def test_till_open_yesterday(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

        self.assertRaises(TillError, Till.get_current, self.store)
        # This is used to close a till
        self.assertEqual(Till.get_last_opened(self.store), till)

        till.close_till()

        self.assertEqual(Till.get_current(self.store), None)
Пример #22
0
    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)
Пример #23
0
    def test_till_open_yesterday(self):
        yesterday = localnow() - datetime.timedelta(1)

        # Open a till, set the opening_date to yesterday
        till = Till(branch=self.current_branch,
                    station=self.current_station,
                    store=self.store)
        till.open_till(self.current_user)
        till.opening_date = yesterday

        with self.assertRaises(TillError):
            Till.get_current(self.store, self.current_station)
        # This is used to close a till
        self.assertEqual(
            Till.get_last_opened(self.store, self.current_station), till)

        till.close_till(self.current_user)

        self.assertEqual(Till.get_current(self.store, self.current_station),
                         None)
Пример #24
0
    def test_needs_closing(self):
        till = Till(station=self.create_station(), store=self.store)
        self.assertFalse(till.needs_closing())

        # Till is opened today, no need to close
        till.open_till()
        self.assertFalse(till.needs_closing())

        # till was onpened yesterday. Should close
        till.opening_date = localnow() - datetime.timedelta(1)
        self.assertTrue(till.needs_closing())

        # Till was opened yesterday, but there is a tolerance
        tolerance = int((localnow() - localtoday()).seconds / (60 * 60)) + 1
        with self.sysparam(TILL_TOLERANCE_FOR_CLOSING=tolerance):
            self.assertFalse(till.needs_closing())

        # Till is now closed, no need to close again
        till.close_till()
        self.assertFalse(till.needs_closing())
Пример #25
0
 def testGetLastClosed(self):
     till = Till(store=self.store,
                 station=get_current_station(self.store))
     till.open_till()
     till.close_till()
     self.assertEquals(Till.get_last_closed(self.store), till)
Пример #26
0
 def test_get_last_closed(self):
     till = Till(store=self.store, station=get_current_station(self.store))
     till.open_till()
     till.close_till()
     self.assertEqual(Till.get_last_closed(self.store), till)