InvoiceCSVPoster.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.Poster.CSV;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. namespace PRS.Shared
  8. {
  9. public class InvoiceCSVPoster : ICSVPoster<Invoice>
  10. {
  11. public CSVPosterSettings Settings { get; set; }
  12. public bool BeforePost(IDataModel<Invoice> model)
  13. {
  14. return true;
  15. }
  16. public ICSVExport<Invoice> Process(IDataModel<Invoice> model)
  17. {
  18. var export = new CSVExport<Invoice, Invoice>();
  19. export.DefineMapping(new()
  20. {
  21. new("Number", x => x.Number),
  22. new("Date", x => x.Date),
  23. new("Description", x => x.Description),
  24. new("ExTax", x => x.ExTax),
  25. new("Tax", x => x.Tax),
  26. new("IncTax", x => x.IncTax)
  27. });
  28. foreach (var invoice in model.GetTable<Invoice>().ToObjects<Invoice>())
  29. {
  30. export.AddSuccess(invoice, invoice);
  31. }
  32. return export;
  33. }
  34. public void AfterPost(IDataModel<Invoice> model, IPostResult<Invoice> result)
  35. {
  36. }
  37. }
  38. }