public static void ConfigureReferences <TData, TMessage, TSg>(ConverterConfigurator <TData, PartyInfo, SecondContractDocument <TMessage>, TSg[], TSg[]> configurator)
            where TSg : IReferenceContainer
        {
            var ulConfigurator = configurator.If(party => party.RussianPartyInfo.RussianPartyType == RussianPartyType.UL).GoTo(sgs => sgs, party => party.RussianPartyInfo.ULInfo);

            ulConfigurator.GoTo(sgs => sgs[0]).SetReference("FC", party => party.Inn);
            ulConfigurator.GoTo(sgs => sgs[1]).SetReference("GN", party => party.OKPOCode);

            var ipConfigurator = configurator.If(party => party.RussianPartyInfo.RussianPartyType == RussianPartyType.IP).GoTo(sgs => sgs, party => party.RussianPartyInfo.IPInfo);

            ipConfigurator.GoTo(sgs => sgs[0]).SetReference("FC", party => party.Inn);
            ipConfigurator.GoTo(sgs => sgs[1]).SetReference("GN", party => party.OKPOCode);
        }
        private void Configure(ConverterConfigurator <SecondContractDocument <SecondContractDocumentBody>, SecondContractDocumentBody, InnerDocument, InnerDocument, InnerDocument> subConfigurator)
        {
            subConfigurator.Target(data => data.OrdersNumber).Set(message => message.BeginningOfMessage.DocumentMessageIdentification.DocumentIdentifier);
            subConfigurator.ConfigureDateOrUtcNow("137", data => data.OrdersDate);
            subConfigurator.ConfigureDate("50", data => data.ReceivingDate);

            subConfigurator.Target(data => data.CurrencyCode).Set(message => (from details in message.Currency.CurrencyDetails
                                                                              where details.UsageCodeQualifier == "2" && details.TypeCodeQualifier == "4"
                                                                              select details.IdentificationCode).FirstOrDefault(),
                                                                  s => defaultConverter.Convert(s));

            subConfigurator.Target(data => data.FlowType).Set(message => message.FreeText.Any(y => y.TextSubjectCodeQualifier == "DEL")
                                                                             ? defaultConverter.Convert(message.FreeText.FirstOrDefault(y => y.TextSubjectCodeQualifier == "DEL").TextReference.FreeTextValueCode)
                                                                             : message.FreeText.Any(y => y.TextSubjectCodeQualifier == "ZZZ" && y.TextLiteral.FreeTextValue[0] == "Fresh")
                                                                                 ? "fresh"
                                                                                 : defaultConverter.Convert(message.SG28.FirstOrDefault().FreeText.FirstOrDefault(y => y.TextSubjectCodeQualifier == "DEL" && y.TextReference.CodeListResponsibleAgencyCode == "ZZZ").TextReference.FreeTextValueCode));

            subConfigurator.Target(data => data.TransportDetails.VehicleNumber)
            .Set(message => message.SG10.FirstOrDefault(sg10 => sg10.DetailsOfTransport.TransportStageCodeQualifier == "1").DetailsOfTransport.TransportIdentification.TransportMeansIdentificationName);

            subConfigurator.Target(data => data.FreeText).Set(message => ArrayStringConverter.ToString(message.FreeText.FirstOrDefault(freeText => freeText.TextSubjectCodeQualifier == "ZZZ" || freeText.TextSubjectCodeQualifier == "PUR" || freeText.TextSubjectCodeQualifier == "AAI").TextLiteral.FreeTextValue));

            subConfigurator.GoTo(x => x, x => x.References).ConfigureReference("BO", data => data.BlanketOrdersNumber);

            subConfigurator.If(message => !string.IsNullOrEmpty(message.ControlTotal.FirstOrDefault(cnt => cnt.Control.ControlTotalTypeCodeQualifier == "11").Control.ControlTotalValue))
            .Target(data => data.OrdersTotalPackageQuantity)
            .Set(message => decimalConverter.ToDecimal(message.ControlTotal.FirstOrDefault(cnt => cnt.Control.ControlTotalTypeCodeQualifier == "11").Control.ControlTotalValue));

            subConfigurator.ConfigureMonetaryAmountsInfo(new MonetaryAmountConfig <InnerDocument>("79", x => x.RecadvTotal),
                                                         new MonetaryAmountConfig <InnerDocument>(new[] { "77", "9" }, x => x.TotalWithVAT));

            subConfigurator.GoTo(x => x.DespatchParties.Each().PartyInfo, message => message.PartiesArray.Where(sg2 => sg2.NameAndAddress.PartyFunctionCodeQualifier == "PW").Current())
            .ConfigureParty <SecondContractDocument <SecondContractDocumentBody>, InnerDocument, SG2, SG3, SG5>();

            subConfigurator.GoTo(data => data.Transports.Each(),
                                 message => message.SG10.Where(sg10 => sg10.DetailsOfTransport.TransportStageCodeQualifier == "20")
                                 .SelectMany(sg10 => DefaultIfNullOrEmpty(sg10.SG11),
                                             (sg10, sg11) => new
            {
                sg10.DetailsOfTransport.TransportMeans.TransportMeansDescription,
                TypeOfTransportCode = defaultConverter.Convert(sg10.DetailsOfTransport.TransportMeans.TransportMeansDescriptionCode),
                sg11.DateTimePeriod
            })
                                 .Where(x => !string.IsNullOrEmpty(x.TypeOfTransportCode) || !string.IsNullOrEmpty(x.TransportMeansDescription) || x.DateTimePeriod != null)
                                 .Current())
            .BatchSet((x, y) => new Batch
            {
                { x.TypeOfTransport, y.TransportMeansDescription },
                { x.TypeOfTransportCode, y.TypeOfTransportCode },
                { x.DeliveryDateForVehicle, dateTimePeriodConverter.ToDateTime(y.DateTimePeriod.FirstOrDefault(period => period.DateTimePeriodGroup.FunctionCodeQualifier == "232").DateTimePeriodGroup) },
            });

            ConfigureGoodItems(subConfigurator.GoTo(data => data.GoodItems.Each(), message => message.SG28.Current()));
        }
        public static void ConfigurePartyName <TSecondContract, TData, TSG2, TPartyInfo>(
            this ConverterConfigurator <TSecondContract, TSG2, TData, TPartyInfo, TPartyInfo> configurator)
            where TSG2 : INameAndAddressContainer
            where TPartyInfo : IContainsRussianPartyInfo
        {
            configurator.Target(party => party.RussianPartyInfo.IPInfo.LastName)
            .Set(sg2 => sg2.NameAndAddress.PartyNameType.PartyName[0])
            .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.IP);
            configurator.Target(party => party.RussianPartyInfo.IPInfo.FirstName)
            .Set(sg2 => sg2.NameAndAddress.PartyNameType.PartyName[1])
            .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.IP);

            configurator.If(sg2 => sg2.NameAndAddress.PartyNameType.PartyName != null)
            .Target(party => party.RussianPartyInfo.ULInfo.Name)
            .Set(sg2 => sg2.NameAndAddress.PartyNameType.PartyName, strings => ArrayStringConverter.ToString(strings))
            .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.UL);

            configurator.If(sg2 => sg2.NameAndAddress.PartyNameType.PartyName == null)
            .Target(party => party.RussianPartyInfo.ULInfo.Name)
            .Set(sg2 => sg2.NameAndAddress.NameAndAddressGroup.NameAndAddressDescription, strings => ArrayStringConverter.ToString(strings))
            .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.UL);
        }
示例#4
0
        private void ConfigureGoodItems(ConverterConfigurator <InnerDocument, CommonGoodItem, SecondContractDocument <SecondContractDocumentBody>, SG28, SG28> configurator)
        {
            configurator.Target(sg26 => sg26.LineItem.LineItemIdentifier).Set(item => (item.CurrentIndex() + 1).ToString());
            configurator.Target(sg26 => sg26.LineItem.ItemNumberIdentification.ItemIdentifier).Set(item => item.GTIN);

            configurator.GoTo(sg26 => sg26.AdditionalProductId[0]).BatchSet(
                (additionalProductId, item) => new Batch
            {
                { additionalProductId.ProductIdentifierCodeQualifier, "z" },
                { additionalProductId.ItemNumberIdentification[0].ItemTypeIdentificationCode, "IN" },
                { additionalProductId.ItemNumberIdentification[0].ItemIdentifier.NotNull(), item.BuyerProductId }
            }
                );

            configurator.GoTo(sg26 => sg26.AdditionalProductId[1]).BatchSet(
                (additionalProductId, item) => new Batch
            {
                { additionalProductId.ProductIdentifierCodeQualifier, "q" },
                { additionalProductId.ItemNumberIdentification[0].ItemTypeIdentificationCode, "SA" },
                { additionalProductId.ItemNumberIdentification[0].ItemIdentifier.NotNull(), item.SupplierProductId }
            }
                );

            configurator.Target(sg26 => sg26.Quantity[0].QuantityDetails.Quantity).Set(item => decimalConverter.ToString(item.Quantity.Value));
            configurator.Target(sg26 => sg26.Quantity[0].QuantityDetails.MeasurementUnitCode).Set(item => defaultConverter.Convert(item.Quantity.MeasurementUnitCode));

            configurator.Target(sg26 => sg26.MonetaryAmount[0].MonetaryAmountGroup.MonetaryAmountTypeCodeQualifier).Set("203");
            configurator.Target(sg26 => sg26.MonetaryAmount[0].MonetaryAmountGroup.MonetaryAmount).Set(item => item.PriceSummary, s => StaticPriceFormatter.FormatPrice(s));

            configurator.Target(message => message.DateTimePeriod[0])
            .Set(data => data.ExpireDate, dateTime => StaticDateTimePeriodConverter.ToDateTimePeriod(dateTime, "36", "102"));

            configurator.If(data => !string.IsNullOrEmpty(data.SerialNumber)).GoTo(gin => gin.GoodsIdentityNumber[0]).BatchSet(
                (gin, item) => new Batch
            {
                { gin.ObjectIdentificationCodeQualifier, "BN" },
                { gin.IdentityNumberRange[0].ObjectIdentifier, ArrayStringConverter.ToArrayString(item.SerialNumber, 35, 2) }
            });

            configurator.GoTo(sg26 => sg26.FreeText.Each(), item => item.FreeTexts(defaultConverter).ToArray().Current()).BatchSet(
                (ft, data) => new Batch
            {
                { ft.TextSubjectCodeQualifier, data.TextSubjectCodeQualifier },
                { ft.TextReference.FreeTextValueCode, data.FreeTextFunctionCode },
                { ft.TextLiteral.FreeTextValue, data.TextLiteral.FreeTextValue }
            });
        }
示例#5
0
        public static void ConfigureFromInnerToFirstContract(ConverterConfigurator <InnerDocument, PartyInfo, FirstContractDocument, FirstContractPartyInfo, FirstContractPartyInfo> configurator, DefaultConverter defaultConverter)
        {
            configurator.Target(x => x.Gln).Set(x => x.Gln);
            configurator.Target(x => x.TaxSystem).If(x => x.UsesSimplifiedTaxSystem).Set("Simplified");

            var foreignConfigurator = configurator.If(x => x.PartyInfoType == PartyInfoType.Foreign)
                                      .GoTo(x => x.ForeignOrganization, x => x.ForeignPartyInfo);

            foreignConfigurator.Target(x => x.Name).Set(x => x.Name);

            var orgConfigurator = configurator.GoTo(x => x.Organization, x => x.RussianPartyInfo.ULInfo);

            orgConfigurator.Target(x => x.Inn).Set(x => x.Inn);
            orgConfigurator.Target(x => x.Name).Set(x => x.Name);

            var ipConfigurator = configurator.GoTo(x => x.SelfEmployed, x => x.RussianPartyInfo.IPInfo);

            ipConfigurator.Target(x => x.Inn).Set(x => x.Inn);
            ipConfigurator.Target(x => x.FullName.FirstName).Set(x => x.FirstName);
            ipConfigurator.Target(x => x.FullName.LastName).Set(x => x.LastName);

            var rusAddrConfigurator = configurator.GoTo(x => x.RussianAddress, x => x.PartyAddress.RussianAddressInfo);

            rusAddrConfigurator.Target(x => x.PostalCode).Set(x => x.PostalCode);
            rusAddrConfigurator.Target(x => x.City).Set(x => x.City);

            var foreignAddrConfigurator = configurator.GoTo(x => x.ForeignAddress, x => x.PartyAddress.ForeignAddressInfo);

            foreignAddrConfigurator.Target(x => x.Address).Set(x => x.Address);
            foreignAddrConfigurator.Target(x => x.CountryIsoCode).Set(x => defaultConverter.Convert(x.CountryCode));

            var chiefConfigurator = configurator.GoTo(x => x.ContactInfo.Ceo, x => x.Chief);

            chiefConfigurator.Target(x => x.Name).Set(x => x.Name);
            chiefConfigurator.Target(x => x.Phone).Set(x => x.Phone);

            var aiConfigurator = configurator.GoTo(x => x.AdditionalInfo);

            aiConfigurator.Target(x => x.Phone).Set(x => string.IsNullOrEmpty(x.OrderContact.Phone) ? x.Chief.Phone : x.OrderContact.Phone);
            aiConfigurator.Target(x => x.NameOfCeo).Set(x => string.IsNullOrEmpty(x.OrderContact.Name) ? x.Chief.Name : x.OrderContact.Name);
        }
示例#6
0
 public static void ConfigureMonetaryAmountsInfo <TSecondContract, TMessage, TData, T>(
     this ConverterConfigurator <TSecondContract, TMessage, TData, T, T> configurator,
     params MonetaryAmountConfig <T>[] monetaryAmountConfigs)
     where TMessage : IMonetaryAmountsArrayContainer
 {
     foreach (var monetaryAmountConfig in monetaryAmountConfigs)
     {
         var config = monetaryAmountConfig;
         foreach (var code in config.MonetaryAmountsFunctionalCodes)
         {
             configurator.If(message => (from amount in message.MonetaryAmount
                                         where amount.MonetaryAmountGroup.MonetaryAmountTypeCodeQualifier == code
                                         select amount.MonetaryAmountGroup.MonetaryAmount).FirstOrDefault() != null)
             .Target(config.PathsToMOA)
             .Set(message => (from amount in message.MonetaryAmount
                              where amount.MonetaryAmountGroup.MonetaryAmountTypeCodeQualifier == code
                              select amount.MonetaryAmountGroup.MonetaryAmount).FirstOrDefault(),
                  s => StaticPriceFormatter.Parse(s),
                  s => new FloatingPointNumberValidator().Validate(s));
         }
     }
 }
示例#7
0
        public static void ConfigureFromFirstContractToInner <TFirst, TInner>(
            ConverterConfigurator <TFirst, FirstContractPartyInfo, TInner, PartyInfo, PartyInfo> configurator, DefaultConverter defaultConverter)
        {
            configurator.Target(x => x.Gln).Set(x => x.Gln);

            configurator.Target(x => x.PartyInfoType).If(x => x.SelfEmployed != null || x.Organization != null).Set(x => PartyInfoType.Russian);
            configurator.Target(x => x.PartyInfoType).If(x => x.ForeignOrganization != null).Set(x => PartyInfoType.Foreign);
            configurator.Target(x => x.PartyAddress.AddressType).Set(x => x.ForeignAddress.IsEmpty() ? AddressType.Russian : AddressType.Foreign);
            configurator.Target(x => x.UsesSimplifiedTaxSystem).Set(x => x.TaxSystem == "Simplified");

            var russianConfigurator = configurator.If((x, y) => y.PartyAddress.AddressType == AddressType.Russian)
                                      .GoTo(x => x.PartyAddress.RussianAddressInfo);

            russianConfigurator.Target(x => x.PostalCode).Set(x => x.RussianAddress.PostalCode);
            russianConfigurator.Target(x => x.City).Set(x => x.RussianAddress.City);

            var foreignConfigurator = configurator.If((x, y) => y.PartyAddress.AddressType == AddressType.Foreign)
                                      .GoTo(x => x.PartyAddress.ForeignAddressInfo);

            foreignConfigurator.Target(x => x.CountryCode).Set(x => defaultConverter.Convert(x.ForeignAddress.CountryIsoCode));
            foreignConfigurator.Target(x => x.Address).Set(x => x.ForeignAddress.Address);

            configurator.Target(x => x.RussianPartyInfo.RussianPartyType).Set(x => x.SelfEmployed == null ? RussianPartyType.UL : RussianPartyType.IP);

            var ulConfigurator = configurator.If((x, y) => y.RussianPartyInfo.RussianPartyType == RussianPartyType.UL)
                                 .GoTo(x => x.RussianPartyInfo.ULInfo);

            ulConfigurator.Target(x => x.Inn).Set(x => x.Organization.Inn);
            ulConfigurator.Target(x => x.Name).Set(x => x.Organization.Name);

            var ipConfigurator = configurator.If((x, y) => y.RussianPartyInfo.RussianPartyType == RussianPartyType.IP)
                                 .GoTo(x => x.RussianPartyInfo.IPInfo);

            ipConfigurator.Target(x => x.Inn).Set(x => x.SelfEmployed.Inn);
            ipConfigurator.Target(x => x.FirstName).Set(x => x.SelfEmployed.FullName.FirstName);
            ipConfigurator.Target(x => x.LastName).Set(x => x.SelfEmployed.FullName.LastName);

            var chiefConfigurator = configurator.GoTo(x => x.Chief, x => x.ContactInfo.Ceo);

            chiefConfigurator.Target(x => x.Name).Set(x => x.Name);
            chiefConfigurator.Target(x => x.Phone).Set(x => x.Phone);

            configurator.If(x => string.IsNullOrEmpty(x.ContactInfo.Ceo.Phone)).Target(x => x.Chief.Phone).Set(x => x.AdditionalInfo.Phone);
            configurator.If(x => string.IsNullOrEmpty(x.ContactInfo.Ceo.Name)).Target(x => x.Chief.Name).Set(x => x.AdditionalInfo.NameOfCeo);
        }