InvoiceCSVPoster.cs 1.1 KB

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