V6Labour.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using InABox.Integration.V6;
  4. namespace PRSDesktop.Integrations.V6
  5. {
  6. public class V6Labour : V6Object, IV6Labour
  7. {
  8. public string Code { get; set; }
  9. public string Description { get; set; }
  10. public double Quantity { get; set; }
  11. public double Cost { get; set; }
  12. public override void ValidateQuery(string sql, List<string> errors)
  13. {
  14. ValidateField(sql,nameof(Code), errors);
  15. ValidateField(sql,nameof(Description), errors);
  16. ValidateField(sql, nameof(Quantity), errors);
  17. ValidateField(sql, nameof(Cost), errors);
  18. }
  19. public static String SQL = $@"select
  20. la.code as {nameof(Code)},
  21. la.code as {nameof(Description)},
  22. sum(bl.lab_time/60.0) as {nameof(Quantity)},
  23. sum(bl.cost) as {nameof(Cost)}
  24. from
  25. bom_labour bl
  26. left outer join
  27. quote_item qi on qi.quote_item_id = bl.quote_item_id
  28. left outer join
  29. quote q on q.quote_id = qi.quote_id
  30. left outer join
  31. (select lab_area_lib_id, lab_area_id, case when descr LIKE '%Cutting%' then 'CUTTING' when descr LIKE '%Site%' OR descr LIKE '%fixings%' OR descr LIKE '%S/Glz%' then 'SITE' else 'FABRICATION' end as code from lab_area) la on la.lab_area_lib_id = bl.lab_area_lib_id and la.lab_area_id = bl.lab_area_id
  32. where
  33. 1=1
  34. group by
  35. la.code";
  36. }
  37. }