コード例 #1
0
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.InjectFrom(this);

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            return(payment);
        }
コード例 #2
0
ファイル: SQLTaxProvider.cs プロジェクト: vinay1988/Ang6API
        /// <summary>
        /// DropDownForClient
        /// Calls [usp_dropdown_Tax_for_Client]
        /// </summary>
        public override List <TaxDetails> DropDownForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_dropdown_Tax_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader      reader = ExecuteReader(cmd);
                List <TaxDetails> lst    = new List <TaxDetails>();
                while (reader.Read())
                {
                    TaxDetails obj = new TaxDetails();
                    obj.TaxId   = GetReaderValue_Int32(reader, "TaxId", 0);
                    obj.TaxName = GetReaderValue_String(reader, "TaxName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Taxs", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
コード例 #3
0
        public virtual void Patch(ShipmentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.Fee                   = Fee;
            target.FeeWithTax            = FeeWithTax;
            target.FulfillmentCenterId   = FulfillmentCenterId;
            target.FulfillmentCenterName = FulfillmentCenterName;
            target.ShipmentMethodCode    = ShipmentMethodCode;
            target.Total                 = Total;
            target.TotalWithTax          = TotalWithTax;
            target.TaxTotal              = TaxTotal;
            target.Price                 = Price;
            target.PriceWithTax          = PriceWithTax;
            target.DiscountAmount        = DiscountAmount;
            target.DiscountAmountWithTax = DiscountAmountWithTax;
            target.TaxPercentRate        = TaxPercentRate;
            target.TaxIncluded           = TaxIncluded;
            target.Currency              = Currency;
            target.WeightUnit            = WeightUnit;
            target.WeightValue           = WeightValue;
            target.DimensionHeight       = DimensionHeight;
            target.DimensionLength       = DimensionLength;
            target.DimensionUnit         = DimensionUnit;
            target.DimensionWidth        = DimensionWidth;
            target.TaxType               = TaxType;
            target.ShipmentMethodOption  = ShipmentMethodOption;

            if (!Addresses.IsNullCollection())
            {
                Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }

            if (!Items.IsNullCollection())
            {
                Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance();

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance();

                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }
コード例 #4
0
ファイル: Display.cs プロジェクト: Liam-Scott-Russell/Katas
 private static void DisplayTaxInformation(TaxDetails taxInfo)
 {
     AlertUser($"Gross Income: {taxInfo.GrossIncome}");
     AlertUser($"Income Tax: {taxInfo.IncomeTax}");
     AlertUser($"Net Income: {taxInfo.NetIncome}");
     AlertUser($"Super: {taxInfo.SuperAmount}");
 }
コード例 #5
0
        public override object Clone()
        {
            var result = base.Clone() as Payment;

            result.Currency              = result.Currency?.Clone() as Currency;
            result.Price                 = result.Price?.Clone() as Money;
            result.PriceWithTax          = result.PriceWithTax?.Clone() as Money;
            result.DiscountAmount        = result.DiscountAmount?.Clone() as Money;
            result.DiscountAmountWithTax = result.DiscountAmountWithTax?.Clone() as Money;
            result.Amount                = result.Amount?.Clone() as Money;
            result.Total                 = result.Total?.Clone() as Money;
            result.TotalWithTax          = result.TotalWithTax?.Clone() as Money;
            result.TaxTotal              = result.TaxTotal?.Clone() as Money;

            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }

            return(result);
        }
コード例 #6
0
ファイル: Shipment.cs プロジェクト: yunly/vc-storefront-core
        public override object Clone()
        {
            var result = base.Clone() as Shipment;

            result.Price                 = Price?.Clone() as Money;
            result.PriceWithTax          = PriceWithTax?.Clone() as Money;
            result.DiscountAmount        = DiscountAmount?.Clone() as Money;
            result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money;
            result.Total                 = Total?.Clone() as Money;
            result.TotalWithTax          = TotalWithTax?.Clone() as Money;
            result.TaxTotal              = TaxTotal?.Clone() as Money;


            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }
            if (Items != null)
            {
                result.Items = new List <CartShipmentItem>(Items.Select(x => x.Clone() as CartShipmentItem));
            }
            if (ValidationErrors != null)
            {
                result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError));
            }

            return(result);
        }
コード例 #7
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var order = operation as CustomerOrder;

            if (order == null)
            {
                throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation));
            }

            order.CustomerId           = CustomerId;
            order.CustomerName         = CustomerName;
            order.StoreId              = StoreId;
            order.StoreName            = StoreName;
            order.OrganizationId       = OrganizationId;
            order.OrganizationName     = OrganizationName;
            order.EmployeeId           = EmployeeId;
            order.EmployeeName         = EmployeeName;
            order.DiscountAmount       = DiscountAmount;
            order.Total                = Total;
            order.SubTotal             = SubTotal;
            order.SubTotalWithTax      = SubTotalWithTax;
            order.ShippingTotal        = ShippingTotal;
            order.ShippingTotalWithTax = ShippingTotalWithTax;
            order.PaymentTotal         = PaymentTotal;
            order.PaymentTotalWithTax  = PaymentTotalWithTax;
            order.FeeTotal             = HandlingTotal;
            order.FeeTotalWithTax      = HandlingTotalWithTax;
            order.DiscountTotal        = DiscountTotal;
            order.DiscountTotalWithTax = DiscountTotalWithTax;
            order.DiscountAmount       = DiscountAmount;
            order.TaxTotal             = TaxTotal;
            order.IsPrototype          = IsPrototype;
            order.SubscriptionNumber   = SubscriptionNumber;
            order.SubscriptionId       = SubscriptionId;
            order.LanguageCode         = LanguageCode;
            order.TaxPercentRate       = TaxPercentRate;

            order.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            order.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            order.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            order.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).OfType <Shipment>().ToList();
            order.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            order.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            order.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            base.ToModel(order);

            Sum = order.Total;

            return(order);
        }
コード例 #8
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.Id           = Id;
            lineItem.CreatedDate  = CreatedDate;
            lineItem.CreatedBy    = CreatedBy;
            lineItem.ModifiedDate = ModifiedDate;
            lineItem.ModifiedBy   = ModifiedBy;
            lineItem.OuterId      = OuterId;

            lineItem.PriceId                 = PriceId;
            lineItem.CatalogId               = CatalogId;
            lineItem.CategoryId              = CategoryId;
            lineItem.Currency                = Currency;
            lineItem.ProductId               = ProductId;
            lineItem.Sku                     = Sku;
            lineItem.ProductType             = ProductType;
            lineItem.Name                    = Name;
            lineItem.ImageUrl                = ImageUrl;
            lineItem.ShippingMethodCode      = ShippingMethodCode;
            lineItem.FulfillmentLocationCode = FulfillmentLocationCode;

            lineItem.Price                 = Price;
            lineItem.PriceWithTax          = PriceWithTax;
            lineItem.DiscountAmount        = DiscountAmount;
            lineItem.DiscountAmountWithTax = DiscountAmountWithTax;
            lineItem.Quantity              = Quantity;
            lineItem.TaxTotal              = TaxTotal;
            lineItem.TaxPercentRate        = TaxPercentRate;
            lineItem.Weight                = Weight;
            lineItem.Height                = Height;
            lineItem.Width                 = Width;
            lineItem.MeasureUnit           = MeasureUnit;
            lineItem.WeightUnit            = WeightUnit;
            lineItem.Length                = Length;
            lineItem.TaxType               = TaxType;
            lineItem.IsCancelled           = IsCancelled;
            lineItem.CancelledDate         = CancelledDate;
            lineItem.CancelReason          = CancelReason;
            lineItem.Comment               = Comment;
            lineItem.IsGift                = IsGift;
            lineItem.Discounts             = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails            = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            lineItem.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(lineItem);
        }
コード例 #9
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.Id           = Id;
            lineItem.CreatedBy    = CreatedBy;
            lineItem.CreatedDate  = CreatedDate;
            lineItem.ModifiedBy   = ModifiedBy;
            lineItem.ModifiedDate = ModifiedDate;

            lineItem.ListPrice        = ListPrice;
            lineItem.ListPriceWithTax = ListPriceWithTax;
            lineItem.SalePrice        = SalePrice;
            lineItem.SalePriceWithTax = SalePriceWithTax;
            lineItem.Fee                     = Fee;
            lineItem.FeeWithTax              = FeeWithTax;
            lineItem.DiscountAmount          = DiscountAmount;
            lineItem.DiscountAmountWithTax   = DiscountAmountWithTax;
            lineItem.Quantity                = Quantity;
            lineItem.TaxTotal                = TaxTotal;
            lineItem.TaxPercentRate          = TaxPercentRate;
            lineItem.Weight                  = Weight;
            lineItem.Height                  = Height;
            lineItem.Width                   = Width;
            lineItem.MeasureUnit             = MeasureUnit;
            lineItem.WeightUnit              = WeightUnit;
            lineItem.Length                  = Length;
            lineItem.TaxType                 = TaxType;
            lineItem.IsReadOnly              = IsReadOnly;
            lineItem.ValidationType          = ValidationType;
            lineItem.PriceId                 = PriceId;
            lineItem.LanguageCode            = LanguageCode;
            lineItem.IsReccuring             = IsReccuring;
            lineItem.IsGift                  = IsGift;
            lineItem.ImageUrl                = ImageUrl;
            lineItem.ProductId               = ProductId;
            lineItem.ProductType             = ProductType;
            lineItem.ShipmentMethodCode      = ShipmentMethodCode;
            lineItem.RequiredShipping        = RequiredShipping;
            lineItem.ProductType             = ProductType;
            lineItem.FulfillmentLocationCode = FulfillmentLocationCode;
            lineItem.Note                    = Comment;

            if (!Discounts.IsNullOrEmpty())
            {
                lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!TaxDetails.IsNullOrEmpty())
            {
                lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            return(lineItem);
        }
コード例 #10
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as PaymentMethod;

            result.Settings   = Settings?.Select(x => x.Clone()).OfType <ObjectSettingEntry>().ToList();
            result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();

            return(result);
        }
コード例 #11
0
        public virtual ShoppingCart ToModel(ShoppingCart cart)
        {
            if (cart == null)
            {
                throw new ArgumentNullException(nameof(cart));
            }

            cart.Id           = Id;
            cart.CreatedBy    = CreatedBy;
            cart.CreatedDate  = CreatedDate;
            cart.ModifiedBy   = ModifiedBy;
            cart.ModifiedDate = ModifiedDate;

            cart.StoreId              = StoreId;
            cart.Fee                  = Fee;
            cart.FeeWithTax           = FeeWithTax;
            cart.Status               = Status;
            cart.Currency             = Currency;
            cart.ValidationType       = ValidationType;
            cart.CustomerId           = CustomerId;
            cart.CustomerName         = CustomerName;
            cart.IsAnonymous          = IsAnonymous;
            cart.IsRecuring           = IsRecuring;
            cart.LanguageCode         = LanguageCode;
            cart.Comment              = Comment;
            cart.OrganizationId       = OrganizationId;
            cart.Total                = Total;
            cart.SubTotal             = SubTotal;
            cart.SubTotalWithTax      = SubTotalWithTax;
            cart.ShippingTotal        = ShippingTotal;
            cart.ShippingTotalWithTax = ShippingTotalWithTax;
            cart.PaymentTotal         = PaymentTotal;
            cart.PaymentTotalWithTax  = PaymentTotalWithTax;
            cart.HandlingTotal        = HandlingTotal;
            cart.HandlingTotalWithTax = HandlingTotalWithTax;
            cart.DiscountTotal        = DiscountTotal;
            cart.DiscountTotalWithTax = DiscountTotalWithTax;
            cart.DiscountAmount       = DiscountAmount;
            cart.TaxTotal             = TaxTotal;
            cart.TaxPercentRate       = TaxPercentRate;
            cart.Type                 = Type;
            cart.Name                 = Name;

            cart.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            cart.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            cart.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            cart.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).ToList();
            cart.Payments   = Payments.Select(x => x.ToModel(AbstractTypeFactory <Payment> .TryCreateInstance())).ToList();
            cart.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            cart.Coupons    = Coupons.Select(x => x.Code).ToList();

            // Assigning single coupon to preserve backwards compatibility with previous versions of CartModule
            cart.Coupon = cart.Coupons.FirstOrDefault();

            return(cart);
        }
コード例 #12
0
        public virtual void Patch(LineItemEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.ListPrice        = ListPrice;
            target.ListPriceWithTax = ListPriceWithTax;
            target.SalePrice        = SalePrice;
            target.SalePriceWithTax = SalePriceWithTax;
            target.Fee                    = Fee;
            target.FeeWithTax             = FeeWithTax;
            target.DiscountAmount         = DiscountAmount;
            target.DiscountAmountWithTax  = DiscountAmountWithTax;
            target.Quantity               = Quantity;
            target.TaxTotal               = TaxTotal;
            target.TaxPercentRate         = TaxPercentRate;
            target.Weight                 = Weight;
            target.Height                 = Height;
            target.Width                  = Width;
            target.MeasureUnit            = MeasureUnit;
            target.WeightUnit             = WeightUnit;
            target.Length                 = Length;
            target.TaxType                = TaxType;
            target.Comment                = Comment;
            target.IsReadOnly             = IsReadOnly;
            target.ValidationType         = ValidationType;
            target.PriceId                = PriceId;
            target.LanguageCode           = LanguageCode;
            target.IsReccuring            = IsReccuring;
            target.IsGift                 = IsGift;
            target.ImageUrl               = ImageUrl;
            target.ProductId              = ProductId;
            target.ProductType            = ProductType;
            target.ShipmentMethodCode     = ShipmentMethodCode;
            target.RequiredShipping       = RequiredShipping;
            target.ProductType            = ProductType;
            target.FulfilmentLocationCode = FulfilmentLocationCode;
            target.FulfillmentCenterId    = FulfillmentCenterId;
            target.FulfillmentCenterName  = FulfillmentCenterName;

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance();

                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance();

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }
        }
コード例 #13
0
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.Id           = Id;
            payment.OuterId      = OuterId;
            payment.CreatedBy    = CreatedBy;
            payment.CreatedDate  = CreatedDate;
            payment.ModifiedBy   = ModifiedBy;
            payment.ModifiedDate = ModifiedDate;

            payment.Amount             = Amount;
            payment.PaymentGatewayCode = PaymentGatewayCode;
            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;
            //TODO
            //payment.Purpose = Purpose;
            payment.Currency = Currency;

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            payment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(payment);
        }
コード例 #14
0
ファイル: Payment.cs プロジェクト: brianmrush/vc-module-cart
        public object Clone()
        {
            var result = MemberwiseClone() as Payment;

            result.BillingAddress    = BillingAddress?.Clone() as Address;
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
コード例 #15
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as LineItem;

            result.Price             = Price?.Clone() as Price;
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
コード例 #16
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as Shipment;

            result.DeliveryAddress   = DeliveryAddress?.Clone() as Address;
            result.Items             = Items?.Select(x => x.Clone()).OfType <ShipmentItem>().ToList();
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
コード例 #17
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.InjectFrom(this);
            lineItem.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            return(lineItem);
        }
コード例 #18
0
        public override object Clone()
        {
            var result = base.Clone() as CustomerOrder;

            result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.Addresses  = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList();
            result.InPayments = InPayments?.Select(x => x.Clone()).OfType <PaymentIn>().ToList();
            result.Items      = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList();
            result.Shipments  = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList();
            result.Discounts  = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();

            return(result);
        }
コード例 #19
0
        public override object Clone()
        {
            var result = base.Clone() as PaymentIn;

            result.PaymentMethod        = PaymentMethod?.Clone() as PaymentMethod;
            result.BillingAddress       = BillingAddress?.Clone() as Address;
            result.ProcessPaymentResult = ProcessPaymentResult?.Clone() as ProcessPaymentRequestResult;
            result.Transactions         = Transactions?.Select(x => x.Clone()).OfType <PaymentGatewayTransaction>().ToList();
            result.Discounts            = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails           = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();

            return(result);
        }
コード例 #20
0
        public async Task AddOrUpdateTax_Created()
        {
            mockMediator.Setup(x => x.Send(It.IsAny <AddOrUpdateTaxCommand>(), default(System.Threading.CancellationToken))).Verifiable();

            var taxDetails = new TaxDetails
            {
                Municipality = "Copenhagen",
                Tax          = 1
            };

            var result = (await taxController.AddOrUpdateTax(0, taxDetails)) as StatusCodeResult;

            Assert.Equal(result.StatusCode, (int)HttpStatusCode.Created);
        }
コード例 #21
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as ShoppingCart;

            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.Addresses         = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList();
            result.Items             = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList();
            result.Payments          = Payments?.Select(x => x.Clone()).OfType <Payment>().ToList();
            result.Shipments         = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
コード例 #22
0
        public async Task <IActionResult> AddOrUpdateTax([Required] TaxType taxType, [Required] TaxDetails taxDetails)
        {
            _logger.LogInformation($"{nameof(AddOrUpdateTax)} method invoked");

            await _mediator.Send(new AddOrUpdateTaxCommand
            {
                Municipality = taxDetails.Municipality,
                Date         = taxDetails.Date,
                TaxType      = taxType,
                Tax          = taxDetails.Tax
            });

            return(StatusCode((int)HttpStatusCode.Created));
        }
コード例 #23
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.Id           = Id;
            lineItem.CreatedDate  = CreatedDate;
            lineItem.CreatedBy    = CreatedBy;
            lineItem.ModifiedDate = ModifiedDate;
            lineItem.ModifiedBy   = ModifiedBy;

            lineItem.PriceId                 = PriceId;
            lineItem.CatalogId               = CatalogId;
            lineItem.CategoryId              = CategoryId;
            lineItem.Currency                = Currency;
            lineItem.ProductId               = ProductId;
            lineItem.Sku                     = Sku;
            lineItem.ProductType             = ProductType;
            lineItem.Name                    = Name;
            lineItem.ImageUrl                = ImageUrl;
            lineItem.ShippingMethodCode      = ShippingMethodCode;
            lineItem.FulfillmentLocationCode = FulfillmentLocationCode;

            lineItem.Price                 = Price;
            lineItem.PriceWithTax          = PriceWithTax;
            lineItem.DiscountAmount        = DiscountAmount;
            lineItem.DiscountAmountWithTax = DiscountAmountWithTax;
            lineItem.Quantity              = Quantity;
            lineItem.TaxTotal              = TaxTotal;
            lineItem.TaxPercentRate        = TaxPercentRate;
            lineItem.Weight                = Weight;
            lineItem.Height                = Height;
            lineItem.Width                 = Width;
            lineItem.MeasureUnit           = MeasureUnit;
            lineItem.WeightUnit            = WeightUnit;
            lineItem.Length                = Length;
            lineItem.TaxType               = TaxType;
            lineItem.IsCancelled           = IsCancelled;
            lineItem.CancelledDate         = CancelledDate;
            lineItem.CancelReason          = CancelReason;
            lineItem.Comment               = Comment;
            lineItem.IsGift                = IsGift;
            lineItem.Discounts             = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails            = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            return(lineItem);
        }
コード例 #24
0
ファイル: Tax.cs プロジェクト: vinay1988/Ang6API
        //[001] code end

        private static Tax PopulateFromDBDetailsObject(TaxDetails obj)
        {
            Tax objNew = new Tax();

            objNew.TaxId      = obj.TaxId;
            objNew.TaxName    = obj.TaxName;
            objNew.ClientNo   = obj.ClientNo;
            objNew.Notes      = obj.Notes;
            objNew.Inactive   = obj.Inactive;
            objNew.UpdatedBy  = obj.UpdatedBy;
            objNew.DLUP       = obj.DLUP;
            objNew.TaxCode    = obj.TaxCode;
            objNew.PrintNotes = obj.PrintNotes;
            return(objNew);
        }
コード例 #25
0
        public override object Clone()
        {
            var result = base.Clone() as PaymentMethod;

            result.Price          = Price?.Clone() as Money;
            result.DiscountAmount = DiscountAmount?.Clone() as Money;
            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }
            return(result);
        }
コード例 #26
0
        public virtual void Patch(LineItemEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.Quantity      = Quantity;
            target.Weight        = Weight;
            target.Height        = Height;
            target.Width         = Width;
            target.MeasureUnit   = MeasureUnit;
            target.WeightUnit    = WeightUnit;
            target.Length        = Length;
            target.TaxType       = TaxType;
            target.IsCancelled   = IsCancelled;
            target.CancelledDate = CancelledDate;
            target.CancelReason  = CancelReason;
            target.Comment       = Comment;

            if (!(GetNonCalculatablePrices().All(x => x == 0m) && target.GetNonCalculatablePrices().Any(x => x != 0m)))
            {
                target.TaxPercentRate        = TaxPercentRate;
                target.Price                 = Price;
                target.DiscountAmount        = DiscountAmount;
                target.PriceWithTax          = PriceWithTax;
                target.DiscountAmountWithTax = DiscountAmountWithTax;
                target.TaxTotal              = TaxTotal;
            }

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AnonymousComparer.Create((DiscountEntity x) => x.PromotionId);
                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }

            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }
コード例 #27
0
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.Id           = Id;
            payment.CreatedBy    = CreatedBy;
            payment.CreatedDate  = CreatedDate;
            payment.ModifiedBy   = ModifiedBy;
            payment.ModifiedDate = ModifiedDate;

            payment.Amount             = Amount;
            payment.PaymentGatewayCode = PaymentGatewayCode;
            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;
            //TODO
            //payment.Purpose = Purpose;
            payment.OuterId  = OuterId;
            payment.Currency = Currency;

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            return(payment);
        }
コード例 #28
0
        public virtual void Patch(PaymentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.Amount             = Amount;
            target.PaymentGatewayCode = PaymentGatewayCode;
            target.Price                 = Price;
            target.PriceWithTax          = PriceWithTax;
            target.DiscountAmount        = DiscountAmount;
            target.DiscountAmountWithTax = DiscountAmountWithTax;
            target.TaxType               = TaxType;
            target.TaxPercentRate        = TaxPercentRate;
            target.TaxTotal              = TaxTotal;
            target.Total                 = Total;
            target.TotalWithTax          = TotalWithTax;
            target.Purpose               = Purpose;
            target.Currency              = Currency;

            if (!Addresses.IsNullCollection())
            {
                Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance();

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance();

                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }
コード例 #29
0
ファイル: SQLTaxProvider.cs プロジェクト: vinay1988/Ang6API
        /// <summary>
        /// GetListForClient
        /// Calls [usp_selectAll_Tax_for_Client]
        /// </summary>
        public override List <TaxDetails> GetListForClient(System.Int32?clientId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_selectAll_Tax_for_Client", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
                cn.Open();
                DbDataReader      reader = ExecuteReader(cmd);
                List <TaxDetails> lst    = new List <TaxDetails>();
                while (reader.Read())
                {
                    TaxDetails obj = new TaxDetails();
                    obj.TaxId     = GetReaderValue_Int32(reader, "TaxId", 0);
                    obj.TaxName   = GetReaderValue_String(reader, "TaxName", "");
                    obj.ClientNo  = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.Notes     = GetReaderValue_String(reader, "Notes", "");
                    obj.Inactive  = GetReaderValue_Boolean(reader, "Inactive", false);
                    obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP      = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.TaxCode   = GetReaderValue_String(reader, "TaxCode", "");
                    //[002] code start
                    obj.PurchaseTaxCode = GetReaderValue_String(reader, "PurchaseTaxCode", "");
                    //[002] code end
                    obj.PrintNotes = GetReaderValue_String(reader, "PrintNotes", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Taxs", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
コード例 #30
0
ファイル: SQLTaxProvider.cs プロジェクト: vinay1988/Ang6API
        /// <summary>
        /// Get
        /// Calls [usp_select_Tax]
        /// </summary>
        public override TaxDetails Get(System.Int32?taxId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Tax", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@TaxId", SqlDbType.Int).Value = taxId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetTaxFromReader(reader);
                    TaxDetails obj = new TaxDetails();
                    obj.TaxId      = GetReaderValue_Int32(reader, "TaxId", 0);
                    obj.TaxName    = GetReaderValue_String(reader, "TaxName", "");
                    obj.ClientNo   = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.Notes      = GetReaderValue_String(reader, "Notes", "");
                    obj.Inactive   = GetReaderValue_Boolean(reader, "Inactive", false);
                    obj.UpdatedBy  = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP       = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.TaxCode    = GetReaderValue_String(reader, "TaxCode", "");
                    obj.PrintNotes = GetReaderValue_String(reader, "PrintNotes", "");
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Tax", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }