V6Labour.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 = $@"
  20. select
  21. la.Descr as {nameof(Code)},
  22. la.Descr as {nameof(Description)},
  23. bl.Cost * 60 as {nameof(Cost)},
  24. sum(bl.lab_time/60.0) as {nameof(Quantity)}
  25. from
  26. bom_labour bl
  27. left outer join
  28. quote_item qi on qi.quote_item_id = bl.quote_item_id
  29. left outer join
  30. quote q on q.quote_id = qi.quote_id
  31. left outer join
  32. lab_area la on la.lab_area_lib_id = bl.lab_area_lib_id and la.lab_area_id = bl.lab_area_id
  33. where
  34. 1=1
  35. and
  36. qi.quote_vers_start <= q.quote_vers and qi.quote_vers_stop >= q.quote_vers
  37. group by
  38. la.Descr, bl.Cost";
  39. }
  40. }