@@ -1659,6 +1659,21 @@ .footer .confidential {{
16591659 private static readonly XLColor PodGreen = XLColor . FromHtml ( "#2E7D32" ) ;
16601660 private static readonly XLColor PodOrange = XLColor . FromHtml ( "#E65100" ) ;
16611661 private static readonly XLColor PodRed = XLColor . FromHtml ( "#C62828" ) ;
1662+ private static readonly HashSet < string > PodExcelExcludedBusinessPartnerCodes = new (
1663+ Enumerable . Range ( 1 , 20 ) . Select ( number => $ "VAN{ number : 000} ")
1664+ . Concat ( [
1665+ "COR006" ,
1666+ "COR007" ,
1667+ "MAC006" ,
1668+ "MAC009" ,
1669+ "CHA009" ,
1670+ "STE014" ,
1671+ "ABI002" ,
1672+ "RED002 FCA" ,
1673+ "RED002(FCA)"
1674+ ] ) ,
1675+ StringComparer . OrdinalIgnoreCase ) ;
1676+ private static readonly HashSet < int > PodExcelExcludedCreatorUserIds = [ 75 , 51 , 70 , 1 , 54 , 32 ] ;
16621677
16631678 private static void PodApplyDefaults ( IXLWorksheet ws )
16641679 {
@@ -1872,6 +1887,18 @@ private static string FormatPodUploadDate(DateTime? uploadedAt) =>
18721887 private static string FormatPodGeneratedLocationDisplay ( PodUploadStatusItem item ) =>
18731888 string . IsNullOrWhiteSpace ( item . CreatedLocation ) ? "Unmapped creator" : item . CreatedLocation . Trim ( ) ;
18741889
1890+ private static bool IsPodExcelExcludedInvoice ( PodUploadStatusItem item ) =>
1891+ IsPodExcelExcludedBusinessPartner ( item )
1892+ || IsPodExcelExcludedCreatorUser ( item ) ;
1893+
1894+ private static bool IsPodExcelExcludedBusinessPartner ( PodUploadStatusItem item ) =>
1895+ ! string . IsNullOrWhiteSpace ( item . CardCode )
1896+ && PodExcelExcludedBusinessPartnerCodes . Contains ( item . CardCode . Trim ( ) ) ;
1897+
1898+ private static bool IsPodExcelExcludedCreatorUser ( PodUploadStatusItem item ) =>
1899+ item . CreatedByUserId . HasValue
1900+ && PodExcelExcludedCreatorUserIds . Contains ( item . CreatedByUserId . Value ) ;
1901+
18751902 private static int CalculatePodDaysAging ( string ? docDate , DateTime now )
18761903 {
18771904 if ( ! DateTime . TryParse ( docDate , out var parsedDate ) )
@@ -1938,12 +1965,18 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
19381965 using var workbook = new XLWorkbook ( ) ;
19391966 var now = CurrentCatNow ( ) ;
19401967 var periodText = FormatPodReportPeriod ( report ) ;
1968+ var reportItems = report . Items
1969+ . Where ( item => ! IsPodExcelExcludedInvoice ( item ) )
1970+ . ToList ( ) ;
19411971
1942- var totalAmount = report . Items . Sum ( item => item . DocTotal ) ;
1943- var uploadedAmount = report . Items . Where ( item => item . HasPod ) . Sum ( item => item . DocTotal ) ;
1944- var pendingAmount = report . Items . Where ( item => ! item . HasPod ) . Sum ( item => item . DocTotal ) ;
1945- var completionPct = report . TotalInvoices > 0
1946- ? report . UploadedCount / ( double ) report . TotalInvoices * 100
1972+ var totalInvoices = reportItems . Count ;
1973+ var uploadedCount = reportItems . Count ( item => item . HasPod ) ;
1974+ var pendingCount = reportItems . Count ( item => ! item . HasPod ) ;
1975+ var totalAmount = reportItems . Sum ( item => item . DocTotal ) ;
1976+ var uploadedAmount = reportItems . Where ( item => item . HasPod ) . Sum ( item => item . DocTotal ) ;
1977+ var pendingAmount = reportItems . Where ( item => ! item . HasPod ) . Sum ( item => item . DocTotal ) ;
1978+ var completionPct = totalInvoices > 0
1979+ ? uploadedCount / ( double ) totalInvoices * 100
19471980 : 0 ;
19481981
19491982 {
@@ -1953,9 +1986,9 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
19531986
19541987 var row = PodTitleBar ( ws , $ "POD UPLOAD STATUS - { periodText } ", lastCol , now ) ;
19551988 row = PodKpiStrip ( ws , row , lastCol ,
1956- ( "Total Invoices" , report . TotalInvoices . ToString ( "N0" ) , null ) ,
1957- ( "Uploaded" , report . UploadedCount . ToString ( "N0" ) , PodGreen ) ,
1958- ( "Pending" , report . PendingCount . ToString ( "N0" ) , report . PendingCount > 0 ? PodOrange : PodGreen ) ,
1989+ ( "Total Invoices" , totalInvoices . ToString ( "N0" ) , null ) ,
1990+ ( "Uploaded" , uploadedCount . ToString ( "N0" ) , PodGreen ) ,
1991+ ( "Pending" , pendingCount . ToString ( "N0" ) , pendingCount > 0 ? PodOrange : PodGreen ) ,
19591992 ( "Completion" , $ "{ completionPct : N1} %", GetPodCompletionColor ( completionPct ) ) ,
19601993 ( "Total Value" , FormatPodAmount ( totalAmount ) , null ) ,
19611994 ( "Pending Value" , FormatPodAmount ( pendingAmount ) , pendingAmount > 0 ? PodOrange : PodGreen ) ) ;
@@ -1978,7 +2011,7 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
19782011 ] ) ;
19792012
19802013 var rowIndex = 0 ;
1981- foreach ( var item in report . Items )
2014+ foreach ( var item in reportItems )
19822015 {
19832016 var isStripe = rowIndex % 2 == 1 ;
19842017 PodDataRow ( ws , row , lastCol , isStripe ) ;
@@ -2023,12 +2056,12 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
20232056
20242057 PodSummaryRow ( ws , row , lastCol ) ;
20252058 ws . Cell ( row , 1 ) . Value = "SUMMARY" ;
2026- ws . Cell ( row , 2 ) . Value = $ "{ report . TotalInvoices : N0} invoices";
2059+ ws . Cell ( row , 2 ) . Value = $ "{ totalInvoices : N0} invoices";
20272060 ws . Cell ( row , 4 ) . Value = periodText ;
20282061 ws . Cell ( row , 6 ) . Value = totalAmount ;
20292062 ws . Cell ( row , 6 ) . Style . NumberFormat . Format = "#,##0.00" ;
20302063 ws . Cell ( row , 6 ) . Style . Alignment . Horizontal = XLAlignmentHorizontalValues . Right ;
2031- ws . Cell ( row , 7 ) . Value = $ "{ report . UploadedCount : N0} uploaded / { report . PendingCount : N0} pending";
2064+ ws . Cell ( row , 7 ) . Value = $ "{ uploadedCount : N0} uploaded / { pendingCount : N0} pending";
20322065 ws . Cell ( row , 7 ) . Style . Alignment . Horizontal = XLAlignmentHorizontalValues . Center ;
20332066 ws . Cell ( row , 9 ) . Value = totalAmount ;
20342067 ws . Cell ( row , 9 ) . Style . NumberFormat . Format = "#,##0.00" ;
@@ -2047,7 +2080,7 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
20472080 ws . Column ( 9 ) . Width = 14 ;
20482081 }
20492082
2050- var pending = report . Items . Where ( item => ! item . HasPod ) . OrderBy ( item => item . DocDate ) . ToList ( ) ;
2083+ var pending = reportItems . Where ( item => ! item . HasPod ) . OrderBy ( item => item . DocDate ) . ToList ( ) ;
20512084 {
20522085 var ws = workbook . Worksheets . Add ( "Pending PODs" ) ;
20532086 const int lastCol = 7 ;
@@ -2125,7 +2158,7 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
21252158 ws . Column ( 7 ) . Width = 14 ;
21262159 }
21272160
2128- var uploadsByUser = report . Items
2161+ var uploadsByUser = reportItems
21292162 . Where ( item => item . HasPod )
21302163 . SelectMany ( item => GetPodUploadedByUsers ( item ) . Select ( uploader => new { Item = item , Uploader = uploader } ) )
21312164 . GroupBy ( entry => entry . Uploader . Username , StringComparer . OrdinalIgnoreCase )
@@ -2211,7 +2244,7 @@ public byte[] ExportPodUploadStatusToExcel(PodUploadStatusReport report)
22112244 ws . Column ( 5 ) . Width = 22 ;
22122245 }
22132246
2214- var uploaded = report . Items . Where ( item => item . HasPod ) . OrderByDescending ( item => item . PodUploadedAt ) . ToList ( ) ;
2247+ var uploaded = reportItems . Where ( item => item . HasPod ) . OrderByDescending ( item => item . PodUploadedAt ) . ToList ( ) ;
22152248 {
22162249 var ws = workbook . Worksheets . Add ( "Uploaded PODs" ) ;
22172250 const int lastCol = 8 ;
0 commit comments