Ejemplo n.º 1
0
        private bool saveTransaction(Guid currencyId, decimal value)
        {
            var currencyExchange = getExchangeRateFromForeignId(currencyId);
            var surcharge        = Surcharges.FirstOrDefault(c => c.CurrencyId == currencyId);

            ICompletedTransaction transaction = new CompletedTransaction();

            transaction.ExchangeRateId    = currencyExchange.Id;
            transaction.LocalValue        = CalculateLocalOwedAmount(currencyId, value);
            transaction.ForeignValue      = value;
            transaction.ExchangeRateValue = currencyExchange.Value;
            transaction.SurchargeId       = surcharge.Id;
            transaction.SurchargePercent  = surcharge.Value;
            transaction.SurchargeValue    = value * (1 + surcharge.Value);

            if (discount.HasValue)
            {
                transaction.Discount = discount.Value;
            }

            if (discount.HasValue)
            {
                transaction.LocalValue = transaction.LocalValue / (1 + discount.Value);
            }

            CompletedTransactionDataAccessor completedTransactionAccessor = new CompletedTransactionDataAccessor(baseUri);
            var saveResult = completedTransactionAccessor.Insert(transaction);

            return(saveResult);
        }
Ejemplo n.º 2
0
 public void ParseNode(XmlNode n)
 {
     _BaseCharge = XmlHelper.ParseDecimal(n, "BaseCharge");
     if (n != null)
     {
         var sn = n.SelectSingleNode("Surcharges");
         if (sn != null)
         {
             foreach (XmlNode snn in sn.ChildNodes)
             {
                 var description = snn.Name;
                 var tempAmount  = snn.InnerText;
                 var amount      = 0m;
                 decimal.TryParse(tempAmount, NumberStyles.Float,
                                  CultureInfo.InvariantCulture, out amount);
                 Surcharges.Add(new Surcharge(description, amount));
             }
         }
     }
     _TotalSurcharge    = XmlHelper.ParseDecimal(n, "TotalSurcharge");
     _NetCharge         = XmlHelper.ParseDecimal(n, "NetCharge");
     _ShipmentNetCharge = XmlHelper.ParseDecimal(n, "ShipmentNetCharge");
     _TotalRebate       = XmlHelper.ParseDecimal(n, "TotalRebate");
     _TotalDiscount     = XmlHelper.ParseDecimal(n, "TotalDiscount");
 }
Ejemplo n.º 3
0
        public void AddSurcharge()
        {
            var surcharge = new Surcharge()
            {
                Name = Name, Price = Price
            };

            _esClinicContext.Surcharges.Add(surcharge);
            _esClinicContext.SaveChanges();

            Surcharges.Add(surcharge);
        }
Ejemplo n.º 4
0
        public decimal CalculateLocalOwedAmount(Guid currencyId, decimal value)
        {
            var currencyExchange = getExchangeRateFromForeignId(currencyId);
            var surcharge        = Surcharges.FirstOrDefault(c => c.CurrencyId == currencyId);

            if (currencyExchange == null || currencyExchange.Value == decimal.Zero)
            {
                return(0);
            }

            var calculatedAmount = value / (currencyExchange.Value);

            if (surcharge != null)
            {
                calculatedAmount = calculatedAmount * (1 + surcharge.Value);
            }

            return(calculatedAmount);
        }
Ejemplo n.º 5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is V1Payment other &&
                   ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((MerchantId == null && other.MerchantId == null) || (MerchantId?.Equals(other.MerchantId) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((CreatorId == null && other.CreatorId == null) || (CreatorId?.Equals(other.CreatorId) == true)) &&
                   ((Device == null && other.Device == null) || (Device?.Equals(other.Device) == true)) &&
                   ((PaymentUrl == null && other.PaymentUrl == null) || (PaymentUrl?.Equals(other.PaymentUrl) == true)) &&
                   ((ReceiptUrl == null && other.ReceiptUrl == null) || (ReceiptUrl?.Equals(other.ReceiptUrl) == true)) &&
                   ((InclusiveTaxMoney == null && other.InclusiveTaxMoney == null) || (InclusiveTaxMoney?.Equals(other.InclusiveTaxMoney) == true)) &&
                   ((AdditiveTaxMoney == null && other.AdditiveTaxMoney == null) || (AdditiveTaxMoney?.Equals(other.AdditiveTaxMoney) == true)) &&
                   ((TaxMoney == null && other.TaxMoney == null) || (TaxMoney?.Equals(other.TaxMoney) == true)) &&
                   ((TipMoney == null && other.TipMoney == null) || (TipMoney?.Equals(other.TipMoney) == true)) &&
                   ((DiscountMoney == null && other.DiscountMoney == null) || (DiscountMoney?.Equals(other.DiscountMoney) == true)) &&
                   ((TotalCollectedMoney == null && other.TotalCollectedMoney == null) || (TotalCollectedMoney?.Equals(other.TotalCollectedMoney) == true)) &&
                   ((ProcessingFeeMoney == null && other.ProcessingFeeMoney == null) || (ProcessingFeeMoney?.Equals(other.ProcessingFeeMoney) == true)) &&
                   ((NetTotalMoney == null && other.NetTotalMoney == null) || (NetTotalMoney?.Equals(other.NetTotalMoney) == true)) &&
                   ((RefundedMoney == null && other.RefundedMoney == null) || (RefundedMoney?.Equals(other.RefundedMoney) == true)) &&
                   ((SwedishRoundingMoney == null && other.SwedishRoundingMoney == null) || (SwedishRoundingMoney?.Equals(other.SwedishRoundingMoney) == true)) &&
                   ((GrossSalesMoney == null && other.GrossSalesMoney == null) || (GrossSalesMoney?.Equals(other.GrossSalesMoney) == true)) &&
                   ((NetSalesMoney == null && other.NetSalesMoney == null) || (NetSalesMoney?.Equals(other.NetSalesMoney) == true)) &&
                   ((InclusiveTax == null && other.InclusiveTax == null) || (InclusiveTax?.Equals(other.InclusiveTax) == true)) &&
                   ((AdditiveTax == null && other.AdditiveTax == null) || (AdditiveTax?.Equals(other.AdditiveTax) == true)) &&
                   ((Tender == null && other.Tender == null) || (Tender?.Equals(other.Tender) == true)) &&
                   ((Refunds == null && other.Refunds == null) || (Refunds?.Equals(other.Refunds) == true)) &&
                   ((Itemizations == null && other.Itemizations == null) || (Itemizations?.Equals(other.Itemizations) == true)) &&
                   ((SurchargeMoney == null && other.SurchargeMoney == null) || (SurchargeMoney?.Equals(other.SurchargeMoney) == true)) &&
                   ((Surcharges == null && other.Surcharges == null) || (Surcharges?.Equals(other.Surcharges) == true)) &&
                   ((IsPartial == null && other.IsPartial == null) || (IsPartial?.Equals(other.IsPartial) == true)));
        }
Ejemplo n.º 6
0
        private ISurcharge getSurchargeFromCurrencyId(Guid currencyId)
        {
            var surcharge = Surcharges.FirstOrDefault(c => c.CurrencyId == currencyId);

            return(surcharge);
        }
Ejemplo n.º 7
0
        public override int GetHashCode()
        {
            int hashCode = -215174345;

            if (Context != null)
            {
                hashCode += Context.GetHashCode();
            }

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (MerchantId != null)
            {
                hashCode += MerchantId.GetHashCode();
            }

            if (CreatedAt != null)
            {
                hashCode += CreatedAt.GetHashCode();
            }

            if (CreatorId != null)
            {
                hashCode += CreatorId.GetHashCode();
            }

            if (Device != null)
            {
                hashCode += Device.GetHashCode();
            }

            if (PaymentUrl != null)
            {
                hashCode += PaymentUrl.GetHashCode();
            }

            if (ReceiptUrl != null)
            {
                hashCode += ReceiptUrl.GetHashCode();
            }

            if (InclusiveTaxMoney != null)
            {
                hashCode += InclusiveTaxMoney.GetHashCode();
            }

            if (AdditiveTaxMoney != null)
            {
                hashCode += AdditiveTaxMoney.GetHashCode();
            }

            if (TaxMoney != null)
            {
                hashCode += TaxMoney.GetHashCode();
            }

            if (TipMoney != null)
            {
                hashCode += TipMoney.GetHashCode();
            }

            if (DiscountMoney != null)
            {
                hashCode += DiscountMoney.GetHashCode();
            }

            if (TotalCollectedMoney != null)
            {
                hashCode += TotalCollectedMoney.GetHashCode();
            }

            if (ProcessingFeeMoney != null)
            {
                hashCode += ProcessingFeeMoney.GetHashCode();
            }

            if (NetTotalMoney != null)
            {
                hashCode += NetTotalMoney.GetHashCode();
            }

            if (RefundedMoney != null)
            {
                hashCode += RefundedMoney.GetHashCode();
            }

            if (SwedishRoundingMoney != null)
            {
                hashCode += SwedishRoundingMoney.GetHashCode();
            }

            if (GrossSalesMoney != null)
            {
                hashCode += GrossSalesMoney.GetHashCode();
            }

            if (NetSalesMoney != null)
            {
                hashCode += NetSalesMoney.GetHashCode();
            }

            if (InclusiveTax != null)
            {
                hashCode += InclusiveTax.GetHashCode();
            }

            if (AdditiveTax != null)
            {
                hashCode += AdditiveTax.GetHashCode();
            }

            if (Tender != null)
            {
                hashCode += Tender.GetHashCode();
            }

            if (Refunds != null)
            {
                hashCode += Refunds.GetHashCode();
            }

            if (Itemizations != null)
            {
                hashCode += Itemizations.GetHashCode();
            }

            if (SurchargeMoney != null)
            {
                hashCode += SurchargeMoney.GetHashCode();
            }

            if (Surcharges != null)
            {
                hashCode += Surcharges.GetHashCode();
            }

            if (IsPartial != null)
            {
                hashCode += IsPartial.GetHashCode();
            }

            return(hashCode);
        }