BillCSVPoster.cs 1.1 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 BillCSVPoster : ICSVPoster<Bill>
  10. {
  11. public CSVPosterSettings Settings { get; set; }
  12. public bool BeforePost(IDataModel<Bill> model)
  13. {
  14. return true;
  15. }
  16. public ICSVExport<Bill> Process(IDataModel<Bill> model)
  17. {
  18. var export = new CSVExport<Bill, Bill>();
  19. export.DefineMapping(new()
  20. {
  21. new("Number", x => x.Number),
  22. new("SupplierCode", x => x.SupplierLink.Code),
  23. new("Date", x => x.BillDate),
  24. new("ExTax", x => x.ExTax),
  25. new("Tax", x => x.Tax),
  26. new("IncTax", x => x.IncTax)
  27. });
  28. foreach (var bill in model.GetTable<Bill>().ToObjects<Bill>())
  29. {
  30. export.AddSuccess(bill, bill);
  31. }
  32. return export;
  33. }
  34. public void AfterPost(IDataModel<Bill> model, IPostResult<Bill> result)
  35. {
  36. }
  37. }
  38. }