Compare commits
No commits in common. "main" and "QA_old_version_61" have entirely different histories.
main
...
QA_old_ver
|
|
@ -2,7 +2,7 @@ import { useState, type ElementType, type ReactNode } from 'react';
|
||||||
import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom';
|
import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Alert, Box, Button, Dialog, GlobalStyles, DialogActions, DialogContent, DialogTitle, Link, Menu, MenuItem, Stack, Table, TableBody, TableCell,
|
Alert, Box, Button, Dialog, GlobalStyles, DialogActions, DialogContent, DialogTitle, Link, Menu, MenuItem, Stack, Table, TableBody, TableCell,
|
||||||
TableHead, TableRow, TablePagination, TextField, Typography,
|
TableHead, TableRow, TablePagination, Typography,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import SummarizeIcon from '@mui/icons-material/Summarize';
|
import SummarizeIcon from '@mui/icons-material/Summarize';
|
||||||
import PrintIcon from '@mui/icons-material/Print';
|
import PrintIcon from '@mui/icons-material/Print';
|
||||||
|
|
@ -53,37 +53,29 @@ export function TripsPage() {
|
||||||
};
|
};
|
||||||
// the report uses the filters of the list (they are in the URL query string)
|
// 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)));
|
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<string, string> = { 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 }[] = [
|
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: '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') },
|
{ 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): the account number is mandatory, see the dialog below
|
{
|
||||||
{ key: 'exchange', label: t('trips.report.exchange'), show: can('refinery.trips.exchangeReport'), go: () => askAccount('exchange') },
|
// الحوالات: 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<string, string> = { bankAccount: account };
|
||||||
|
for (const k of ['statusCode', 'hasWageClaim', 'paymentedDateFrom', 'paymentedDateTo']) if (c[k]) params[k] = c[k];
|
||||||
|
void run('exchange', params, 'refinery-transfers.xlsx');
|
||||||
|
},
|
||||||
|
},
|
||||||
{ key: 'diesel', label: t('trips.report.diesel'), show: can('refinery.trips.dieselReport'), go: () => void run('diesel', current(), 'refinery-diesel.xlsx') },
|
{ 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: '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: () => askAccount('bank') },
|
{
|
||||||
|
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');
|
||||||
|
},
|
||||||
|
},
|
||||||
].filter((r) => r.show);
|
].filter((r) => r.show);
|
||||||
|
|
||||||
const meta = tripsGrid((r) => navigate(`${ROOT}/${r.id}`));
|
const meta = tripsGrid((r) => navigate(`${ROOT}/${r.id}`));
|
||||||
|
|
@ -101,23 +93,6 @@ export function TripsPage() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<DataGrid meta={meta} />
|
<DataGrid meta={meta} />
|
||||||
<Dialog open={ask !== null} onClose={() => setAsk(null)} fullWidth maxWidth="xs">
|
|
||||||
<form noValidate onSubmit={(e) => { e.preventDefault(); submitAccount(); }}>
|
|
||||||
<DialogTitle>{ask === 'bank' ? t('trips.report.bank') : t('trips.report.exchange')}</DialogTitle>
|
|
||||||
<DialogContent>
|
|
||||||
<TextField
|
|
||||||
autoFocus required fullWidth margin="dense" label={t('trips.bankAccount')} value={account}
|
|
||||||
onChange={(e) => { setAccount(e.target.value); if (e.target.value.trim()) setAccountError(false); }}
|
|
||||||
error={accountError} helperText={accountError ? t('trips.report.bankAsk') : ' '}
|
|
||||||
slotProps={{ htmlInput: { dir: 'ltr' } }}
|
|
||||||
/>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={() => setAsk(null)}>{t('common.cancel')}</Button>
|
|
||||||
<Button type="submit" variant="contained">{t('trips.report.create')}</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</form>
|
|
||||||
</Dialog>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,7 @@ export default defineStrings({
|
||||||
'trips.report.diesel': { en: 'Diesel charges (Excel)', ar: 'شحن الديزل (Excel)' },
|
'trips.report.diesel': { en: 'Diesel charges (Excel)', ar: 'شحن الديزل (Excel)' },
|
||||||
'trips.report.cards': { en: 'Diesel balances (Excel)', ar: 'أرصدة الديزل (Excel)' },
|
'trips.report.cards': { en: 'Diesel balances (Excel)', ar: 'أرصدة الديزل (Excel)' },
|
||||||
'trips.report.bank': { en: 'Bank report (Excel)', ar: 'تقرير البنك (Excel)' },
|
'trips.report.bank': { en: 'Bank report (Excel)', ar: 'تقرير البنك (Excel)' },
|
||||||
'trips.report.bankAsk': { en: 'The bank account number is required', ar: 'يجب ادخال رقم الحساب' },
|
'trips.report.bankAsk': { en: 'Enter the bank account number of the report', ar: 'يجب ادخال رقم الحساب' },
|
||||||
'trips.report.create': { en: 'Create report', ar: 'إنشاء التقرير' },
|
|
||||||
'trips.report.done': { en: 'The report was generated', ar: 'تم انشاء التقرير بنجاح' },
|
'trips.report.done': { en: 'The report was generated', ar: 'تم انشاء التقرير بنجاح' },
|
||||||
|
|
||||||
// form sections
|
// form sections
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue