fix: use correct state column for AWAITING_PAYMENT orders
- Fix column o.payment_status does not exist error - orders_orders uses 'state' column, not 'payment_status' - Changed all 3 affected queries
This commit is contained in:
@@ -15,7 +15,7 @@ export function notificationsRoutes(fastify: FastifyInstance, pool: Pool) {
|
||||
AND updated_at < NOW() - INTERVAL '24 hours'
|
||||
) AS shipped_24h,
|
||||
COUNT(*) FILTER (
|
||||
WHERE payment_status = 'AWAITING'
|
||||
WHERE state = 'AWAITING_PAYMENT'
|
||||
AND state = 'PENDING'
|
||||
) AS awaiting_payment
|
||||
FROM pos_orders
|
||||
|
||||
@@ -166,7 +166,7 @@ export async function registerBackofficeRoutes(
|
||||
SELECT
|
||||
COUNT(*) FILTER (WHERE state = 'PENDING') AS pending,
|
||||
COUNT(*) FILTER (WHERE state = 'SHIPPED' AND updated_at < NOW() - INTERVAL '24 hours') AS shipped_24h,
|
||||
COUNT(*) FILTER (WHERE payment_status = 'AWAITING' AND state = 'PENDING') AS awaiting_payment
|
||||
COUNT(*) FILTER (WHERE state = 'AWAITING_PAYMENT') AS awaiting_payment
|
||||
FROM pos_orders
|
||||
WHERE deleted_at IS NULL AND created_at > NOW() - INTERVAL '30 days'
|
||||
`);
|
||||
|
||||
@@ -546,8 +546,7 @@ export async function registerOrdersRoutes(
|
||||
COUNT(*) OVER()::int AS total_count
|
||||
FROM orders_orders o
|
||||
LEFT JOIN identity_users u ON u.id = o.user_id
|
||||
WHERE o.payment_status = 'AWAITING'
|
||||
AND o.state = 'PENDING'
|
||||
WHERE o.state = 'AWAITING_PAYMENT'
|
||||
AND o.deleted_at IS NULL
|
||||
ORDER BY o.created_at ASC
|
||||
LIMIT 20`,
|
||||
|
||||
Reference in New Issue
Block a user