コード例 #1
0
    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))
コード例 #2
0
    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))
コード例 #3
0
ファイル: test_views.py プロジェクト: rg3915/stoq
    def test_find_pending(self):
        due_date = localtoday() + datetime.timedelta(-4), localtoday()
        for i in range(5):
            if i % 2 == 0:
                payment = self.create_payment(payment_type=Payment.TYPE_IN)
                payment.status = Payment.STATUS_PENDING
                payment.due_date = localtoday() + datetime.timedelta(-2)
            else:
                payment = self.create_payment(payment_type=Payment.TYPE_IN)
                payment.status = Payment.STATUS_PENDING
                payment.due_date = Date(localtoday())

        result = InPaymentView.find_pending(store=self.store, due_date=due_date)
        self.assertEquals(result.count(), 5)

        result = InPaymentView.find_pending(store=self.store, due_date=Date(localtoday()))
        self.assertEquals(result.count(), 2)
        result = InPaymentView.find_pending(store=self.store, due_date=None)
        self.assertEquals(result.count(), 7)
コード例 #4
0
ファイル: test_views.py プロジェクト: 5l1v3r1/stoq-1
    def test_find_pending(self):
        for i in range(5):
            payment = self.create_payment(payment_type=Payment.TYPE_IN)
            payment.status = Payment.STATUS_PENDING
            if i % 2 == 0:
                payment.due_date = localtoday() + datetime.timedelta(-2)
            else:
                payment.due_date = Date(localtoday())

        # Between 4 days ago and today
        due_date = (localtoday() + datetime.timedelta(-4), localtoday())
        result = InPaymentView.find_pending(store=self.store,
                                            due_date=due_date)
        self.assertEqual(result.count(), 5)

        result = InPaymentView.find_pending(store=self.store,
                                            due_date=Date(localtoday()))
        self.assertEqual(result.count(), 2)
        result = InPaymentView.find_pending(store=self.store, due_date=None)
        self.assertEqual(result.count(), 7)
コード例 #5
0
 def _collect_inpayments(self, start, end, day_events, store):
     for pv in InPaymentView.find_pending(store, (start, end)):
         date, ev = self._create_in_payment(pv)
         self._append_event(day_events, date, 'receivable', ev)
コード例 #6
0
 def _collect_inpayments(self, start, end, day_events, store):
     for pv in InPaymentView.find_pending(store, (start, end)):
         date, ev = self._create_in_payment(pv)
         self._append_event(day_events, date, 'receivable', ev)