public static string ToDecriptionString(this EFIPaymentTypeEnum val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : "" + val);
 }
Exemplo n.º 2
0
 public static EFIReceipt CalculateTotalAmount(this EFIReceipt receipt, EFIPaymentTypeEnum paymentType)
 {
     receipt.Payments = new List <EFIPaymentItem>();
     receipt.Payments.Add(new EFIPaymentItem
     {
         PaymentType = paymentType.ToDecriptionString(),
         Amount      = receipt.Sales.Sum(item => item.Price * item.Quantity * (1 - item.DiscountPercentage / 100))
     });
     return(receipt);
 }
Exemplo n.º 3
0
 public static EFIReceipt AddPayment(this EFIReceipt receipt, EFIPaymentTypeEnum paymentType, decimal amount)
 {
     if (receipt.Payments == null)
     {
         receipt.Payments = new List <EFIPaymentItem>();
     }
     receipt.Payments.Add(new EFIPaymentItem
     {
         PaymentType = paymentType.ToDecriptionString(),
         Amount      = amount,
     });
     return(receipt);
 }