public static IEnumerable <ReferenceInfo> GetReferencesArray(InnerDocument document) { yield return(new ReferenceInfo(document.OrdersNumber, document.OrdersDate, "ON")); foreach (var contract in document.Contracts?.Where(x => x != null) ?? new ContractInfo[0]) { yield return(new ReferenceInfo(contract.ContractNumber, contract.ContractDate, "CT")); } yield return(new ReferenceInfo(document.BlanketOrdersNumber, null, "BO")); }
public void TestCalculatingConstants() { var converter = converterCollection.GetConverter(new TestConverterContext()); var innerDocument = new InnerDocument(); var firstResult = converter(innerDocument); Thread.Sleep(100); var secondResult = converter(innerDocument); firstResult.Document[0].Comment.Should().NotBe(secondResult.Document[0].Comment); firstResult.Document[0].MessageCodes[0].Should().Be(secondResult.Document[0].MessageCodes[0]); firstResult.Header.CreationDateTime.Value.Should().NotBe(secondResult.Header.CreationDateTime.Value); firstResult.CreationDateTime.Value.Should().Be(secondResult.CreationDateTime.Value); }
public void Test() { #region inner document var inner = new InnerDocument { FromGln = "12344321", ToGln = "43211234", IsTest = true, OrdersNumber = "OR 431", OrdersDate = new DateTime(2013, 02, 03), DeliveryType = null, TransportBy = "bus", SumTotal = 12.34m, RecadvType = TypeOfDocument.Canceled, IntervalLength = 12, Buyer = new PartyInfo { Gln = "buyer gln", UsesSimplifiedTaxSystem = true, PartyInfoType = PartyInfoType.Foreign, ForeignPartyInfo = new ForeignPartyInfo { Name = "foreignParty" }, RussianPartyInfo = new RussianPartyInfo { ULInfo = new UlInfo { Inn = "buyer inn", Name = "buyer name", }, IPInfo = new IpInfo { Inn = "IP inn", FirstName = "Zzz", LastName = "Qxx", }, }, PartyAddress = new PartyAddress { RussianAddressInfo = new RussianAddressInfo { PostalCode = "617470", City = "Moscow", }, ForeignAddressInfo = new ForeignAddressInfo { Address = "Some address", CountryCode = "922", }, }, Chief = new ContactInformation { Name = "Ceo name", Phone = "22747", }, OrderContact = new ContactInformation { Phone = "25016", }, }, Supplier = new PartyInfo { Gln = "supplier gln", UsesSimplifiedTaxSystem = false, PartyInfoType = PartyInfoType.Russian, RussianPartyInfo = new RussianPartyInfo { ULInfo = new UlInfo { Inn = "supplier inn", Name = "supplier name", }, }, Chief = new ContactInformation { Name = "Name", Phone = "34050", }, OrderContact = new ContactInformation { Name = "Contact name", }, }, GoodItems = new[] { new CommonGoodItem { GTIN = "131", Quantity = new Quantity { Value = 23.456m, MeasurementUnitCode = "kg", }, IsReturnable = true, TypeOfUnit = "package", Marks = new[] { "123", "345", "321" }, QuantityVariances = new[] { new QuantityVariance { Reason = "some reason", QuantityValue = 11m, }, } }, new CommonGoodItem { GTIN = "222", Quantity = new Quantity { Value = 0.56m, MeasurementUnitCode = "g", }, IsReturnable = false, TypeOfUnit = "package", }, }, }; #endregion #region expected document var expectedDocument = new FirstContractDocument { Header = new FirstContractDocumentHeader { Sender = "12344321", Recipient = "43211234", IsTest = "1", }, Document = new[] { new FirstContractDocumentBody { OriginOrder = new DocumentIdentificator { Number = "OR 431", Date = new DateTime(2013, 02, 03), }, DeliveryType = null, DeliveryInfo = new DeliveryInfo { TransportBy = "bus" }, IntervalLength = "12", Status = "canceled", Buyer = new FirstContractPartyInfo { Gln = "buyer gln", TaxSystem = "Simplified", ForeignAddress = new ForeignAddress { Address = "Some address", CountryIsoCode = "922", }, Organization = new Organization { Inn = "buyer inn", Name = "buyer name", }, SelfEmployed = new SelfEmployed { Inn = "IP inn", FullName = new FullName { FirstName = "Zzz", LastName = "Qxx", }, }, ForeignOrganization = new ForeignOrganization { Name = "foreignParty", }, RussianAddress = new RussianAddress { City = "Moscow", PostalCode = "617470", }, ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Ceo name", Phone = "22747", } }, AdditionalInfo = new AdditionalInfo { Phone = "25016", NameOfCeo = "Ceo name", } }, Seller = new FirstContractPartyInfo { Gln = "supplier gln", TaxSystem = null, Organization = new Organization { Inn = "supplier inn", Name = "supplier name", }, ForeignAddress = new ForeignAddress(), SelfEmployed = new SelfEmployed { FullName = new FullName() }, RussianAddress = new RussianAddress(), ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Name", Phone = "34050", } }, AdditionalInfo = new AdditionalInfo { Phone = "34050", NameOfCeo = "Contact name", } }, LineItems = new LineItems { TotalSumExcludingTaxes = "12.34", LineItem = new[] { new LineItem { Gtin = "131", OrderedQuantity = new MeasureUnitQuantity { Quantity = "23.46", UnitOfMeasure = "kg", }, TypeOfUnit = "RET", ControlMarks = new[] { "123", "345", "321" }, ToBeReturnedQuantity = new[] { new ReasonQuantity { Quantity = "11.00", ReasonOfReturn = "some reason", } }, Declarations = new string[0], }, new LineItem { Gtin = "222", OrderedQuantity = new MeasureUnitQuantity { Quantity = "0.56", UnitOfMeasure = "g", }, TypeOfUnit = "package", ControlMarks = new string[0], ToBeReturnedQuantity = new ReasonQuantity[0], Declarations = new string[0], }, }, }, } } }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext()); var convertedDocument = converter(inner); convertedDocument.Should().BeEquivalentTo(expectedDocument, config => config .Excluding(x => x.Document[0].Comment) .Excluding(x => x.Header.CreationDateTime) .Excluding(x => x.CreationDateTime) .Excluding(x => x.Document[0].MessageCodes)); }
public void TestNoneContext() { #region inner document var innerDocument = new InnerDocument { OrdersNumber = "Orders123", OrdersDate = new DateTime(2014, 11, 22, 0, 0, 0, DateTimeKind.Utc), BlanketOrdersNumber = "bo123", Contracts = new[] { new ContractInfo { ContractNumber = "CN1", ContractDate = new DateTime(2014, 04, 04, 0, 0, 0, DateTimeKind.Utc), }, null, new ContractInfo { ContractNumber = "CN2", ContractDate = new DateTime(2014, 05, 05, 0, 0, 0, DateTimeKind.Utc), }, }, Supplier = new PartyInfo { Gln = "supplier gln", RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.UL, ULInfo = new UlInfo { Inn = "supplier inn", OKPOCode = "supplier okpo", Name = "Very long supplier name for ArrayStringConverterTest", }, }, PartyAddress = new PartyAddress { AddressType = AddressType.Russian, RussianAddressInfo = new RussianAddressInfo { City = "City", Village = "Village", Street = "Street", House = "House", Flat = "Flat", RegionCode = "R1", District = "D1", } }, BankAccount = new BankAccount { BankAccountNumber = "bn1", CorrespondentAccountNumber = "cn1", BankName = "Bank", }, }, Buyer = new PartyInfo { Gln = "buyer gln", RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.IP, IPInfo = new IpInfo { Inn = "buyer inn", OKPOCode = "buyer okpo", FirstName = "First", LastName = "Last", MiddleName = "Middle", } }, PartyAddress = new PartyAddress { AddressType = AddressType.Foreign, ForeignAddressInfo = new ForeignAddressInfo { CountryCode = "121", Address = "Some Foreign Address", } }, BankAccount = new BankAccount { BankAccountNumber = null, CorrespondentAccountNumber = "cn2", BankName = null, }, }, GoodItems = new[] { new CommonGoodItem { GTIN = "GTIN 1", BuyerProductId = "bid1", SupplierProductId = null, Quantity = new InnerQuantity { Value = 12.34m, MeasurementUnitCode = "PCE", }, PriceSummary = 0.12m, SerialNumber = "SN1", }, new CommonGoodItem { GTIN = "GTIN 2", BuyerProductId = null, SupplierProductId = "sid2", FlowType = "Flow type", Comment = "Comment", Quantity = new InnerQuantity { Value = 133.10m, MeasurementUnitCode = "KGM", }, }, }, }; #endregion #region second contract var secondContractDocument = new SecondContractDocument <SecondContractDocumentBody> { SG0 = new[] { new SecondContractDocumentBody { BeginningOfMessage = new BeginningOfMessage { DocumentMessageIdentification = new DocumentMessageIdentification { DocumentIdentifier = "Orders123", } }, DateTimePeriod = new[] { new DateTimePeriod { DateTimePeriodGroup = new DateTimePeriodGroup { FormatCode = "203", FunctionCodeQualifier = "137", Value = "201411220000", }, } }, References = new[] { new SG1 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "ON", ReferenceIdentifier = "Orders123", }, }, DateTimePeriod = new[] { new DateTimePeriod { DateTimePeriodGroup = new DateTimePeriodGroup { Value = "201411220000", FunctionCodeQualifier = "171", FormatCode = "203", } } } }, new SG1 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "BO", ReferenceIdentifier = "bo123", }, }, DateTimePeriod = new DateTimePeriod[] { null }, }, new SG1 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "CT", ReferenceIdentifier = "CN1", }, }, DateTimePeriod = new[] { new DateTimePeriod { DateTimePeriodGroup = new DateTimePeriodGroup { FormatCode = "203", FunctionCodeQualifier = "171", Value = "201404040000", } } }, }, new SG1 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "CT", ReferenceIdentifier = "CN2", }, }, DateTimePeriod = new[] { new DateTimePeriod { DateTimePeriodGroup = new DateTimePeriodGroup { FormatCode = "203", FunctionCodeQualifier = "171", Value = "201405050000", } } }, } }, PartiesArray = new[] { new SG2 { NameAndAddress = new NameAndAddress { PartyFunctionCodeQualifier = "SU", PartyIdentificationDetails = new PartyIdentificationDetails { PartyIdentifier = "supplier gln", }, PartyNameType = new PartyNameType { PartyName = new[] { "Very long supplier name for ArraySt", "ringConverterTest" }, PartyNameFormatCode = "UL", }, Street = new Street { StreetAndNumberOrPostBoxIdentifier = new[] { "Street; House; Flat" } }, CountryNameCode = "643", CityName = "City, Village", CountrySubEntityDetails = new CountrySubEntityDetails { CountrySubEntityName = "R1, D1", }, }, References = new[] { new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "FC", ReferenceIdentifier = "supplier inn", } } }, new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "GN", ReferenceIdentifier = "supplier okpo", } } }, }, FinancialInstitutionInformation = new[] { new FinancialInstitutionInformation { PartyFunctionCodeQualifier = "BK", HolderIdentification = new HolderIdentificationType { HolderIdentification = "bn1", HolderName = new[] { "cn1" }, }, InstitutionIdentification = new InstitutionIdentification { InstitutionName = "Bank", }, }, }, }, new SG2 { NameAndAddress = new NameAndAddress { PartyFunctionCodeQualifier = "BY", PartyIdentificationDetails = new PartyIdentificationDetails { PartyIdentifier = "buyer gln", }, PartyNameType = new PartyNameType { PartyName = new[] { "Last", "First", "Middle" }, PartyNameFormatCode = "IP", }, Street = new Street { StreetAndNumberOrPostBoxIdentifier = new[] { "Some Foreign Address" } }, CountryNameCode = "121", CountrySubEntityDetails = new CountrySubEntityDetails { }, }, References = new[] { new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "FC", ReferenceIdentifier = "buyer inn", } } }, new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "GN", ReferenceIdentifier = "buyer okpo", } } }, }, FinancialInstitutionInformation = new[] { new FinancialInstitutionInformation { HolderIdentification = new HolderIdentificationType { HolderName = new string[1], }, InstitutionIdentification = new InstitutionIdentification(), }, }, }, }, SG13 = new[] { new SG13 { Package = new Package { PackageType = new PackageType(), } } }, SG28 = new[] { new SG28 { LineItem = new LineItem { LineItemIdentifier = "1", ItemNumberIdentification = new ItemNumberIdentification { ItemIdentifier = "GTIN 1", }, }, AdditionalProductId = new[] { new AdditionalProductId { ItemNumberIdentification = new[] { new ItemNumberIdentification { ItemTypeIdentificationCode = "IN", ItemIdentifier = "bid1", }, }, ProductIdentifierCodeQualifier = "z", }, new AdditionalProductId { ItemNumberIdentification = new[] { new ItemNumberIdentification(), }, }, }, Quantity = new[] { new SecondContractQuantity { QuantityDetails = new QuantityDetails { Quantity = "12.34", MeasurementUnitCode = "PCE", }, }, }, DateTimePeriod = new DateTimePeriod[1], MonetaryAmount = new[] { new MonetaryAmount { MonetaryAmountGroup = new MonetaryAmountGroup { MonetaryAmountTypeCodeQualifier = "203", MonetaryAmount = "0.1200", } } }, FreeText = new FreeText[0], GoodsIdentityNumber = new[] { new GoodsIdentityNumber { ObjectIdentificationCodeQualifier = "BN", IdentityNumberRange = new[] { new IdentityNumberRange { ObjectIdentifier = new[] { "SN1" }, } } } } }, new SG28 { LineItem = new LineItem { LineItemIdentifier = "2", ItemNumberIdentification = new ItemNumberIdentification { ItemIdentifier = "GTIN 2", }, }, AdditionalProductId = new[] { new AdditionalProductId { ItemNumberIdentification = new[] { new ItemNumberIdentification() }, }, new AdditionalProductId { ItemNumberIdentification = new[] { new ItemNumberIdentification { ItemTypeIdentificationCode = "SA", ItemIdentifier = "sid2", }, }, ProductIdentifierCodeQualifier = "q", }, }, Quantity = new[] { new SecondContractQuantity { QuantityDetails = new QuantityDetails { Quantity = "133.10", MeasurementUnitCode = "KGM", }, }, }, DateTimePeriod = new DateTimePeriod[1], MonetaryAmount = new[] { new MonetaryAmount { MonetaryAmountGroup = new MonetaryAmountGroup { MonetaryAmountTypeCodeQualifier = "203", MonetaryAmount = "", } } }, FreeText = new[] { new FreeText { TextSubjectCodeQualifier = "DEL", TextLiteral = new TextLiteral { FreeTextValue = new[] { "Flow type" } }, TextReference = new TextReference { FreeTextValueCode = "ZZZ", }, }, new FreeText { TextSubjectCodeQualifier = "ACB", TextLiteral = new TextLiteral { FreeTextValue = new[] { "Comment" } }, TextReference = new TextReference(), }, }, }, }, ControlTotal = new[] { new ControlTotal { Control = new Control { ControlTotalValue = "145.44", } } } }, } }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext()); converter(innerDocument).Should().BeEquivalentTo(secondContractDocument); }
public void TestNoneContext() { #region second contract var secondContractDocument = new SecondContractDocument <SecondContractDocumentBody> { SG0 = new[] { new SecondContractDocumentBody { BeginningOfMessage = new BeginningOfMessage { DocumentMessageIdentification = new DocumentMessageIdentification { DocumentIdentifier = "Message123", }, }, ControlTotal = new[] { new ControlTotal { Control = new Control { ControlTotalTypeCodeQualifier = "1", ControlTotalValue = "10.1", }, }, new ControlTotal { Control = new Control { ControlTotalTypeCodeQualifier = "11", ControlTotalValue = "12.34", }, }, }, Currency = new Currencies { CurrencyDetails = new[] { new CurrencyDetails { UsageCodeQualifier = "1", TypeCodeQualifier = "2", IdentificationCode = "first", }, new CurrencyDetails { UsageCodeQualifier = "2", TypeCodeQualifier = "4", IdentificationCode = "second", }, new CurrencyDetails { UsageCodeQualifier = "2", TypeCodeQualifier = "4", IdentificationCode = "third", }, } }, FreeText = new[] { new FreeText { TextSubjectCodeQualifier = "PUR", TextLiteral = new TextLiteral { FreeTextValue = new[] { "purchasing", " info" }, }, } }, References = new[] { new SG1 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceIdentifier = "blanket number", ReferenceCodeQualifier = "BO", }, }, }, }, SG10 = new[] { new SG10 { DetailsOfTransport = new DetailsOfTransport { TransportStageCodeQualifier = "1", TransportIdentification = new TransportIdentification { TransportMeansIdentificationName = "vehicle number", }, }, }, new SG10 { DetailsOfTransport = new DetailsOfTransport { TransportStageCodeQualifier = "20", TransportMeans = new TransportMeans { TransportMeansDescription = "transport means", TransportMeansDescriptionCode = "transport means code", }, }, SG11 = new[] { new SG11 { DateTimePeriod = new[] { new DateTimePeriod { DateTimePeriodGroup = new DateTimePeriodGroup { FunctionCodeQualifier = "232", FormatCode = "102", Value = "20130314", } }, }, }, }, }, }, SG28 = new[] { new SG28 { FreeText = new[] { new FreeText { TextSubjectCodeQualifier = "DEL", TextReference = new TextReference { CodeListResponsibleAgencyCode = "ZZZ", FreeTextValueCode = "flow type", }, }, }, ItemDescription = new[] { new ItemDescription { DescriptionFormatCode = "C", ItemDescriptionGroup = new ItemDescriptionGroup { ItemDescriptionCode = "RC", ItemDescription = new[] { "first ", "good item", " name" } }, }, }, LineItem = new LineItem { ItemNumberIdentification = new ItemNumberIdentification { ItemIdentifier = "GTIN 1" }, }, AdditionalProductId = new[] { new AdditionalProductId { ItemNumberIdentification = new[] { new ItemNumberIdentification { ItemIdentifier = "additional id1", ItemTypeIdentificationCode = "STB", }, }, ProductIdentifierCodeQualifier = "5", }, }, MonetaryAmount = new[] { new MonetaryAmount { MonetaryAmountGroup = new MonetaryAmountGroup { MonetaryAmountTypeCodeQualifier = "161", MonetaryAmount = "22.33", }, }, }, AdditionalInformation = new[] { new AdditionalInformation { CountryOfOriginNameCode = "DefaultCountry", }, new AdditionalInformation { CountryOfOriginNameCode = "country", }, }, SG34 = new[] { new SG34 { Package = new Package { PackageType = new PackageType { PackageTypeDescriptionCode = "default", }, PackageQuantity = "321.3", }, Quantity = new[] { new Quantity { QuantityDetails = new QuantityDetails { QuantityTypeCodeQualifier = "52", Quantity = "0.01", MeasurementUnitCode = "DEFAULT", }, }, }, }, new SG34 { Package = new Package { PackageType = new PackageType { PackageTypeDescriptionCode = "package type code", }, PackageQuantity = "324.3", }, Quantity = new[] { new Quantity { QuantityDetails = new QuantityDetails { QuantityTypeCodeQualifier = "52", Quantity = "0.02", MeasurementUnitCode = "PCE", }, }, }, } }, }, }, MonetaryAmount = new[] { new MonetaryAmount { MonetaryAmountGroup = new MonetaryAmountGroup { MonetaryAmountTypeCodeQualifier = "79", MonetaryAmount = "34.21", }, }, new MonetaryAmount { MonetaryAmountGroup = new MonetaryAmountGroup { MonetaryAmountTypeCodeQualifier = "9", MonetaryAmount = "3.14", }, }, }, PartiesArray = new[] { new SG2 { NameAndAddress = new NameAndAddress { PartyFunctionCodeQualifier = "PW", PartyIdentificationDetails = new PartyIdentificationDetails { PartyIdentifier = "GLN", }, PartyNameType = new PartyNameType { PartyName = new[] { "last name", "first name" }, PartyNameFormatCode = "IN", }, CountryNameCode = "foreign country code", Street = new Street { StreetAndNumberOrPostBoxIdentifier = new[] { "street ", "number ", "postbox" } }, PostalIdentificationCode = "post code", }, References = new[] { new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "YC1", ReferenceIdentifier = "Supplier Code", }, }, }, new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "FC", ReferenceIdentifier = "inn ip", }, }, }, }, ContactInformationArray = new[] { new SG5 { ContactInformation = new ContactInformation { ContactFunctionCode = "MGR", DepartmentOrEmployeeDetails = new DepartmentOrEmployeeDetails { DepartmentOrEmployeeName = "chief name", }, }, CommunicationContact = new[] { new CommunicationContact { CommunicationContactGroup = new CommunicationContactGroup { CommunicationAddressCodeQualifier = "TE", CommunicationAddressIdentifier = "phone", }, }, }, }, }, FinancialInstitutionInformation = new[] { new FinancialInstitutionInformation { PartyFunctionCodeQualifier = "BK", HolderIdentification = new HolderIdentificationType { HolderIdentification = "bank account number", }, }, }, }, new SG2 { NameAndAddress = new NameAndAddress { PartyFunctionCodeQualifier = "PW", PartyIdentificationDetails = new PartyIdentificationDetails { PartyIdentifier = "GLN1", }, PartyNameType = new PartyNameType { PartyName = new[] { "ul ", "name" }, PartyNameFormatCode = "LE", }, CountryNameCode = null, Street = new Street { StreetAndNumberOrPostBoxIdentifier = new[] { "str", "eet" }, }, PostalIdentificationCode = "post code", CityName = "city", }, References = new[] { new SG3 { Reference = new Reference { ReferenceGroup = new ReferenceGroup { ReferenceCodeQualifier = "FC", ReferenceIdentifier = "inn ul", }, }, }, }, } }, }, }, }; #endregion #region inner document var innerDocument = new InnerDocument { OrdersNumber = "Message123", CurrencyCode = "second", FlowType = "flow type", TransportDetails = new TransportDetails { VehicleNumber = "vehicle number", }, FreeText = "purchasing info", Transports = new[] { new TransportDetails { TypeOfTransport = "transport means", TypeOfTransportCode = "transport means code", DeliveryDateForVehicle = new DateTime(2013, 03, 14, 0, 0, 0, DateTimeKind.Utc), }, }, DespatchParties = new[] { new DespatchPartyInfo { PartyInfo = new PartyInfo { Gln = "GLN", SupplierCodeInBuyerSystem = "Supplier Code", PartyAddress = new PartyAddress { AddressType = AddressType.Foreign, RussianAddressInfo = new RussianAddressInfo(), ForeignAddressInfo = new ForeignAddressInfo { CountryCode = "foreign country code", Address = "street number postbox", }, }, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.IP, IPInfo = new IpInfo { LastName = "last name", FirstName = "first name", Inn = "inn ip", }, ULInfo = new UlInfo(), }, BankAccount = new BankAccount { BankAccountNumber = "bank account number", }, Chief = new InnerContract.ContactInformation { Name = "chief name", Phone = "phone", }, }, }, new DespatchPartyInfo { PartyInfo = new PartyInfo { Gln = "GLN1", PartyAddress = new PartyAddress { AddressType = AddressType.Russian, RussianAddressInfo = new RussianAddressInfo { Street = "street", City = "city", }, ForeignAddressInfo = new ForeignAddressInfo(), }, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.UL, IPInfo = new IpInfo(), ULInfo = new UlInfo { Inn = "inn ul", Name = "ul name", }, }, BankAccount = new BankAccount(), Chief = new InnerContract.ContactInformation(), }, } }, BlanketOrdersNumber = "blanket number", OrdersTotalPackageQuantity = 12.34m, RecadvTotal = 34.21m, TotalWithVAT = 3.14m, GoodItems = new[] { new CommonGoodItem { GoodNumber = new GoodNumber { Number = 1 }, Name = "first good item name", GTIN = "GTIN 1", AdditionalId = "additional id1", CountriesOfOriginCode = new[] { null, "country" }, IsReturnableContainer = true, TypeOfUnit = "RC", ExciseTax = 22.33m, Packages = new[] { new PackageForItem { PackageTypeCode = null, OnePackageQuantity = new InnerContract.Quantity { Value = 0.01m, MeasurementUnitCode = "DME", }, Quantity = 321.3m, }, new PackageForItem { PackageTypeCode = "package type code", OnePackageQuantity = new InnerContract.Quantity { Value = 0.02m, MeasurementUnitCode = "PCE", }, Quantity = 324.3m, }, }, }, }, }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext()); converter(secondContractDocument).Should().BeEquivalentTo(innerDocument, config => config.Excluding(x => x.OrdersDate)); }
public void TestReconfigureForContextA() { #region first contract document var firstContractDocument = new FirstContractDocument { Id = "id_dqd", Header = new FirstContractDocumentHeader { Sender = "sender", Recipient = "recipient", IsTest = "1", CreationDateTime = null, }, CreationDateTime = new DateTime(2012, 02, 02), Document = new[] { new FirstContractDocumentBody { OriginOrder = new DocumentIdentificator { Number = "OR123", Date = new DateTime(2012, 01, 01), }, DeliveryType = "Paper", DeliveryInfo = new DeliveryInfo { TransportBy = "transportBy", }, Status = "canceled", IntervalLength = "21", Buyer = new FirstContractPartyInfo { Gln = "12345678", SelfEmployed = new SelfEmployed { Inn = "inn", FullName = new FullName { FirstName = "First Name", LastName = "Last name", } }, Organization = null, ForeignOrganization = null, ForeignAddress = new ForeignAddress { Address = null, CountryIsoCode = null }, TaxSystem = "Simplified", RussianAddress = new RussianAddress { PostalCode = "620142", City = "Ekat", }, ContactInfo = new ContactInfo { Ceo = new ContactPersonInfo { Name = "Jeff", Phone = "8909" } } }, Seller = new FirstContractPartyInfo { Gln = "87654321", SelfEmployed = null, Organization = new Organization { Inn = "org inn", Name = "org name", }, ForeignOrganization = new ForeignOrganization { Name = "foreign org name", }, ForeignAddress = new ForeignAddress { Address = "221B, Baker st., London", CountryIsoCode = "111", }, TaxSystem = "complex", RussianAddress = null, ContactInfo = new ContactInfo { Ceo = null, }, AdditionalInfo = new AdditionalInfo { NameOfCeo = "Bezos", Phone = "8808", } }, LineItems = new LineItems { TotalSumExcludingTaxes = "123.45", LineItem = new[] { new LineItem { Gtin = "134143", OrderedQuantity = new MeasureUnitQuantity { Quantity = "0.43", UnitOfMeasure = "kg", }, TypeOfUnit = "RET", ControlMarks = new[] { "abc", "def", "zzz" }, Declarations = new[] { "123", "345", "567" }, ToBeReturnedQuantity = new[] { new ReasonQuantity { ReasonOfReturn = "bad goods", Quantity = "92", }, new ReasonQuantity { Quantity = "23", ReasonOfReturn = "no need" } }, FlowType = "very flow", }, } }, MessageCodes = new[] { "nullify", "azb", "czf" } }, } }; #endregion #region inner document var innerDocument = new InnerDocument { FromGln = "recipient", ToGln = "sender", IsTest = true, CreationDateTimeBySender = new DateTime(2012, 02, 02), OrdersNumber = "OR123", OrdersDate = new DateTime(2012, 01, 01), DeliveryType = DocumentsDeliveryType.Paper, TransportBy = "transportBy", RecadvType = TypeOfDocument.Canceled, SumTotal = 123.45m, FlowType = "very flow", IntervalLength = 21, Buyer = new PartyInfo { Gln = "12345678", PartyInfoType = PartyInfoType.Russian, PartyAddress = new PartyAddress { AddressType = AddressType.Russian, RussianAddressInfo = new RussianAddressInfo { PostalCode = "620142", City = "Ekat", } }, UsesSimplifiedTaxSystem = true, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.IP, IPInfo = new IpInfo { Inn = "inn", FirstName = "First Name", LastName = "Last name", } }, Chief = new ContactInformation { Name = "Jeff", Phone = "8909", } }, Supplier = new PartyInfo { Gln = "87654321", PartyInfoType = PartyInfoType.Foreign, PartyAddress = new PartyAddress { AddressType = AddressType.Foreign, ForeignAddressInfo = new ForeignAddressInfo { CountryCode = "111", Address = "221B, Baker st., London", } }, UsesSimplifiedTaxSystem = false, RussianPartyInfo = new RussianPartyInfo { RussianPartyType = RussianPartyType.UL, ULInfo = new UlInfo { Inn = "org inn", Name = "org name", } }, Chief = new ContactInformation { Name = "Bezos", Phone = "8808", } }, GoodItems = new[] { new CommonGoodItem { GTIN = "134143", Quantity = new Quantity { Value = 0.43m, MeasurementUnitCode = "kg", }, GoodNumber = new GoodNumber { Number = 1, MessageType = MessageType.ReceivingAdvice, }, IsReturnable = true, Marks = new[] { "123", "345", "567" }, Declarations = new[] { new CustomDeclaration { Number = "abc" }, new CustomDeclaration { Number = "def" }, new CustomDeclaration { Number = "zzz" }, }, QuantityVariances = new[] { new QuantityVariance { Reason = "bad goods", QuantityValue = 92m, }, new QuantityVariance { Reason = "no need", QuantityValue = 23m, }, }, } }, Nullify = true, MessageCodes = new[] { "nullify", null, "czf" }, }; #endregion var converter = converterCollection.GetConverter(new TestConverterContext(MutatorsContextType.A)); converter(firstContractDocument).Should().BeEquivalentTo(innerDocument); }