Example #1
0
    def setUp(self):
        self.profile = factories.PaymentProfileFactory(
            payment_type=models.PaymentType.FIXED_PRICE,
            attributes={'end_date': '2020-01-31'},
        )

        factories.PaymentProfileFactory(
            payment_type=models.PaymentType.FIXED_PRICE,
            attributes={'end_date': '2020-02-15'},
        )

        factories.PaymentProfileFactory(
            payment_type=models.PaymentType.FIXED_PRICE, )
Example #2
0
 def setUp(self):
     self.fixture = structure_fixtures.ProjectFixture()
     self.profile = factories.PaymentProfileFactory(
         organization=self.fixture.customer)
     self.url = factories.PaymentProfileFactory.get_url(
         profile=self.profile)
     self.customer_url = structure_factories.CustomerFactory.get_url(
         customer=self.fixture.customer)
Example #3
0
    def test_proof_is_not_required_for_payment_of_invoice(self):
        factories.PaymentProfileFactory(organization=self.invoice.customer,
                                        is_active=True)

        self.client.force_authenticate(getattr(self.fixture, 'staff'))
        date = datetime.date.today()
        response = self.client.post(self.url,
                                    data={'date': date},
                                    format='multipart')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Example #4
0
    def setUp(self):
        self.fixture = structure_fixtures.ProjectFixture()
        self.profile = factories.PaymentProfileFactory(
            organization=self.fixture.customer)
        self.payment = factories.PaymentFactory(profile=self.profile)
        self.invoice = factories.InvoiceFactory(
            customer=self.fixture.customer, state=models.Invoice.States.PAID)
        self.url = factories.PaymentFactory.get_url(payment=self.payment,
                                                    action='link_to_invoice')

        self.url_unlink = factories.PaymentFactory.get_url(
            payment=self.payment, action='unlink_from_invoice')
Example #5
0
 def test_report_context(self):
     invoice_1 = factories.InvoiceFactory()
     invoice_2 = factories.InvoiceFactory()
     invoice_3 = factories.InvoiceFactory()
     factories.PaymentProfileFactory(
         organization=invoice_1.customer,
         payment_type=models.PaymentType.FIXED_PRICE,
         is_active=True,
         attributes={
             'end_date': '2017-10-01',
             'contract_sum': 100
         },
     )
     factories.PaymentProfileFactory(
         organization=invoice_2.customer,
         payment_type=models.PaymentType.FIXED_PRICE,
         is_active=True,
     )
     factories.PaymentProfileFactory(
         organization=invoice_2.customer,
         payment_type=models.PaymentType.FIXED_PRICE,
         is_active=False,
     )
     context = invoices_utils.get_monthly_invoicing_reports_context()
     self.assertEqual(len(context['invoices']), 1)
     self.assertEqual(context['invoices'][0], invoice_3)
     self.assertEqual(len(context['contracts']), 2)
     customer_1_context = [
         c for c in context['contracts']
         if c['name'] == invoice_1.customer.abbreviation
     ][0]
     self.assertEqual(customer_1_context['end_date_alarm'], True)
     self.assertEqual(customer_1_context['payments_alarm'], True)
     customer_2_context = [
         c for c in context['contracts']
         if c['name'] == invoice_2.customer.abbreviation
     ][0]
     self.assertEqual(customer_2_context['end_date_alarm'], False)
     self.assertEqual(customer_2_context['payments_alarm'], None)
Example #6
0
    def test_if_enabling_payment_profile_disables_other_existing_profiles(
            self):
        # creation
        new_profile = factories.PaymentProfileFactory(
            organization=self.customer, is_active=True)
        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.is_active)

        # update
        self.profile.is_active = True
        self.profile.save()
        new_profile.refresh_from_db()
        self.assertIsNone(new_profile.is_active)
        self.assertTrue(self.profile.is_active)
Example #7
0
 def test_enable_action(self):
     self.client.force_authenticate(self.fixture.staff)
     new_profile = factories.PaymentProfileFactory(
         organization=self.fixture.customer,
         is_active=False,
     )
     url = factories.PaymentProfileFactory.get_url(profile=new_profile,
                                                   action='enable')
     response = self.client.post(url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     new_profile.refresh_from_db()
     self.profile.refresh_from_db()
     self.assertIsNone(self.profile.is_active)
     self.assertTrue(new_profile.is_active)
Example #8
0
    def test_create_payment_if_payment_data_has_been_passed(self):
        profile = factories.PaymentProfileFactory(
            organization=self.invoice.customer, is_active=True)

        self.client.force_authenticate(getattr(self.fixture, 'staff'))
        date = datetime.date.today()
        response = self.client.post(self.url,
                                    data={
                                        'date': date,
                                        'proof': dummy_image()
                                    },
                                    format='multipart')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.invoice.refresh_from_db()
        self.assertEqual(self.invoice.state, models.Invoice.States.PAID)
        self.assertEqual(
            models.Payment.objects.filter(date_of_payment=date,
                                          profile=profile).count(),
            1,
        )
Example #9
0
 def setUp(self):
     self.profile = factories.PaymentProfileFactory(
         payment_type=models.PaymentType.FIXED_PRICE)
Example #10
0
 def setUp(self):
     self.customer = structure_factories.CustomerFactory()
     self.profile = factories.PaymentProfileFactory(
         organization=self.customer, is_active=True)
Example #11
0
 def test_user_with_access_can_create_payments(self, user):
     self.fixture = structure_fixtures.ProjectFixture()
     self.profile = factories.PaymentProfileFactory(
         organization=self.fixture.customer)
     self.url = factories.PaymentFactory.get_list_url()