diff --git a/db/refinery-op-permissions.sql b/db/refinery-op-permissions.sql
new file mode 100644
index 0000000..8fee332
--- /dev/null
+++ b/db/refinery-op-permissions.sql
@@ -0,0 +1,54 @@
+-- Refinery (المصفاة): role REFINERY_OP (موظف عطاء الصرف) sees the الارساليات screen with the شحن الديزل (Excel) report, print and the
+-- payment actions. Safe to re-run; not run by the app.
+-- Run order: part 1 in the NTP schema (only needed where the role row is missing; it exists in the legacy data), part 2 in the primary
+-- (NAFITHTCS) schema, after db/grains-screen-permissions.sql. Afterwards assign role REFINERY_OP to the users who need it (NTPUSERS):
+-- they sign in as before. The API applies the rows within about a minute, the browser on the next reload / sign-in.
+-- SU needs no rows. Everything else of the refinery module (wage claims, commission claims, wallets, variables, cards, the other
+-- trip reports, the reverse-advance actions, recalculate balance) stays with REFINERY_MGR and SU.
+
+-- ---------------------------------------------------------------------------------------------------------------------------
+-- Part 1 (NTP schema): the role row, copied from REFINERY_MGR (level, type, manager columns) when REFINERY_OP does not exist yet.
+-- ---------------------------------------------------------------------------------------------------------------------------
+INSERT INTO ROLES (CODE, NAME, DIRECTMANAGER, EMPLOYEES, MANAGERS, LEVELNUMBER, ROLETYPE, TENDER)
+SELECT 'REFINERY_OP', 'موظف عطاء الصرف', r.DIRECTMANAGER, r.EMPLOYEES, r.MANAGERS, r.LEVELNUMBER, r.ROLETYPE, r.TENDER
+ FROM ROLES r
+ WHERE r.CODE = 'REFINERY_MGR'
+ AND NOT EXISTS (SELECT 1 FROM ROLES x WHERE x.CODE = 'REFINERY_OP');
+
+COMMIT;
+
+-- ---------------------------------------------------------------------------------------------------------------------------
+-- Part 2 (primary schema): 13 keys.
+-- screen refinery.trips (list, view, history)
+-- report refinery.trips.dieselReport (شحن الديزل Excel)
+-- print refinery.trips.print (cash voucher)
+-- diesel refinery.trips.firstAdvance, secondAdvance
+-- cash refinery.trips.cashPayment, receipt
+-- bank / orange refinery.trips.payment, orangePayment
+-- e-wallet refinery.trips.exchange, exchangeAudit, activateWalletExchange, confirmExchange (Dinarak is OFF until configured)
+-- ---------------------------------------------------------------------------------------------------------------------------
+INSERT INTO GRAINS_SCREEN_PERMISSIONS (ROLECODE, RESOURCE_KEY)
+SELECT 'REFINERY_OP', v.resource_key
+ FROM (SELECT 'refinery.trips' AS resource_key FROM dual UNION ALL
+ SELECT 'refinery.trips.dieselReport' FROM dual UNION ALL
+ SELECT 'refinery.trips.print' FROM dual UNION ALL
+ SELECT 'refinery.trips.firstAdvance' FROM dual UNION ALL
+ SELECT 'refinery.trips.secondAdvance' FROM dual UNION ALL
+ SELECT 'refinery.trips.cashPayment' FROM dual UNION ALL
+ SELECT 'refinery.trips.receipt' FROM dual UNION ALL
+ SELECT 'refinery.trips.payment' FROM dual UNION ALL
+ SELECT 'refinery.trips.orangePayment' FROM dual UNION ALL
+ SELECT 'refinery.trips.exchange' FROM dual UNION ALL
+ SELECT 'refinery.trips.exchangeAudit' FROM dual UNION ALL
+ SELECT 'refinery.trips.activateWalletExchange' FROM dual UNION ALL
+ SELECT 'refinery.trips.confirmExchange' FROM dual) v
+ WHERE NOT EXISTS (
+ SELECT 1 FROM GRAINS_SCREEN_PERMISSIONS p
+ WHERE p.rolecode = 'REFINERY_OP' AND p.resource_key = v.resource_key);
+
+COMMIT;
+
+-- Check (expect 13 rows):
+-- SELECT resource_key FROM GRAINS_SCREEN_PERMISSIONS WHERE rolecode = 'REFINERY_OP' ORDER BY resource_key;
+-- Take a right away by deleting its row, e.g.:
+-- DELETE FROM GRAINS_SCREEN_PERMISSIONS WHERE rolecode = 'REFINERY_OP' AND resource_key = 'refinery.trips.confirmExchange';
diff --git a/docs/ENVIRONMENTS.md b/docs/ENVIRONMENTS.md
index 3c4712f..b9a4c5f 100644
--- a/docs/ENVIRONMENTS.md
+++ b/docs/ENVIRONMENTS.md
@@ -59,6 +59,7 @@ Apply these scripts once per database (not run by the application), in this orde
7. `db/grains-jobs.sql` - tables of the scheduled jobs (`GRAINS_JOBS`, `GRAINS_JOB_RUNS`), primary schema. Without it the scheduler stays idle. Jobs are then started, stopped and timed on the SU screen "المهام المجدولة" (`/jobs`); nothing runs until a job is started there. `Jobs:SchedulerEnabled=false` (set in appsettings.Development.json) switches the scheduler loop off for a process
6. `db/gnac-finance-screens.sql` - GNAC gets claims, fines, wages, invoices and the invoice check report (safe to re-run)
8. `db/refinery-permissions.sql` - refinery (المصفاة) modules: REFINERY_MGR gets the 6 screens and every action key (47 rows); SU needs none (safe to re-run). The external services are OFF until configured: `Refinery__Dinarak__Enabled/BaseUrl/UserName/Password` (trip payment) and `Refinery__Jopetrol__Enabled/Url/UserName/Password` (wage claim ترحيل); `Refinery__Trips__MaxPaymentAmount` (default 500, unverified)
+9. `db/refinery-op-permissions.sql` - role REFINERY_OP (موظف عطاء الصرف): the الارساليات screen, the شحن الديزل (Excel) report, print and the payment actions (13 keys); part 1 (role row, NTP schema) is only needed where the row is missing, part 2 (primary schema) writes the rows (safe to re-run). Everything else of the refinery module stays with REFINERY_MGR and SU
**Switching a feature off for everybody:** a row with `ROLECODE = 'DISABLED'` takes that resource out of the system for all users, SU
included: the menu entry and buttons disappear and the API answers 403. It overrides every other row. Delete the row to bring the
diff --git a/src/NTP.Application/Refinery/Trips/LegacyReportWorkbook.cs b/src/NTP.Application/Refinery/Trips/LegacyReportWorkbook.cs
new file mode 100644
index 0000000..0ef6641
--- /dev/null
+++ b/src/NTP.Application/Refinery/Trips/LegacyReportWorkbook.cs
@@ -0,0 +1,291 @@
+using System.Globalization;
+using System.IO.Compression;
+using System.Security;
+using System.Text;
+using NTP.Application.Grains.Orders;
+
+namespace NTP.Application.Refinery.Trips;
+
+///
+/// One report in the layout of the legacy AqabaTCS reports (backend/common/report.cfc): company name and title on the first row,
+/// the applied filters as label / value pairs, a spacer row, the column captions, then the rows. The first column is the counter
+/// (متسلسل). are the legacy column widths in points.
+///
+public sealed record LegacyReport(
+ string CompanyName,
+ string Title,
+ IReadOnlyList<(string Label, string Value)> Filters,
+ IReadOnlyList Headers,
+ IReadOnlyList WidthsPt,
+ IReadOnlyList> Rows);
+
+///
+/// The legacy الحوالات list (refineryBankReport, companyreport.cfr): a banner with the company and the list title, a block with the
+/// account details and the total, then the trips table. are the label / value rows of the block;
+/// are the column widths in characters.
+///
+public sealed record TransfersReport(
+ string CompanyName,
+ string Title,
+ IReadOnlyList<(string Label, object? Value)> Info,
+ IReadOnlyList Headers,
+ IReadOnlyList WidthsChars,
+ IReadOnlyList> Rows);
+
+///
+/// Writes legacy-style reports as .xlsx workbooks (right-to-left sheet, Arial Unicode MS 11, centred and wrapped cells, navy #003366 header
+/// cells with white text, thin borders). Strings are written as inline strings, so cell text can never be evaluated as a formula.
+///
+public static class LegacyReportWorkbook
+{
+ private const string Font = "Arial Unicode MS";
+
+ // cellXfs indexes of the report.cfc style sheet below
+ private const int Company = 1, Title = 2, Header = 3, FilterValue = 4, Data = 5;
+ // cellXfs indexes of the transfers style sheet
+ private const int TBanner = 1, TLabel = 2, TValue = 3, THeader = 4, TData = 5;
+
+ /// Legacy widths are points (ss:Width); the sheet needs characters: ((pt * 4/3) - 5) / 7.
+ public static double Chars(int points) => Math.Round((points * 4.0 / 3.0 - 5) / 7, 2);
+
+ public static byte[] ToXlsx(LegacyReport r) => Package(r.Title, Styles(), Sheet(r));
+
+ public static byte[] ToTransfersXlsx(TransfersReport r) => Package(r.Title, TransfersStyles(), TransfersSheet(r));
+
+ private static byte[] Package(string title, string styles, string sheet)
+ {
+ using var ms = new MemoryStream();
+ using (var zip = new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
+ {
+ Add(zip, "[Content_Types].xml",
+ "");
+ Add(zip, "_rels/.rels",
+ "");
+ Add(zip, "xl/workbook.xml",
+ "");
+ Add(zip, "xl/_rels/workbook.xml.rels",
+ "");
+ Add(zip, "xl/styles.xml", styles);
+ Add(zip, "xl/worksheets/sheet1.xml", sheet);
+ }
+ return ms.ToArray();
+ }
+
+ // ------------------------------------------------------------------ report.cfc layout
+ /// Style sheet: fonts 0 normal, 1 navy 14, 2 white 11, 3 black 12; fills 2 navy, 3 grey; borders 1 all thin black, 2 data row.
+ internal static string Styles()
+ {
+ static string F(int size, string color) => $"";
+ static string B(string l, string r, string t, string b) =>
+ $" 0 ? "thin" : "none")}\">{(t.Length > 0 ? $"" : "")}";
+ static string X(int font, int fill, int border, string h, string v) =>
+ $"";
+ var sb = new StringBuilder();
+ sb.Append("");
+ sb.Append("").Append(F(11, "FF000000")).Append(F(14, "FF003366")).Append(F(11, "FFFFFFFF")).Append(F(12, "FF000000")).Append("");
+ sb.Append("")
+ .Append("")
+ .Append("");
+ sb.Append("")
+ .Append(B("FF000000", "FF000000", "FF000000", "FF000000")) // header: black box
+ .Append(B("FF666699", "FF666699", "", "FF000000")) // data: violet sides, black bottom
+ .Append("");
+ sb.Append("");
+ sb.Append("")
+ .Append(X(1, 0, 0, "right", "top")) // 1 company name
+ .Append(X(1, 0, 0, "center", "center")) // 2 title
+ .Append(X(2, 2, 1, "center", "top")) // 3 header / filter label
+ .Append(X(3, 3, 0, "center", "top")) // 4 filter value
+ .Append(X(0, 0, 2, "center", "top")) // 5 data
+ .Append("");
+ return sb.ToString();
+ }
+
+ private static string Sheet(LegacyReport r)
+ {
+ var cols = r.Headers.Count;
+ var sb = new StringBuilder();
+ sb.Append("");
+ sb.Append("");
+ sb.Append("");
+ for (var c = 0; c < cols; c++)
+ Col(sb, c, Chars(c < r.WidthsPt.Count ? r.WidthsPt[c] : 150));
+ sb.Append("");
+
+ // row 1: company name over the first three columns, title over columns E:F (legacy cell layout)
+ sb.Append("");
+ Text(sb, 0, 1, r.CompanyName, Company);
+ Blank(sb, 1, 1, Company); Blank(sb, 2, 1, Company);
+ Text(sb, 4, 1, r.Title, Title);
+ Blank(sb, 5, 1, Title);
+ sb.Append("");
+
+ // row 2: filters as label / value pairs
+ sb.Append("");
+ var fc = 0;
+ foreach (var (label, value) in r.Filters)
+ {
+ Text(sb, fc++, 2, label, Header);
+ Text(sb, fc++, 2, value, FilterValue);
+ }
+ sb.Append("");
+
+ // row 3: spacer, row 4: column captions
+ sb.Append("");
+ sb.Append("");
+ for (var c = 0; c < cols; c++) Text(sb, c, 4, r.Headers[c], Header);
+ sb.Append("");
+
+ var rowNo = 5;
+ foreach (var row in r.Rows)
+ {
+ sb.Append("");
+ for (var c = 0; c < cols && c < row.Count; c++) Value(sb, c, rowNo, row[c], Data);
+ sb.Append("");
+ rowNo++;
+ }
+ sb.Append("");
+ return sb.ToString();
+ }
+
+ // ------------------------------------------------------------------ الحوالات layout (companyreport.cfr output)
+ ///
+ /// Style sheet read from a legacy output file: fonts 1 Arial bold 21 (banner), 2 bold white 11 (labels), 3 bold black 11 (values), 4 white 11
+ /// (column captions), 0 black 11 (data); navy #003366 fills; thin borders, violet (#666699) sides on the data rows.
+ ///
+ internal static string TransfersStyles()
+ {
+ static string Fn(string name, int size, string color, bool bold) =>
+ $"{(bold ? "" : "")}";
+ static string X(int font, int fill, int border, string h) =>
+ $"";
+ var sb = new StringBuilder();
+ sb.Append("");
+ sb.Append("").Append(Fn(Font, 11, "FF000000", false)).Append(Fn("Arial", 21, "FF000000", true))
+ .Append(Fn(Font, 11, "FFFFFFFF", true)).Append(Fn(Font, 11, "FF000000", true)).Append(Fn(Font, 11, "FFFFFFFF", false)).Append("");
+ sb.Append("")
+ .Append("")
+ .Append("");
+ sb.Append("")
+ .Append("")
+ .Append("")
+ .Append("");
+ sb.Append("");
+ sb.Append("")
+ .Append(X(1, 0, 0, "center")) // 1 banner (company, title)
+ .Append(X(2, 2, 1, "center")) // 2 label of the account block
+ .Append(X(3, 3, 1, "right")) // 3 value of the account block
+ .Append(X(4, 2, 1, "center")) // 4 column caption
+ .Append(X(0, 3, 2, "center")) // 5 data
+ .Append("");
+ return sb.ToString();
+ }
+
+ private static string TransfersSheet(TransfersReport r)
+ {
+ var cols = r.Headers.Count;
+ var last = TabularExport.ColumnName(cols - 1);
+ var merges = new List();
+ var sb = new StringBuilder();
+ sb.Append("");
+ sb.Append("");
+ sb.Append("");
+ for (var c = 0; c < cols; c++) Col(sb, c, c < r.WidthsChars.Count ? r.WidthsChars[c] : 14);
+ sb.Append("");
+
+ // rows 1-3: company, title, blank banner row, each merged over the whole table width
+ void Banner(int row, string? text)
+ {
+ sb.Append("");
+ if (text is null) Blank(sb, 0, row, TBanner); else Text(sb, 0, row, text, TBanner);
+ for (var c = 1; c < cols; c++) Blank(sb, c, row, TBanner);
+ sb.Append("");
+ merges.Add($"A{row}:{last}{row}");
+ }
+ Banner(1, r.CompanyName);
+ Banner(2, r.Title);
+ Banner(3, null);
+
+ // account block: label over A:B, value over C:last
+ var rowNo = 4;
+ foreach (var (label, value) in r.Info)
+ {
+ sb.Append("");
+ Text(sb, 0, rowNo, label, TLabel);
+ Blank(sb, 1, rowNo, TLabel);
+ Value(sb, 2, rowNo, value, TValue);
+ for (var c = 3; c < cols; c++) Blank(sb, c, rowNo, TValue);
+ sb.Append("");
+ merges.Add($"A{rowNo}:B{rowNo}");
+ merges.Add($"C{rowNo}:{last}{rowNo}");
+ rowNo++;
+ }
+ // blank row, then the column captions (height 45)
+ sb.Append("");
+ merges.Add($"A{rowNo}:{last}{rowNo}");
+ rowNo++;
+ sb.Append("");
+ for (var c = 0; c < cols; c++) Text(sb, c, rowNo, r.Headers[c], THeader);
+ sb.Append("");
+ rowNo++;
+ foreach (var row in r.Rows)
+ {
+ sb.Append("");
+ for (var c = 0; c < cols && c < row.Count; c++) Value(sb, c, rowNo, row[c], TData);
+ sb.Append("");
+ rowNo++;
+ }
+ sb.Append("");
+ foreach (var m in merges) sb.Append("");
+ sb.Append("");
+ return sb.ToString();
+ }
+
+ // ------------------------------------------------------------------ shared pieces
+ private static void Col(StringBuilder sb, int c, double width) =>
+ sb.Append("
");
+
+ private static string Ref(int col, int row) => TabularExport.ColumnName(col) + row.ToString(CultureInfo.InvariantCulture);
+
+ private static void Blank(StringBuilder sb, int col, int row, int style) =>
+ sb.Append("");
+
+ private static void Text(StringBuilder sb, int col, int row, string text, int style) =>
+ sb.Append("")
+ .Append(Esc(text)).Append("");
+
+ private static void Value(StringBuilder sb, int col, int row, object? v, int style)
+ {
+ if (v is null) { Blank(sb, col, row, style); return; }
+ if (v is sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal)
+ sb.Append("")
+ .Append(Convert.ToString(v, CultureInfo.InvariantCulture)).Append("");
+ else Text(sb, col, row, TabularExport.FormatCell(v), style);
+ }
+
+ /// Sheet names: at most 31 characters and none of : \ / ? * [ ].
+ public static string SheetName(string title)
+ {
+ var s = new string(title.Where(ch => ":\\/?*[]".IndexOf(ch) < 0).ToArray()).Trim();
+ if (s.Length == 0) s = "Report";
+ return s.Length > 31 ? s[..31] : s;
+ }
+
+ private static void Add(ZipArchive zip, string name, string content)
+ {
+ var entry = zip.CreateEntry(name, CompressionLevel.Fastest);
+ using var s = entry.Open();
+ var bytes = new UTF8Encoding(false).GetBytes(content);
+ s.Write(bytes, 0, bytes.Length);
+ }
+
+ private static string Esc(string s)
+ {
+ var clean = new StringBuilder(s.Length);
+ foreach (var ch in s)
+ if (ch == '\t' || ch == '\n' || ch == '\r' || ch >= 0x20 && ch != 0xFFFE && ch != 0xFFFF) clean.Append(ch);
+ return SecurityElement.Escape(clean.ToString()) ?? string.Empty;
+ }
+}
diff --git a/src/NTP.Application/Refinery/Trips/TripReportService.cs b/src/NTP.Application/Refinery/Trips/TripReportService.cs
index 6cdcbb1..aa8b50f 100644
--- a/src/NTP.Application/Refinery/Trips/TripReportService.cs
+++ b/src/NTP.Application/Refinery/Trips/TripReportService.cs
@@ -27,6 +27,50 @@ public sealed class TripReportService(ITripRepository trips) : ITripReportServic
private static string Day(DateTime? d) => d?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) ?? string.Empty;
+ // ---- legacy report layout (aqabaTCSBCommon.report.create): the trips, exchange and diesel-balance reports use it
+ private const string CompanyName = "شركة نافذ للخدمات اللوجستية"; // caption PUBLIC.NAFITH_NAME
+ private const string TripsTitle = "شاشة الارساليات"; // caption MENU.REFINERYTRIPS
+ private const string CardsTitle = "أرصدة الديزل"; // caption PUBLIC.CARD_REPORT
+
+ // column widths in points, as set in the legacy factory: report() manager set (650-820), refineryCardsReport (559-576)
+ private static readonly int[] TripsWidths =
+ [100, 150, 150, 150, 200, 200, 200, 200, 150, 150, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 220, 200, 200, 200, 200, 200, 200, 200, 150];
+ private static readonly int[] CardsWidths = [100, 150, 150, 150];
+
+ private static TripExportFile Legacy(
+ string name, string title, IReadOnlyList<(string Label, string Value)> filters, string[] headers, int[] widths,
+ IReadOnlyList> data) =>
+ new(LegacyReportWorkbook.ToXlsx(new LegacyReport(CompanyName, title, filters, headers, widths, data)),
+ $"{name}-{Stamp}.xlsx", TabularExport.XlsxContentType);
+
+ /// The filters row of the legacy report: the text filters in a fixed order (status shown with its caption), then the dates, oldest first.
+ public static IReadOnlyList<(string Label, string Value)> Filters(TripQuery q)
+ {
+ var f = new List<(string Label, string Value)>();
+ void Add(string label, string? v) { if (!string.IsNullOrWhiteSpace(v)) f.Add((label, v.Trim())); }
+ Add("رقم الارسالية", q.Pn);
+ Add("رقم القاطرة", q.Tn);
+ Add("رقم المقطورة", q.Trn);
+ Add("الرقم الوطني", q.Nnpn);
+ Add("رقم الحمولة", q.LoadingNo);
+ Add("رقم النموذج", q.DischargeAuthNo);
+ if (!string.IsNullOrWhiteSpace(q.StatusCode))
+ f.Add(("الحالة", string.Join("،", q.StatusCode.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
+ .Select(s => s.Trim('\'')).Select(s => TripStatus.Captions.GetValueOrDefault(s, s)))));
+ Add("رقم مطالبة اجور النقل", q.WageClaimNo);
+ Add("رقم الحساب", q.BankAccount);
+ var dates = new List<(DateTime Value, string Label)>();
+ void AddDate(string label, DateTime? d) { if (d is not null) dates.Add((d.Value, label)); }
+ AddDate("تاريخ الارسالية", q.DispatchDate);
+ AddDate("تاريخ النموذج", q.DischargeEntryDate);
+ AddDate("من تاريخ التحميل", q.LoadingDateFrom);
+ AddDate("الى تاريخ التحميل", q.LoadingDateTo);
+ AddDate("من تاريخ الدفع", q.PaymentedDateFrom);
+ AddDate("الى تاريخ الدفع", q.PaymentedDateTo);
+ foreach (var (value, label) in dates.OrderBy(d => d.Value)) f.Add((label, Day(value)));
+ return f;
+ }
+
public async Task TripsAsync(TripQuery query, CancellationToken ct)
{
TripQueryService.ValidateRanges(query);
@@ -67,7 +111,7 @@ public sealed class TripReportService(ITripRepository trips) : ITripReportServic
"تاريخ الاستلام", "اسم المستلم", "تاريخ التحميل", "آلية الصرف", "صاحب الحساب", "صاحب الحساب بالانجليزي", "البنك", "IBAN",
"رقم الحساب", "رقم المحفظة", "رقم هوية المالك"
];
- return Xlsx("refinery-trips", new ExportTable(["شاشة الارساليات"], headers, data));
+ return Legacy("refinery-trips", TripsTitle, Filters(query), headers, TripsWidths, data);
}
/// factoryweb.report, REFINERY_OP column set (lines 825-870): form no., truck, net wage, paid / received dates and receiver.
@@ -82,22 +126,49 @@ public sealed class TripReportService(ITripRepository trips) : ITripReportServic
return Xlsx("refinery-trips-operator", new ExportTable(["شاشة الارساليات"], headers, data));
}
- /// factoryweb.report, EXCHANGE_OP column set (lines 870-940): the trip, weights, truck, trailer, driver id, net wage and status.
+ // legacy الحوالات list (companyreport.cfr output): title and column widths in characters, as in the legacy sample files
+ private const string TransfersTitle = "قائمة ارقام نماذج التفريغ المعدة لصرف أجور النقل";
+ private static readonly double[] TransfersWidths = [9.14, 10.86, 16.71, 12.29, 12.71, 24.86, 12.29, 13.57, 13.71, 11.43, 15.43, 15.43, 24.29];
+
+ ///
+ /// الحوالات (legacy refineryBankReport, layout of companyreport.cfr): the discharge forms prepared for payment by bank transfer to ONE account.
+ /// The bank account is required (ERROR.NO_BANK_ACCOUNT); the other filters are the legacy ones: status, wage-claim flag and payment dates.
+ /// The sheet shows the account block (owner, English name, bank, account number, IBAN, total net wage) and then the trips table.
+ ///
public async Task ExchangeAsync(TripQuery query, CancellationToken ct)
{
- TripQueryService.ValidateRanges(query);
- var rows = await trips.ReportAsync(query, ct);
+ if (string.IsNullOrWhiteSpace(query.BankAccount)) throw TripErrors.NoBankAccount();
+ if (query.PaymentedDateFrom > query.PaymentedDateTo) throw TripErrors.FromAfterTo();
+ var q = new TripQuery(
+ BankAccount: query.BankAccount, StatusCode: query.StatusCode, HasWageClaim: query.HasWageClaim,
+ PaymentedDateFrom: query.PaymentedDateFrom, PaymentedDateTo: query.PaymentedDateTo);
+ var rows = await trips.ReportAsync(q, ct);
+
+ var first = rows.FirstOrDefault();
+ var total = Math.Round(rows.Sum(r => r.NetWage ?? 0m), 3);
+ IReadOnlyList<(string Label, object? Value)> info =
+ [
+ ("صاحب الحساب", first?.OwnerName),
+ ("الاسم بالانجليزي", first?.OwnerNameEnglish),
+ ("اسم البنك", first?.BankName),
+ ("رقم الحساب", first?.BankAccount ?? query.BankAccount.Trim()),
+ ("IBAN", first?.Iban),
+ ("صافي قيمة اجور النقل", total)
+ ];
var data = rows.Select((r, i) => (IReadOnlyList