private void ReconfigureForA(ConverterConfigurator <FirstContractDocument, InnerDocument> configurator) { configurator.Target(x => x.FromGln).Set(x => x.Header.Recipient); configurator.Target(x => x.ToGln).Set(x => x.Header.Sender); configurator.Target(x => x.GoodItems.Each().Marks.Each()).Set(x => x.Document[0].LineItems.LineItem.Current().Declarations.Each()); configurator.Target(x => x.GoodItems.Each().Declarations.Each().Number).Set(x => x.Document[0].LineItems.LineItem.Current().ControlMarks.Each()); }
public static void ConfigureIdentifiers <TData, TMessage>( ConverterConfigurator <TData, PartyInfo, TMessage, NameAndAddress, NameAndAddress> configurator, Expression <Func <PartyInfo, string> > getFunctionCodeQualifier) { configurator.Target(nameAndAddress => nameAndAddress.PartyFunctionCodeQualifier).Set(getFunctionCodeQualifier); configurator.Target(nameAndAddress => nameAndAddress.PartyIdentificationDetails.PartyIdentifier).Set(party => party.Gln); }
private void Configure(ConverterConfigurator <FirstContractDocument, InnerDocument> configurator) { configurator.Target(x => x.FromGln).Set(x => x.Header.Sender); configurator.Target(x => x.ToGln).Set(x => x.Header.Recipient); configurator.Target(x => x.IsTest).Set(x => x.Header.IsTest == "1"); configurator.Target(x => x.CreationDateTimeBySender).Set(x => x.Header.CreationDateTime ?? x.CreationDateTime); var subConfigurator = configurator.GoTo(x => x, x => x.Document[0]); subConfigurator.Target(x => x.OrdersNumber).Set(x => x.OriginOrder.Number); subConfigurator.Target(x => x.OrdersDate).Set(x => x.OriginOrder.Date); subConfigurator.Target(x => x.DeliveryType).Set(x => x.DeliveryType.ParseNullableEnum <DocumentsDeliveryType>()); subConfigurator.Target(x => x.TransportBy).Set(x => x.DeliveryInfo.TransportBy, x => defaultConverter.Convert(x)); subConfigurator.Target(x => x.SumTotal).Set(x => decimalConverter.ToDecimal(x.LineItems.TotalSumExcludingTaxes)); subConfigurator.Target(x => x.RecadvType) .If(x => !string.IsNullOrEmpty(x.Status) && x.Status.Contains("canceled")) .Set(x => TypeOfDocument.Canceled); subConfigurator.Target(x => x.FlowType).Set(x => x.Comment == "Fresh" ? "fresh" : defaultConverter.Convert(x.LineItems.LineItem.FirstOrDefault().FlowType)); subConfigurator.Target(x => x.IntervalLength).Set(x => x.IntervalLength.ParseNullableInt()); PartyInfoConfigurators.ConfigureFromFirstContractToInner(subConfigurator.GoTo(x => x.Buyer, x => x.Buyer), defaultConverter); PartyInfoConfigurators.ConfigureFromFirstContractToInner(subConfigurator.GoTo(x => x.Supplier, x => x.Seller), defaultConverter); ConfigureGoodItems(subConfigurator.GoTo(x => x.GoodItems.Each(), x => x.LineItems.LineItem.Current())); subConfigurator.Target(x => x.MessageCodes.Each()).Set(x => x.MessageCodes.Current()); subConfigurator.Target(x => x.Nullify).Set(x => x.MessageCodes[0] == "nullify"); subConfigurator.Target(x => x.MessageCodes[1]).NullifyIf(x => x.Nullify); }
public static void SetReference <TData, TReferencePath, TMessage, TSg>(this ConverterConfigurator <TData, TReferencePath, SecondContractDocument <TMessage>, TSg, TSg> configurator, Expression <Func <TReferencePath, string> > pathToCodeQualifier, Expression <Func <TReferencePath, string> > pathToNumber) where TSg : IReferenceContainer { configurator.Target(sg1 => sg1.Reference.ReferenceGroup.ReferenceCodeQualifier).Set(pathToCodeQualifier); configurator.Target(sg1 => sg1.Reference.ReferenceGroup.ReferenceIdentifier).Set(pathToNumber); }
public static void ConfigureRussianPartyAddress <TSecondContract, TData, TPartyInfo>(this ConverterConfigurator <TSecondContract, NameAndAddress, TData, TPartyInfo, TPartyInfo> configurator) where TPartyInfo : IContainsRussianPartyAdress, IContainsAddressType { configurator.Target(party => party.RussianAddressInfo.City) .Set(nameAndAddress => nameAndAddress.CityName) .NullifyIf(party => party.AddressType != AddressType.Russian); configurator.Target(party => party.RussianAddressInfo.Street) .Set(nameAndAddress => nameAndAddress.Street.StreetAndNumberOrPostBoxIdentifier, strings => ArrayStringConverter.ToString(strings)) .NullifyIf(party => party.AddressType != AddressType.Russian); }
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 ConfigureIdentifiers <TSecondContract, TData, TSG2, TSG3, TPartyInfo>( this ConverterConfigurator <TSecondContract, TSG2, TData, TPartyInfo, TPartyInfo> configurator) where TSG2 : IReferenceArrayContainer <TSG3>, INameAndAddressContainer where TSG3 : IReferenceContainer where TPartyInfo : IContainsPartyIndentifiers { configurator.Target(party => party.Gln).Set(sg2 => sg2.NameAndAddress.PartyIdentificationDetails.PartyIdentifier); configurator.Target(party => party.SupplierCodeInBuyerSystem).Set(sg2 => (from sg3 in sg2.References where sg3.Reference.ReferenceGroup.ReferenceCodeQualifier == "YC1" select sg3.Reference.ReferenceGroup.ReferenceIdentifier).First()); }
public static void ConfigureGoodItemBaseInfo <TSecondContract, TSecondContractGoodItem, TData, TGoodItem>( this ConverterConfigurator <TSecondContract, TSecondContractGoodItem, TData, TGoodItem, TGoodItem> configurator) where TSecondContractGoodItem : ISecondContractGoodItemWithAdditionalInfo where TGoodItem : GoodItemBase { configurator.Target(goodItem => goodItem.GTIN).Set(sg28 => sg28.LineItem.ItemNumberIdentification.ItemIdentifier); configurator.Target(goodItem => goodItem.AdditionalId) .Set(sg28 => (from id in sg28.AdditionalProductId from identification in id.ItemNumberIdentification where (id.ProductIdentifierCodeQualifier == "1" || id.ProductIdentifierCodeQualifier == "5") && identification.ItemTypeIdentificationCode == "STB" select identification.ItemIdentifier).FirstOrDefault()); }
private void ConfigureGoodItems(ConverterConfigurator <SecondContractDocument <SecondContractDocumentBody>, SG28, InnerDocument, CommonGoodItem, CommonGoodItem> configurator) { configurator.Target(goodItem => goodItem.GoodNumber.Number).Set(sg28 => sg28.CurrentIndex() + 1); configurator.ConfigureCommonGoodItemInfo <SecondContractDocument <SecondContractDocumentBody>, SG28, InnerDocument, CommonGoodItem>(); configurator.ConfigureMonetaryAmountsInfo(new MonetaryAmountConfig <CommonGoodItem>("161", x => x.ExciseTax)); configurator.ConfigureCountiesOfOrigin <SecondContractDocument <SecondContractDocumentBody>, SG28, InnerDocument>(); ConfigurePackages(configurator.GoTo(x => x.Packages.Each(), sg28 => sg28.SG34.Each())); }
public static void ConfigureDateOrUtcNow <TSecondContract, TData, T, TSg>(this ConverterConfigurator <TSecondContract, TSg, TData, T, T> configurator, string dateTimePeriodFunctionCodeQualifier, Expression <Func <T, DateTime?> > pathToDate) where TSg : IDtmArrayContainer { configurator.Target(pathToDate) .Set(message => message.DateTimePeriod.FirstOrDefault(period => period.DateTimePeriodGroup.FunctionCodeQualifier == dateTimePeriodFunctionCodeQualifier), period => StaticDateTimePeriodConverter.ToDateTimeOrUtcNow(period.DateTimePeriodGroup)); }
public static void SetReferenceWithDatesArray <TData, TReferencePath, TMessage, TSg>(this ConverterConfigurator <TData, TReferencePath, SecondContractDocument <TMessage>, TSg, TSg> configurator, Expression <Func <TReferencePath, string> > pathToCodeQualifier, Expression <Func <TReferencePath, string> > pathToNumber, Expression <Func <TReferencePath, DateTime?> > pathToDate, string dateTimePeriodFormatCode = "203") where TSg : IReferenceContainer, IDtmArrayContainer { configurator.SetReference(pathToCodeQualifier, pathToNumber); configurator.Target(sg1 => sg1.DateTimePeriod[0]).Set(pathToDate, dateTime => StaticDateTimePeriodConverter.ToDateTimePeriod(dateTime, "171", dateTimePeriodFormatCode)); }
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); }
public static void ConfigureRussianPartyInfo <TSecondContract, TData, TSG2, TSG3, TPartyInfo>( this ConverterConfigurator <TSecondContract, TSG2, TData, TPartyInfo, TPartyInfo> configurator) where TSG2 : IReferenceArrayContainer <TSG3>, INameAndAddressContainer where TSG3 : IReferenceContainer where TPartyInfo : IContainsRussianPartyInfo { configurator.ConfigurePartyName(); configurator.Target(party => party.RussianPartyInfo.RussianPartyType) .Set(sg2 => new { sg2.NameAndAddress.PartyNameType.PartyNameFormatCode, sg2.References.First(sg3 => sg3.Reference.ReferenceGroup.ReferenceCodeQualifier == "FC").Reference.ReferenceGroup.ReferenceIdentifier }, o => GetRussianPartyType(o.PartyNameFormatCode, o.ReferenceIdentifier)); configurator.Target(party => party.RussianPartyInfo.IPInfo.Inn) .Set(sg2 => sg2.References.First(sg3 => sg3.Reference.ReferenceGroup.ReferenceCodeQualifier == "FC").Reference.ReferenceGroup.ReferenceIdentifier) .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.IP); configurator.Target(party => party.RussianPartyInfo.ULInfo.Inn) .Set(sg2 => sg2.References.First(sg3 => sg3.Reference.ReferenceGroup.ReferenceCodeQualifier == "FC").Reference.ReferenceGroup.ReferenceIdentifier) .NullifyIf(party => party.RussianPartyInfo.RussianPartyType != RussianPartyType.UL); }
public static void ConfigurePartyAddress <TSecondContract, TData>( this ConverterConfigurator <TSecondContract, NameAndAddress, TData, PartyInfo, PartyInfo> configurator) { configurator.Target(party => party.PartyAddress.AddressType) .Set(nameAndAddress => defaultConverter.Convert(nameAndAddress.CountryNameCode), code => GetAddressType(code)); configurator.Target(party => party.PartyAddress.ForeignAddressInfo.CountryCode) .Set(nameAndAddress => nameAndAddress.CountryNameCode, s => defaultConverter.Convert(s), s => s != null && defaultConverter.Convert(s) == null, s => new TestText { Text = s }) .NullifyIf(party => party.PartyAddress.AddressType != AddressType.Foreign); configurator.Target(party => party.PartyAddress.ForeignAddressInfo.Address) .Set(nameAndAddress => nameAndAddress.Street.StreetAndNumberOrPostBoxIdentifier, strings => ArrayStringConverter.ToString(strings)) .NullifyIf(party => party.PartyAddress.AddressType != AddressType.Foreign); configurator.GoTo(x => x.PartyAddress).ConfigureRussianPartyAddress(); configurator.Target(party => party.PartyAddress.RussianAddressInfo).NullifyIf(party => party.PartyAddress.AddressType != AddressType.Russian); }
public static void ConfigureCountiesOfOrigin <TSecondContract, TGoodItem, TData>(this ConverterConfigurator <TSecondContract, TGoodItem, TData, CommonGoodItem, CommonGoodItem> configurator) where TGoodItem : ISecondContractGoodItemWithAdditionalInfo { configurator.Target(goodItem => goodItem.CountriesOfOriginCode.Each()) .Set(sg28 => sg28.AdditionalInformation.Current().CountryOfOriginNameCode, s => defaultConverter.ConvertWithDefault(s, "DefaultCountry"), s => s == null, s => new ValueMustBelongToText { Value = s, }); }
private void Configure(ConverterConfigurator <InnerDocument, InnerDocument, SecondContractDocument <SecondContractDocumentBody>, SecondContractDocumentBody, SecondContractDocumentBody> configurator, TestConverterContext context) { configurator.Target(message => message.BeginningOfMessage.DocumentMessageIdentification.DocumentIdentifier).Set(data => data.OrdersNumber); configurator.Target(message => message.DateTimePeriod[0]) .Set(data => data.OrdersDate, dateTime => StaticDateTimePeriodConverter.ToDateTimePeriod(dateTime, "137", "203")); var referencesConfigurator = configurator.GoTo(message => message.References.Each(), data => SecondContractConvertingHelpers.GetReferencesArray(data).Current()); referencesConfigurator.SetReferenceWithDatesArray(data => data.Code, data => data.Number, data => data.Date); ConfigureParty(configurator.GoTo(message => message.PartiesArray[0]), data => data.Supplier, "SU", context); ConfigureParty(configurator.GoTo(message => message.PartiesArray[1]), data => data.Buyer, "BY", context); ConfigureGoodItems(configurator.GoTo(message => message.SG28.Each(), data => data.GoodItems.Current())); configurator.GoTo(message => message.SG13[0], data => data.Packages[0]) .Target(sg13 => sg13.Package.PackageType.PackageTypeDescriptionCode) .Set(package => defaultConverter.Convert(package.PackageQuantity.TypeOfPackage)); configurator.Target(message => message.ControlTotal[0].Control.ControlTotalValue) .Set(data => decimalConverter.ToString(data.GoodItems.Aggregate <CommonGoodItem, decimal>(0, (current, item) => current + (item.Quantity.Value ?? 0)))); }
public static void ConfigureNameAndAddress <TInner, TSecondContract>(ConverterConfigurator <TInner, PartyInfo, TSecondContract, NameAndAddress, NameAndAddress> configurator, TestConverterContext context, DefaultConverter defaultConverter) { configurator.Target(nameAndAddress => nameAndAddress.PartyNameType.PartyName) .Set(party => party.RussianPartyInfo.RussianPartyType == RussianPartyType.IP ? new[] { party.RussianPartyInfo.IPInfo.LastName, party.RussianPartyInfo.IPInfo.FirstName, party.RussianPartyInfo.IPInfo.MiddleName } : ArrayStringConverter.ToArrayString(party.RussianPartyInfo.ULInfo.Name, 35, 5)); configurator.Target(nameAndAddress => nameAndAddress.PartyNameType.PartyNameFormatCode) .Set(party => party.RussianPartyInfo.RussianPartyType == RussianPartyType.IP ? "IP" : "UL"); var addressConfigurator = configurator.GoTo(address => address, party => party.PartyAddress); addressConfigurator.If((x, address) => address.CityName != null || address.CountrySubEntityDetails.CountrySubEntityNameCode != null || address.CountrySubEntityDetails.CountrySubEntityName != null || address.PostalIdentificationCode != null || address.Street.StreetAndNumberOrPostBoxIdentifier != null) .Target(address => address.CountryNameCode) .Set(address => defaultConverter.Convert(address.AddressType == AddressType.Russian ? "643" : address.ForeignAddressInfo.CountryCode)); var useSemicolon = new[] { MutatorsContextType.None }.Contains(context.MutatorsContextType); addressConfigurator.Target(address => address.Street.StreetAndNumberOrPostBoxIdentifier) .Set(address => address.AddressType == AddressType.Russian ? new[] { address.RussianAddressInfo.Street, address.RussianAddressInfo.House, address.RussianAddressInfo.Flat }.JoinIgnoreEmpty(useSemicolon ? "; " : ", ") : address.ForeignAddressInfo.Address, s => ArrayStringConverter.ToArrayString(s, 35, 4)); addressConfigurator.Target(address => address.CityName) .Set(address => address.AddressType == AddressType.Russian ? new[] { address.RussianAddressInfo.City, address.RussianAddressInfo.Village }.JoinIgnoreEmpty(", ") : null); addressConfigurator.Target(address => address.CountrySubEntityDetails.CountrySubEntityName) .Set(address => address.AddressType == AddressType.Russian ? new[] { defaultConverter.Convert(address.RussianAddressInfo.RegionCode), address.RussianAddressInfo.District }.JoinIgnoreEmpty(", ") : null); addressConfigurator.Target(address => address.PostalIdentificationCode) .Set(address => address.AddressType == AddressType.Russian ? address.RussianAddressInfo.PostalCode : null); }
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); }
private void ConfigureGoodItems(ConverterConfigurator <FirstContractDocument, LineItem, InnerDocument, CommonGoodItem, CommonGoodItem> configurator) { configurator.Target(x => x.GoodNumber.Number).Set(x => x.CurrentIndex() + 1); configurator.Target(x => x.GoodNumber.MessageType).Set(MessageType.ReceivingAdvice); configurator.Target(x => x.GTIN).Set(x => x.Gtin); configurator.Target(x => x.Quantity.Value).Set(x => decimalConverter.ToDecimal(x.OrderedQuantity.Quantity)); configurator.Target(x => x.Quantity.MeasurementUnitCode) .If(x => defaultConverter.Convert(x.OrderedQuantity.UnitOfMeasure) != null) .Set(x => defaultConverter.Convert(x.OrderedQuantity.UnitOfMeasure)); configurator.Target(x => x.Quantity.MeasurementUnitCode) .If(x => defaultConverter.Convert(x.OrderedQuantity.UnitOfMeasure) == null) .Set(x => "PCE"); configurator.Target(x => x.IsReturnable).Set(x => x.TypeOfUnit == "RET"); configurator.Target(x => x.Marks.Each()).Set(x => x.ControlMarks.Current()); configurator.Target(x => x.Declarations.Each().Number).Set(x => defaultConverter.Convert(x.Declarations.Current())); configurator.Target(x => x.ExcludeFromSummation).Set(x => x.Declarations.Any(y => y.Contains("exclude"))); ConfigureQuantityVariances(configurator.GoTo(x => x.QuantityVariances.Each(), x => x.ToBeReturnedQuantity.Current())); }
private void ConfigurePackages(ConverterConfigurator <SecondContractDocument <SecondContractDocumentBody>, SG34, InnerDocument, PackageForItem, PackageForItem> configurator) { configurator.Target(x => x.PackageTypeCode) .Set(sg34 => sg34.Package.PackageType.PackageTypeDescriptionCode, s => defaultConverter.ConvertWithDefault(s, "default"), s => s == null, s => new ValueMustBelongToText { Value = s }); configurator.Target(x => x.Quantity).Set(sg34 => decimalConverter.ToDecimal(sg34.Package.PackageQuantity)); var subConfigurator = configurator.GoTo(x => x.OnePackageQuantity, sg34 => sg34.Quantity.FirstOrDefault(x => x.QuantityDetails.QuantityTypeCodeQualifier == "52").QuantityDetails); subConfigurator.Target(x => x.Value).Set(x => decimalConverter.ToDecimal(x.Quantity)); subConfigurator.If(x => defaultConverter.ConvertWithDefault(x.MeasurementUnitCode, "DEFAULT") == null && decimalConverter.ToDecimal(x.Quantity).HasValue) .Target(x => x.MeasurementUnitCode) .Set("DME"); subConfigurator.If(x => defaultConverter.ConvertWithDefault(x.MeasurementUnitCode, "DEFAULT") != null) .Target(x => x.MeasurementUnitCode) .Set(x => defaultConverter.Convert(x.MeasurementUnitCode)); }
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 } }); }
private void ConfigureGoodItems(ConverterConfigurator <InnerDocument, CommonGoodItem, FirstContractDocument, LineItem, LineItem> configurator) { configurator.Target(x => x.Gtin).Set(x => x.GTIN); configurator.Target(x => x.OrderedQuantity.Quantity).Set(x => decimalConverter.ToString(x.Quantity.Value)); configurator.Target(x => x.OrderedQuantity.UnitOfMeasure).Set(x => defaultConverter.Convert(x.Quantity.MeasurementUnitCode)); configurator.Target(x => x.TypeOfUnit).Set(x => x.IsReturnable ? "RET" : defaultConverter.Convert(x.TypeOfUnit)); configurator.Target(x => x.ControlMarks.Each()).Set(x => x.Marks.Current()); configurator.Target(x => x.Declarations.Each()).Set(x => defaultConverter.Convert(x.Declarations.Current().Number)); ConfigureQuantityVariances(configurator.GoTo(x => x.ToBeReturnedQuantity.Each(), x => x.QuantityVariances.Current())); }
public static void ConfigureCommonGoodItemInfo <TSecondContract, TSecondContractGoodItem, TData, TGoodItem>( this ConverterConfigurator <TSecondContract, TSecondContractGoodItem, TData, TGoodItem, TGoodItem> configurator) where TSecondContractGoodItem : ISecondContractGoodItemWithAdditionalInfo where TGoodItem : GoodItemWithAdditionalInfo { ConfigureGoodItemBaseInfo(configurator); var typeOfUnitConfigurator = configurator.GoTo(goodItem => goodItem, lin => lin.ItemDescription.Where(id => id.DescriptionFormatCode == "C")); typeOfUnitConfigurator.Target(goodItem => goodItem.IsReturnableContainer) .Set(x => x.FirstOrDefault(code => code.ItemDescriptionGroup.ItemDescriptionCode == "RC").ItemDescriptionGroup.ItemDescriptionCode, rc => rc == "RC"); typeOfUnitConfigurator.Target(goodItem => goodItem.TypeOfUnit) .Set(x => x.FirstOrDefault().ItemDescriptionGroup.ItemDescriptionCode, type => defaultConverter.Convert(type)); configurator.Target(goodItem => goodItem.Name).Set(goodItem => (from description in goodItem.ItemDescription where description.ItemCharacteristic.ItemCharacteristicCode == null where description.ItemDescriptionGroup.ItemDescription.Length > 0 select description.ItemDescriptionGroup.ItemDescription).FirstOrDefault(), strings => ArrayStringConverter.ToString(strings)); }
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); }
private void Configure(ConverterConfigurator <InnerDocument, FirstContractDocument> configurator) { configurator.Target(x => x.CreationDateTime).Set(x => UtcNow()); var headerConfigurator = configurator.GoTo(x => x.Header, x => x); headerConfigurator.Target(x => x.Sender).Set(x => x.FromGln); headerConfigurator.Target(x => x.Recipient).Set(x => x.ToGln); headerConfigurator.Target(x => x.IsTest).Set(x => x.IsTest ? "1" : null); headerConfigurator.Target(x => x.CreationDateTime).Set(x => DateTime.UtcNow); var subConfigurator = configurator.GoTo(x => x.Document[0], x => x); subConfigurator.Target(x => x.Comment).Set(x => Guid.NewGuid().ToString()); subConfigurator.Target(x => x.MessageCodes[0]).Set(x => NewGuid().ToString()); subConfigurator.Target(x => x.OriginOrder.Number).Set(x => x.OrdersNumber); subConfigurator.Target(x => x.OriginOrder.Date).Set(x => x.OrdersDate); subConfigurator.Target(x => x.DeliveryType).Set(x => x.DeliveryType.Value.ToString()); subConfigurator.Target(x => x.DeliveryInfo.TransportBy).Set(x => defaultConverter.Convert(x.TransportBy)); subConfigurator.Target(x => x.LineItems.TotalSumExcludingTaxes).Set(x => decimalConverter.ToString(x.SumTotal)); subConfigurator.Target(x => x.Status) .If(x => x.RecadvType.GetValueOrDefault(TypeOfDocument.Original) == TypeOfDocument.Canceled) .Set(x => "canceled"); subConfigurator.Target(x => x.IntervalLength).Set(x => x.IntervalLength.Value.ToString()); PartyInfoConfigurators.ConfigureFromInnerToFirstContract(subConfigurator.GoTo(x => x.Buyer, x => x.Buyer), defaultConverter); PartyInfoConfigurators.ConfigureFromInnerToFirstContract(subConfigurator.GoTo(x => x.Seller, x => x.Supplier), defaultConverter); ConfigureGoodItems(subConfigurator.GoTo(x => x.LineItems.LineItem.Each(), x => x.GoodItems.Current())); }
private void ConfigureQuantityVariances(ConverterConfigurator <InnerDocument, QuantityVariance, FirstContractDocument, ReasonQuantity, ReasonQuantity> configurator) { configurator.Target(x => x.ReasonOfReturn).Set(x => x.Reason); configurator.Target(x => x.Quantity).Set(x => decimalConverter.ToString(x.QuantityValue)); }