V6Profile.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using InABox.Integration.V6;
  4. namespace PRSDesktop.Integations.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 =
  17. "SELECT \n" +
  18. $" e.extn_code as {nameof(Code)}, \n" +
  19. $" e.descr as {nameof(Description)}, \n" +
  20. $" f.fincol_code as {nameof(Finish)}, \n" +
  21. $" round(coalesce(bb.bar_length, 0.0) * 0.0254, 2) as {nameof(Length)}, \n" +
  22. $" sum(bp.piece_count) as {nameof(Quantity)}, \n" +
  23. $" round(bb.cost * coalesce(bb.bar_length, 0.0),2) as {nameof(Cost)} \n" +
  24. "FROM \n" +
  25. " bom_piece bp \n" +
  26. "left outer join \n" +
  27. " extn e on bp.extn_id = e.extn_id \n" +
  28. "left outer join \n" +
  29. " quote_item qi on qi.quote_item_id = bp.quote_item_id \n" +
  30. "left outer join \n" +
  31. " quote q on q.quote_id = qi.quote_id \n" +
  32. "left outer join \n" +
  33. " (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 \n" +
  34. "left outer join \n" +
  35. " bom_bar bb on bb.bom_cutplan_id = bcp.bom_cutplan_id \n" +
  36. "left outer join \n" +
  37. " fincol f on f.fincol_lib_id = bp.fincol_lib_id and f.fincol_id = bp.fincol_id \n" +
  38. "where \n" +
  39. " 1 = 1 \n" +
  40. "and \n" +
  41. " bb.bar_length is not null \n" +
  42. "group by \n" +
  43. " e.extn_code, \n" +
  44. " e.descr, \n" +
  45. " f.fincol_code, \n" +
  46. " bb.bar_length, \n" +
  47. " bb.cost";
  48. }
  49. }