Billing entry: editable weights and fines, all destinations; searchable company lists; dark disabled text

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Samer Salameh 2026-11-15 15:21:24 +03:00
parent 85a7e4a41d
commit 174734c359
14 changed files with 64 additions and 55 deletions

View File

@ -43,15 +43,15 @@ public sealed class BillingService(
{ {
await validator.ValidateAndThrowAsync(request, ct); await validator.ValidateAndThrowAsync(request, ct);
// Weights are re-read server side (legacy trusted hidden form fields).
var info = await repository.GetPermitBillingInfoAsync(request.Pn, ct) ?? throw OrdersErrors.InvalidPn(); var info = await repository.GetPermitBillingInfoAsync(request.Pn, ct) ?? throw OrdersErrors.InvalidPn();
if (info.Scac != request.Scac) throw OrdersErrors.PnNotOfCompany(); if (info.Scac != request.Scac) throw OrdersErrors.PnNotOfCompany();
if (!BillingCalculator.IsDischargeAfterLoad(request.LoadDate, request.DischargeDate)) throw OrdersErrors.DischargeBeforeLoad(); if (!BillingCalculator.IsDischargeAfterLoad(request.LoadDate, request.DischargeDate)) throw OrdersErrors.DischargeBeforeLoad();
var lnw = BillingCalculator.NetWeight(info.Lgw, info.Ltw); // Sent / received weights are typed by the user (prefilled from the permit), like the legacy LNW / DNW inputs.
var dnw = BillingCalculator.NetWeight(info.Dgw, info.Dtw); var lnw = request.Lnw;
if (dnw == 0) throw OrdersErrors.ReceivedWeightMissing(); var dnw = request.Dnw;
if (dnw <= 0) throw OrdersErrors.ReceivedWeightMissing();
if (!BillingCalculator.IsSentWeightInRange(lnw)) throw OrdersErrors.SentWeightRange(); if (!BillingCalculator.IsSentWeightInRange(lnw)) throw OrdersErrors.SentWeightRange();
// PRICE / FINEPRICE come from the static price table (legacy: readonly inputs filled from the same table). // PRICE / FINEPRICE come from the static price table (legacy: readonly inputs filled from the same table).
@ -73,7 +73,7 @@ public sealed class BillingService(
request.LoadDate.Date, request.DischargeDate.Date, request.LoadDate.Date, request.DischargeDate.Date,
info.Dtw, info.Dgw, dnw, info.Ltw, info.Lgw, lnw, info.Dtw, info.Dgw, dnw, info.Ltw, info.Lgw, lnw,
request.Scac, request.InvoiceNumber, GrainsOrderConstants.BillingOriginId, request.Scac, request.InvoiceNumber, GrainsOrderConstants.BillingOriginId,
price.Value, finePrice.Value, finalCost, loseFine, user.UserId), token); price.Value, finePrice.Value, finalCost, loseFine, user.UserId, request.DemurrageFine, request.OtherFine), token);
return new OrdersResult(OrdersErrors.Success, id); return new OrdersResult(OrdersErrors.Success, id);
}, ct); }, ct);

View File

@ -114,7 +114,11 @@ public sealed record AddBillingRequest(
DateTime DischargeDate, DateTime DischargeDate,
long Destination, long Destination,
long CargoType, long CargoType,
string Tn); string Tn,
decimal Lnw = 0,
decimal Dnw = 0,
decimal DemurrageFine = 0,
decimal OtherFine = 0);
public sealed record WageRate(decimal Wage); public sealed record WageRate(decimal Wage);
public sealed record FineRate(decimal Allowance, decimal Fine); public sealed record FineRate(decimal Allowance, decimal Fine);

View File

@ -29,7 +29,7 @@ public interface IOrderLookupRepository
/// <summary>LOCATIONS where DOMAIN='GN', STATUS=1 and TYPE = EN (loading) or EX (destination).</summary> /// <summary>LOCATIONS where DOMAIN='GN', STATUS=1 and TYPE = EN (loading) or EX (destination).</summary>
Task<IReadOnlyList<LookupOptionDto>> GetLocationsAsync(string type, CancellationToken ct = default); Task<IReadOnlyList<LookupOptionDto>> GetLocationsAsync(string type, CancellationToken ct = default);
/// <summary>Invoice.cfc getLocations: GN exit locations with AREA IS NULL and STATUS=1.</summary> /// <summary>Invoice.cfc getLocations: every active GN exit location (STATUS=1), AREA NULL first.</summary>
Task<IReadOnlyList<LookupOptionDto>> GetBillingDestinationsAsync(CancellationToken ct = default); Task<IReadOnlyList<LookupOptionDto>> GetBillingDestinationsAsync(CancellationToken ct = default);
/// <summary>register.getDistination: GN exit locations of GN_TYPE 'PCKD', ordered by SORTORDER.</summary> /// <summary>register.getDistination: GN exit locations of GN_TYPE 'PCKD', ordered by SORTORDER.</summary>

View File

@ -46,6 +46,8 @@ public sealed class AddBillingValidator : AbstractValidator<AddBillingRequest>
RuleFor(x => x.Destination).GreaterThan(0).WithMessage("الى مطلوب"); RuleFor(x => x.Destination).GreaterThan(0).WithMessage("الى مطلوب");
RuleFor(x => x.CargoType).GreaterThan(0).WithMessage("نوع المادة مطلوب"); RuleFor(x => x.CargoType).GreaterThan(0).WithMessage("نوع المادة مطلوب");
RuleFor(x => x.Tn).NotEmpty().MaximumLength(20).WithMessage("رقم السيارة مطلوب"); RuleFor(x => x.Tn).NotEmpty().MaximumLength(20).WithMessage("رقم السيارة مطلوب");
RuleFor(x => x.DemurrageFine).GreaterThanOrEqualTo(0).WithMessage("غرامة التاخير غير صحيحة");
RuleFor(x => x.OtherFine).GreaterThanOrEqualTo(0).WithMessage("غرامات أخرى غير صحيحة");
} }
} }

View File

@ -59,4 +59,5 @@ public sealed record NewTenderOrder(
public sealed record NewGrainsBilling( public sealed record NewGrainsBilling(
long Pn, string SerialNo, string Tn, long CargoType, long Destination, DateTime LoadDate, DateTime DischargeDate, long Pn, string SerialNo, string Tn, long CargoType, long Destination, DateTime LoadDate, DateTime DischargeDate,
decimal Dtw, decimal Dgw, decimal Dnw, decimal Ltw, decimal Lgw, decimal Lnw, long Scac, long InvoiceNumber, decimal Dtw, decimal Dgw, decimal Dnw, decimal Ltw, decimal Lgw, decimal Lnw, long Scac, long InvoiceNumber,
long Origin, decimal Price, decimal FinePrice, decimal FinalCost, decimal LoseFine, string CreateUserId = ""); long Origin, decimal Price, decimal FinePrice, decimal FinalCost, decimal LoseFine, string CreateUserId = "",
decimal DemurrageFine = 0, decimal OtherFine = 0);

View File

@ -81,17 +81,19 @@ internal sealed class BillingRepository(IDbSession session, ILogger<BillingRepos
b.FinePrice, b.FinePrice,
b.FinalCost, b.FinalCost,
b.LoseFine, b.LoseFine,
b.CreateUserId b.CreateUserId,
b.DemurrageFine,
b.OtherFine
}); });
p.Add("NewId", dbType: DbType.Int64, direction: ParameterDirection.Output); p.Add("NewId", dbType: DbType.Int64, direction: ParameterDirection.Output);
await ExecuteAsync(""" await ExecuteAsync("""
INSERT INTO GRAINS_BILLING INSERT INTO GRAINS_BILLING
(ID, PN, SERIALNO, TN, CARGOTYPE, DESTINATION, LOADDATE, DISCHARGEDATE, DTW, DGW, DNW, LTW, LGW, LNW, (ID, PN, SERIALNO, TN, CARGOTYPE, DESTINATION, LOADDATE, DISCHARGEDATE, DTW, DGW, DNW, LTW, LGW, LNW,
SCAC, INVOICENUMBER, ORIGIN, PRICE, FINEPRICE, FINALCOST, LOSEFINE, CREATEUSERID) SCAC, INVOICENUMBER, ORIGIN, PRICE, FINEPRICE, FINALCOST, LOSEFINE, CREATEUSERID, DEMURRAGEFINE, OTHERFINE)
VALUES VALUES
(seq_GRAINS_BILLING.NEXTVAL, :Pn, :SerialNo, :Tn, :CargoType, :Destination, :LoadDate, :DischargeDate, :Dtw, :Dgw, :Dnw, :Ltw, :Lgw, :Lnw, (seq_GRAINS_BILLING.NEXTVAL, :Pn, :SerialNo, :Tn, :CargoType, :Destination, :LoadDate, :DischargeDate, :Dtw, :Dgw, :Dnw, :Ltw, :Lgw, :Lnw,
:Scac, :InvoiceNumber, :Origin, :Price, :FinePrice, :FinalCost, :LoseFine, :CreateUserId) :Scac, :InvoiceNumber, :Origin, :Price, :FinePrice, :FinalCost, :LoseFine, :CreateUserId, :DemurrageFine, :OtherFine)
RETURNING ID INTO :NewId RETURNING ID INTO :NewId
""", p, ct); """, p, ct);
return OracleSql.ToInt64(p.Get<object>("NewId")); return OracleSql.ToInt64(p.Get<object>("NewId"));
@ -116,7 +118,7 @@ internal sealed class BillingRepository(IDbSession session, ILogger<BillingRepos
t.createuserid AS CreateUserId t.createuserid AS CreateUserId
FROM GRAINS_BILLING t, FROM GRAINS_BILLING t,
(SELECT * FROM CARGOTYPE WHERE domain = 'GN') ctp, (SELECT * FROM CARGOTYPE WHERE domain = 'GN') ctp,
(SELECT * FROM LOCATIONS l WHERE l.domain = 'GN' AND l.type = 'EX' AND l.area IS NULL AND l.status = '1') loc (SELECT * FROM LOCATIONS l WHERE l.domain = 'GN' AND l.type = 'EX' AND l.status = '1') loc
WHERE t.cargotype = ctp.id WHERE t.cargotype = ctp.id
AND t.destination = loc.id AND t.destination = loc.id
AND NVL(t.statuscode, 'ACTIVE') <> 'DELETED' AND NVL(t.statuscode, 'ACTIVE') <> 'DELETED'

View File

@ -32,8 +32,8 @@ internal sealed class OrderLookupRepository(IDbSession session, ILogger<OrderLoo
public Task<IReadOnlyList<LookupOptionDto>> GetBillingDestinationsAsync(CancellationToken ct = default) => public Task<IReadOnlyList<LookupOptionDto>> GetBillingDestinationsAsync(CancellationToken ct = default) =>
OptionsAsync(""" OptionsAsync("""
SELECT id AS Id, name AS Name FROM LOCATIONS t SELECT id AS Id, name AS Name FROM LOCATIONS t
WHERE t.domain = 'GN' AND t.type = 'EX' AND t.area IS NULL AND t.status = '1' WHERE t.domain = 'GN' AND t.type = 'EX' AND t.status = '1'
ORDER BY name, id ORDER BY t.area NULLS FIRST, name, id
""", null, ct); """, null, ct);
public Task<IReadOnlyList<LookupOptionDto>> GetPackedDestinationsAsync(CancellationToken ct = default) => public Task<IReadOnlyList<LookupOptionDto>> GetPackedDestinationsAsync(CancellationToken ct = default) =>

View File

@ -57,10 +57,10 @@ export const billingForm: FormMeta = {
{ name: 'destination', type: 'select', label: { en: 'To', ar: 'الى' }, required: true, options: billingDestinationOptions }, { name: 'destination', type: 'select', label: { en: 'To', ar: 'الى' }, required: true, options: billingDestinationOptions },
{ name: 'cargoType', type: 'select', label: { en: 'Cargo type', ar: 'نوع المادة' }, required: true, options: cargoTypeOptions }, { name: 'cargoType', type: 'select', label: { en: 'Cargo type', ar: 'نوع المادة' }, required: true, options: cargoTypeOptions },
{ name: 'tn', type: 'text', label: { en: 'Truck number', ar: 'رقم السيارة' }, required: true, inputKind: 'plate', maxLength: 20 }, { name: 'tn', type: 'text', label: { en: 'Truck number', ar: 'رقم السيارة' }, required: true, inputKind: 'plate', maxLength: 20 },
{ name: 'lnw', type: 'number', label: { en: 'Sent weight', ar: 'الوزن المرسل' }, readOnly: true }, { name: 'lnw', type: 'number', label: { en: 'Sent weight', ar: 'الوزن المرسل' }, required: true, min: 0, max: 50000 },
{ name: 'dnw', type: 'number', label: { en: 'Received weight', ar: 'الوزن المستلم' }, readOnly: true }, { name: 'dnw', type: 'number', label: { en: 'Received weight', ar: 'الوزن المستلم' }, required: true, min: 0 },
{ name: 'price', type: 'number', label: { en: 'Price', ar: 'السعر' }, readOnly: true }, { name: 'demurrageFine', type: 'number', label: { en: 'Delay fine', ar: 'غرامة التاخير' }, min: 0 },
{ name: 'finePrice', type: 'number', label: { en: 'Fine price', ar: 'سعر التغريم' }, readOnly: true }, { name: 'otherFine', type: 'number', label: { en: 'Other fines', ar: 'غرامات أخرى' }, min: 0 },
], ],
}, },
], ],

View File

@ -1,7 +1,7 @@
import { useEffect, useMemo, useState, type KeyboardEvent } from 'react'; import { useEffect, useMemo, useState, type KeyboardEvent } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { import {
Alert, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Paper, Stack, Alert, Autocomplete, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Paper, Stack,
Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography,
} from '@mui/material'; } from '@mui/material';
import AddIcon from '@mui/icons-material/Add'; import AddIcon from '@mui/icons-material/Add';
@ -287,6 +287,24 @@ export function BillingListPage() {
); );
} }
/** Company drop list the user can type in to search (by name or number). */
function CompanySelect(props: { value: string; onChange: (v: string) => void; exclude?: number }) {
const { t } = useFeatureUi(strings);
const companies = useCompanies();
const options = (companies.data ?? []).filter((c) => c.scac !== props.exclude);
const selected = options.find((c) => String(c.scac) === props.value) ?? null;
return (
<Autocomplete
size="small" fullWidth options={options} value={selected} loading={companies.isPending}
getOptionLabel={(c) => c.label ?? String(c.scac)}
isOptionEqualToValue={(a, b) => a.scac === b.scac}
onChange={(_, c) => props.onChange(c ? String(c.scac) : '')}
noOptionsText={t('ord.noCompany')}
renderInput={(params) => <TextField {...params} label={t('ord.company')} placeholder={t('ord.selectCompany')} />}
/>
);
}
/** Company + permit-number picker shared by the billing and weights screens. */ /** Company + permit-number picker shared by the billing and weights screens. */
function PermitBar(props: { function PermitBar(props: {
withCompany: boolean; withCompany: boolean;
@ -298,21 +316,12 @@ function PermitBar(props: {
hint: string; hint: string;
}) { }) {
const { t } = useFeatureUi(strings); const { t } = useFeatureUi(strings);
const companies = useCompanies();
return ( return (
<Paper variant="outlined" sx={{ p: 2, mb: 2 }}> <Paper variant="outlined" sx={{ p: 2, mb: 2 }}>
<Typography variant="body2" color="text.secondary" sx={{ mb: 1.5 }}>{props.hint}</Typography> <Typography variant="body2" color="text.secondary" sx={{ mb: 1.5 }}>{props.hint}</Typography>
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} useFlexGap> <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} useFlexGap>
{props.withCompany && ( {props.withCompany && (
<TextField <Box sx={{ flex: 2 }}><CompanySelect value={props.scac} onChange={props.onScac} /></Box>
select fullWidth size="small" label={t('ord.company')} value={props.scac}
onChange={(e) => props.onScac(e.target.value)}
slotProps={{ select: { native: true }, inputLabel: { shrink: true } }}
sx={{ flex: 2 }}
>
<option value="">{companies.isPending ? '...' : t('ord.selectCompany')}</option>
{(companies.data ?? []).map((c) => <option key={c.scac} value={String(c.scac)}>{c.label}</option>)}
</TextField>
)} )}
<TextField <TextField
fullWidth size="small" label={t('ord.billing.pn')} value={props.pn} fullWidth size="small" label={t('ord.billing.pn')} value={props.pn}
@ -363,8 +372,8 @@ export function BillingEntryPage() {
tn: permit.tn ?? '', tn: permit.tn ?? '',
lnw: permit.lnw, lnw: permit.lnw,
dnw: permit.dnw ?? '', dnw: permit.dnw ?? '',
price: permit.price ?? '', demurrageFine: 0,
finePrice: permit.finePrice ?? '', otherFine: 0,
}, },
[permit, tr], [permit, tr],
); );
@ -519,7 +528,6 @@ export function WeightsPage() {
export function CompanyDestinationsPage() { export function CompanyDestinationsPage() {
const { t } = useFeatureUi(strings); const { t } = useFeatureUi(strings);
const confirm = useConfirm(); const confirm = useConfirm();
const companies = useCompanies();
const groupsData = useDestinationGroups(); const groupsData = useDestinationGroups();
const [scac, setScac] = useState<number | null>(null); const [scac, setScac] = useState<number | null>(null);
const current = useCompanyDestinations(scac); const current = useCompanyDestinations(scac);
@ -548,14 +556,7 @@ export function CompanyDestinationsPage() {
<PageHeader title={t('ord.compDest.title')} subtitle={t('ord.compDest.subtitle')} /> <PageHeader title={t('ord.compDest.title')} subtitle={t('ord.compDest.subtitle')} />
<Paper variant="outlined" sx={{ p: 2 }}> <Paper variant="outlined" sx={{ p: 2 }}>
<Stack spacing={2}> <Stack spacing={2}>
<TextField <CompanySelect value={scac === null ? '' : String(scac)} onChange={(v) => setScac(v ? Number(v) : null)} exclude={INDIVIDUALS_SCAC} />
select fullWidth size="small" label={t('ord.company')} value={scac === null ? '' : String(scac)}
onChange={(e) => setScac(e.target.value ? Number(e.target.value) : null)}
slotProps={{ select: { native: true }, inputLabel: { shrink: true } }}
>
<option value="">{companies.isPending ? '...' : t('ord.selectCompany')}</option>
{(companies.data ?? []).filter((c) => c.scac !== INDIVIDUALS_SCAC).map((c) => <option key={c.scac} value={String(c.scac)}>{c.label}</option>)}
</TextField>
{scac === null && <Alert severity="info">{t('ord.compDest.pick')}</Alert>} {scac === null && <Alert severity="info">{t('ord.compDest.pick')}</Alert>}
{scac !== null && (current.isPending || groupsData.isPending) && <LoadingBanner variant="first" />} {scac !== null && (current.isPending || groupsData.isPending) && <LoadingBanner variant="first" />}
@ -691,7 +692,6 @@ const pad = (v: number, int: number) => v.toFixed(3).padStart(int + 4, '0');
export function InvoiceCheckPage() { export function InvoiceCheckPage() {
const { t } = useFeatureUi(strings); const { t } = useFeatureUi(strings);
const toast = useToast(); const toast = useToast();
const companies = useCompanies();
const [scac, setScac] = useState(''); const [scac, setScac] = useState('');
const [inv, setInv] = useState(''); const [inv, setInv] = useState('');
const invoices = useInvoiceNumbers(scac); const invoices = useInvoiceNumbers(scac);
@ -731,14 +731,7 @@ export function InvoiceCheckPage() {
actions={<Button variant="contained" startIcon={<SearchIcon />} disabled={!scac || !inv || busy} onClick={() => void search()}>{t('common.search')}</Button>} actions={<Button variant="contained" startIcon={<SearchIcon />} disabled={!scac || !inv || busy} onClick={() => void search()}>{t('common.search')}</Button>}
> >
<Stack spacing={2}> <Stack spacing={2}>
<TextField <CompanySelect value={scac} onChange={(v) => { setScac(v); setInv(''); setRows(null); }} />
select fullWidth size="small" label={t('ord.company')} value={scac}
onChange={(e) => { setScac(e.target.value); setInv(''); setRows(null); }}
slotProps={{ select: { native: true }, inputLabel: { shrink: true } }}
>
<option value="">{companies.isPending ? '...' : t('ord.selectCompany')}</option>
{(companies.data ?? []).map((c) => <option key={c.scac} value={String(c.scac)}>{c.label}</option>)}
</TextField>
<TextField <TextField
select fullWidth size="small" label={t('ord.check.invoice')} value={inv} disabled={!scac} select fullWidth size="small" label={t('ord.check.invoice')} value={inv} disabled={!scac}
onChange={(e) => { setInv(e.target.value); setRows(null); }} onChange={(e) => { setInv(e.target.value); setRows(null); }}

View File

@ -24,6 +24,7 @@ export default defineStrings({
'ord.export.xlsx': { en: 'Export Excel', ar: 'تصدير Excel' }, 'ord.export.xlsx': { en: 'Export Excel', ar: 'تصدير Excel' },
'ord.export.failed': { en: 'Could not download the file', ar: 'تعذر تنزيل الملف' }, 'ord.export.failed': { en: 'Could not download the file', ar: 'تعذر تنزيل الملف' },
'ord.company': { en: 'Company', ar: 'الشركة' }, 'ord.company': { en: 'Company', ar: 'الشركة' },
'ord.noCompany': { en: 'No matching company', ar: 'لا توجد شركة مطابقة' },
'ord.selectCompany': { en: 'Select a company', ar: 'اختر الشركة' }, 'ord.selectCompany': { en: 'Select a company', ar: 'اختر الشركة' },
'ord.load': { en: 'Load', ar: 'تحميل' }, 'ord.load': { en: 'Load', ar: 'تحميل' },

View File

@ -68,7 +68,7 @@ export const permitFilters = (companyUser: boolean): FilterMeta[] => [
{ name: 'creationDate', type: 'date', label: { en: 'Turn date', ar: 'تاريخ الدور' } }, { name: 'creationDate', type: 'date', label: { en: 'Turn date', ar: 'تاريخ الدور' } },
{ name: 'shipmentMode', type: 'select', label: { en: 'Cargo class', ar: 'نوع المادة' }, options: shipmentModeOptions }, { name: 'shipmentMode', type: 'select', label: { en: 'Cargo class', ar: 'نوع المادة' }, options: shipmentModeOptions },
{ name: 'destAddressId', type: 'select', label: { en: 'Destination', ar: 'الوجهة' }, options: exitLocationOptions }, { name: 'destAddressId', type: 'select', label: { en: 'Destination', ar: 'الوجهة' }, options: exitLocationOptions },
...(companyUser ? [] : [{ name: 'companyCode', type: 'select', label: { en: 'Company', ar: 'اسم الشركة' }, options: companyFilterOptions } as FilterMeta]), ...(companyUser ? [] : [{ name: 'companyCode', type: 'autocomplete', label: { en: 'Company', ar: 'اسم الشركة' }, options: companyFilterOptions } as FilterMeta]),
{ name: 'tenderOrder', type: 'select', label: { en: 'By order', ar: 'حسب الطلبية' }, options: tenderOrderDateOptions }, { name: 'tenderOrder', type: 'select', label: { en: 'By order', ar: 'حسب الطلبية' }, options: tenderOrderDateOptions },
]; ];

View File

@ -16,7 +16,7 @@ export function trailerGrid(h: { isCompanyUser: boolean; onOpen: (r: TrailerRow)
filters: [ filters: [
{ name: 'tn', type: 'text', label: lbl('Trailer number', 'رقم المقطورة'), inputKind: 'plate' }, { name: 'tn', type: 'text', label: lbl('Trailer number', 'رقم المقطورة'), inputKind: 'plate' },
{ name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), ltr: true }, { name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), ltr: true },
...(h.isCompanyUser ? [] : [{ name: 'tcscac', type: 'select' as const, label: lbl('Company', 'الشركة'), options: companyOptions }]), ...(h.isCompanyUser ? [] : [{ name: 'tcscac', type: 'autocomplete' as const, label: lbl('Company', 'الشركة'), options: companyOptions }]),
], ],
columns: [ columns: [
{ key: 'tn', header: lbl('Number', 'الرقم'), ltr: true }, { key: 'tn', header: lbl('Number', 'الرقم'), ltr: true },
@ -54,7 +54,7 @@ export function trailerForm(o: TrailerFormOptions): FormMeta {
pattern: DIGITS_ONLY(12), readOnly: o.isEdit, pattern: DIGITS_ONLY(12), readOnly: o.isEdit,
}, },
{ {
name: 'tcscac', type: 'select', label: lbl('Company', 'الشركة'), required: true, options: companyOptions, name: 'tcscac', type: 'autocomplete', label: lbl('Company', 'الشركة'), required: true, options: companyOptions,
disabledWhen: o.isEdit || o.companyLocked ? { field: 'tcscac', op: 'notEmpty' } : undefined, disabledWhen: o.isEdit || o.companyLocked ? { field: 'tcscac', op: 'notEmpty' } : undefined,
}, },
{ name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), requiredWhen: full, maxLength: 20, ltr: true, pattern: NO_SPECIAL }, { name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), requiredWhen: full, maxLength: 20, ltr: true, pattern: NO_SPECIAL },

View File

@ -24,7 +24,7 @@ export function truckGrid(h: { isCompanyUser: boolean; onOpen: (r: TruckRow) =>
{ value: 'Tripper', label: lbl('Tipper', 'قلاب') }, { value: 'Tripper', label: lbl('Tipper', 'قلاب') },
{ value: 'Single', label: lbl('Single', 'سنجل') }, { value: 'Single', label: lbl('Single', 'سنجل') },
] }, ] },
...(h.isCompanyUser ? [] : [{ name: 'tcscac', type: 'select' as const, label: lbl('Company', 'الشركة'), options: companyOptions }]), ...(h.isCompanyUser ? [] : [{ name: 'tcscac', type: 'autocomplete' as const, label: lbl('Company', 'الشركة'), options: companyOptions }]),
], ],
columns: [ columns: [
{ key: 'tn', header: lbl('Number', 'الرقم'), ltr: true }, { key: 'tn', header: lbl('Number', 'الرقم'), ltr: true },
@ -73,7 +73,7 @@ export function truckForm(o: TruckFormOptions): FormMeta {
pattern: DIGITS_ONLY(12), readOnly: o.isEdit, pattern: DIGITS_ONLY(12), readOnly: o.isEdit,
}, },
{ {
name: 'tcscac', type: 'select', label: lbl('Company', 'الشركة'), required: true, options: companyOptions, name: 'tcscac', type: 'autocomplete', label: lbl('Company', 'الشركة'), required: true, options: companyOptions,
disabledWhen: o.isEdit || o.companyLocked ? { field: 'tcscac', op: 'notEmpty' } : undefined, disabledWhen: o.isEdit || o.companyLocked ? { field: 'tcscac', op: 'notEmpty' } : undefined,
}, },
{ name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), requiredWhen: isBadiya, maxLength: 20, ltr: true, pattern: NO_SPECIAL }, { name: 'chasesNumber', type: 'text', label: lbl('Chassis number', 'رقم الشصي'), requiredWhen: isBadiya, maxLength: 20, ltr: true, pattern: NO_SPECIAL },

View File

@ -56,7 +56,13 @@ export function buildTheme(mode: ThemeMode, direction: 'rtl' | 'ltr'): Theme {
}, },
MuiDialogActions: { styleOverrides: { root: { padding: '8px 24px 16px', gap: 4 } } }, MuiDialogActions: { styleOverrides: { root: { padding: '8px 24px 16px', gap: 4 } } },
MuiTable: { defaultProps: { size: 'small' } }, MuiTable: { defaultProps: { size: 'small' } },
MuiInputBase: { styleOverrides: { root: { fontSize: BASE } } }, // disabled / read-only fields keep the normal dark text (MUI greys it out by default, which is hard to read)
MuiInputBase: {
styleOverrides: {
root: { fontSize: BASE, '&.Mui-disabled': { color: k.text, WebkitTextFillColor: k.text } },
input: { '&.Mui-disabled': { color: k.text, WebkitTextFillColor: k.text } },
},
},
MuiMenuItem: { styleOverrides: { root: { fontSize: BASE } } }, MuiMenuItem: { styleOverrides: { root: { fontSize: BASE } } },
MuiInputLabel: { styleOverrides: { root: { fontSize: BASE } } }, MuiInputLabel: { styleOverrides: { root: { fontSize: BASE } } },
MuiFormHelperText: { styleOverrides: { root: { fontSize: 12 } } }, MuiFormHelperText: { styleOverrides: { root: { fontSize: 12 } } },