You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

2 years ago
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace EasyBL
  6. {
  7. public class CbmVolume
  8. {
  9. public string OrgID { set; get; }
  10. public string ParentID { set; get; }
  11. public string BillNO { set; get; }
  12. public string sVolumes { set; get; }
  13. public double Volumes
  14. {
  15. get
  16. {
  17. if (double.TryParse(sVolumes, out double Result))
  18. return Result;
  19. else
  20. return 0;
  21. }
  22. }
  23. public string IsReturn { set; get; }
  24. public static decimal GetCBMPercent(List<CbmVolume> feeItems, string AllocatedBillNO)
  25. {
  26. if (feeItems.Count == 1)
  27. return 1;
  28. var CBMPercent = decimal.Zero;
  29. var CBMUsed = feeItems.FirstOrDefault(c => c.BillNO == AllocatedBillNO);
  30. var CBMTotal = feeItems.Sum(c => c.Volumes);
  31. if (CBMUsed != null && CBMTotal >0)
  32. CBMPercent = Convert.ToDecimal(CBMUsed.Volumes / feeItems.Sum(c => c.Volumes));
  33. return CBMPercent;
  34. }
  35. }
  36. }