Ejemplo n.º 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)
Ejemplo n.º 2
0
    def test_till_history_report(self):
        from stoqlib.gui.dialogs.tillhistory import TillHistoryDialog
        dialog = TillHistoryDialog(self.store)

        till = Till(station=self.current_station,
                    branch=self.current_branch,
                    store=self.store)
        till.open_till(self.current_user)

        sale = self.create_sale()
        sellable = self.create_sellable()
        sale.add_sellable(sellable, price=100)
        method = PaymentMethod.get_by_name(self.store, u'bill')
        payment = method.create_payment(sale.branch, sale.station,
                                        Payment.TYPE_IN, sale.group,
                                        Decimal(100))
        TillEntry(value=25,
                  identifier=20,
                  description=u"Cash In",
                  payment=None,
                  till=till,
                  branch=till.station.branch,
                  station=self.current_station,
                  date=datetime.date(2007, 1, 1),
                  store=self.store)
        TillEntry(value=-5,
                  identifier=21,
                  description=u"Cash Out",
                  payment=None,
                  till=till,
                  branch=till.station.branch,
                  station=self.current_station,
                  date=datetime.date(2007, 1, 1),
                  store=self.store)

        TillEntry(value=100,
                  identifier=22,
                  description=sellable.get_description(),
                  payment=payment,
                  till=till,
                  branch=till.station.branch,
                  station=self.current_station,
                  date=datetime.date(2007, 1, 1),
                  store=self.store)
        till_entry = list(self.store.find(TillEntry, till=till))
        today = datetime.date.today().strftime('%x')
        for item in till_entry:
            if today in item.description:
                date = datetime.date(2007, 1, 1).strftime('%x')
                item.description = item.description.replace(today, date)

            item.date = datetime.date(2007, 1, 1)
            dialog.results.append(item)

        self._diff_expected(TillHistoryReport, 'till-history-report',
                            dialog.results, list(dialog.results))
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 def test_branch_name(self):
     till = self.create_till()
     till.open_till()
     branch = self.create_branch(name=u'Test')
     person = branch.person
     person.company.fancy_name = u'Test Shop'
     entry = TillEntry(store=self.store,
                       till=till,
                       branch=branch,
                       date=datetime.datetime(2014, 1, 1))
     self.assertEqual(entry.branch_name, u'Test Shop')
     person.company.fancy_name = None
     self.assertNotEqual(entry.branch_name, u'Test Shop')
     self.assertEqual(entry.branch_name, u'Test')
Ejemplo n.º 5
0
    def test_date_search(self):
        entry = TillEntry(identifier=1234,
                          description=u'desc',
                          date=localdate(2011, 01, 01).date(),
                          value=Decimal(123.0),
                          till=self.store.find(Till)[0],
                          payment=None,
                          branch=api.get_current_branch(self.store),
                          store=self.store)

        dialog = TillHistoryDialog(self.store)
        dialog.date_filter.select(DateSearchFilter.Type.USER_DAY)
        dialog.date_filter.start_date.update(entry.date)
        self.click(dialog.search.search_button)
        self.check_dialog(dialog, 'till-history-dialog-custom-day')
Ejemplo n.º 6
0
    def test_description_money(self):
        till = self.create_till()
        till.open_till()
        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)

        summary = till.get_day_summary()
        self.assertEqual(len(summary), 1)
        self.assertEqual(summary[0].description, 'Money')
Ejemplo n.º 7
0
    def test_description_card(self):
        till = self.create_till()
        till.open_till()
        till.initial_cash_amount = 0
        payment = self.create_card_payment(provider_id='VISA')
        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)

        summary = till.get_day_summary()
        self.assertEqual(len(summary),
                         2)  # There are two, since money is always there.

        card_summary = [i for i in summary
                        if i.method.method_name == 'card'][0]
        self.assertEqual(card_summary.description, 'Card VISA Credit')
Ejemplo n.º 8
0
 def test_time(self):
     entry = TillEntry(store=self.store,
                       date=datetime.datetime(2000, 1, 1, 12, 34, 59, 789))
     self.assertEqual(entry.time, datetime.time(12, 34, 59))
Ejemplo n.º 9
0
 def test_time(self):
     entry = TillEntry(store=self.store,
                       branch=self.current_branch,
                       station=self.current_station,
                       date=datetime.datetime(2000, 1, 1, 12, 34, 59, 789))
     self.assertEqual(entry.time, datetime.time(12, 34, 59))