feat: enhance payment status handling and summary in MyPaymentsPage

- Added support for 'partial' payment status in MyPaymentsPage and related components.
- Updated API responses to include 'paid_rials' and 'summary' for invoices.
- Introduced InvoicePaymentStatus service to derive payment status based on actual payments.
- Enhanced tests to cover new payment scenarios including partial payments and payment methods.
- Updated documentation to reflect changes in payment status and API responses.
This commit is contained in:
hamed
2026-07-19 10:38:29 +03:30
parent 5c8fe8ece4
commit 357adb1d14
18 changed files with 620 additions and 188 deletions
+11 -3
View File
@@ -16,9 +16,11 @@ const get = api.get as ReturnType<typeof vi.fn>;
const ROWS = [
{ invoice_uuid: 'iv1', patient_uuid: 'p1', patient_name: 'دنیا خلیلی', national_code: '1744023654',
issued_at: 1717000000, amount_rials: 2350000, status: 'paid' },
issued_at: 1717000000, amount_rials: 2350000, paid_rials: 2350000, status: 'paid' },
{ invoice_uuid: 'iv2', patient_uuid: 'p2', patient_name: 'علی بدیعی', national_code: '2200112233',
issued_at: 1718000000, amount_rials: 6000000, status: 'unsettled' },
issued_at: 1718000000, amount_rials: 6000000, paid_rials: 0, status: 'unsettled' },
{ invoice_uuid: 'iv3', patient_uuid: 'p3', patient_name: 'مریم رضایی', national_code: '3300112233',
issued_at: 1719000000, amount_rials: 1000000, paid_rials: 400000, status: 'partial' },
];
const SUMMARY = { total_rials: 8350000, paid_rials: 2350000, unsettled_rials: 6000000, invoices_count: 2 };
@@ -47,10 +49,16 @@ describe('MyPaymentsPage (لیست پرداخت‌ها)', () => {
expect(screen.getByText('2200112233')).toBeInTheDocument();
});
it('renders the two-state invoice status badge', async () => {
it('renders the derived payment status badge for each state', async () => {
renderWithProviders(<MyPaymentsPage />, { route: '/admin/my-payments' });
expect(await screen.findByText('پرداخت شده')).toBeInTheDocument();
expect(screen.getByText('تسویه نشده')).toBeInTheDocument();
expect(screen.getByText('پرداخت ناقص')).toBeInTheDocument();
});
it('shows how much was collected on a partially paid invoice', async () => {
renderWithProviders(<MyPaymentsPage />, { route: '/admin/my-payments' });
expect(await screen.findByText(/پرداخت‌شده:/)).toBeInTheDocument();
});
it('renders the summary stat cards', async () => {