From 0819427bdf089a70e9e53375dc262269d7c7a73c Mon Sep 17 00:00:00 2001 From: Samer Salameh Date: Sun, 22 Nov 2026 17:13:45 +0300 Subject: [PATCH] =?UTF-8?q?Refinery=20trips:=20bank=20account=20number=20i?= =?UTF-8?q?s=20mandatory=20for=20the=20=D8=A7=D9=84=D8=AD=D9=88=D8=A7?= =?UTF-8?q?=D9=84=D8=A7=D8=AA=20and=20bank=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Choosing either report opens a dialog with the account number field instead of the browser prompt; an empty value shows "يجب ادخال رقم الحساب" and nothing is generated until a number is entered. The report keeps the list's status, wage-claim and payment-date filters. Co-Authored-By: Claude Sonnet 5.5 --- web/src/features/refinery/trips/pages.tsx | 63 +++++++++++++++------- web/src/features/refinery/trips/strings.ts | 3 +- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/web/src/features/refinery/trips/pages.tsx b/web/src/features/refinery/trips/pages.tsx index cc793da..e14deba 100644 --- a/web/src/features/refinery/trips/pages.tsx +++ b/web/src/features/refinery/trips/pages.tsx @@ -2,7 +2,7 @@ import { useState, type ElementType, type ReactNode } from 'react'; import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom'; import { Alert, Box, Button, Dialog, GlobalStyles, DialogActions, DialogContent, DialogTitle, Link, Menu, MenuItem, Stack, Table, TableBody, TableCell, - TableHead, TableRow, TablePagination, Typography, + TableHead, TableRow, TablePagination, TextField, Typography, } from '@mui/material'; import SummarizeIcon from '@mui/icons-material/Summarize'; import PrintIcon from '@mui/icons-material/Print'; @@ -53,29 +53,37 @@ export function TripsPage() { }; // the report uses the filters of the list (they are in the URL query string) const current = () => Object.fromEntries([...new URLSearchParams(window.location.search)].filter(([k]) => !['page', 'size', 'f'].includes(k))); + + // the account-list reports (الحوالات and the bank report) cannot run without a bank account number: a dialog asks for it and refuses an empty value + const [ask, setAsk] = useState<'exchange' | 'bank' | null>(null); + const [account, setAccount] = useState(''); + const [accountError, setAccountError] = useState(false); + const askAccount = (kind: 'exchange' | 'bank') => { + setMenu(null); + setAccount(current().bankAccount ?? ''); + setAccountError(false); + setAsk(kind); + }; + const submitAccount = () => { + const value = account.trim(); + if (!value) { setAccountError(true); return; } + // the legacy filters of the list: status, wage-claim flag and payment dates + const c = current(); + const params: Record = { bankAccount: value }; + for (const k of ['statusCode', 'hasWageClaim', 'paymentedDateFrom', 'paymentedDateTo']) if (c[k]) params[k] = c[k]; + const kind = ask; + setAsk(null); + if (kind === 'exchange') void run('exchange', params, 'refinery-transfers.xlsx'); + else if (kind === 'bank') void run('bank', params, 'refinery-bank.xlsx'); + }; const reports: { key: string; label: string; show: boolean; go: () => void }[] = [ { key: 'trips', label: t('trips.report.trips'), show: can('refinery.trips.report'), go: () => void run('trips', current(), 'refinery-trips.xlsx') }, { key: 'operator', label: t('trips.report.operator'), show: can('refinery.trips.operatorReport'), go: () => void run('operator', current(), 'refinery-trips-operator.xlsx') }, - { - // الحوالات: the list of ONE bank account (legacy refineryBankReport), so the account number is asked first; the other filters are the - // legacy ones (status, wage claim flag, payment dates), taken from the list - key: 'exchange', label: t('trips.report.exchange'), show: can('refinery.trips.exchangeReport'), go: () => { - const c = current(); - const account = window.prompt(t('trips.report.bankAsk'), c.bankAccount ?? '')?.trim(); - if (!account) { setMenu(null); return; } - const params: Record = { bankAccount: account }; - for (const k of ['statusCode', 'hasWageClaim', 'paymentedDateFrom', 'paymentedDateTo']) if (c[k]) params[k] = c[k]; - void run('exchange', params, 'refinery-transfers.xlsx'); - }, - }, + // الحوالات: the list of ONE bank account (legacy refineryBankReport): the account number is mandatory, see the dialog below + { key: 'exchange', label: t('trips.report.exchange'), show: can('refinery.trips.exchangeReport'), go: () => askAccount('exchange') }, { key: 'diesel', label: t('trips.report.diesel'), show: can('refinery.trips.dieselReport'), go: () => void run('diesel', current(), 'refinery-diesel.xlsx') }, { key: 'cards', label: t('trips.report.cards'), show: can('refinery.trips.cardsReport'), go: () => void run('cards', { tn: current().tn ?? '' }, 'refinery-cards.xlsx') }, - { - key: 'bank', label: t('trips.report.bank'), show: can('refinery.trips.bankReport'), go: () => { - const account = window.prompt(t('trips.report.bankAsk'), current().bankAccount ?? ''); - if (account) void run('bank', { bankAccount: account, statusCode: current().statusCode ?? '' }, 'refinery-bank.xlsx'); - }, - }, + { key: 'bank', label: t('trips.report.bank'), show: can('refinery.trips.bankReport'), go: () => askAccount('bank') }, ].filter((r) => r.show); const meta = tripsGrid((r) => navigate(`${ROOT}/${r.id}`)); @@ -93,6 +101,23 @@ export function TripsPage() { )} /> + setAsk(null)} fullWidth maxWidth="xs"> +
{ e.preventDefault(); submitAccount(); }}> + {ask === 'bank' ? t('trips.report.bank') : t('trips.report.exchange')} + + { setAccount(e.target.value); if (e.target.value.trim()) setAccountError(false); }} + error={accountError} helperText={accountError ? t('trips.report.bankAsk') : ' '} + slotProps={{ htmlInput: { dir: 'ltr' } }} + /> + + + + + +
+
); } diff --git a/web/src/features/refinery/trips/strings.ts b/web/src/features/refinery/trips/strings.ts index 1cfb703..9159e0f 100644 --- a/web/src/features/refinery/trips/strings.ts +++ b/web/src/features/refinery/trips/strings.ts @@ -50,7 +50,8 @@ export default defineStrings({ 'trips.report.diesel': { en: 'Diesel charges (Excel)', ar: 'شحن الديزل (Excel)' }, 'trips.report.cards': { en: 'Diesel balances (Excel)', ar: 'أرصدة الديزل (Excel)' }, 'trips.report.bank': { en: 'Bank report (Excel)', ar: 'تقرير البنك (Excel)' }, - 'trips.report.bankAsk': { en: 'Enter the bank account number of the report', ar: 'يجب ادخال رقم الحساب' }, + 'trips.report.bankAsk': { en: 'The bank account number is required', ar: 'يجب ادخال رقم الحساب' }, + 'trips.report.create': { en: 'Create report', ar: 'إنشاء التقرير' }, 'trips.report.done': { en: 'The report was generated', ar: 'تم انشاء التقرير بنجاح' }, // form sections