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