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

Python dateutils.localdate函数代码示例

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

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



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

示例1: test_find_pending

    def test_find_pending(self):
        wo1 = self.create_workorder()
        wo1.status = WorkOrder.STATUS_OPENED
        wo2 = self.create_workorder()
        wo2.status = WorkOrder.STATUS_WORK_WAITING
        wo3 = self.create_workorder()
        wo3.status = WorkOrder.STATUS_WORK_IN_PROGRESS
        wo4 = self.create_workorder()
        wo4.status = WorkOrder.STATUS_WORK_FINISHED
        # Those 2 should not appear on the results
        wo5 = self.create_workorder()
        wo5.status = WorkOrder.STATUS_DELIVERED
        wo6 = self.create_workorder()
        wo6.status = WorkOrder.STATUS_CANCELLED

        work_orders = set(wov.work_order for wov in WorkOrderView.find_pending(self.store))
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))

        wo1.estimated_finish = localdate(2013, 1, 1)
        wo2.estimated_finish = localdate(2013, 2, 1)
        wo3.estimated_finish = localdate(2013, 3, 1)
        wo4.estimated_finish = localdate(2013, 4, 1)
        wo5.estimated_finish = localdate(2013, 1, 1)
        wo6.estimated_finish = localdate(2013, 2, 1)

        # Filtering by start date only
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, start_date=localdate(2013, 1, 1))
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, start_date=localdate(2013, 1, 2))
        )
        self.assertEqual(work_orders, set([wo2, wo3, wo4]))

        # Filtering by end date only
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, end_date=localdate(2013, 1, 2))
        )
        self.assertEqual(work_orders, set([wo1]))
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, end_date=localdate(2013, 4, 2))
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))

        # Filtering by both start and end dates
        work_orders = set(
            wov.work_order
            for wov in WorkOrderView.find_pending(
                self.store, start_date=localdate(2013, 1, 1), end_date=localdate(2013, 4, 2)
            )
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))
        work_orders = set(
            wov.work_order
            for wov in WorkOrderView.find_pending(
                self.store, start_date=localdate(2013, 3, 1), end_date=localdate(2013, 4, 2)
            )
        )
        self.assertEqual(work_orders, set([wo3, wo4]))
开发者ID:amaurihamasu,项目名称:stoq,代码行数:60,代码来源:test_workorder.py


示例2: test_confirm

    def test_confirm(self):
        editor = OutPaymentEditor(self.store)
        self.assertFalse(editor.validate_confirm())
        editor.description.update('Payment name')
        self.assertFalse(editor.validate_confirm())

        editor.value.update(100)
        self.assertFalse(editor.validate_confirm())

        editor.due_date.update(localdate(2015, 1, 1).date())
        self.assertTrue(editor.validate_confirm())

        editor.repeat.update(INTERVALTYPE_WEEK)
        self.assertFalse(editor.validate_confirm())

        editor.end_date.update(localdate(2014, 1, 10).date())
        self.assertFalse(editor.validate_confirm())

        editor.end_date.update(localdate(2015, 1, 10).date())
        self.assertTrue(editor.validate_confirm())

        editor.main_dialog.confirm()

        model = editor.retval
        self.check_editor(editor, 'editor-payment-confirm',
                          [model.group] + list(model.group.payments))
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:26,代码来源:test_payment_editor.py


示例3: _create_domain

    def _create_domain(self):
        branch = get_current_branch(self.store)
        sale = self.create_sale(branch=branch)
        sale_item = self.create_sale_item(sale=sale)
        sale_item.quantity = 66
        sale_item.quantity_decreased = 23
        sale_item.sellable.description = u'Schrubbery'
        sale_item.sale.identifier = 42
        sale.status = sale.STATUS_ORDERED
        sale.open_date = localdate(2013, 12, 11)

        sale2 = self.create_sale(branch=branch)
        sale_item2 = self.create_sale_item(sale=sale2)
        sale_item2.quantity = 29
        sale_item2.quantity_decreased = 29
        sale_item2.sellable.description = u'Holy Grail'
        sale_item2.sale.identifier = 73
        sale2.open_date = localdate(2013, 12, 11)
        sale2.status = sale2.STATUS_QUOTE

        self.branch2 = self.create_branch(u'The Meaning of Life')
        sale3 = self.create_sale(branch=self.branch2)
        sale_item3 = self.create_sale_item(sale=sale3)
        sale_item3.quantity = 41
        sale_item3.quantity_decreased = 1
        sale_item3.sellable.description = u'The Funniest Joke in this Code'
        sale_item3.sale.identifier = 99
        sale3.open_date = localdate(2013, 12, 11)
        sale3.status = sale3.STATUS_QUOTE
开发者ID:pkaislan,项目名称:stoq,代码行数:29,代码来源:test_salessearch.py


示例4: test_estimated_finish

 def test_estimated_finish(self, localtoday_):
     workorder = self.create_workorder()
     slave = WorkOrderOpticalSlave(self.store, workorder)
     localtoday_.return_value = localdate(2014, 1, 1)
     res = slave.estimated_finish.emit("validate", localdate(2013, 1, 1))
     self.assertEquals(unicode(res),
                       u'Estimated finish date cannot be in the past.')
开发者ID:Joaldino,项目名称:stoq,代码行数:7,代码来源:test_optical_slave.py


示例5: test_get_birthday_date_query

    def test_get_birthday_date_query(self):
        start = localdate(2000, 3, 4)

        query = Individual.get_birthday_query(start)

        start_year = DateTrunc(u'year', Date(start))
        age_in_year = Age(Individual.birth_date,
                          DateTrunc(u'year', Individual.birth_date))
        test_query = (
            start_year + age_in_year +
            Case(condition=age_in_year < Age(Date(start), start_year),
                 result=Interval(u'1 year'),
                 else_=Interval(u'0 year'))
        )
        test_query = (test_query == Date(start))

        self.assertEquals(query, test_query)

        individuals = list(self.store.find(Individual, test_query))
        self.assertEquals(len(individuals), 0)

        client1 = self.create_client(u'Junio C. Hamano')
        client1.person.individual.birth_date = localdate(1972, 10, 15)
        client2 = self.create_client(u'Richard Stallman')
        client2.person.individual.birth_date = localdate(1989, 3, 4)
        client3 = self.create_client(u'Linus Torvalds')
        client3.person.individual.birth_date = localdate(2000, 3, 4)
        client4 = self.create_client(u'Guido van Rossum')
        client4.person.individual.birth_date = localdate(2005, 3, 4)

        individuals = list(self.store.find(Individual, test_query))
        self.assertEquals(len(individuals), 3)
        self.assertTrue(client2.person.individual in individuals)
        self.assertTrue(client3.person.individual in individuals)
        self.assertTrue(client4.person.individual in individuals)
开发者ID:rosalin,项目名称:stoq,代码行数:35,代码来源:test_person.py


示例6: _create_domain

    def _create_domain(self):
        address = self.create_address()
        service_item = self.create_sale_item()
        service_item.sale.identifier = 10
        service_item.sale.status = Sale.STATUS_CONFIRMED
        transporter = self.create_transporter(name=u'Hall')
        delivery = Delivery(transporter=transporter,
                            address=address,
                            invoice=service_item.sale.invoice,
                            open_date=localdate(2012, 1, 1).date(),
                            store=self.store)
        delivery.tracking_code = u'45'

        service_item = self.create_sale_item()
        service_item.sale.identifier = 20
        service_item.sale.status = Sale.STATUS_CONFIRMED
        transporter = self.create_transporter(name=u'Torvalds')
        delivery = Delivery(transporter=transporter,
                            address=address,
                            invoice=service_item.sale.invoice,
                            open_date=localdate(2012, 2, 2).date(),
                            send_date=localdate(2012, 3, 3).date(),
                            receive_date=localdate(2012, 4, 4).date(),
                            store=self.store)
        delivery.tracking_code = u'78'
        delivery.status = Delivery.STATUS_RECEIVED
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:test_deliverysearch.py


示例7: test_send

    def test_send(self, localnow):
        localnow.return_value = localdate(2013, 1, 1)

        package = self.create_workorder_package()
        package.destination_branch = self.create_branch()
        workorder1 = self.create_workorder()
        workorder2 = self.create_workorder()

        with mock.patch('stoqlib.domain.workorder.get_current_branch') as gcb:
            gcb.return_value = self.create_branch()
            with self.assertRaisesRegexp(
                    ValueError,
                    ("This package's source branch is <Branch u'[0-9a-f-]+'> "
                     "and you are in <Branch u'[0-9a-f-]+'>. It's not possible "
                     "to send a package outside the source branch")):
                package.send()

        with self.assertRaisesRegexp(
                ValueError, "There're no orders to send"):
            package.send()

        for order in [workorder1, workorder2]:
            self.assertNotEqual(order.branch, None)
            self.assertEqual(order.branch, order.current_branch)
            package.add_order(order)

        self.assertEqual(package.status, WorkOrderPackage.STATUS_OPENED)
        self.assertEqual(package.send_date, None)
        package.send()
        self.assertEqual(package.status, WorkOrderPackage.STATUS_SENT)
        self.assertEqual(package.send_date, localdate(2013, 1, 1))

        for order in [workorder1, workorder2]:
            self.assertEqual(order.current_branch, None)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:34,代码来源:test_workorder.py


示例8: _create_domain

    def _create_domain(self):
        self.clean_domain([Commission, SaleItem, Sale])

        branches = self.store.find(Branch)

        sale = self.create_sale(branch=branches[0])
        sale_item = self.create_sale_item(sale=sale)
        self.create_storable(sale_item.sellable.product, branches[0], 10)
        self.create_payment(payment_type=Payment.TYPE_IN, group=sale.group)
        sale.order()
        sale.confirm()
        sale_item.sellable.code = u'1'
        sale_item.sellable.description = u'Luvas'
        sale.open_date = localdate(2012, 1, 1).date()
        sale.confirm_date = localdate(2012, 1, 1).date()

        sale = self.create_sale(branch=branches[1])
        sale_item = self.create_sale_item(sale=sale)
        self.create_storable(sale_item.sellable.product, branches[0], 10)
        self.create_payment(payment_type=Payment.TYPE_IN, group=sale.group)
        sale.order()
        sale.confirm()
        sale_item.sellable.code = u'2'
        sale_item.sellable.description = u'Botas'
        sale.open_date = localdate(2012, 2, 2).date()
        sale.confirm_date = localdate(2012, 2, 2).date()
开发者ID:leandrorchaves,项目名称:stoq,代码行数:26,代码来源:test_salessearch.py


示例9: test_receive

    def test_receive(self, localnow):
        localnow.return_value = localdate(2013, 1, 1)

        package = self.create_workorder_package(
            source_branch=self.create_branch())
        package.destination_branch = get_current_branch(self.store)
        workorder1 = self.create_workorder(current_branch=package.source_branch)
        workorder2 = self.create_workorder(current_branch=package.source_branch)

        # Mimic WorkOrderPackage.send
        for order in [workorder1, workorder2]:
            package.add_order(order)
            order.current_branch = None
        package.status = WorkOrderPackage.STATUS_SENT

        with mock.patch('stoqlib.domain.workorder.get_current_branch') as gcb:
            gcb.return_value = self.create_branch()
            with self.assertRaisesRegexp(
                    ValueError,
                    ("This package's destination branch is <Branch u'[0-9a-f-]+'> "
                     "and you are in <Branch u'[0-9a-f-]+'>. It's not possible "
                     "to receive a package outside the destination branch")):
                package.receive()

        self.assertEqual(package.receive_date, None)
        package.receive()
        self.assertEqual(package.status, WorkOrderPackage.STATUS_RECEIVED)
        self.assertEqual(package.receive_date, localdate(2013, 1, 1))

        for order in [workorder1, workorder2]:
            self.assertEqual(order.current_branch, package.destination_branch)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:31,代码来源:test_workorder.py


示例10: test_create_repeated_with_temporary_identifier

 def test_create_repeated_with_temporary_identifier(self):
     payment = self.create_payment()
     payment.description = u'temporary'
     payments = Payment.create_repeated(self.store, payment,
                                        INTERVALTYPE_MONTH,
                                        localdate(2012, 1, 1).date(),
                                        localdate(2012, 3, 1).date(),
                                        temporary_identifiers=True)
     (self.assertTrue(p.identifier < 0) for p in payments)
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:test_payment.py


示例11: test_optical_sales

    def test_optical_sales(self):
        app = self.create_app(SalesApp, u'sales')
        for sales in app.results:
            sales.open_date = localdate(2012, 1, 1)
            sales.confirm_date = localdate(2012, 2, 3)
            sales.close_date = localdate(2012, 4, 5)
        self.check_app(app, u'sales-optical-plugin')

        self.window.hide_app(empty=True)
开发者ID:Joaldino,项目名称:stoq,代码行数:9,代码来源:test_optical_ui.py


示例12: test_prescription_date

 def test_prescription_date(self, localtoday_):
     localtoday_.return_value = localdate(2014, 1, 1)
     not_late_date = localdate(2013, 6, 1).date()
     late_date = localdate(2012, 1, 1).date()
     workorder = self.create_workorder()
     slave = WorkOrderOpticalSlave(self.store, workorder)
     slave.prescription_date.set_date(localdate(2014, 1, 1))
     slave.prescription_date.set_date(not_late_date)
     slave.prescription_date.set_date(late_date)
     slave.prescription_date.set_date(None)
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:test_optical_slave.py


示例13: test_expire_date_validate

    def test_expire_date_validate(self, localtoday_):
        localtoday_.return_value = localdate(2020, 1, 5)

        wizard = OpticalSaleQuoteWizard(self.store)
        step = wizard.get_current_step()

        res = step.expire_date.emit('validate', localdate(2013, 1, 1).date())
        self.assertEquals(
            unicode(res),
            u"The expire date must be set to today or a future date.")
开发者ID:reashninja,项目名称:stoq,代码行数:10,代码来源:test_optical_wizard.py


示例14: _create_domain

 def _create_domain(self, localnow):
     self.clean_domain([WorkOrder])
     localnow.return_value = localdate(2014, 1, 1)
     work_order = self.create_workorder()
     work_order.open_date = localdate(2014, 1, 1)
     work_order.identifier = 123
     work_order.approve()
     work_order.work()
     work_order.add_sellable(self.create_sellable(), quantity=1)
     work_order.finish()
开发者ID:amaurihamasu,项目名称:stoq,代码行数:10,代码来源:test_workordersearch.py


示例15: test_estimated_finish

 def test_estimated_finish(self, localtoday_):
     workorder = self.create_workorder()
     workorder.open_date = localdate(2015, 4, 2)
     slave = WorkOrderOpticalSlave(self.store, workorder)
     #localtoday_.return_value = localdate(2014, 1, 1)
     res = slave.estimated_finish.emit("validate", localdate(2015, 4, 1))
     self.assertEqual(str(res),
                      u'Estimated finish date cannot be in the past.')
     # Can be edited without changing the estimated_finish
     res2 = slave.estimated_finish.emit("validate", localdate(2015, 4, 2))
     self.assertEqual(res2, None)
开发者ID:hackedbellini,项目名称:stoq,代码行数:11,代码来源:test_optical_slave.py


示例16: _on_results__row_activated

 def _on_results__row_activated(self, results, item):
     chart_type_name = item.chart_class.__name__
     if chart_type_name == 'YearlyPayments':
         start = localdate(item.year, 1, 1).date()
         end = localdate(item.year, 12, 31).date()
         chart_type_name = 'MonthlyPayments'
     elif chart_type_name == 'MonthlyPayments':
         start = localdate(item.year, item.month, 1).date()
         end = start + relativedelta(days=31)
         chart_type_name = 'DailyPayments'
     else:
         return
     self._show_one(chart_type_name, start, end)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:13,代码来源:chartdialog.py


示例17: test_show

    def test_show(self):
        till = self.create_till()
        till.open_till()
        till.close_till(u"Observation...")
        till.opening_date = localdate(2014, 5, 6).date()
        till.closing_date = localdate(2014, 5, 6).date()
        till.responsible_open_id = self.create_user().id
        till.initial_cash_amount = Decimal(5656.64)
        till.final_cash_amount = Decimal(246823.22)

        model = self.store.find(TillClosedView, id=till.id).one()

        dialog = TillDetailsDialog(self.store, model)
        self.check_dialog(dialog, 'till-details-dialog-show')
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:14,代码来源:test_tilldetails.py


示例18: test_create_for_another_branch

    def test_create_for_another_branch(self, current_branch):
        branch = self.create_branch()

        with self.sysparam(SYNCHRONIZED_MODE=True):
            editor = OutPaymentEditor(self.store)
            current_branch.return_value = branch
            editor.description.update('Payment name')
            editor.value.update(100)
            editor.due_date.update(localdate(2015, 1, 1).date())
            editor.repeat.update(INTERVALTYPE_MONTH)
            editor.end_date.update(localdate(2016, 1, 10).date())
            editor.main_dialog.confirm()

        self.assertEquals(editor.model.identifier, -1)
开发者ID:hackedbellini,项目名称:stoq,代码行数:14,代码来源:test_payment_editor.py


示例19: test_installments

    def test_installments(self):
        sysparam(self.store).update_parameter(u'ALLOW_OUTDATED_OPERATIONS', u'1')
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'bill')
        order = self.create_purchase_order()
        order.identifier = 12345

        slave = BillMethodSlave(wizard, None, self.store, order, method,
                                Decimal(200), localdate(2012, 01, 01).date())
        self.check_slave(slave, 'slave-bill-method-1-installments')

        slave.installments_number.update(2)
        self.check_slave(slave, 'slave-bill-method-2-installments')
开发者ID:LeonamSilva,项目名称:stoq,代码行数:14,代码来源:test_payment_slave.py


示例20: test_show

    def test_show(self):
        date = localdate(2012, 1, 1).date()
        supplier = self.create_supplier()

        # New purchase
        order = self.create_purchase_order()
        order.identifier = 123
        order.supplier = supplier
        order.open_date = date

        # Product
        purchase_item = self.create_purchase_order_item(order)
        purchase_item.ipi_value = 80

        # New receiving
        receiving_order = self.create_receiving_order(purchase_order=order)
        self.create_receiving_order_item(receiving_order, purchase_item=purchase_item)

        # Payments
        payment = self.add_payments(order, date=date)[0]
        payment.identifier = 999
        payment.group.payer = supplier.person

        dialog = PurchaseDetailsDialog(self.store, order)
        self.check_editor(dialog, 'dialog-purchase-details')
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:test_purchasedetails.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python dateutils.localdatetime函数代码示例发布时间:2022-05-27
下一篇:
Python configparser.StoqConfig类代码示例发布时间: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