• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python dateutils.localtoday函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stoqlib.lib.dateutils.localtoday函数的典型用法代码示例。如果您正苦于以下问题:Python localtoday函数的具体用法?Python localtoday怎么用?Python localtoday使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_show

    def test_show(self, run_dialog):
        optical = self.create_optical_work_order()
        optical.medic = self.create_optical_medic()

        sale = self.create_sale()
        sale.identifier = 99413

        workorder = optical.work_order
        workorder.sale = sale

        sellable = self.create_sellable()
        sale_item = sale.add_sellable(sellable)
        wo_item = self.create_work_order_item(order=workorder)
        wo_item.sale_item = sale_item
        self.add_payments(sale)
        sale.order()
        sale.confirm()
        sale.open_date = localtoday()
        sale.confirm_date = localtoday()

        search = MedicSalesSearch(self.store)
        search._date_filter.select(data=Any)
        search.search.refresh()
        self.check_search(search, 'optical-medic-sales-search')

        search.results.select(search.results[0])
        self.click(search.sale_details_button)

        self.assertEquals(run_dialog.call_count, 1)
        self.assertEquals(run_dialog.call_args[0][0], SaleDetailsDialog)
        self.assertEquals(run_dialog.call_args[0][1], search)
        self.assertEquals(run_dialog.call_args[0][2], self.store)
        self.assertEquals(run_dialog.call_args[0][3].id, sale.id)
开发者ID:Guillon88,项目名称:stoq,代码行数:33,代码来源:test_optical_search.py


示例2: test_price

    def test_price(self):
        p1 = self.create_product()
        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        pv = results[0]
        self.assertEquals(pv.price, 10)

        # Set a sale price
        sellable = p1.sellable
        sellable.on_sale_price = Decimal("5.55")

        # And a interval that includes today
        yesterday = localtoday() - datetime.timedelta(days=1)
        tomorrow = localtoday() + datetime.timedelta(days=1)
        sellable.on_sale_start_date = yesterday
        sellable.on_sale_end_date = tomorrow

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, Decimal("5.55"))

        # Testing with a sale price set, but in the past
        date1 = localtoday() - datetime.timedelta(days=10)
        date2 = localtoday() - datetime.timedelta(days=5)
        sellable.on_sale_start_date = date1
        sellable.on_sale_end_date = date2

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, 10)
开发者ID:rg3915,项目名称:stoq,代码行数:28,代码来源:test_views.py


示例3: testPrice

    def testPrice(self):
        branch = self.create_branch()
        p1 = self.create_product(branch=branch, stock=1, price=Decimal('10.15'))
        results = SellableFullStockView.find_by_branch(self.store, branch).find(
            SellableFullStockView.product_id == p1.id)
        self.failUnless(list(results))

        self.assertEquals(results[0].price, Decimal('10.15'))

        # Set a sale price
        sellable = p1.sellable
        sellable.on_sale_price = Decimal('5.55')

        # And a interval that includes today
        yesterday = localtoday().date() - datetime.timedelta(days=1)
        tomorrow = localtoday().date() + datetime.timedelta(days=1)
        sellable.on_sale_start_date = yesterday
        sellable.on_sale_end_date = tomorrow

        results = SellableFullStockView.find_by_branch(self.store, branch).find(
            SellableFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, Decimal('5.55'))

        # Testing with a sale price set, but in the past
        date1 = localtoday().date() - datetime.timedelta(days=10)
        date2 = localtoday().date() - datetime.timedelta(days=5)
        sellable.on_sale_start_date = date1
        sellable.on_sale_end_date = date2

        results = SellableFullStockView.find_by_branch(self.store, branch).find(
            SellableFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, Decimal('10.15'))
开发者ID:marianaanselmo,项目名称:stoq,代码行数:32,代码来源:test_views.py


示例4: test_show

    def test_show(self):
        stock_transaction = self.create_stock_transaction_history()
        entry = self.create_cost_center_entry(stock_transaction=stock_transaction)
        cost_center = entry.cost_center
        sale_item = self.create_sale_item()
        sale = sale_item.sale
        stock_decrease = self.create_stock_decrease()
        # The decrease needs an item to be shown in the dialog
        self.create_stock_decrease_item(stock_decrease=stock_decrease)

        stock_transaction.type = StockTransactionHistory.TYPE_SELL
        stock_transaction.object_id = sale_item.id
        stock_transaction.date = localtoday().date()
        stock_transaction.quantity = 5
        stock_transaction.stock_cost = currency('10.50')

        entry.stock_transaction = stock_transaction

        sale.cost_center = cost_center
        sale.identifier = 1234
        sale.open_date = localtoday().date()
        sale.total_amount = sale.get_total_sale_amount()

        stock_decrease.cost_center = cost_center
        stock_decrease.identifier = 5678
        stock_decrease.confirm_date = localtoday().date()

        dialog = CostCenterDialog(self.store, cost_center)
        self.check_dialog(dialog, 'dialog-cost-center-details')
开发者ID:Guillon88,项目名称:stoq,代码行数:29,代码来源:test_costcenterdialog.py


示例5: _create_payment

    def _create_payment(self):
        group = PaymentGroup()
        group.payer = self.client.person

        method = PaymentMethod.get_by_name(self.store, u'credit')
        branch = api.get_current_branch(self.store)

        if self.model.value < 0:
            payment_type = Payment.TYPE_IN
        else:
            payment_type = Payment.TYPE_OUT

        # Set status to PENDING now, to avoid calling set_pending on
        # on_confirm for payments that shoud not have its status changed.
        payment = Payment(open_date=localtoday(),
                          branch=branch,
                          status=Payment.STATUS_PENDING,
                          description=self.model.description,
                          value=abs(self.model.value),
                          base_value=abs(self.model.value),
                          due_date=localtoday(),
                          method=method,
                          group=group,
                          till=None,
                          category=None,
                          payment_type=payment_type,
                          bill_received=False)
        payment.pay()

        return payment
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:30,代码来源:crediteditor.py


示例6: __init__

 def __init__(self, source_branch):
     self.items = []
     self.open_date = localtoday().date()
     self.receival_date = localtoday().date()
     self.source_branch = source_branch
     self.destination_branch = None
     self.source_responsible = None
     self.destination_responsible = None
开发者ID:leandrorchaves,项目名称:stoq,代码行数:8,代码来源:stocktransferwizard.py


示例7: test_get_days_late

    def test_get_days_late(self):
        payment = self.create_payment(payment_type=Payment.TYPE_IN)
        view = self.store.find(InPaymentView, id=payment.id).one()
        self.assertFalse(view.get_days_late())

        payment.due_date = localtoday() + datetime.timedelta(-4)
        view = self.store.find(InPaymentView, id=payment.id).one()
        self.assertEquals(view.get_days_late(), 4)

        payment.due_date = localtoday() + datetime.timedelta(+4)
        view = self.store.find(InPaymentView, id=payment.id).one()
        self.assertFalse(view.get_days_late())
开发者ID:dionimf,项目名称:stoq,代码行数:12,代码来源:test_views.py


示例8: on_close_date__validate

    def on_close_date__validate(self, widget, date):
        if sysparam(self.store).ALLOW_OUTDATED_OPERATIONS:
            return

        if date > localtoday().date() or date < self.model.open_date:
            return ValidationError(_("Paid date must be between "
                                     "%s and today") % (self.model.open_date, ))
开发者ID:LeonamSilva,项目名称:stoq,代码行数:7,代码来源:paymentconfirmslave.py


示例9: on_estimated_start__validate

    def on_estimated_start__validate(self, widget, value):
        sysparam_ = api.sysparam(self.store)
        if (value < localtoday().date() and
                not sysparam_.ALLOW_OUTDATED_OPERATIONS):
            return ValidationError(u"The start date cannot be on the past")

        self.estimated_finish.validate(force=True)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:7,代码来源:workorderslave.py


示例10: _populate_date_filter

    def _populate_date_filter(self, date_filter):
        # The options we want to show to the users are the following:
        #   'May 2007'
        #   'June 2007'
        #   ...
        #   'September 2008'

        initial_date = self.store.find(SystemTable).min(
            SystemTable.updated).date()

        # Start is the first day of the month
        # End is the last day of the month
        start = initial_date + relativedelta(day=1)
        end = localtoday().date() + relativedelta(day=31)
        intervals = []
        while start < end:
            intervals.append((start, start + relativedelta(day=31)))
            start = start + relativedelta(months=1)

        # When we have the list of intervals, add them to the list and
        # make sure that they are translated
        month_names = get_month_names()
        for start, end in intervals:
            # Translators: Do not translate 'month' and 'year'. You can
            #              change it's positions. In the way it is,
            #              it will product for example 'December 2012'
            name = _('{month} {year}').format(
                month=month_names[start.month - 1],
                year=start.year)
            date_filter.add_option_fixed_interval(
                name, start, end, position=0)
开发者ID:tmaxter,项目名称:stoq,代码行数:31,代码来源:sintegradialog.py


示例11: testChangeDueDateSale

    def testChangeDueDateSale(self, warning):
        sale = self.create_sale()
        sale.client = self.create_client()
        sale.identifier = 9123
        payment = self.add_payments(sale, date=localdate(2001, 1, 1).date())[0]
        editor = PaymentDueDateChangeDialog(self.store, payment, sale)
        self.check_editor(editor, 'editor-payment-change-due-date-sale')

        today = localtoday().date()
        yesterday = today - relativedelta(days=1)

        # By default, we cannot set a due date to the past
        editor.due_date.update(yesterday)
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])

        # Now we should be able to confirm the dialog
        editor.due_date.update(today)
        self.assertSensitive(editor.main_dialog, ['ok_button'])

        # Ok button is enabled, but should show a warning
        self.click(editor.main_dialog.ok_button)
        warning.assert_called_once_with('You can not change the due date '
                                        'without a reason!')
        warning.reset_mock()

        editor.change_reason.update('Just because')
        self.click(editor.main_dialog.ok_button)
        self.assertEquals(warning.call_count, 0)

        self.assertEquals(payment.due_date.date(), today)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:30,代码来源:test_paymentchangedialog.py


示例12: test_can_remove

    def test_can_remove(self):
        product = self.create_product()
        test = ProductQualityTest(store=self.store, product=product)

        # Test has never been used
        self.assertTrue(test.can_remove())

        order = self.create_production_order()
        user = self.create_user()
        item = ProductionProducedItem(product=product,
                                      order=order,
                                      produced_by=user,
                                      produced_date=localtoday().date(),
                                      serial_number=1,
                                      store=self.store)
        self.assertTrue(test.can_remove())

        # Test has been used in a production
        ProductionItemQualityResult(produced_item=item,
                                    quality_test=test,
                                    tested_by=user,
                                    result_value=u'True',
                                    test_passed=True,
                                    store=self.store)
        self.assertFalse(test.can_remove())
开发者ID:LeonamSilva,项目名称:stoq,代码行数:25,代码来源:test_product.py


示例13: test_has_late_payments

    def test_has_late_payments(self):
        client = self.create_client()
        today = localtoday().date()
        method = PaymentMethod.get_by_name(self.store, u'bill')

        # client does not have any payments
        self.assertFalse(InPaymentView.has_late_payments(self.store,
                                                         client.person))

        # client has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN,
                                      today + relativedelta(days=1),
                                      method=method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertFalse(InPaymentView.has_late_payments(self.store,
                                                         client.person))

        # client has overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=2),
                                      method=method)
        payment.status = Payment.STATUS_PENDING
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(InPaymentView.has_late_payments(self.store,
                                                        client.person))
开发者ID:leandrorchaves,项目名称:stoq,代码行数:27,代码来源:test_payment_views.py


示例14: test_select_by_branch_data

    def test_select_by_branch_data(self):
        branch = get_current_branch(self.store)
        sale = self.create_sale()
        sale.branch = branch
        sellable = self.add_product(sale)
        sale.order()
        self.add_payments(sale, method_type=u"money")
        sale.confirm()

        results = SoldItemView.find_by_branch_date(self.store, None, None)
        self.assertFalse(results.is_empty())

        results = SoldItemView.find_by_branch_date(self.store, branch, None)
        self.assertFalse(results.is_empty())

        results = SoldItemView.find_by_branch_date(self.store, branch, None).find(SoldItemView.id == sellable.id)
        # FIXME: Storm does not support count() with group_by
        # self.assertEquals(results.count(), 1)
        self.assertEquals(len(list(results)), 1)

        today = localtoday()
        results = SoldItemView.find_by_branch_date(self.store, None, today).find(SoldItemView.id == sellable.id)
        self.assertEquals(len(list(results)), 1)

        yesterday = today - datetime.timedelta(days=1)
        results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))
        results = results.find(SoldItemView.id == sellable.id)
        self.assertEquals(len(list(results)), 1)

        yesterday = today - datetime.timedelta(days=1)
        results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))

        self.assertFalse(results.is_empty())
开发者ID:rg3915,项目名称:stoq,代码行数:33,代码来源:test_views.py


示例15: testCreate

    def testCreate(self):
        person = self.create_person()
        editor = CallsEditor(self.store, None, person, None)
        self.assertTrue(isinstance(editor.model, Calls))
        editor.date.update(localtoday().date())

        self.check_editor(editor, 'editor-calls-create')
开发者ID:leandrorchaves,项目名称:stoq,代码行数:7,代码来源:test_calls_editor.py


示例16: open_till

    def open_till(self):
        """Open the till.

        It can only be done once per day.
        The final cash amount of the previous till will be used
        as the initial value in this one after opening it.
        """
        if self.status == Till.STATUS_OPEN:
            raise TillError(_('Till is already open'))

        # Make sure that the till has not been opened today
        today = localtoday().date()
        if not self.store.find(Till,
                               And(Date(Till.opening_date) >= today,
                                   Till.station_id == self.station.id)).is_empty():
            raise TillError(_("A till has already been opened today"))

        last_till = self._get_last_closed_till()
        if last_till:
            if not last_till.closing_date:
                raise TillError(_("Previous till was not closed"))

            initial_cash_amount = last_till.final_cash_amount
        else:
            initial_cash_amount = 0

        self.initial_cash_amount = initial_cash_amount

        self.opening_date = TransactionTimestamp()
        self.status = Till.STATUS_OPEN
开发者ID:rosalin,项目名称:stoq,代码行数:30,代码来源:till.py


示例17: test_confirm

    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client.update(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            self.click(wizard.next_button)
            self.assertEquals(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

        yesno.assert_called_once_with(_('Would you like to print the receipt now?'),
                                      gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)
开发者ID:rosalin,项目名称:stoq,代码行数:34,代码来源:test_loanwizard.py


示例18: test_can_purchase_allow_all

    def test_can_purchase_allow_all(self):
        #: This parameter always allows the client to purchase, no matter if he
        #: has late payments
        sysparam(self.store).update_parameter(u'LATE_PAYMENTS_POLICY',
                                              unicode(int(LatePaymentPolicy.ALLOW_SALES)))

        client = self.create_client()
        bill_method = PaymentMethod.get_by_name(self.store, u'bill')
        check_method = PaymentMethod.get_by_name(self.store, u'check')
        money_method = PaymentMethod.get_by_name(self.store, u'money')
        store_credit_method = PaymentMethod.get_by_name(self.store,
                                                        u'store_credit')
        today = localtoday()

        # client can pay if he doesn't have any payments
        client.credit_limit = Decimal("1000")
        self.assertTrue(client.can_purchase(money_method, currency("200")))

        # client can pay if he has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN, today, method=bill_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(check_method, currency("200")))

        # client can pay even if he does have overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=1), method=check_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(store_credit_method, currency("200")))

        # But he cannot pay if its above the credit limit
        self.assertRaises(SellError, client.can_purchase, store_credit_method, currency("1001"))
开发者ID:rosalin,项目名称:stoq,代码行数:33,代码来源:test_person.py


示例19: test_show

    def test_show(self):
        today = localtoday().date()
        client = self.create_client()
        # Nova venda
        sale = self.create_sale()
        sale.identifier = 123
        sale.client = client
        sale.open_date = today

        # Product
        sellable = self.create_sellable(description=u'Normal',
                                        storable=True, price=100)
        sale.add_sellable(sellable)
        # Service
        sellable2 = self.create_sellable(description=u'Service', product=False,
                                         price=100)
        item = sale.add_sellable(sellable2)
        item.estimated_fix_date = today
        # Payments
        payment = self.add_payments(sale, date=today)[0]
        payment.identifier = 999
        payment.group.payer = client.person
        # Call
        self.create_call(client.person)

        dialog = ClientDetailsDialog(self.store, client)
        self.check_editor(dialog, 'dialog-client-details')
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:27,代码来源:test_client_details.py


示例20: test_can_purchase_disallow_store_credit

    def test_can_purchase_disallow_store_credit(self):
        #: This parameter disallows the client to purchase with store credit
        #: when he has late payments
        sysparam(self.store).update_parameter(u'LATE_PAYMENTS_POLICY',
                                              unicode(int(LatePaymentPolicy.DISALLOW_STORE_CREDIT)))

        client = self.create_client()
        bill_method = PaymentMethod.get_by_name(self.store, u'bill')
        check_method = PaymentMethod.get_by_name(self.store, u'check')
        money_method = PaymentMethod.get_by_name(self.store, u'money')
        store_credit_method = PaymentMethod.get_by_name(self.store,
                                                        u'store_credit')
        today = localtoday()

        # client can pay if he doesn't have any payments
        self.assertTrue(client.can_purchase(money_method, currency("0")))

        # client can pay if he has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN, today, method=bill_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(money_method, currency("0")))

        # for a client with overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=1),
                                      method=money_method)
        payment.status = Payment.STATUS_PENDING
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        # client can pay if payment method is not store credit
        self.assertTrue(client.can_purchase(check_method, currency("0")))
        self.assertTrue(client.can_purchase(money_method, currency("0")))
        # client can not pay if payment method is store credit
        self.assertRaises(SellError, client.can_purchase, store_credit_method, currency("0"))
开发者ID:rosalin,项目名称:stoq,代码行数:35,代码来源:test_person.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python defaults.quantize函数代码示例发布时间:2022-05-27
下一篇:
Python dateutils.localnow函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap