public virtual coreDto.TaxEvaluationContext ToTaxEvaluationContextDto(TaxEvaluationContext taxContext)
        {
            var retVal = new coreDto.TaxEvaluationContext();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(taxContext);
            if (taxContext.Address != null)
            {
                retVal.Address = taxContext.Address.ToCoreAddressDto();
            }
            if (taxContext.Customer != null)
            {
                retVal.Customer            = taxContext.Customer.ToCoreContactDto();
                retVal.Customer.MemberType = "Contact";
            }
            if (taxContext.Currency != null)
            {
                retVal.Currency = taxContext.Currency.Code;
            }

            retVal.Lines = new List <coreDto.TaxLine>();
            if (!taxContext.Lines.IsNullOrEmpty())
            {
                foreach (var line in taxContext.Lines)
                {
                    var serviceModelLine = new coreDto.TaxLine();
                    serviceModelLine.InjectFrom <NullableAndEnumValueInjecter>(line);
                    serviceModelLine.Amount = (double)line.Amount.Amount;
                    serviceModelLine.Price  = (double)line.Price.Amount;

                    retVal.Lines.Add(serviceModelLine);
                }
            }
            return(retVal);
        }
        public static coreDto.TaxEvaluationContext ToTaxEvaluationContextDto(this TaxEvaluationContext taxContext)
        {
            var retVal = new coreDto.TaxEvaluationContext();

            retVal.Code = taxContext.Code;
            retVal.Id   = taxContext.Id;
            retVal.Type = taxContext.Type;

            if (taxContext.Address != null)
            {
                retVal.Address = taxContext.Address.ToCoreAddressDto();
            }

            retVal.Customer = taxContext?.Customer?.Contact?.ToCoreContactDto();
            if (retVal.Customer != null)
            {
                retVal.Customer.MemberType = "Contact";
            }

            if (taxContext.Currency != null)
            {
                retVal.Currency = taxContext.Currency.Code;
            }

            retVal.Lines = new List <coreDto.TaxLine>();
            if (!taxContext.Lines.IsNullOrEmpty())
            {
                retVal.Lines = taxContext.Lines.Select(x => x.ToTaxLineDto()).ToList();
            }
            return(retVal);
        }
예제 #3
0
        public static coreDto.TaxEvaluationContext ToTaxEvaluationContextDto(this TaxEvaluationContext taxContext)
        {
            var retVal = new coreDto.TaxEvaluationContext();

            retVal.Code = taxContext.Code;
            retVal.Id   = taxContext.Id;
            retVal.Type = taxContext.Type;

            if (taxContext.Address != null)
            {
                retVal.Address = taxContext.Address.ToCoreAddressDto();
            }

            retVal.Customer = taxContext?.Customer?.Contact?.ToCoreContactDto();
            if (retVal.Customer != null)
            {
                retVal.Customer.MemberType = "Contact";
            }

            if (taxContext.Currency != null)
            {
                retVal.Currency = taxContext.Currency.Code;
            }

            retVal.Lines = new List <coreDto.TaxLine>();
            if (!taxContext.Lines.IsNullOrEmpty())
            {
                foreach (var line in taxContext.Lines)
                {
                    var serviceModelLine = new coreDto.TaxLine
                    {
                        Id       = line.Id,
                        Code     = line.Code,
                        Name     = line.Name,
                        Quantity = line.Quantity,
                        TaxType  = line.TaxType,
                        Amount   = (double)line.Amount.Amount,
                        Price    = (double)line.Price.Amount
                    };

                    retVal.Lines.Add(serviceModelLine);
                }
            }
            return(retVal);
        }