Пример #1
0
    def test_export_prism_payments_with_exclusions_easter_2020(self):
        now = timezone.now().date()
        start_date = now
        end_date = now + timedelta(days=14)
        # Create an activity etc which is required.
        case = create_case(self.case_worker, self.municipality, self.district)
        section = create_section()
        appropriation = create_appropriation(sbsys_id="XXX-YYY",
                                             case=case,
                                             section=section)
        main_activity_details = create_activity_details()
        create_section_info(
            main_activity_details,
            section,
            main_activity_main_account_number="1234",
        )
        activity = create_activity(
            case,
            appropriation,
            start_date=start_date,
            end_date=end_date,
            activity_type=MAIN_ACTIVITY,
            status=STATUS_GRANTED,
            details=main_activity_details,
        )
        payment_schedule = create_payment_schedule(
            payment_frequency=PaymentSchedule.DAILY,
            payment_type=PaymentSchedule.RUNNING_PAYMENT,
            recipient_type=PaymentSchedule.PERSON,
            payment_method=CASH,
            payment_amount=Decimal(666),
            activity=activity,
        )
        # Generate payment exclusion dates and export.
        exclusion_dates = generate_payment_date_exclusion_dates(years=[2020])
        for exclusion_date in exclusion_dates:
            create_payment_date_exclusion(date=exclusion_date)

        export_prism_payments_for_date(date=None)

        # Assert 2020-04-07 includes weekend + easter days.
        self.assertCountEqual(
            payment_schedule.payments.filter(paid=True).values_list("date",
                                                                    flat=True),
            [
                date(2020, 4, 8),  # "Normal" day
                date(2020, 4, 9),  # Maundy Thursday - holiday
                date(2020, 4, 10),  # Good Friday - holiday
                date(2020, 4, 11),  # Saturday - weekend
                date(2020, 4,
                     12),  # Easter Sunday - holiday / Sunday - weekend
                date(2020, 4, 13),  # Easter Monday
                date(2020, 4, 14),  # Should be paid 2 "normal" days prior
            ],
        )
Пример #2
0
    def test_export_prism_payments_for_date(self):
        # Create a payment that is due today
        now = timezone.now().date()
        start_date = now - timedelta(days=1)
        end_date = now + timedelta(days=1)
        # Create an activity etc which is required.
        case = create_case(self.case_worker, self.municipality, self.district)
        section = create_section()
        appropriation = create_appropriation(sbsys_id="XXX-YYY",
                                             case=case,
                                             section=section)
        main_activity_details = create_activity_details(
            name="Betaling til andre kommuner/region for specialtandpleje",
            activity_id="010001",
        )
        create_section_info(
            main_activity_details,
            section,
            main_activity_main_account_number="1234",
        )
        activity = create_activity(
            case,
            appropriation,
            start_date=start_date,
            end_date=end_date,
            activity_type=MAIN_ACTIVITY,
            status=STATUS_GRANTED,
            details=main_activity_details,
        )
        create_payment_schedule(
            payment_frequency=PaymentSchedule.DAILY,
            payment_type=PaymentSchedule.RUNNING_PAYMENT,
            recipient_type=PaymentSchedule.PERSON,
            payment_method=CASH,
            payment_amount=Decimal(666),
            activity=activity,
        )
        # Check that there's unpaid payments for today.
        due_payments = due_payments_for_prism(start_date)
        self.assertEqual(due_payments.count(), 1)

        export_prism_payments_for_date(date=start_date)

        # Check that there's NO unpaid payments for that date.
        due_payments = due_payments_for_prism(start_date)
        self.assertEqual(due_payments.count(), 0)

        # Also process for today
        export_prism_payments_for_date()

        # Repeat the previous processing to have an example with no due
        # payments.
        export_prism_payments_for_date()
Пример #3
0
    def test_export_prism_payments_with_exclusions_wednesday(self):
        now = timezone.now().date()
        start_date = now
        end_date = now + timedelta(days=14)
        # Create an activity etc which is required.
        case = create_case(self.case_worker, self.municipality, self.district)
        section = create_section()
        appropriation = create_appropriation(sbsys_id="XXX-YYY",
                                             case=case,
                                             section=section)
        main_activity_details = create_activity_details()
        create_section_info(
            main_activity_details,
            section,
            main_activity_main_account_number="1234",
        )
        activity = create_activity(
            case,
            appropriation,
            start_date=start_date,
            end_date=end_date,
            activity_type=MAIN_ACTIVITY,
            status=STATUS_GRANTED,
            details=main_activity_details,
        )
        payment_schedule = create_payment_schedule(
            payment_frequency=PaymentSchedule.DAILY,
            payment_type=PaymentSchedule.RUNNING_PAYMENT,
            recipient_type=PaymentSchedule.PERSON,
            payment_method=CASH,
            payment_amount=Decimal(666),
            activity=activity,
        )

        # Generate payment exclusion dates and export.
        exclusion_dates = generate_payment_date_exclusion_dates(years=[2020])
        for exclusion_date in exclusion_dates:
            create_payment_date_exclusion(date=exclusion_date)

        export_prism_payments_for_date(date=None)

        # Assert Wednesday only includes Thursday.
        self.assertCountEqual(
            payment_schedule.payments.filter(paid=True).values_list("date",
                                                                    flat=True),
            [date(2020, 5, 14)],  # Thursday
        )
Пример #4
0
    def test_export_prism_payments_with_exclusions_christmas_2024(self):
        now = timezone.now().date()
        start_date = now
        end_date = now + timedelta(days=14)
        # Create an activity etc which is required.
        case = create_case(self.case_worker, self.municipality, self.district)
        section = create_section()
        appropriation = create_appropriation(sbsys_id="XXX-YYY",
                                             case=case,
                                             section=section)
        main_activity_details = create_activity_details()
        create_section_info(
            main_activity_details,
            section,
            main_activity_main_account_number="1234",
        )
        activity = create_activity(
            case,
            appropriation,
            start_date=start_date,
            end_date=end_date,
            activity_type=MAIN_ACTIVITY,
            status=STATUS_GRANTED,
            details=main_activity_details,
        )
        payment_schedule = create_payment_schedule(
            payment_frequency=PaymentSchedule.DAILY,
            payment_type=PaymentSchedule.RUNNING_PAYMENT,
            recipient_type=PaymentSchedule.PERSON,
            payment_method=CASH,
            payment_amount=Decimal(666),
            activity=activity,
        )

        # Generate payment exclusion dates and export.
        exclusion_dates = generate_payment_date_exclusion_dates(
            years=[2024, 2025])
        for exclusion_date in exclusion_dates:
            create_payment_date_exclusion(date=exclusion_date)
        # Create Christmas Eve and New Years Eve as well.
        create_payment_date_exclusion(date=date(2024, 12, 24))
        create_payment_date_exclusion(date=date(2024, 12, 31))

        export_prism_payments_for_date(date=None)

        # Assert Thursday includes Friday + weekend + Monday.
        self.assertCountEqual(
            payment_schedule.payments.filter(paid=True).values_list("date",
                                                                    flat=True),
            [
                date(2024, 12, 20),  # Friday
                date(2024, 12, 21),  # Saturday
                date(2024, 12, 22),  # Sunday
                date(2024, 12, 23),  # Monday
                date(2024, 12, 24),  # Christmas Eve
                date(2024, 12, 25),  # Christmas Day
                date(2024, 12, 26),  # 2nd Christmas Day
                date(2024, 12, 27),  # Friday
                date(2024, 12, 28),  # Saturday
                date(2024, 12, 29),  # Sunday
                date(2024, 12, 30),  # Monday
                date(2024, 12, 31),  # New Years Eve
                date(2025, 1, 1),  # New Years Day
                date(2025, 1, 2),  # First day after exclusion dates.
            ],
        )
Пример #5
0
    def test_format_prism_financial_record(self):
        # Create a payment that is due today
        now = timezone.now().date()
        start_date = now - timedelta(days=1)
        end_date = now + timedelta(days=1)

        # Create an activity etc which is required.

        case_cpr_number = "1234567890"
        case = create_case(
            self.case_worker,
            self.municipality,
            self.district,
            cpr_number=case_cpr_number,
        )
        section = create_section()
        appropriation = create_appropriation(sbsys_id="XXX-YYY",
                                             case=case,
                                             section=section)
        main_activity_details = create_activity_details(
            name="Betaling til andre kommuner/region for specialtandpleje",
            activity_id="010001",
        )
        create_section_info(
            details=main_activity_details,
            section=section,
            main_activity_main_account_number="12345",
        )
        activity = create_activity(
            case,
            appropriation,
            start_date=start_date,
            end_date=end_date,
            activity_type=MAIN_ACTIVITY,
            status=STATUS_GRANTED,
            details=main_activity_details,
        )
        payment_schedule = create_payment_schedule(
            payment_frequency=PaymentSchedule.DAILY,
            payment_type=PaymentSchedule.RUNNING_PAYMENT,
            recipient_type=PaymentSchedule.PERSON,
            payment_method=CASH,
            payment_amount=Decimal(666),
            activity=activity,
        )
        # This will generate three payments on the payment plan, and one
        # of them will be for today.
        due_payments = due_payments_for_prism(now)
        records = generate_records_for_prism(due_payments)
        self.assertEqual(len(records), 2)
        due_payments = due_payments_for_prism(end_date)
        records = generate_records_for_prism(due_payments)
        self.assertEqual(len(records), 2)
        finance_reference = records[0].split("&117")[1][:20]
        payment_reference = records[1].split("&16")[1][:20]
        # These references is what links the two records.
        # This is a simple sanity check.
        self.assertEqual(payment_reference, finance_reference)
        # Check that the CPR number on G69 is the one from the case.
        finance_cpr = records[0].split("&133")[1][:10]
        payment_cpr = records[1].split("&11")[1][:10]
        self.assertEqual(finance_cpr, case_cpr_number)
        self.assertEqual(payment_cpr, payment_schedule.recipient_id)
        self.assertNotEqual(finance_cpr, payment_cpr)