InvoiceGeneratorFromWZ is a .NET 10 Windows Worker Service that automatically creates sales invoices in Comarch XL based on WZ documents retrieved from SQL Server.
The service runs in the background, checks eligible WZ documents on a schedule, groups them by business rules, and creates invoice documents through the XL API.
InvoiceGeneratorFromWZ.Service- Worker host and scheduling logic.
- Dependency injection and Serilog setup.
- Main orchestration via
WorkerandInvoiceProcessingService.
InvoiceGeneratorFromWZ.Infrastructure- SQL access with
Dapper(DapperDbExecutor). - Repository implementation (
DocumentRepository). - Comarch XL integration (
XlApiService) usingcdn_api20251.net.dll.
- SQL access with
InvoiceGeneratorFromWZ.Contracts- Shared models, interfaces, enums, and settings contracts.
Workerruns continuously as a hosted background service.- At the configured hour (once per day), it triggers
IInvoiceProcessingService.ProcessInvoicesAsync(). InvoiceProcessingServiceloads WZ documents fromIDocumentRespository.- Documents are filtered by
WZDocument.ShouldInvoiceToday(day). - Remaining items are grouped by:
ClientAcronymCourierPaymentNumberPaymentDueDateAddressIdClientId
- For each group,
IXlApiService:- Logs in to XL,
- Starts a transaction,
- Creates an invoice header,
- Attaches WZ documents to the binder,
- Closes the invoice,
- Commits the transaction (or rolls back on failure),
- Logs out.
WZDocument- Represents source WZ data required for invoice generation.
- Includes
DaysWhenMakeInvoiceandShouldInvoiceToday(int day)for billing-day selection.
- Logging is handled by
Serilog. - Logs are written to:
- Console
- Daily rolling files in
logsunder the service base directory
- Group-level failures are logged and do not stop processing of other groups.
- XL login/logout is protected with
try/finallyin processing flow.
.NET 10Worker ServiceMicrosoft.Extensions.Hosting.WindowsServicesDapperMicrosoft.Data.SqlClientSerilog(Console+Filesinks)- Comarch XL API (
cdn_api20251.net.dll)
This project is proprietary and confidential.
It was developed for a client and is not permitted to be shared, redistributed, or used without explicit written permission from the owner.
See LICENSE for details.
© 2026-present calKU0