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())
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)
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)
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)
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)
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)
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())
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)
def _createUnclosedTill(self): till = Till(station=get_current_station(self.store), store=self.store) till.open_till() yesterday = datetime.date.today() - datetime.timedelta(1) till.opening_date = yesterday
def _createUnclosedTill(self): till = Till(station=get_current_station(self.store), store=self.store) till.open_till() yesterday = localtoday() - datetime.timedelta(1) till.opening_date = yesterday