Updated financial report and sms outside of Ethiopia

This commit is contained in:
Roba Boru
2026-08-13 22:47:22 +03:00
parent f5a19a705a
commit 376c23a0ad
12 changed files with 509 additions and 308 deletions

View File

@@ -85,14 +85,20 @@ export class PaymentsController {
@ApiBearerAuth("IAM-auth")
@ApiOperation({ summary: "Get all payments with filters (staff/admin only)" })
@ApiQuery({ name: "search", required: false })
@ApiQuery({ name: "status", required: false })
@ApiQuery({ name: "status", required: false, description: "PaymentIntentStatus value, e.g. SUCCEEDED" })
@ApiQuery({ name: "method", required: false })
@ApiQuery({
name: "bookingStatus",
required: false,
description: "Comma-separated Booking.status values, e.g. CONFIRMED,BOARDED — restricts to payments backing bookings in those states.",
})
@ApiQuery({ name: "page", required: false })
@ApiQuery({ name: "pageSize", required: false })
async getAll(
@Query("search") search?: string,
@Query("status") status?: string,
@Query("method") method?: string,
@Query("bookingStatus") bookingStatus?: string,
@Query("page") page?: string,
@Query("pageSize") pageSize?: string,
) {
@@ -100,6 +106,7 @@ export class PaymentsController {
search,
status,
method,
bookingStatus,
page: page ? parseInt(page) : 1,
pageSize: pageSize ? parseInt(pageSize) : 10,
});

View File

@@ -99,10 +99,13 @@ export class PaymentsService {
search?: string;
status?: string;
method?: string;
/** Comma-separated Booking.status values, e.g. "CONFIRMED,BOARDED" — lets a caller ask
* for exactly the payments that back confirmed revenue, not every payment attempt. */
bookingStatus?: string;
page?: number;
pageSize?: number;
}) {
const { search, status, method, page = 1, pageSize = 10 } = filters;
const { search, status, method, bookingStatus, page = 1, pageSize = 10 } = filters;
const skip = (page - 1) * pageSize;
const where: any = {};
@@ -118,6 +121,12 @@ export class PaymentsService {
if (method) {
where.method = method;
}
if (bookingStatus) {
const statuses = bookingStatus.split(",").map((s) => s.trim()).filter(Boolean);
if (statuses.length > 0) {
where.booking = { status: { in: statuses } };
}
}
const [items, total] = await Promise.all([
this.prisma.paymentIntent.findMany({
@@ -133,6 +142,7 @@ export class PaymentsService {
childCount: true,
totalMinor: true,
currency: true,
status: true,
priceTier: { select: { priceMinor: true } },
},
},
@@ -172,6 +182,7 @@ export class PaymentsService {
bookingRef: b?.bookingRef,
totalMinor: b?.totalMinor,
currency: b?.currency,
status: b?.status,
},
amountMinor,
currency: item.currency,