V6Profile.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using InABox.Integration.V6;
  4. namespace PRSDesktop.Integrations.V6
  5. {
  6. public class V6Profile : V6BOMItem, IV6Profile
  7. {
  8. public double Length { get; set; }
  9. public string Finish { get; set; }
  10. public override void ValidateQuery(string sql, List<string> errors)
  11. {
  12. base.ValidateQuery(sql, errors);
  13. ValidateField(sql, nameof(Length), errors);
  14. ValidateField(sql, nameof(Finish), errors);
  15. }
  16. public static String SQL = $@"select
  17. e.extn_code as {nameof(Code)},
  18. e.descr as {nameof(Description)},
  19. f.fincol_code as {nameof(Finish)},
  20. round(coalesce(bb.bar_length, 0.0) * 0.0254, 2) as {nameof(Length)},
  21. sum(bp.piece_count) as {nameof(Quantity)},
  22. round(bb.cost * coalesce(bb.bar_length, 0.0),2) as {nameof(Cost)}
  23. from
  24. bom_piece bp
  25. left outer join
  26. extn e on bp.extn_id = e.extn_id
  27. left outer join
  28. quote_item qi on qi.quote_item_id = bp.quote_item_id
  29. left outer join
  30. quote q on q.quote_id = qi.quote_id
  31. left outer join
  32. (Select bcp.bom_piece_id, MAX(bcp.bom_cutplan_id) as bom_cutplan_id from bom_cutplan_piece bcp group by bcp.bom_piece_id) bcp on bcp.bom_piece_id = bp.bom_piece_id
  33. left outer join
  34. bom_bar bb on bb.bom_cutplan_id = bcp.bom_cutplan_id
  35. left outer join
  36. fincol f on f.fincol_lib_id = bp.fincol_lib_id and f.fincol_id = bp.fincol_id
  37. where
  38. 1 = 1
  39. and
  40. bb.bar_length is not null
  41. group by
  42. e.extn_code,
  43. e.descr,
  44. f.fincol_code,
  45. bb.bar_length,
  46. bb.cost";
  47. }
  48. }