当前位置: 首页>>代码示例>>Python>>正文


Python Till.get_last_opened方法代码示例

本文整理汇总了Python中stoqlib.domain.till.Till.get_last_opened方法的典型用法代码示例。如果您正苦于以下问题:Python Till.get_last_opened方法的具体用法?Python Till.get_last_opened怎么用?Python Till.get_last_opened使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stoqlib.domain.till.Till的用法示例。


在下文中一共展示了Till.get_last_opened方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSalesPersonReport

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def testSalesPersonReport(self):
        sysparam(self.store).SALE_PAY_COMMISSION_WHEN_CONFIRMED = 1
        salesperson = self.create_sales_person()
        product = self.create_product(price=100)
        sellable = product.sellable

        sale = self.create_sale()
        sale.salesperson = salesperson
        sale.add_sellable(sellable, quantity=1)

        self.create_storable(product, get_current_branch(self.store), stock=100)

        CommissionSource(sellable=sellable,
                         direct_value=Decimal(10),
                         installments_value=1,
                         store=self.store)

        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        till = Till.get_last_opened(self.store)
        method.create_inpayment(sale.group, sale.branch,
                                sale.get_sale_subtotal(),
                                till=till)
        sale.confirm()
        sale.set_paid()

        salesperson_name = salesperson.person.name
        commissions = list(self.store.find(CommissionView))
        commissions[0].identifier = 1
        commissions[1].identifier = 139

        self._diff_expected(SalesPersonReport, 'sales-person-report', commissions,
                            salesperson_name)
开发者ID:romaia,项目名称:stoq,代码行数:36,代码来源:test_reporting.py

示例2: close_till

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def close_till(self, close_db=True, close_ecf=True):
        """Closes the till

        There are 3 possibilities for parameters combination:
          * *total close*: Both *close_db* and *close_ecf* are ``True``.
            The till on both will be closed.
          * *partial close*: Both *close_db* and *close_ecf* are ``False``.
            It's more like a till verification. The actual user will do it
            to check and maybe remove money from till, leaving it ready
            for the next one. Note that this will not emit
            'till-status-changed' event, since the till will not
            really close.
          * *fix conflicting status*: *close_db* and *close_ecf* are
            different. Use this only if you need to fix a conflicting
            status, like if the DB is open but the ECF is closed, or
            the other way around.

        :param close_db: If the till in the DB should be closed
        :param close_ecf: If the till in the ECF should be closed
        :returns: True if the till was closed, otherwise False
        """
        is_partial = not close_db and not close_ecf
        manager = get_plugin_manager()

        # This behavior is only because of ECF
        if not is_partial and not self._previous_day:
            if (manager.is_active('ecf') and
                not yesno(_("You can only close the till once per day. "
                            "You won't be able to make any more sales today.\n\n"
                            "Close the till?"),
                          Gtk.ResponseType.NO, _("Close Till"), _("Not now"))):
                return
        elif not is_partial:
            # When closing from a previous day, close only what is needed.
            close_db = self._close_db
            close_ecf = self._close_ecf

        if close_db:
            till = Till.get_last_opened(self.store)
            assert till

        store = api.new_store()
        editor_class = TillVerifyEditor if is_partial else TillClosingEditor
        model = run_dialog(editor_class, self._parent, store,
                           previous_day=self._previous_day, close_db=close_db,
                           close_ecf=close_ecf)

        if not model:
            store.confirm(model)
            store.close()
            return

        # TillClosingEditor closes the till
        retval = store.confirm(model)
        store.close()
        if retval and not is_partial:
            self._till_status_changed(closed=True, blocked=False)

        return retval
开发者ID:hackedbellini,项目名称:stoq,代码行数:61,代码来源:fiscalprinter.py

示例3: test_till_open_other_station

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def test_till_open_other_station(self):
        till = Till(station=self.create_station(), store=self.store)
        till.open_till()

        till = Till(station=get_current_station(self.store), store=self.store)
        till.open_till()

        self.assertEqual(Till.get_last_opened(self.store), till)
开发者ID:rg3915,项目名称:stoq,代码行数:10,代码来源:test_till.py

示例4: test_till_daily_movement

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def test_till_daily_movement(self):
        date = datetime.date(2013, 1, 1)
        # create sale payment
        sale = self.create_sale()
        sellable = self.create_sellable()
        sale.add_sellable(sellable, price=100)
        sale.identifier = 1000
        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        till = Till.get_last_opened(self.store)
        payment = method.create_payment(Payment.TYPE_IN, sale.group, sale.branch,
                                        sale.get_sale_subtotal(),
                                        till=till)
        sale.confirm()
        sale.group.pay()

        sale.confirm_date = date

        payment.identifier = 1010
        payment.paid_date = date

        # create lonely input payment
        payer = self.create_client()
        address = self.create_address()
        address.person = payer.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        group = self.create_payment_group()
        branch = self.create_branch()
        payment_lonely_input = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(100))
        payment_lonely_input.description = u"Test receivable account"
        payment_lonely_input.group.payer = payer.person
        payment_lonely_input.set_pending()
        payment_lonely_input.pay()
        payment_lonely_input.identifier = 1001
        payment_lonely_input.paid_date = date

        # create purchase payment
        drawee = self.create_supplier()
        address = self.create_address()
        address.person = drawee.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        group = self.create_payment_group()
        branch = self.create_branch()
        payment = method.create_payment(Payment.TYPE_OUT, group, branch, Decimal(100))
        payment.description = u"Test payable account"
        payment.group.recipient = drawee.person
        payment.set_pending()
        payment.pay()
        payment.identifier = 1002
        payment.paid_date = date

        # create lonely output payment
        self._diff_expected(TillDailyMovementReport,
                            'till-daily-movement-report', self.store, date)
开发者ID:rosalin,项目名称:stoq,代码行数:59,代码来源:test_reporting.py

示例5: test_till_open_yesterday

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    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)
开发者ID:rg3915,项目名称:stoq,代码行数:17,代码来源:test_till.py

示例6: on_confirm

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def on_confirm(self):
        till = self.model.till
        # Using api.get_default_store instead of self.store
        # or it will return self.model.till
        last_opened = Till.get_last_opened(api.get_default_store())
        if (last_opened and
            last_opened.opening_date.date() == till.opening_date.date()):
            warning(_("A till was opened earlier this day."))
            self.retval = False
            return

        try:
            TillOpenEvent.emit(till=till)
        except (TillError, DeviceError), e:
            warning(str(e))
            self.retval = False
            return
开发者ID:romaia,项目名称:stoq,代码行数:19,代码来源:tilleditor.py

示例7: test_till_daily_movement

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def test_till_daily_movement(self):
        date = datetime.date(2013, 1, 1)
        # create sale payment
        sale = self.create_sale()
        sellable = self.create_sellable()
        sale.add_sellable(sellable, price=100)
        sale.identifier = 1000
        sale.order()

        till = Till.get_last_opened(self.store)
        device = self.create_card_device(description=u"MAQ1")
        provider = self.create_credit_provider(u"PRO1")
        credit_card = self.create_credit_card_data(
            device=device, provider=provider, payment_type=Payment.TYPE_IN, payment_value=sale.get_sale_subtotal()
        )
        credit_card.auth = 1234
        payment = credit_card.payment
        payment.group = sale.group
        payment.branch = sale.branch
        payment.till = till
        sale.confirm()
        sale.group.pay()

        sale.confirm_date = date

        payment.identifier = 1010
        payment.paid_date = date

        # create lonely input payment
        payer = self.create_client()
        address = self.create_address()
        address.person = payer.person

        method = PaymentMethod.get_by_name(self.store, u"money")
        group = self.create_payment_group()
        branch = self.create_branch()
        payment_lonely_input = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(100))
        payment_lonely_input.description = u"Test receivable account"
        payment_lonely_input.group.payer = payer.person
        payment_lonely_input.set_pending()
        payment_lonely_input.pay()
        payment_lonely_input.identifier = 1001
        payment_lonely_input.paid_date = date

        # create purchase payment
        drawee = self.create_supplier()
        address = self.create_address()
        address.person = drawee.person

        method = PaymentMethod.get_by_name(self.store, u"money")
        purchase = self.create_purchase_order()
        purchase.identifier = 12345
        branch = self.create_branch()
        payment = method.create_payment(Payment.TYPE_OUT, purchase.group, branch, Decimal(100))
        payment.description = u"Test payable account"
        payment.group.recipient = drawee.person
        payment.set_pending()
        payment.pay()
        payment.identifier = 1002
        payment.paid_date = date

        # create sale payment
        sale = self.create_sale()
        self.add_product(sale)
        self.add_product(sale)
        self.add_payments(sale)
        sale.order()
        sale.confirm()
        sale.identifier = 23456
        returned_sale = sale.create_sale_return_adapter()
        returned_sale.return_()
        sale.return_date = date

        payment = returned_sale.group.get_items()[1]
        payment.branch = branch
        payment.till = till
        payment.identifier = 1003
        payment.pay()
        payment.paid_date = date

        # create lonely output payment
        group = self.create_payment_group()
        method = PaymentMethod.get_by_name(self.store, u"money")
        payment = method.create_payment(Payment.TYPE_OUT, group, branch, Decimal(100))
        payment.branch = branch
        payment.till = till
        payment.identifier = 1004
        payment.paid_date = date
        payment.status = Payment.STATUS_PAID

        self._diff_expected(TillDailyMovementReport, "till-daily-movement-report", self.store, date)

        end_date = datetime.date(2013, 6, 1)
        self._diff_expected(TillDailyMovementReport, "till-daily-movement-report-end", self.store, date, end_date)
开发者ID:rg3915,项目名称:stoq,代码行数:96,代码来源:test_reporting.py

示例8: test_till_daily_movement

# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_last_opened [as 别名]
    def test_till_daily_movement(self):
        branch = get_current_branch(self.store)
        branch2 = self.store.find(Branch, Branch.id != branch.id).any()

        # Data used to create the examples
        till = Till.get_last_opened(self.store)
        device = self.create_card_device(description=u'MAQ1')
        provider = self.create_credit_provider(u'PRO1')
        date = datetime.date(2013, 1, 1)

        # First, create one sale
        sale = self.create_sale(branch=branch)
        sellable = self.create_sellable()
        sale.add_sellable(sellable, price=100)
        sale.identifier = 1000
        sale.order()

        # With two card payments
        card_data1 = self.create_credit_card_data(
            device=device,
            provider=provider,
            payment_type=Payment.TYPE_IN,
            payment_value=sale.get_sale_subtotal())
        card_data1.auth = 1234
        card_data1.card_type = CreditCardData.TYPE_CREDIT
        card_data1.payment.group = sale.group
        card_data1.payment.branch = sale.branch
        card_data1.payment.till = till
        card_data1.payment.identifier = 1010

        card_data2 = self.create_credit_card_data(
            device=device,
            provider=provider,
            payment_type=Payment.TYPE_IN,
            payment_value=sale.get_sale_subtotal())
        card_data2.auth = 1234
        card_data2.card_type = CreditCardData.TYPE_DEBIT

        card_data2.payment.group = sale.group
        card_data2.payment.branch = sale.branch
        card_data2.payment.till = till
        card_data2.payment.identifier = 1011

        # Confirm the sale and pay the payments
        sale.confirm()
        sale.group.pay()

        sale.confirm_date = date

        # After calling sale.group.pay(), we need to fix the paid_date
        card_data1.payment.paid_date = date
        card_data2.payment.paid_date = date

        # create lonely input payment
        payer = self.create_client()
        address = self.create_address()
        address.person = payer.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        group = self.create_payment_group()
        payment_lonely_input = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(100))
        payment_lonely_input.description = u"Test receivable account"
        payment_lonely_input.group.payer = payer.person
        payment_lonely_input.set_pending()
        payment_lonely_input.pay()
        payment_lonely_input.identifier = 1001
        payment_lonely_input.paid_date = date

        # create purchase payment
        drawee = self.create_supplier()
        address = self.create_address()
        address.person = drawee.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        purchase = self.create_purchase_order(branch=branch)
        purchase.identifier = 12345
        payment = method.create_payment(Payment.TYPE_OUT,
                                        purchase.group, branch, Decimal(100))
        payment.description = u"Test payable account"
        payment.group.recipient = drawee.person
        payment.set_pending()
        payment.pay()
        payment.identifier = 1002
        payment.paid_date = date

        # Create a returned sale
        sale = self.create_sale(branch=branch)
        self.add_product(sale)
        self.add_product(sale)
        payment = self.add_payments(sale, date=date)[0]
        sale.order()
        sale.confirm()
        sale.identifier = 23456
        returned_sale = sale.create_sale_return_adapter()
        returned_sale.return_()
        sale.return_date = date
        payment.paid_date = date

        payment = returned_sale.group.get_items()[1]
        payment.branch = branch
#.........这里部分代码省略.........
开发者ID:Joaldino,项目名称:stoq,代码行数:103,代码来源:test_reporting.py


注:本文中的stoqlib.domain.till.Till.get_last_opened方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。