public void Format_Urban_Address()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "RURAL" };

            formatter.Format(postalAddress);
        }
        public void Format_Box_Address()
        {
            BagPostalAddressFormatter formatter = new BagPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "BAG" };

            formatter.Format(postalAddress);
        }
        public void Invalid_AddressType_rural()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "URBAN" };

            formatter.Format(postalAddress);
        }
        public void Format_Urban_Address()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "URBAN" };

            formatter.Format(postalAddress);
        }
        public void Invalid_AddressType_rural()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "RURAL" };

            formatter.Format(postalAddress);
        }
 public AgentParty()
 {
     PartyIdentification = new PartyIdentification();
     PartyName = new PartyName();
     PostalAddress = new PostalAddress();
     PartyLegalEntity = new PartyLegalEntity();
 }
        public void Format_Box_Address_Set_AddressType()
        {
            BagPostalAddressFormatter formatter = new BagPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "BAG" };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("BAG", format.AddressType);
        }
        public void Format_Urban_Address_Set_AddressType()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "RURAL" };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("RURAL", format.AddressType);
        }
        public void Format_Urban_Address_Set_AddressType()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress() { AddressType = "URBAN" };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("URBAN", format.AddressType);
        }
        public void Box_Address()
        {
            BoxPostalAddressFormatter formatter = new BoxPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "BOX",
                BoxBagLobbyName = "Manners Street",
                BoxBagNumber = "24001",
                DeliveryServiceType = "PO Box",
                PostCode = "6142",
                TownCityMailTown = "Wellington"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("PO Box 24001", format.AddressLine1);
            Assert.AreEqual("Manners Street", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual(string.Empty, format.Suburb);
            Assert.AreEqual("Wellington", format.City);
            Assert.AreEqual("6142", format.PostCode);
        }
        public void Box_Address()
        {
            BagPostalAddressFormatter formatter = new BagPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "BAG",
                BoxBagLobbyName = "Onehunga",
                BoxBagNumber = "999028",
                DeliveryServiceType = "Private Bag",
                PostCode = "1643",
                TownCityMailTown = "Auckland"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("Private Bag 999028", format.AddressLine1);
            Assert.AreEqual("Onehunga", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual(string.Empty, format.Suburb);
            Assert.AreEqual("Auckland", format.City);
            Assert.AreEqual("1643", format.PostCode);
        }
        public void Urban_Street()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "URBAN",
                PostCode = "6011",
                StreetName = "Manners Street",
                StreetNumber = "2",
                StreetType = "Street",
                SuburbName = "Te Aro",
                TownCityMailTown = "Wellington"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("2 Manners Street", format.AddressLine1);
            Assert.AreEqual("Te Aro", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("Te Aro", format.Suburb);
            Assert.AreEqual("Wellington", format.City);
            Assert.AreEqual("6011", format.PostCode);
        }
        public void Rural_Flat()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "RURAL",
                PostCode = "0174",
                RDNumber = "4",
                StreetName = "Whangarei Heads Road",
                StreetNumber = "803",
                StreetType = "Road",
                TownCityMailTown = "Whangarei",
                UnitId = "19",
                UnitType = "UNIT"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("19/803 Whangarei Heads Road", format.AddressLine1);
            Assert.AreEqual("RD 4", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("RD 4", format.Suburb);
            Assert.AreEqual("Whangarei", format.City);
            Assert.AreEqual("0174", format.PostCode);
        }
Exemplo n.º 14
0
 public GeoPoint GetGeoPointFor(PostalAddress address)
 {
     return(_geoCodeLookupProvider.GetGeoCodingFor(address));
 }
Exemplo n.º 15
0
        public CustomerResponse ConvertCustomer(Customer customer)
        {
            var phonenumber  = string.Empty;
            var mobilenumber = string.Empty;
            var faxnumber    = string.Empty;
            var address      = new PostalAddress();

            foreach (var a in customer.Addresses.Address)
            {
                if (a.Telephone.StartsWith("06"))
                {
                    mobilenumber = a.Telephone;
                }
                else
                {
                    phonenumber = a.Telephone;
                }

                faxnumber = a.Telefax;
                address   = new PostalAddress
                {
                    Address1      = a.Field2,
                    Address2      = a.Field3,
                    City          = a.City,
                    ContactPerson = a.Field1,
                    ZipCode       = a.Postcode
                };
                address.Country.Code = a.Country;
                address.Country.Name = a.CountryName;
            }

            var bank = new BankM();

            for (int i = 0; i < customer.Banks.Bank.Count; i++)
            {
                if (customer.Banks.Bank[i] != null)
                {
                    bank.AccountNumber = customer.Banks.Bank[i].Accountnumber;
                    bank.AccountHolder = customer.Banks.Bank[i].Ascription;
                    bank.BicCode       = customer.Banks.Bank[i].Biccode;
                    bank.Iban          = customer.Banks.Bank[i].Iban;
                    bank.Name          = customer.Banks.Bank[i].Bankname;
                }
            }

            var customerResponse = new CustomerResponse
            {
                Code      = customer.Code,
                Name      = customer.Name,
                VATNumber = customer.Vatnumber,
                Website   = customer.Website,
            };

            customerResponse.Addresses.General                 = address;
            customerResponse.Bank.Name                         = bank.Name;
            customerResponse.Bank.AccountNumber                = bank.AccountNumber;
            customerResponse.Bank.AccountHolder                = bank.AccountHolder;
            customerResponse.Bank.BicCode                      = bank.BicCode;
            customerResponse.Bank.Iban                         = bank.Iban;
            customerResponse.EMailAddresses.General.To         = customer.Financials.Ebillmail;
            customerResponse.EMailAddresses.Invoice.To         = customer.Financials.Ebillmail;
            customerResponse.EMailAddresses.InvoiceReminder.To = customer.Creditmanagement.Reminderemail;
            customerResponse.PhoneNumbers.General              = phonenumber;
            customerResponse.PhoneNumbers.Fax                  = faxnumber;
            customerResponse.PhoneNumbers.Mobile               = mobilenumber;
            return(customerResponse);
        }
        public void Urban_Street_Suite_UnitID_AlphaNumeric()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "URBAN",
                PostCode = "6011",
                StreetName = "Manners Street",
                StreetNumber = "125",
                StreetType = "Street",
                SuburbName = "Te Aro",
                TownCityMailTown = "Wellington",
                UnitId = "3A",
                UnitType = "SUITE"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("3A/125 Manners Street", format.AddressLine1);
            Assert.AreEqual("Te Aro", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("Te Aro", format.Suburb);
            Assert.AreEqual("Wellington", format.City);
            Assert.AreEqual("6011", format.PostCode);
        }
        public void Urban_Street_Numeric_Unit_UnitID_Alpha()
        {
            UrbanPostalAddressFormatter formatter = new UrbanPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "URBAN",
                PostCode = "1050",
                StreetName = "Buttle Street",
                StreetNumber = "15",
                StreetType = "Street",
                SuburbName = "Remuera",
                TownCityMailTown = "Auckland",
                UnitId = "A",
                UnitType = "UNIT"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("15A Buttle Street", format.AddressLine1);
            Assert.AreEqual("Remuera", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("Remuera", format.Suburb);
            Assert.AreEqual("Auckland", format.City);
            Assert.AreEqual("1050", format.PostCode);
        }
        public void Urban_Street_Suite_UnitID_AlphaNumeric()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "RURAL",
                PostCode = "7691",
                RDNumber = "1",
                StreetName = "Williams Street",
                StreetNumber = "548",
                StreetType = "Street",
                TownCityMailTown = "Kaiapoi",
                UnitId = "18A",
                UnitType = "UNIT"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("18A/548 Williams Street", format.AddressLine1);
            Assert.AreEqual("RD 1", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("RD 1", format.Suburb);
            Assert.AreEqual("Kaiapoi", format.City);
            Assert.AreEqual("7691", format.PostCode);
        }
 private string formatAddress(PostalAddress address)
 {
     return(address.RecipientName + " " + address.StreetAddress + " " +
            address.ExtendedAddress + " " + address.Locality + " " + address.Region +
            " " + address.PostalCode + " " + address.CountryCodeAlpha2);
 }
 public Party()
 {
     PartyName = new PartyName();
     PostalAddress = new PostalAddress();
     PartyLegalEntity = new PartyLegalEntity();
 }
Exemplo n.º 21
0
 public Response EditPostalAddress(PostalAddress postalAddress)
 {
     return(postalAddressRepository.EditPostalAddress(postalAddress));
 }
Exemplo n.º 22
0
        public void PostalAddressConstructorTest()
        {
            PostalAddress target = new PostalAddress();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemplo n.º 23
0
        public Participant Read(int sampleNo)
        {
            try
            {
                Init();
                var sheet = workbook.GetSheetAt(0);

                Participant.Id Id = new Participant.Id();
                Participant.PhysicalAddress           physicalAddress                     = new PhysicalAddress();
                Participant.PostalAddress             postalAddress                       = new PostalAddress();
                Participant.Contacts                  contacts                            = new Contacts();
                Participant.ExternalSystemsReferences externalSystemsReferences           = new ExternalSystemsReferences();
                Participant.NOTES                          notes                          = new NOTES();
                Participant.BankingDetails                 bankingDetails                 = new BankingDetails();
                Participant.Conventions                    conventions                    = new Conventions();
                Participant.BillingPracticeDetails         billingPracticeDetails         = new BillingPracticeDetails();
                Participant.PenaltyGracePeriod             penaltyGracePeriod             = new PenaltyGracePeriod();
                Participant.PenaltyGracePeriodforGuarantor penaltyGracePeriodforGuarantor = new PenaltyGracePeriodforGuarantor();
                Participant.BusinessDayConvention          businessDayConvention          = new BusinessDayConvention();
                Participant.IssuerPractices                issuerPractices                = new IssuerPractices();
                Participant.LimitsandRatings               limitsandRatings               = new LimitsandRatings();
                Participant.CreditLimit                    creditLimit                    = new CreditLimit();
                Participant.CreditRatings                  creditRatings                  = new CreditRatings();
                foreach (IRow row in sheet)



                {
                    var attrib = row.GetCell(1).StringCellValue.ToUpper();
                    var value  = GetUnformattedValue(row.GetCell(2 + sampleNo));

                    switch (row.GetCell(1).StringCellValue.ToUpper())
                    {
                    case "IDENTIFICATION":

                        if (attrib == "NAME")
                        {
                            Id.Name = value;
                        }
                        else if (attrib == "COUNTRY OF RESIDENCE")
                        {
                            Id.CountryOfResidence = value;
                        }
                        else if (attrib == "COUNTRY OF DOMICILE")
                        {
                            Id.CountryOfDomicile = value;
                        }
                        else if (attrib == "RESIDENCY")
                        {
                            Id.Residency = value;
                        }
                        else if (attrib == "ROLE")
                        {
                            Id.Role = value;
                        }
                        else if (attrib == "CATEGORY")
                        {
                            Id.Category = value;
                        }
                        else if (attrib == "NATIONALSECTOR")
                        {
                            Id.NationalSector = value;
                        }
                        else if (attrib == "INSTTITUTINALSECTOR")
                        {
                            Id.InsttitutinalSector = value;
                        }
                        else if (attrib == "PARENTCOMPANY")
                        {
                            Id.ParentCompany = value;
                        }
                        else if (attrib == "STATUS")
                        {
                            Id.Status = value;
                        }
                        else if (attrib == "PARTICIPANTNOTUSED")
                        {
                            Id.ParticipantNotUsed = value;
                        }
                        else if (attrib == "PARTICIPANTISOWNER")
                        {
                            Id.ParticipantIsOwner = value;
                        }
                        else if (attrib == "EXPORTCODE")
                        {
                            Id.ExportCode = value;
                        }
                        else if (attrib == "EXTERNALCODE")
                        {
                            Id.ExternalCode = value;
                        }
                        break;

                    case "PHYSICAL ADDRESS":
                        if (attrib == "ADDRESSLINE1")
                        {
                            physicalAddress.AddressLine1 = value;
                        }
                        else if (attrib == "ADDRESSLINE2")
                        {
                            physicalAddress.AddressLine2 = value;
                        }
                        else if (attrib == "ADDRESSLINE3")
                        {
                            physicalAddress.AddressLine3 = value;
                        }
                        else if (attrib == "CODE")
                        {
                            physicalAddress.Code = value;
                        }
                        else if (attrib == "COUNTRY")
                        {
                            physicalAddress.Country = value;
                        }
                        else if (attrib == "CITY")
                        {
                            physicalAddress.City = value;
                        }
                        break;

                    case "POSTAL ADDRESS":
                        if (attrib == "ADDRESSLINE1")
                        {
                            postalAddress.AddressLine1 = value;
                        }
                        else if (attrib == "ADDRESSLINE2")
                        {
                            postalAddress.AddressLine2 = value;
                        }
                        else if (attrib == "ADDRESSLINE3")
                        {
                            postalAddress.AddressLine3 = value;
                        }
                        else if (attrib == "CODE")
                        {
                            postalAddress.Code = value;
                        }
                        else if (attrib == "CITY")
                        {
                            postalAddress.City = value;
                        }
                        else if (attrib == "WEBADDRESS")
                        {
                            postalAddress.WebAddress = value;
                        }

                        break;

                    case "CONTACTS":
                        if (attrib == "CONTACTNAME")
                        {
                            contacts.ContactName = value;
                        }
                        else if (attrib == "CONTACTTELEPHONENUMBER")
                        {
                            contacts.ContactTelephoneNumber = value;
                        }
                        else if (attrib == "CONTACTFAXNUMBER")
                        {
                            contacts.ContactFaxNumber = value;
                        }
                        else if (attrib == "CONTACTEMAIL")
                        {
                            contacts.ContactEmail = value;
                        }
                        else if (attrib == "PRIMARYCONTACTINDICATOR")
                        {
                            contacts.PrimaryContactIndicator = value;
                        }
                        break;

                    case "EXTERNAL SYSTEMS REFERENCES":
                        if (attrib == "EXTERNALSYSTEM")
                        {
                            externalSystemsReferences.Externalsystem = value;
                        }
                        else if (attrib == "REFERENCE")
                        {
                            externalSystemsReferences.Reference = value;
                        }
                        break;

                    case "NOTES":
                        if (attrib == "NOTESDATE")
                        {
                            notes.NotesDate = value;
                        }
                        else if (attrib == "NOTES")
                        {
                            notes.Notes = value;
                        }
                        break;

                    case "BANKING DETAILS":
                        if (attrib == "BANKNAME")
                        {
                            bankingDetails.BankName = value;
                        }
                        else if (attrib == "ACCOUNTNAME")
                        {
                            bankingDetails.AccountName = value;
                        }
                        else if (attrib == "CURRENCY")
                        {
                            bankingDetails.Currency = value;
                        }
                        else if (attrib == "IBAN")
                        {
                            bankingDetails.IBAN = value;
                        }
                        else if (attrib == "SWIFTBICNUMBER")
                        {
                            bankingDetails.SWIFTBICNumber = value;
                        }
                        else if (attrib == "COUNTRY")
                        {
                            bankingDetails.Country = value;
                        }
                        else if (attrib == "CITY")
                        {
                            bankingDetails.City = value;
                        }
                        else if (attrib == "STARTDATE")
                        {
                            bankingDetails.StartDate = value;
                        }
                        else if (attrib == "ENDDATE")
                        {
                            bankingDetails.EndDate = value;
                        }
                        else if (attrib == "ACCOUNTUSE")
                        {
                            bankingDetails.AccountUse = value;
                        }
                        else if (attrib == "BANKACCOUNTSTATUS")
                        {
                            bankingDetails.BankAccountStatus = value;
                        }
                        else if (attrib == "APPLICABLEINSTRUMENTTYPES")
                        {
                            bankingDetails.ApplicableInstrumentTypes = value;
                        }
                        else if (attrib == "DEFAULTDEBITACCOUNT")
                        {
                            bankingDetails.DefaultDebitAccount = value;
                        }
                        else if (attrib == "DEFAULTDEBITSTARTDATE")
                        {
                            bankingDetails.DefaultDebitStartDate = value;
                        }
                        else if (attrib == "DEFAULTDEBITENDDATE")
                        {
                            bankingDetails.DefaultDebitEndDate = value;
                        }
                        else if (attrib == "DEFAULTCREDITACCOUNT")
                        {
                            bankingDetails.DefaultCreditAccount = value;
                        }
                        else if (attrib == "DEFAULTCREDITSTARTDATE")
                        {
                            bankingDetails.DefaultCreditStartDate = value;
                        }
                        else if (attrib == "DEFAULTCREDITENDDATE")
                        {
                            bankingDetails.DefaultCreditEndDate = value;
                        }
                        else if (attrib == "INTERMEDIARYBANKINGDETAILS")
                        {
                            bankingDetails.IntermediaryBankingdetails = value;
                        }
                        break;

                    case "BILLING PRACTICE DETAILS":
                        if (attrib == "OPTIONS")
                        {
                            billingPracticeDetails.Options = value;
                        }
                        else if (attrib == "INTERMEDIARYBANKINGDETAILS")
                        {
                            billingPracticeDetails.Period = value;
                        }
                        break;

                    case "PENALTY GRACE PERIOD":
                        if (attrib == "PERIOD")
                        {
                            penaltyGracePeriod.Period = value;
                        }
                        else if (attrib == "PERIODICITY")
                        {
                            penaltyGracePeriod.Periodicity = value;
                        }
                        break;

                    case "PENALTY GRACE PERIOD (FOR GUARANTOR)":
                        if (attrib == "PERIOD")
                        {
                            penaltyGracePeriodforGuarantor.Period = value;
                        }
                        else if (attrib == "PERIODICITY")
                        {
                            penaltyGracePeriodforGuarantor.Periodicity = value;
                        }
                        else if (attrib == "PAYMENTFREQUENCY")
                        {
                            penaltyGracePeriodforGuarantor.PaymentFrequency = value;
                        }
                        else if (attrib == "EXPECTEDTIMEFORCLAIMSETTLEMENTINDAYS")
                        {
                            penaltyGracePeriodforGuarantor.ExpectedTimeforClaimSettlementindays = value;
                        }
                        else if (attrib == "PAYMENTAPPLICATIONMETHOD")
                        {
                            penaltyGracePeriodforGuarantor.PaymentApplicationMethod = value;
                        }
                        else if (attrib == "MINIMUMBILLAMOUNT")
                        {
                            penaltyGracePeriodforGuarantor.MinimumBillAmount = value;
                        }
                        else if (attrib == "PREPAYMENTMETHODS")
                        {
                            penaltyGracePeriodforGuarantor.Prepaymentmethods = value;
                        }
                        else if (attrib == "LEGALCLAUSES")
                        {
                            penaltyGracePeriodforGuarantor.LegalClauses = value;
                        }
                        break;

                    case "BUSINESS DAY CONVENTION":
                        if (attrib == "CASHFLOWTYPE")
                        {
                            businessDayConvention.CashFlowType = value;
                        }
                        else if (attrib == "DATEROLL")
                        {
                            businessDayConvention.DateRoll = value;
                        }
                        else if (attrib == "CALCULATEARREARSFROM")
                        {
                            businessDayConvention.Calculatearrearsfrom = value;
                        }
                        else if (attrib == "ENDMONTHINDICATOR")
                        {
                            businessDayConvention.EndMonthIndicator = value;
                        }
                        else if (attrib == "INTERESTCALCULATEDTO")
                        {
                            businessDayConvention.InterestCalculatedTo = value;
                        }
                        break;

                    case "ISSUER PRACTICES":
                        if (attrib == "OPTIONS")
                        {
                            issuerPractices.Options = value;
                        }
                        else if (attrib == "BOOKCLOSEDPERIODPERIOD")
                        {
                            issuerPractices.BookClosedPeriodPeriod = value;
                        }
                        else if (attrib == "PERIODICITY")
                        {
                            issuerPractices.Periodicity = value;
                        }
                        break;

                    case "CREDIT LIMIT":
                        if (attrib == "CATEGORY")
                        {
                            creditLimit.Category = value;
                        }
                        else if (attrib == "AMOUNTPERIOD")
                        {
                            creditLimit.AmountPeriod = value;
                        }
                        break;

                    case "CREDIT RATINGS":
                        if (attrib == "RATINGAGENCY")
                        {
                            creditRatings.RatingAgency = value;
                        }
                        else if (attrib == "RATINGDATE")
                        {
                            creditRatings.RatingDate = value;
                        }
                        else if (attrib == "CREDITRATING")
                        {
                            creditRatings.CreditRating = value;
                        }
                        else if (attrib == "RATINGOUTLOOK")
                        {
                            creditRatings.RatingOutlook = value;
                        }
                        else if (attrib == "WATCHDATE")
                        {
                            creditRatings.WatchDate = value;
                        }
                        break;
                    }
                }


                participant     = new Participant();
                participant._Id = Id;
                //participant._PhysicalAddress =

                return(participant);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error Reading Input Excel file");
                throw (ex);
            }
        }
Exemplo n.º 24
0
 public bool Validate(PostalAddress postalAddress)
 {
     return(ValidateAll(Valid(postalAddress != null, "PostalAddress"),
                        Valid(!string.IsNullOrWhiteSpace(postalAddress?.Country), "PostalAddress.Country"),
                        Valid(!string.IsNullOrWhiteSpace(postalAddress?.Town), "PostalAddress.Town")));
 }
Exemplo n.º 25
0
 protected sealed override string FormatNonNullValue(FormatContext context, PostalAddress postalAddress, int indentLevel)
 {
     AbstractAdPropertyFormatter.AD_VALIDATION_UTILS.ValidatePostalAddress(postalAddress, context.Type, context.GetVersion(),
                                                                           null, context.GetPropertyPath(), context.GetModelToXmlResult());
     return(base.FormatNonNullValue(context, postalAddress, indentLevel));
 }
Exemplo n.º 26
0
        private void CreateDocument_STAThread()
        {
            #region Prep
            System.Collections.ArrayList data = objData;
            //Create new document
            FixedDocument doc = new FixedDocument();
            //Set page size
            doc.DocumentPaginator.PageSize = new Size(PAPER_SIZE_WIDTH_96, PAPER_SIZE_HEIGHT_96);

            //Number of records
            double count = (double)data.Count;
            #endregion

            if (count > 0)
            {
                #region Declare Variables
                AveryBarcodeLabel label;

                //Determine number of pages to generate
                double pageCount = Math.Ceiling(count / LABELS_PER_SHEET);

                int dataIndex        = 0;
                int currentColumn    = 0;
                int currentPDFColumn = 0;
                int currentRow       = 0;

                iTextSharp.text.pdf.PdfPTable objPDFTable = null;
                #endregion

                #region Open PDF Document
                iTextSharp.text.Rectangle rectPaperSize = new iTextSharp.text.Rectangle((float)PAPER_SIZE_WIDTH_72, (float)PAPER_SIZE_HEIGHT_72);
                iTextSharp.text.Document  objPDFDoc     = CreatePagePDF(_strFilePathPDF, rectPaperSize, (float)SIDE_MARGIN_72, (float)SIDE_MARGIN_72, (float)(TOP_MARGIN_72), 0);
                //objPDFDoc.
                #endregion

                #region Define PDF Column Widths
                //Define PDF Column Widths
                float[] columnWidth = new float[5];
                columnWidth[0] = (float)LABEL_WIDTH_72;
                columnWidth[1] = (float)HORIZONTAL_GAP_72;
                columnWidth[2] = (float)LABEL_WIDTH_72;
                columnWidth[3] = (float)HORIZONTAL_GAP_72;
                columnWidth[4] = (float)LABEL_WIDTH_72;
                #endregion

                for (int i = 0; i < pageCount; i++)
                {
                    #region Prep XPS Page
                    //Create page
                    PageContent page      = new PageContent();
                    FixedPage   fixedPage = this.CreatePageXPS();
                    #endregion

                    //Create labels
                    for (int j = 0; j < 30; j++)
                    {
                        #region Set currentRow
                        if (j % 10 == 0)
                        {
                            currentRow = 0;
                        }
                        else
                        {
                            currentRow++;
                        }
                        #endregion

                        #region Set curentColumn (Vertically)
                        if (j < 10)
                        {
                            currentColumn = 0;
                        }
                        else if (j > 19)
                        {
                            currentColumn = 2;
                        }
                        else
                        {
                            currentColumn = 1;
                        }
                        #endregion

                        #region Set currentPDFColumn (Horizontally)
                        if (j % 3 == 0)
                        {
                            currentPDFColumn = 0;
                        }
                        else if (j % 3 == 1)
                        {
                            currentPDFColumn = 1;
                        }
                        else if (j % 3 == 2)
                        {
                            currentPDFColumn = 2;
                        }
                        #endregion

                        if (dataIndex < count)
                        {
                            #region Start a New Page When Necessary
                            if (dataIndex % 30 == 0 || dataIndex == 0)
                            {
                                if (objPDFTable != null)
                                {
                                    objPDFDoc.Add(objPDFTable);
                                    objPDFDoc.NewPage();
                                }
                                objPDFTable = new iTextSharp.text.pdf.PdfPTable(5);
                                objPDFTable.SetTotalWidth(columnWidth);
                                objPDFTable.LockedWidth = true;
                                //objPDFTable.SplitLate = false;
                                objPDFTable.SkipLastFooter = true;
                                objPDFTable.KeepTogether   = true;
                                //objPDFTable.ExtendLastRow = true;
                            }
                            #endregion

                            #region Get Data and Fill Lines
                            label = new AveryBarcodeLabel();

                            if (data[dataIndex].GetType() == typeof(AveryBarcodeLabel))
                            {
                                label = (AveryBarcodeLabel)data[dataIndex];
                            }
                            else if (data[dataIndex].GetType() == typeof(AveryLabelDataModel))
                            {
                                label = new AveryBarcodeLabel((AveryLabelDataModel)data[dataIndex]);
                            }
                            else if (data[dataIndex].GetType() == typeof(PostalAddress))
                            {
                                PostalAddress objAddr = (PostalAddress)data[dataIndex];
                                label.Line1 = objAddr.Reference;
                                label.Line2 = objAddr.Address1;
                                if (!StringFunctions.IsNullOrWhiteSpace(objAddr.Address2))
                                {
                                    label.Line2 += " " + objAddr.Address2;
                                }
                                if (!StringFunctions.IsNullOrWhiteSpace(objAddr.Address3))
                                {
                                    label.Line2 += " " + objAddr.Address3;
                                }
                                label.Line3 = objAddr.ToLocationString() + " " + objAddr.PostalCode;
                            }
                            else if (data[dataIndex].GetType() == typeof(AddressBookEntry))
                            {
                                AddressBookEntry objAddr = (AddressBookEntry)data[dataIndex];
                                label.Line1 = objAddr.FullName;
                                label.Line2 = objAddr.Address1;
                                if (!StringFunctions.IsNullOrWhiteSpace(objAddr.Address2))
                                {
                                    label.Line2 += " " + objAddr.Address2;
                                }
                                if (!StringFunctions.IsNullOrWhiteSpace(objAddr.Address3))
                                {
                                    label.Line2 += " " + objAddr.Address3;
                                }
                                label.Line3 = objAddr.ToLocationString() + " " + objAddr.PostalCode;
                                label.Email = objAddr.Email;
                                label.Phone = objAddr.Phone;
                            }

                            /*
                             * line1 = (string)data.Rows[dataIndex]["Name"];
                             * line2 = (string)data.Rows[dataIndex]["Address"];
                             * postalCode = (string)data.Rows[dataIndex]["PostalCode"];
                             * line3 = (string)data.Rows[dataIndex]["City"] + " " + (string)data.Rows[dataIndex]["State"] + " " + postalCode;
                             */
                            #endregion

                            #region Draw Label Cell in PDF
                            //Create individual label
                            iTextSharp.text.pdf.PdfPTable tblCell;

                            if ((label.Phone != null && label.Phone.Valid) || (label.Email != null && label.Email.Valid) || (label.Date != null && label.Date != DateTime.MinValue && label.Date != DateTime.MaxValue))
                            {
                                #region Label With Phone/Email/Date
                                Font objFont = new Font();
                                objFont.Size = Font.DEFAULTSIZE - 4;

                                tblCell = new iTextSharp.text.pdf.PdfPTable(2);

                                if (label.Date != null && label.Date != DateTime.MinValue && label.Date != DateTime.MaxValue)
                                {
                                    iTextSharp.text.pdf.PdfPCell objLine1 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line1, objFont));
                                    objLine1.Border = 0;
                                    tblCell.AddCell(objLine1);

                                    iTextSharp.text.pdf.PdfPCell objDate = new iTextSharp.text.pdf.PdfPCell(new Phrase("wd: " + label.Date.ToShortDateString(), objFont));
                                    objDate.HorizontalAlignment = 2; //Right
                                    objDate.Border = 0;
                                    tblCell.AddCell(objDate);
                                }
                                else
                                {
                                    iTextSharp.text.pdf.PdfPCell objLine1 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line1, objFont));
                                    objLine1.Border  = 0;
                                    objLine1.Colspan = 2;
                                    tblCell.AddCell(objLine1);
                                }

                                iTextSharp.text.pdf.PdfPCell objLine2 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line2, objFont));
                                objLine2.Border  = 0;
                                objLine2.Colspan = 2;
                                tblCell.AddCell(objLine2);

                                if (label.Phone != null && label.Phone.Valid)
                                {
                                    iTextSharp.text.pdf.PdfPCell objLine3 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line3, objFont));
                                    objLine3.Border = 0;
                                    objLine3.NoWrap = true;
                                    tblCell.AddCell(objLine3);

                                    iTextSharp.text.pdf.PdfPCell objPhone = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Phone.ToString(), objFont));
                                    objPhone.HorizontalAlignment = 2; //Right
                                    objPhone.Border = 0;
                                    tblCell.AddCell(objPhone);
                                }
                                else
                                {
                                    iTextSharp.text.pdf.PdfPCell objLine3 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line3, objFont));
                                    objLine3.Border  = 0;
                                    objLine3.Colspan = 2;
                                    tblCell.AddCell(objLine3);
                                }

                                if (label.Email != null && label.Email.Valid)
                                {
                                    iTextSharp.text.pdf.PdfPCell objEmail = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Email.ToString(), objFont));
                                    objEmail.HorizontalAlignment = 2; //Right
                                    objEmail.Border  = 0;
                                    objEmail.Colspan = 2;
                                    tblCell.AddCell(objEmail);
                                }

                                #endregion
                            }
                            else
                            {
                                #region Standard Address Label
                                tblCell = new iTextSharp.text.pdf.PdfPTable(1);

                                Font objNameFont = new Font();
                                objNameFont.Size = Font.DEFAULTSIZE - 1;
                                iTextSharp.text.pdf.PdfPCell objLine1 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line1, objNameFont));
                                objLine1.Border = 0;
                                tblCell.AddCell(objLine1);

                                Font objAddrFont = new Font();
                                objAddrFont.Size = Font.DEFAULTSIZE - 3;
                                iTextSharp.text.pdf.PdfPCell objLine2 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line2, objAddrFont));
                                objLine2.Border = 0;
                                tblCell.AddCell(objLine2);

                                if (!StringFunctions.IsNullOrWhiteSpace(label.Line3))
                                {
                                    iTextSharp.text.pdf.PdfPCell objLine3 = new iTextSharp.text.pdf.PdfPCell(new Phrase(label.Line3, objAddrFont));
                                    objLine3.Border = 0;
                                    tblCell.AddCell(objLine3);
                                }

                                #endregion
                            }
                            iTextSharp.text.pdf.PdfPCell pCell = new iTextSharp.text.pdf.PdfPCell(tblCell);
                            pCell.FixedHeight = (float)(LABEL_HEIGHT_72);
                            pCell.Padding     = 5;
                            pCell.Border      = 0;
                            objPDFTable.AddCell(pCell);
                            #endregion

                            #region Add Spacer Cell
                            iTextSharp.text.pdf.PdfPCell objGap = new iTextSharp.text.pdf.PdfPCell();
                            objGap.Border = 0;

                            if (currentPDFColumn == 0)
                            {
                                objPDFTable.AddCell(objGap);
                            }
                            else if (currentPDFColumn == 1)
                            {
                                objPDFTable.AddCell(objGap);
                            }
                            #endregion

                            #region Set XPS Position and Add to Document
                            //Set label location
                            if (currentColumn == 0)
                            {
                                FixedPage.SetLeft(label, SIDE_MARGIN_96);
                            }
                            else if (currentColumn == 1)
                            {
                                FixedPage.SetLeft(label, SIDE_MARGIN_96 + LABEL_WIDTH_96 + HORIZONTAL_GAP_96);
                            }
                            else
                            {
                                FixedPage.SetLeft(label, SIDE_MARGIN_96 + LABEL_WIDTH_96 * 2 + HORIZONTAL_GAP_96 * 2);
                            }
                            FixedPage.SetTop(label, TOP_MARGIN_96 + currentRow * LABEL_HEIGHT_96);

                            //Add label object to page
                            fixedPage.Children.Add(label);
                            #endregion

                            #region Finish Last PDF Row By Adding Blanks
                            if (dataIndex == count - 1) //If I'm on the last cell
                            {
                                if (currentPDFColumn != 3)
                                {
                                    while (currentPDFColumn != 3)
                                    {
                                        currentPDFColumn++;
                                        objPDFTable.AddCell(objGap);
                                    }
                                }
                            }
                            #endregion

                            dataIndex++;
                        }
                    }

                    #region Finalize XPS Page
                    //Invoke Measure(), Arrange() and UpdateLayout() for drawing
                    fixedPage.Measure(new Size(PAPER_SIZE_WIDTH_96, PAPER_SIZE_HEIGHT_96));
                    fixedPage.Arrange(new Rect(new Point(), new Size(PAPER_SIZE_WIDTH_96, PAPER_SIZE_HEIGHT_96)));
                    fixedPage.UpdateLayout();
                    ((IAddChild)page).AddChild(fixedPage);
                    doc.Pages.Add(page);
                    #endregion
                }

                #region Finalize PDF Document
                objPDFDoc.Add(objPDFTable);
                objPDFDoc.Close();
                #endregion
            }

            #region Write XPS Document
            if (!StringFunctions.IsNullOrWhiteSpace(_strFilePathXPS))
            {
                if (File.Exists(_strFilePathXPS))
                {
                    File.Delete(_strFilePathXPS);
                }
                XpsDocument xpsd = new XpsDocument(_strFilePathXPS, FileAccess.ReadWrite);
                System.Windows.Xps.XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd);
                xw.Write(doc);
                xpsd.Close();
            }
            #endregion
        }
Exemplo n.º 27
0
 public override string ToString()
 {
     return($"{PostalAddress.ToShortString()}: {Name}.");
 }
        private void RegisterAdministratorFor(
            Tenant tenant,
            FullName administorName,
            EmailAddress emailAddress,
            PostalAddress postalAddress,
            Telephone primaryTelephone,
            Telephone secondaryTelephone)
        {
            RegistrationInvitation invitation = tenant.OfferRegistrationInvitation("init").OpenEnded();
            string strongPassword             = new PasswordService().GenerateStrongPassword();

            // Publishes domain event UserRegistered.
            User admin = tenant.RegisterUser(
                invitation.InvitationId,
                "admin",
                strongPassword,
                Enablement.IndefiniteEnablement(),
                new Person(
                    tenant.TenantId,
                    administorName,
                    new ContactInformation(
                        emailAddress,
                        postalAddress,
                        primaryTelephone,
                        secondaryTelephone)));

            tenant.WithdrawInvitation(invitation.InvitationId);

            // Since this is a new entity, add it to
            // the collection-oriented repository.
            // Subsequent changes to the entity
            // are implicitly persisted.
            this.userRepository.Add(admin);

            // Publishes domain event RoleProvisioned.
            Role adminRole = tenant.ProvisionRole(
                "Administrator",
                string.Format("Default {0} administrator.", tenant.Name));

            // Publishes domain event UserAssignedToRole,
            // but not GroupUserAdded because the group
            // reference held by the role is an "internal" group.
            adminRole.AssignUser(admin);

            //if (adminRole.)

            // Since this is a new entity, add it to
            // the collection-oriented repository.
            // Subsequent changes to the entity
            // are implicitly persisted.
            this.roleRepository.Add(adminRole);

            DomainEventPublisher
            .Instance
            .Publish(new TenantAdministratorRegistered(
                         tenant.TenantId,
                         admin.Username,
                         administorName,
                         emailAddress,
                         admin.Username,
                         strongPassword));
        }
        public override void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, DateTime today)
        {
            //throw new NotImplementedException();
            if (this.IsNew)
            {
                var asset = AddAsset(loanApplication, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Add(asset, today);
                }

                Land land = new Land();
                land.Asset = asset;
                land.UomId = this.LandUOM;
                land.LandTypeId = this.LandType;
                land.OctTctNumber = this.TCTNumber;
                land.LandArea = this.LandArea;

                //add property location
                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var propertyLocation = PostalAddress.CreatePostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, today);
                propertyLocation.StreetAddress = this.StreetAddress;
                propertyLocation.Barangay = this.Barangay;
                propertyLocation.Municipality = this.Municipality;
                propertyLocation.CountryId = this.CountryId;
                propertyLocation.City = this.City;
                propertyLocation.Province = this.Province;
                propertyLocation.PostalCode = this.PostalCode;
                propertyLocation.Address.Asset = asset;
            }
            else if (this.ToBeDeleted)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                RemoveCurrentMortgagee(asset, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Remove(today);
                }

                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var propertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);

                if (asset.Land != null)
                {
                    Address address = propertyLocation.Address;
                    Context.Lands.DeleteObject(asset.Land);
                    Context.PostalAddresses.DeleteObject(propertyLocation);
                    Context.Addresses.DeleteObject(address);
                }

                Context.Assets.DeleteObject(asset);
            }
            else if (this.IsEdited)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                UpdateAsset(asset, today);

                Land land = asset.Land;
                land.UomId = this.LandUOM;
                land.LandTypeId = this.LandType;
                land.OctTctNumber = this.TCTNumber;
                land.LandArea = this.LandArea;

                //add property location
                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var currentPropertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);
                var propertyLocation = new PostalAddress();
                propertyLocation.StreetAddress = this.StreetAddress;
                propertyLocation.Barangay = this.Barangay;
                propertyLocation.Municipality = this.Municipality;
                propertyLocation.CountryId = this.CountryId;
                propertyLocation.City = this.City;
                propertyLocation.Province = this.Province;
                propertyLocation.PostalCode = this.PostalCode;

                PostalAddress.CreateOrUpdatePostalAddress(currentPropertyLocation, propertyLocation, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Save(asset, today);
                }
            }else if(this.IsNew == false && this.ToBeDeleted == false && this.IsEdited == false)
            {
                if (this.AssetId == 0)
                {
                    var asset = AddAsset(loanApplication, today);

                    foreach (PropertyOwner owner in PropertyOwners)
                    {
                        owner.Add(asset, today);
                    }

                    Land land = new Land();
                    land.Asset = asset;
                    land.UomId = this.LandUOM;
                    land.LandTypeId = this.LandType;
                    land.OctTctNumber = this.TCTNumber;
                    land.LandArea = this.LandArea;

                    //add property location
                    var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                    //var currentPropertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);
                    var propertyLocation = PostalAddress.CreatePostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, today);
                    propertyLocation.StreetAddress = this.StreetAddress;
                    propertyLocation.Barangay = this.Barangay;
                    propertyLocation.Municipality = this.Municipality;
                    propertyLocation.CountryId = this.CountryId;
                    propertyLocation.City = this.City;
                    propertyLocation.Province = this.Province;
                    propertyLocation.PostalCode = this.PostalCode;
                    propertyLocation.Address.Asset = asset;
                }
            }
        }
Exemplo n.º 30
0
        public static Invoice Create()
        {
            var customerName                = "Zákazník";
            var customerICO                 = "123456789";
            var customerContact             = new Contact(customerName, "+420 605 123 456", "*****@*****.**");
            var customerAddress             = new PostalAddress(Country.CzechRepulic(), "Ostrava", "Nádražní", "17", "702 00");
            var supplierName                = "Dodavatel";
            var supplierICO                 = "987654321";
            var supplierDIC                 = "CZ987654321";
            var supplierRegisterInformation = "Zaregistrováno u Soudu AAA";
            var supplierContact             = new Contact(supplierName, "+420 605 123 456", "*****@*****.**");
            var supplierAddress             = new PostalAddress(Country.CzechRepulic(), "Praha", "Dvořákova", "13", "105 00");

            var result = new ISDOCNet.Invoice();

            result.version           = "6.0.1";
            result.LocalCurrencyCode = "CZK";
            result.CurrRate          = 1;
            result.ID            = "20200001";                //Invoice Number
            result.UUID          = Guid.NewGuid().ToString(); // Unique inovice identification
            result.IssueDate     = DateTime.Now;
            result.TaxPointDate  = DateTime.Now;
            result.VATApplicable = true; //With VAT
            result.RefCurrRate   = 1;    // CZK To CZK
            result.ElectronicPossibilityAgreementReference = new Note();
            result.BuyerCustomerParty                                     = new BuyerCustomerParty();
            result.BuyerCustomerParty.Party                               = new Party();
            result.BuyerCustomerParty.Party.Contact                       = customerContact;
            result.BuyerCustomerParty.Party.PartyIdentification           = new PartyIdentification("Zákazník 1", "", customerICO);
            result.BuyerCustomerParty.Party.PartyName                     = new PartyName(customerName);
            result.BuyerCustomerParty.Party.PostalAddress                 = customerAddress;
            result.AccountingCustomerParty                                = new AccountingCustomerParty();
            result.AccountingCustomerParty.Party                          = new Party();
            result.AccountingCustomerParty.Party.Contact                  = customerContact;
            result.AccountingCustomerParty.Party.PartyIdentification      = new PartyIdentification("Zákazník 1", "", customerICO);
            result.AccountingCustomerParty.Party.PartyName                = new PartyName(customerName);
            result.AccountingCustomerParty.Party.PostalAddress            = customerAddress;
            result.SellerSupplierParty                                    = new SellerSupplierParty();
            result.SellerSupplierParty.Party                              = new Party();
            result.SellerSupplierParty.Party.Contact                      = supplierContact;
            result.SellerSupplierParty.Party.PartyIdentification          = new PartyIdentification("Dodavatel 1", "", supplierICO);
            result.SellerSupplierParty.Party.PartyName                    = new PartyName(supplierName);
            result.SellerSupplierParty.Party.PostalAddress                = supplierAddress;
            result.SellerSupplierParty.Party.PartyTaxScheme               = new PartyTaxScheme();
            result.SellerSupplierParty.Party.PartyTaxScheme.CompanyID     = supplierDIC;
            result.SellerSupplierParty.Party.PartyTaxScheme.TaxScheme     = "VAT";
            result.SellerSupplierParty.Party.RegisterIdentification       = new RegisterIdentification(supplierRegisterInformation);
            result.AccountingSupplierParty                                = new AccountingSupplierParty();
            result.AccountingSupplierParty.Party                          = new Party();
            result.AccountingSupplierParty.Party.Contact                  = supplierContact;
            result.AccountingSupplierParty.Party.PartyIdentification      = new PartyIdentification("Dodavatel 1", "", supplierICO);
            result.AccountingSupplierParty.Party.PartyName                = new PartyName(supplierName);
            result.AccountingSupplierParty.Party.PostalAddress            = supplierAddress;
            result.AccountingSupplierParty.Party.PartyTaxScheme           = new PartyTaxScheme();
            result.AccountingSupplierParty.Party.PartyTaxScheme.CompanyID = supplierDIC;
            result.AccountingSupplierParty.Party.PartyTaxScheme.TaxScheme = "VAT";
            result.AccountingSupplierParty.Party.RegisterIdentification   = new RegisterIdentification(supplierRegisterInformation);
            var i = 1;

            //foreach (var item in invoice.InvoiceItems)
            //{
            //    var line = new InvoiceLine();
            //    line.ClassifiedTaxCategory = new ClassifiedTaxCategory();
            //    line.ClassifiedTaxCategory.Percent = item.TaxVat.Value;
            //    line.ClassifiedTaxCategory.VATApplicable = item.TaxVat.Value >= 0;
            //    line.ClassifiedTaxCategory.VATCalculationMethod = VATCalculationMethod.Item0;
            //    line.ID = i.ToString();
            //    line.InvoicedQuantity = new Quantity(item.UnitType.Code, item.Quantity);
            //    line.Item = new Item();
            //    line.Item.Description = item.Name;
            //    line.UnitPrice = item.Price;
            //    line.UnitPriceTaxInclusive = item.PriceVAT;
            //    line.LineExtensionAmount = item.Price;
            //    line.LineExtensionAmountTaxInclusive = item.PriceVAT;
            //    line.LineExtensionTaxAmount = item.PriceVAT - item.Price;

            //    if (result.InvoiceLines == null)
            //        result.InvoiceLines = new List<InvoiceLine>();
            //    result.InvoiceLines.Add(line);
            //    i++;
            //}

            var line = new InvoiceLine();

            line.ClassifiedTaxCategory                      = new ClassifiedTaxCategory();
            line.ClassifiedTaxCategory.Percent              = 21; //VAT
            line.ClassifiedTaxCategory.VATApplicable        = true;
            line.ClassifiedTaxCategory.VATCalculationMethod = VATCalculationMethod.Item0;
            line.ID = i.ToString();
            line.InvoicedQuantity                = new Quantity("KS", 1);
            line.Item                            = new Item();
            line.Item.Description                = "Product";
            line.UnitPrice                       = 100;
            line.UnitPriceTaxInclusive           = 121;
            line.LineExtensionAmount             = 100;
            line.LineExtensionAmountTaxInclusive = 121;
            line.LineExtensionTaxAmount          = 21;

            if (result.InvoiceLines == null)
            {
                result.InvoiceLines = new List <InvoiceLine>();
            }
            result.InvoiceLines.Add(line);
            i++;

            result.TaxTotal             = new TaxTotal();
            result.TaxTotal.TaxAmount   = 0;
            result.TaxTotal.TaxSubTotal = new List <TaxSubTotal>();
            foreach (var taxGroup in result.InvoiceLines.GroupBy(p => p.ClassifiedTaxCategory.Percent))
            {
                var taxSubTotal = new TaxSubTotal();
                taxSubTotal.TaxableAmount      = taxGroup.Sum(p => p.LineExtensionAmount);
                taxSubTotal.TaxInclusiveAmount = taxGroup.Sum(p => p.LineExtensionAmountTaxInclusive);
                taxSubTotal.TaxAmount          = taxSubTotal.TaxInclusiveAmount - taxSubTotal.TaxableAmount;
                if (taxGroup.Key.Value > 0)
                {
                    taxSubTotal.TaxCategory = new TaxCategory();
                    taxSubTotal.TaxCategory.VATApplicable = true;
                    taxSubTotal.TaxCategory.Percent       = taxGroup.Key.Value;
                }
                else
                {
                    taxSubTotal.TaxCategory = new TaxCategory();
                    taxSubTotal.TaxCategory.VATApplicable = false;
                    taxSubTotal.TaxCategory.Percent       = 0;
                }

                taxSubTotal.AlreadyClaimedTaxableAmount      = 0;
                taxSubTotal.AlreadyClaimedTaxAmount          = 0;
                taxSubTotal.AlreadyClaimedTaxInclusiveAmount = 0;
                taxSubTotal.DifferenceTaxableAmount          = taxSubTotal.TaxableAmount - taxSubTotal.AlreadyClaimedTaxableAmount;
                taxSubTotal.DifferenceTaxAmount          = taxSubTotal.TaxAmount - taxSubTotal.AlreadyClaimedTaxAmount;
                taxSubTotal.DifferenceTaxInclusiveAmount = taxSubTotal.TaxInclusiveAmount - taxSubTotal.AlreadyClaimedTaxInclusiveAmount;
                result.TaxTotal.TaxSubTotal.Add(taxSubTotal);
            }

            result.LegalMonetaryTotal = new LegalMonetaryTotal();
            result.LegalMonetaryTotal.TaxExclusiveAmount = result.InvoiceLines.Sum(p => p.LineExtensionAmount);
            result.LegalMonetaryTotal.TaxInclusiveAmount = result.InvoiceLines.Sum(p => p.LineExtensionAmountTaxInclusive);
            result.LegalMonetaryTotal.AlreadyClaimedTaxExclusiveAmount = 0;
            result.LegalMonetaryTotal.AlreadyClaimedTaxInclusiveAmount = 0;
            result.LegalMonetaryTotal.DifferenceTaxExclusiveAmount     = result.LegalMonetaryTotal.TaxExclusiveAmount - result.LegalMonetaryTotal.AlreadyClaimedTaxExclusiveAmount;
            result.LegalMonetaryTotal.DifferenceTaxInclusiveAmount     = result.LegalMonetaryTotal.TaxInclusiveAmount - result.LegalMonetaryTotal.AlreadyClaimedTaxInclusiveAmount;
            result.LegalMonetaryTotal.PayableRoundingAmount            = 0;
            result.LegalMonetaryTotal.PaidDepositsAmount = 0;
            result.LegalMonetaryTotal.PayableAmount      = result.LegalMonetaryTotal.TaxInclusiveAmount - result.LegalMonetaryTotal.PaidDepositsAmount;
            return(result);
        }
 public TenantAddress(TenantId tenantId, PostalAddress postalAddress)
 {
     Id                 = Guid.NewGuid();
     this.TenantId      = tenantId;
     this.PostalAddress = postalAddress;
 }
Exemplo n.º 32
0
        public void CreateSessionRequest(
            string beneficiaryName,
            string originatorName,
            PostalAddress originatorPostalAddress,
            PlaceOfBirth placeOfBirth,
            VirtualAssetType assetType,
            decimal transferAmount)
        {
            (VaspInformation vaspInfoPerson, VaspContractInfo vaspContractInfoPerson) = VaspInformationBuilder.CreateForNaturalPersonAsync(
                _ethereumRpc,
                _vaspSmartContractAddressPerson,
                _naturalPersonIds,
                placeOfBirth)
                                                                                        .GetAwaiter()
                                                                                        .GetResult();

            VaspClient originator = VaspClient.Create(
                vaspInfoPerson,
                vaspContractInfoPerson,
                _personHandshakePrivateKeyHex,
                _personSignaturePrivateKeyHex,
                _ethereumRpc,
                _whisperRpc,
                _fakeEnsProvider,
                _signService,
                _transportClient);

            (VaspInformation vaspInfoJuridical, VaspContractInfo vaspContractInfoJuridical) = VaspInformationBuilder.CreateForJuridicalPersonAsync(
                _ethereumRpc,
                _vaspSmartContractAddressJuridical,
                _juridicalPersonIds)
                                                                                              .GetAwaiter()
                                                                                              .GetResult();

            VaspClient beneficiary = VaspClient.Create(
                vaspInfoJuridical,
                vaspContractInfoJuridical,
                _juridicalHandshakePrivateKeyHex,
                _juridicalSignaturePrivateKeyHex,
                _ethereumRpc,
                _whisperRpc,
                _fakeEnsProvider,
                _signService,
                _transportClient);

            var originatorVaan  = VirtualAssetssAccountNumber.Create(vaspInfoPerson.GetVaspCode(), "524ee3fb082809");
            var beneficiaryVaan = VirtualAssetssAccountNumber.Create(vaspInfoJuridical.GetVaspCode(), "524ee3fb082809");

            var vaspSession = new VaspSessionWrapper(
                beneficiaryName,
                originator,
                beneficiary);

            VaspSessions[vaspSession.Id] = vaspSession;

            var originatorDoc = Originator.CreateOriginatorForNaturalPerson(
                originatorName,
                originatorVaan,
                originatorPostalAddress,
                placeOfBirth,
                new NaturalPersonId[]
            {
                new NaturalPersonId("Id", NaturalIdentificationType.NationalIdentityNumber, Country.List["DE"]),
            });

            vaspSession.StartSession(originatorDoc, beneficiaryVaan, assetType, transferAmount);
        }
Exemplo n.º 33
0
 public virtual void SetAddr(PostalAddress addr)
 {
     this.addr.Value = addr;
 }
Exemplo n.º 34
0
 public virtual void SetAddress(PostalAddress address)
 {
     this.address.Value = address;
 }
        public void Rural_Street()
        {
            RuralPostalAddressFormatter formatter = new RuralPostalAddressFormatter();
            PostalAddress postalAddress = new PostalAddress()
            {
                AddressType = "RURAL",
                PostCode = "9382",
                RDNumber = "2",
                StreetName = "Charles Court",
                StreetNumber = "6",
                StreetType = "Coart",
                TownCityMailTown = "Wanaka"
            };

            var format = formatter.Format(postalAddress);
            Assert.AreEqual("6 Charles Court", format.AddressLine1);
            Assert.AreEqual("RD 2", format.AddressLine2);
            Assert.AreEqual(string.Empty, format.AddressLine3);
            Assert.AreEqual("RD 2", format.Suburb);
            Assert.AreEqual("Wanaka", format.City);
            Assert.AreEqual("9382", format.PostCode);
        }
Exemplo n.º 36
0
 public Response SavePostalAddress(PostalAddress postalAddress)
 {
     return(postalAddressRepository.SavePostalAddress(postalAddress));
 }
        public async Task CreateOrderAsync(int basketId, PostalAddress billingAddress, PostalAddress shippingAddress)
        {
            // TODO:
            // write address to buyer, to be looked up on po creation
            // Create purchase order on chain
            // using basket to populate
            // we need the buyer nonce

            var basket = await _basketRepository.GetByIdAsync(basketId);

            Guard.Against.NullBasket(basketId, basket);

            throw new NotImplementedException();
            //var items = new List<OrderItem>();
            //foreach (var item in basket.Items)
            //{


            //    var catalogItem = await _itemRepository.GetByIdAsync(item.CatalogItemId);
            //    var itemOrdered = new CatalogItemOrdered(catalogItem.Id, catalogItem.Name, catalogItem.PictureUri);
            //    var orderItem = new OrderItem(itemOrdered, item.UnitPrice, item.Quantity);
            //    items.Add(orderItem);
            //}
            //var order = new Order(basket.BuyerId, billingAddress, shippingAddress, items);

            //await _orderRepository.AddAsync(order);
        }
Exemplo n.º 38
0
        private static TransferConfirmationMessage GetTransferConfirmationMessage()
        {
            //Should be a contract
            var vaspKey = EthECKey.GenerateKey();

            var message = new Message(
                Guid.NewGuid().ToByteArray().ToHex(prefix: false),
                Guid.NewGuid().ToByteArray().ToHex(prefix: false),
                "1");

            var postalAddress = new PostalAddress(
                "TestingStreet",
                61,
                "Test Address Line",
                "410000",
                "TownN",
                Country.List["DE"]
                );
            var placeOfBirth    = new PlaceOfBirth(DateTime.UtcNow, "TownN", Country.List["DE"]);
            var vaspInformation = new VaspInformation(
                "Test test",
                vaspKey.GetPublicAddress(),
                vaspKey.GetPubKey().ToHex(prefix: false),
                postalAddress,
                placeOfBirth,
                new NaturalPersonId[]
            {
                new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber,
                                    Country.List["DE"]),
            },
                new JuridicalPersonId[]
            {
                new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification,
                                      Country.List["DE"]),
            },
                "DEUTDEFF");

            var originator = new Originator("Originator1", "VaaN", postalAddress, placeOfBirth,
                                            new NaturalPersonId[]
            {
                new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber,
                                    Country.List["DE"]),
            },
                                            new JuridicalPersonId[]
            {
                new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification,
                                      Country.List["DE"]),
            },
                                            "DEUTDEFF");

            var beneficiary = new Beneficiary("Ben1", "VaaN");

            var transferReply = new TransferReply(VirtualAssetType.ETH, TransferType.BlockchainTransfer, "10000000", "0x0000001");
            var transaction   = new Transaction("txId", DateTime.UtcNow, "0x0000002");

            var request = new TransferConfirmationMessage(message, originator, beneficiary, transferReply, transaction, vaspInformation)
            {
                Comment = "This is test message",
            };

            return(request);
        }
Exemplo n.º 39
0
        public void ProcessRequest(HttpContext context)
        {
            response = context.Response;
            request  = context.Request;

            //response.ContentType = "text/plain";
            response.ContentType = "application/json"; // jQuery 1.4.2 requires this now!

            try
            {
                StoreContext storeContext = new StoreContext(request);
                StoreUrls    storeUrls    = new StoreUrls(storeContext);

                string  action    = request.Params["action"];
                int?    productId = WA.Parser.ToInt(request.Params["productId"]);
                Product product   = null;
                if (productId.HasValue)
                {
                    product = Product.GetProduct(productId.Value);
                }

                switch (action)
                {
                case "updateShippingRateTypeName":
                    int?shippingRateTypeId = WA.Parser.ToInt(request.Params["shippingServiceRateTypeId"]);
                    if (shippingRateTypeId.HasValue)
                    {
                        string shippingName = request.Params["name"];
                        DataModel.ShippingServiceRateType shippingMethod = DataModel.ShippingServiceRateType.Get(shippingRateTypeId.Value);
                        if (shippingMethod != null)
                        {
                            shippingMethod.DisplayName = shippingName;
                            shippingMethod.Save();

                            RespondWithSuccess();
                        }
                    }
                    break;

                case "getShippingRatesJson":
                    DataModel.ShippingServiceRateType rateType = DataModel.ShippingServiceRateType.Get(WA.Parser.ToShort(request.Params["shippingServiceRateTypeId"]).GetValueOrDefault(-1));
                    if (rateType != null)
                    {
                        List <ShippingServiceRate>     rates     = rateType.GetRates();
                        List <JsonShippingServiceRate> jsonRates = rates.ConvertAll(
                            r =>
                            new JsonShippingServiceRate()
                        {
                            RateTypeId  = rateType.Id.Value,
                            CountryCode = r.CountryCode,
                            Region      = r.Region,
                            MinWeight   = r.WeightMin,
                            MaxWeight   = r.WeightMax,
                            Cost        = r.Cost
                        }
                            );
                        string json = Newtonsoft.Json.JsonConvert.SerializeObject(jsonRates);
                        response.Write(json);
                    }
                    break;
                //case "applyShippingRate":
                //    string shippingRate = request.Params["shippingServiceRateTypeId"];
                //    if (shippingRate != null)
                //    {

                //        var store = storeContext.CurrentStore;

                //        var checkoutOrderInfo = HttpContext.Current.Session[storeContext.SessionKeys.CheckoutOrderInfo] as CheckoutOrderInfo;

                //        string[] rateParts = shippingRate.Split("||");
                //        checkoutOrderInfo.ShippingRate.ServiceType = rateParts[0];
                //        checkoutOrderInfo.ShippingRate.ServiceTypeDescription = rateParts[1];
                //        checkoutOrderInfo.ShippingRate.Rate = Convert.ToDecimal(rateParts.Length == 3 ? rateParts[2] : rateParts[1]);
                //        checkoutOrderInfo.ReCalculateOrderTotals();

                //        Session[StoreContext.SessionKeys.CheckoutOrderInfo] = checkoutOrderInfo;
                //    }
                //    break;
                case "getShippingOptionEstimatesJson":

                    string address1   = request.Params["address1"];
                    string address2   = request.Params["address2"];
                    string city       = request.Params["city"];
                    string country    = request.Params["country"];
                    string region     = request.Params["region"];
                    string postalCode = request.Params["postalCode"];
                    bool   isBusiness = Convert.ToBoolean(request.Params["isBusiness"]);

                    var store = storeContext.CurrentStore;

                    var cartController    = new CartController(storeContext);
                    var checkoutOrderInfo = HttpContext.Current.Session[storeContext.SessionKeys.CheckoutOrderInfo] as CheckoutOrderInfo;
                    if (checkoutOrderInfo == null)
                    {
                        var cart = cartController.GetCart(false);
                        checkoutOrderInfo = new CheckoutOrderInfo()
                        {
                            Cart = cart
                        };
                    }
                    //List<string> errors;
                    //var shippingOptionEstimates = store.GetShippingOptionEstimates(origin, destination, checkoutOrderInfo.Cart.GetCartItemsWithProductInfo(), out errors);
                    //var shippingOptions = shippingOptionEstimates.ConvertAll(x => new
                    //                        {
                    //                            Value = x.Cost.GetValueOrDefault(0).ToString("F2"),
                    //                            Name = x.DisplayName,
                    //                            Text = string.Format(@"{0}  :  {1}", x.DisplayName, store.FormatCurrency(x.Cost))
                    //                        });

                    IPostalAddress origin      = store.Address.ToPostalAddress();
                    IPostalAddress destination = new PostalAddress()
                    {
                        Address1 = address1, Address2 = address2, City = city, CountryCode = country, Region = region.ToUpper(), PostalCode = postalCode.ToUpper(), IsResidential = !isBusiness
                    };

                    ShipmentPackagingStrategy shipmentPackagingStrategy = WA.Enum <ShipmentPackagingStrategy> .TryParseOrDefault(store.GetSetting(StoreSettingNames.ShipmentPackagingStrategy), ShipmentPackagingStrategy.SingleBox);

                    var shipmentPackages = checkoutOrderInfo.Cart.GetCartItemsAsShipmentPackages(shipmentPackagingStrategy);
                    var shippingRates    = new List <IShippingRate>();
                    var shippingServices = store.GetEnabledShippingProviders(null, checkoutOrderInfo.Cart.Id);
                    foreach (var shipper in shippingServices)
                    {
                        shippingRates.AddRange(shipper.GetRates(origin, destination, shipmentPackages));
                    }
                    var shippingOptions = shippingRates.Select(x => new
                    {
                        Value = x.Rate.ToString("F2"),
                        Name  = x.ServiceType,
                        Text  = string.Format(@"{0}  :  {1}", x.ServiceType, store.FormatCurrency(x.Rate))
                    });

                    string shippingOptionsJson = Newtonsoft.Json.JsonConvert.SerializeObject(shippingOptions);
                    response.Write(shippingOptionsJson);
                    break;

                case "getProductPhotosJson":
                    if (productId.HasValue)
                    {
                        List <ProductPhoto> productPhotos     = Product.GetAllPhotosInSortOrder(productId.Value);
                        List <JsonPhoto>    jsonProductPhotos =
                            productPhotos.ConvertAll(
                                p =>
                                new JsonPhoto()
                        {
                            Id           = p.Id.Value,
                            OriginalUrl  = storeUrls.ProductPhoto(p, null, null),
                            ThumbnailUrl = storeUrls.ProductPhoto(p, 120, 90)
                        });
                        string jsonPhotos = Newtonsoft.Json.JsonConvert.SerializeObject(jsonProductPhotos);

                        response.Write(jsonPhotos);
                    }
                    break;

                case "deleteProductPhoto":
                    int?photoId = WA.Parser.ToInt(request.Params["photoId"]);
                    if (ProductPhoto.DeletePhoto(photoId.GetValueOrDefault(-1)))
                    {
                        RespondWithSuccess();
                    }
                    else
                    {
                        RespondWithError("unable to delete photo: " + photoId);
                    }
                    break;

                case "updateProductPhotoSortOrder":
                    if (productId.HasValue && request.Params["photoList[]"] != null)
                    {
                        List <string> sortedPhotoList = new List <string>(request.Params.GetValues("photoList[]"));
                        List <int>    sortedPhotoIds  = sortedPhotoList.ConvertAll(p => Convert.ToInt32(p.Split('-')[1]));

                        ProductPhotoQuery q = new ProductPhotoQuery();
                        q.Where(q.ProductId == productId.Value);
                        ProductPhotoCollection photos = new ProductPhotoCollection();
                        if (photos.Load(q))
                        {
                            foreach (ProductPhoto photo in photos)
                            {
                                photo.SortOrder = (short)sortedPhotoIds.IndexOf(photo.Id.Value);
                            }
                            photos.Save();
                        }
                        RespondWithSuccess();
                    }
                    break;

                case "getProductCustomFieldsJson":
                    if (product != null)
                    {
                        List <ProductField>     productFields     = product.GetProductFieldsInSortOrder();
                        List <JsonProductField> jsonProductFields = productFields.ConvertAll(
                            f => new JsonProductField()
                        {
                            Id               = f.Id.Value,
                            WidgetType       = f.WidgetType,
                            Name             = f.Name,
                            Slug             = f.Slug,
                            IsRequired       = f.IsRequired.GetValueOrDefault(),
                            PriceAdjustment  = f.PriceAdjustment.GetValueOrDefault(0),
                            WeightAdjustment = f.WeightAdjustment.GetValueOrDefault(0),
                            SortOrder        = f.SortOrder.GetValueOrDefault(),
                            Choices          = f.GetChoicesInSortOrder().ToList().ConvertAll(
                                c => new JsonProductFieldChoice()
                            {
                                Id               = c.Id.Value,
                                ProductFieldId   = f.Id.Value,
                                Name             = c.Name,
                                PriceAdjustment  = c.PriceAdjustment.GetValueOrDefault(0),
                                WeightAdjustment = c.WeightAdjustment.GetValueOrDefault(0),
                                SortOrder        = c.SortOrder.GetValueOrDefault()
                            })
                        });
                        string jsonCustomFields = Newtonsoft.Json.JsonConvert.SerializeObject(jsonProductFields);

                        response.Write(jsonCustomFields);
                    }
                    break;

                case "updateCategorySortOrder":
                    string[] sortedCatIdStrings = request.Params.GetValues("sortedCategoryIds");
                    if (sortedCatIdStrings != null)
                    {
                        List <int> sortedCatIds = new List <string>(sortedCatIdStrings).ConvertAll(s => WA.Parser.ToInt(s).GetValueOrDefault(-1));
                        CategoryCollection.SetSortOrderByListPosition(sortedCatIds);
                        CacheHelper.ClearCache();
                        RespondWithSuccess();
                    }
                    else
                    {
                        RespondWithError("no category ids found to update sort order");
                    }
                    break;

                case "updateProductFieldSortOrder":
                    var sortedProductFieldIdStrings = request.Params.GetValues("sortedProductFieldIds[]");
                    if (sortedProductFieldIdStrings != null)
                    {
                        List <int> sortedProductFieldIds = new List <string>(sortedProductFieldIdStrings).ConvertAll(s => WA.Parser.ToInt(s).GetValueOrDefault(-1));
                        ProductFieldCollection.SetSortOrderByListPosition(sortedProductFieldIds);
                        RespondWithSuccess();
                    }
                    else
                    {
                        RespondWithError("no product field ids found to update sort order");
                    }
                    break;

                default:
                    RespondWithError("unknown action");
                    break;
                }

                //response.Write("{ success: true }");
            }
            catch (Exception ex)
            {
                RespondWithError(ex.Message + " Stack Trace:" + ex.StackTrace);
            }

            response.Flush();
        }
Exemplo n.º 40
0
        public SupplierResponse ConvertSupplier(Supplier supplier)
        {
            var phonenumber  = string.Empty;
            var mobilenumber = string.Empty;
            var faxnumber    = string.Empty;
            var address      = new PostalAddress();

            for (int i = 0; i < supplier.Addresses.Address.Count; i++)
            {
                var a = supplier.Addresses.Address[i];
                if (a.Telephone.StartsWith("06"))
                {
                    mobilenumber = a.Telephone;
                }
                else
                {
                    phonenumber = a.Telephone;
                }

                faxnumber = a.Telefax;
                address   = new PostalAddress
                {
                    Address1      = a.Name,
                    City          = a.City,
                    ContactPerson = a.Contact,
                    ZipCode       = a.Postcode
                };
                address.Country.Code = a.Country;
                address.Country.Name = a.CountryName;
            }
            var bank = new BankM();

            for (int i = 0; i < supplier.Banks.Bank.Count; i++)
            {
                if (supplier.Banks.Bank[i] != null)
                {
                    bank.AccountNumber = supplier.Banks.Bank[i].Accountnumber;
                    bank.AccountHolder = supplier.Banks.Bank[i].Ascription;
                    bank.BicCode       = supplier.Banks.Bank[i].Biccode;
                    bank.Iban          = supplier.Banks.Bank[i].Iban;
                    bank.Name          = supplier.Banks.Bank[i].Bankname;
                }
            }

            var supplierResponse = new SupplierResponse
            {
                Name      = supplier.Name,
                Code      = supplier.Code,
                VatNumber = supplier.Vatnumber,
                Comment   = supplier.Shortname,
                Website   = supplier.Website,
            };

            supplierResponse.Addresses.General        = address;
            supplierResponse.Bank.Name                = bank.Name;
            supplierResponse.Bank.AccountNumber       = bank.AccountNumber;
            supplierResponse.Bank.AccountHolder       = bank.AccountHolder;
            supplierResponse.Bank.BicCode             = bank.BicCode;
            supplierResponse.Bank.Iban                = bank.Iban;
            supplierResponse.PhoneNumbers.General     = phonenumber;
            supplierResponse.PhoneNumbers.Fax         = faxnumber;
            supplierResponse.PhoneNumbers.Mobile      = mobilenumber;
            supplierResponse.MailAddresses.General.To = supplier.Financials.Ebillmail;
            supplierResponse.MailAddresses.Invoice.To = supplier.Financials.Ebillmail;
            return(supplierResponse);
        }
Exemplo n.º 41
0
 public virtual void ValidatePostalAddress(PostalAddress postalAddress, string type, VersionNumber version, XmlElement element
                                           , string propertyPath, Hl7Errors errors)
 {
     ValidatePostalAddressUses(postalAddress, type, version, element, propertyPath, errors);
     ValidatePostalAddressParts(postalAddress, type, version, element, propertyPath, errors);
 }
Exemplo n.º 42
0
        protected XmlElement AddressToXml(XmlDocument doc,
                                          string tagName,
                                          PostalInfo nameAddress)
        {
            XmlElement name_address_element = null;

            if (nameAddress != null)
            {
                name_address_element = doc.CreateElement(tagName, Namespace);

                if (nameAddress.m_type == null)
                {
                    throw new EppException("missing the address type (postal info)");
                }

                name_address_element.SetAttribute("type", nameAddress.m_type);

                if (nameAddress.m_name != null)
                {
                    AddXmlElement(doc, name_address_element, "contact:name", nameAddress.m_name, ContactNamespace);
                }
                if (nameAddress.m_org != null)
                {
                    AddXmlElement(doc, name_address_element, "contact:org", nameAddress.m_org, ContactNamespace);
                }

                if (nameAddress.m_address != null)
                {
                    PostalAddress address         = nameAddress.m_address;
                    XmlElement    address_element = doc.CreateElement("contact:addr", ContactNamespace);
                    // Because this method is used by contact create and update,
                    // the lowest common denominator (update), says that all
                    // members are optional.
                    if (address.Street1 != null)
                    {
                        AddXmlElement(doc, address_element, "contact:street", address.Street1, ContactNamespace);
                    }
                    if (address.Street2 != null)
                    {
                        AddXmlElement(doc, address_element, "contact:street", address.Street2, ContactNamespace);
                    }
                    if (address.Street3 != null)
                    {
                        AddXmlElement(doc, address_element, "contact:street", address.Street3, ContactNamespace);
                    }
                    if (address.City != null)
                    {
                        AddXmlElement(doc, address_element, "contact:city", address.City, ContactNamespace);
                    }
                    if (address.StateProvince != null)
                    {
                        AddXmlElement(doc, address_element, "contact:sp", address.StateProvince, ContactNamespace);
                    }
                    if (address.PostalCode != null)
                    {
                        AddXmlElement(doc, address_element, "contact:pc", address.PostalCode, ContactNamespace);
                    }
                    if (address.CountryCode != null)
                    {
                        AddXmlElement(doc, address_element, "contact:cc", address.CountryCode, ContactNamespace);
                    }

                    if (address_element.ChildNodes.Count > 0)
                    {
                        name_address_element.AppendChild(address_element);
                    }
                }
            }

            return(name_address_element);
        }
Exemplo n.º 43
0
 /// <summary>
 /// Determines whether the postal address source instance is equal to other postal address
 /// instance passed as an argument.
 /// </summary>
 /// <param name="source">The original source postal address instance.</param>
 /// <param name="address">Other postal address instance to be compared to.</param>
 /// <returns>True, if both postal addresses are equal; otherwise, false.</returns>
 public static bool IsEqualTo(this PostalAddress source, PostalAddress address)
 {
     return false;
 }
Exemplo n.º 44
0
        private void ValidatePostalAddressParts(PostalAddress postalAddress, string type, VersionNumber version, XmlElement element
                                                , string propertyPath, Hl7Errors errors)
        {
            int  countBlankParts = 0;
            bool isBasic         = StandardDataType.AD_BASIC.Type.Equals(type);
            bool isSearch        = StandardDataType.AD_SEARCH.Type.Equals(type);
            bool isFull          = StandardDataType.AD_FULL.Type.Equals(type);
            bool isAd            = StandardDataType.AD.Type.Equals(type);

            foreach (PostalAddressPart postalAddressPart in postalAddress.Parts)
            {
                int partLength = StringUtils.Length(postalAddressPart.Value);
                if (partLength > MAX_PART_LENGTH)
                {
                    // value max length of 80
                    CreateError("Address part types have a maximum allowed length of " + MAX_PART_LENGTH + " (length found: " + partLength +
                                ")", element, propertyPath, errors);
                }
                // error if part type not allowed
                PostalAddressPartType partType = postalAddressPart.Type;
                if (partType == null)
                {
                    countBlankParts++;
                    // no part type : only allowed for BASIC (max 4, plus max 4 delimiter)
                    if (!isBasic)
                    {
                        CreateError("Text without an address part only allowed for AD.BASIC", element, propertyPath, errors);
                    }
                }
                else
                {
                    if (partType == PostalAddressPartType.DELIMITER)
                    {
                        if (isSearch)
                        {
                            CreateError("Part type " + partType.Value + " is not allowed for AD.SEARCH", element, propertyPath, errors);
                        }
                    }
                    else
                    {
                        if (isFull || isAd)
                        {
                            if (!PostalAddressPartType.IsFullAddressPartType(partType))
                            {
                                CreateError("Part type " + partType.Value + " is not allowed for AD or AD.FULL", element, propertyPath, errors);
                            }
                        }
                        else
                        {
                            if (!PostalAddressPartType.IsBasicAddressPartType(partType))
                            {
                                CreateError("Part type " + partType.Value + " is not allowed for AD.BASIC or AD.SEARCH", element, propertyPath, errors);
                            }
                        }
                    }
                }
                // code/codesystem are only for state/country
                if (postalAddressPart.Code != null)
                {
                    if (partType != PostalAddressPartType.STATE && partType != PostalAddressPartType.COUNTRY)
                    {
                        CreateError("Part type " + partType.Value + " is not allowed to specify code or codeSystem", element, propertyPath, errors
                                    );
                    }
                }
            }
            if (isBasic && countBlankParts > MAX_DELIMITED_LINES)
            {
                CreateError("AD.BASIC is only allowed a maximum of " + MAX_DELIMITED_LINES + " delimiter-separated address lines (address lines without an address part type)"
                            , element, propertyPath, errors);
            }
            if (isSearch && CollUtils.IsEmpty(postalAddress.Parts))
            {
                CreateError("AD.SEARCH must specify at least one part type", element, propertyPath, errors);
            }
            // city/state/postalCode/country mandatory for AD.FULL
            // new change for R02.05 (pre-adopted by R02.04.03 AB) onwards - these fields are now only *required*, not mandatory
            if (isFull && !SpecificationVersion.IsExactVersion(SpecificationVersion.R02_04_03_AB, version))
            {
                ValidatePartTypeProvided(PostalAddressPartType.CITY, postalAddress.Parts, element, propertyPath, errors);
                ValidatePartTypeProvided(PostalAddressPartType.STATE, postalAddress.Parts, element, propertyPath, errors);
                ValidatePartTypeProvided(PostalAddressPartType.POSTAL_CODE, postalAddress.Parts, element, propertyPath, errors);
                ValidatePartTypeProvided(PostalAddressPartType.COUNTRY, postalAddress.Parts, element, propertyPath, errors);
            }
        }
Exemplo n.º 45
0
 public virtual void SetUp()
 {
     this.address   = new PostalAddress();
     this.formatter = new AdBasicPropertyFormatter();
 }
Exemplo n.º 46
0
 public Customer(Name name, PostalAddress homeAddress, ...)
 {
     this.name        = name;
     this.homeAddress = homeAddress;
Exemplo n.º 47
0
        protected internal override NamedTradeline GetNamedReceivableForItemAndGroup(string item, string grp,
                                                                                     AmericanDomusOpesOptions options, double rate)
        {
            const StringComparison OPT      = StringComparison.OrdinalIgnoreCase;
            const float            FED_RATE = RiskFreeInterestRate.DF_VALUE;

            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var startDate = options.Inception;
            var amtR      = options.SumTotal;

            var isCheckingAccount = string.Equals(grp, AssetGroupNames.INSTITUTIONAL, OPT) &&
                                    string.Equals(item, INSTITUTIONAL_CHECKING, OPT);
            var isSavingsAccount = string.Equals(grp, AssetGroupNames.INSTITUTIONAL, OPT) &&
                                   string.Equals(item, INSTITUTIONAL_SAVINGS, OPT);
            var isMortgage = !options.IsRenting && string.Equals(grp, AssetGroupNames.REAL_PROPERTY, OPT) &&
                             string.Equals(item, REAL_PROPERTY_HOME_OWNERSHIP, OPT);
            var isCarLoan = options.NumberOfVehicles > 0 &&
                            string.Equals(grp, AssetGroupNames.PERSONAL_PROPERTY, OPT) &&
                            string.Equals(item, PERSONAL_PROPERTY_MOTOR_VEHICLES, OPT);

            NamedTradeline p;

            if (isCheckingAccount)
            {
                var checkingAmt = amtR == null || amtR == 0
                    ? _randCheckingAcctAmt
                    : _checkingAccountRate * amtR;
                p = DepositAccount.RandomCheckingAccount(options.PersonsName, startDate,
                                                         $"{Etx.RandomInteger(1, 9999):0000}");
                ((DepositAccount)p).Deposit(startDate.AddDays(-1), (checkingAmt ?? 0).ToPecuniam());
            }
            else if (isSavingsAccount)
            {
                var savingAmt = amtR == null || amtR == 0
                    ? _randSavingsAcctAmt
                    : _savingsAccountRate * amtR;
                p = DepositAccount.RandomSavingAccount(options.PersonsName, startDate);
                ((DepositAccount)p).Deposit(startDate.AddDays(-1), (savingAmt ?? 0).ToPecuniam());
            }
            else if (isMortgage || isCarLoan)
            {
                var homeDebtAmt = amtR == null || amtR == 0
                    ? _randHomeDebt
                    : _homeDebtRate * amtR;
                var homeEquityAmt = amtR == null || amtR == 0
                    ? _randHomeEquity
                    : _homeEquityRate * amtR;
                var carDebtAmt = amtR == null || amtR == 0
                    ? _randCarDebt
                    : _carDebtRate * amtR;
                var carEquityAmt = amtR == null || amtR == 0
                    ? _randCarEquity
                    : _carEquityRate * amtR;

                var baseRate    = isMortgage ? FED_RATE : FED_RATE + 3.2;
                var creditScore = new PersonalCreditScore(options.FactorOptions.DateOfBirth)
                {
                    OpennessZscore          = options.Personality?.Openness?.Value?.Zscore ?? 0D,
                    ConscientiousnessZscore = options.Personality?.Conscientiousness?.Value?.Zscore ?? 0D
                };
                var randRate = (float)creditScore.GetRandomInterestRate(null, baseRate) * 0.01f;

                var id = isMortgage
                    ? (Identifier)PostalAddress.RandomAmericanAddress()
                    : Vin.RandomVin();

                var remainingCost = isMortgage
                    ? (homeDebtAmt ?? 0).ToPecuniam()
                    : (carDebtAmt ?? 0).ToPecuniam();

                var totalValue = isMortgage
                    ? ((homeDebtAmt ?? 0) + (homeEquityAmt ?? 0)).ToPecuniam()
                    : ((carDebtAmt ?? 0) + (carEquityAmt ?? 0)).ToPecuniam();

                var buyer = options.Personality;

                var termInYears = isMortgage ? 30 : 5;

                Func <bool> irresp = () => false;
                if (buyer != null)
                {
                    irresp = buyer.GetRandomActsIrresponsible;
                }

                p = SecuredFixedRateLoan.RandomSecuredFixedRateLoanWithHistory(remainingCost,
                                                                               totalValue,
                                                                               randRate,
                                                                               termInYears,
                                                                               id, irresp);

                p.Name = item;
                p.AddName(KindsOfNames.Group, grp);
            }
            else
            {
                p = base.GetNamedReceivableForItemAndGroup(item, grp, options, rate);
            }

            return(p);
        }
        public static void Run()
        {
            try
            {
                // ExStart:CreateGmailContact
                GoogleTestUser User2 = new GoogleTestUser("user", "email address", "password", "clientId", "client secret");
                string         accessToken;
                string         refreshToken;
                GoogleOAuthHelper.GetAccessToken(User2, out accessToken, out refreshToken);

                // Gmail Client
                IGmailClient client = GmailClient.GetInstance(accessToken, User2.EMail);

                // Create a Contact
                Contact contact = new Contact();
                contact.Prefix         = "Prefix";
                contact.GivenName      = "GivenName";
                contact.Surname        = "Surname";
                contact.MiddleName     = "MiddleName";
                contact.DisplayName    = "Test User 1";
                contact.Suffix         = "Suffix";
                contact.JobTitle       = "JobTitle";
                contact.DepartmentName = "DepartmentName";
                contact.CompanyName    = "CompanyName";
                contact.Profession     = "Profession";
                contact.Notes          = "Notes";
                PostalAddress address = new PostalAddress();
                address.Category        = PostalAddressCategory.Work;
                address.Address         = "Address";
                address.Street          = "Street";
                address.PostOfficeBox   = "PostOfficeBox";
                address.City            = "City";
                address.StateOrProvince = "StateOrProvince";
                address.PostalCode      = "PostalCode";
                address.Country         = "Country";
                contact.PhysicalAddresses.Add(address);
                PhoneNumber pnWork = new PhoneNumber();
                pnWork.Number   = "323423423423";
                pnWork.Category = PhoneNumberCategory.Work;
                contact.PhoneNumbers.Add(pnWork);
                PhoneNumber pnHome = new PhoneNumber();
                pnHome.Number   = "323423423423";
                pnHome.Category = PhoneNumberCategory.Home;
                contact.PhoneNumbers.Add(pnHome);
                PhoneNumber pnMobile = new PhoneNumber();
                pnMobile.Number   = "323423423423";
                pnMobile.Category = PhoneNumberCategory.Mobile;
                contact.PhoneNumbers.Add(pnMobile);
                contact.Urls.Blog                    = "Blog.ru";
                contact.Urls.BusinessHomePage        = "BusinessHomePage.ru";
                contact.Urls.HomePage                = "HomePage.ru";
                contact.Urls.Profile                 = "Profile.ru";
                contact.Events.Birthday              = DateTime.Now.AddYears(-30);
                contact.Events.Anniversary           = DateTime.Now.AddYears(-10);
                contact.InstantMessengers.AIM        = "AIM";
                contact.InstantMessengers.GoogleTalk = "GoogleTalk";
                contact.InstantMessengers.ICQ        = "ICQ";
                contact.InstantMessengers.Jabber     = "Jabber";
                contact.InstantMessengers.MSN        = "MSN";
                contact.InstantMessengers.QQ         = "QQ";
                contact.InstantMessengers.Skype      = "Skype";
                contact.InstantMessengers.Yahoo      = "Yahoo";
                contact.AssociatedPersons.Spouse     = "Spouse";
                contact.AssociatedPersons.Sister     = "Sister";
                contact.AssociatedPersons.Relative   = "Relative";
                contact.AssociatedPersons.ReferredBy = "ReferredBy";
                contact.AssociatedPersons.Partner    = "Partner";
                contact.AssociatedPersons.Parent     = "Parent";
                contact.AssociatedPersons.Mother     = "Mother";
                contact.AssociatedPersons.Manager    = "Manager";

                // Email Address
                EmailAddress eAddress = new EmailAddress();
                eAddress.Address = "*****@*****.**";
                contact.EmailAddresses.Add(eAddress);
                string contactUri = client.CreateContact(contact);
                // ExEnd:CreateGmailContact
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// Generates a payment file in the XML format Credit Transfer ISO20022 pain003.
        /// </summary>
        /// <param name="Company">Uniconta company</param>
        /// <param name="xxx">xxx.</param>
        /// <returns>An XML payment file</returns>
        public XMLDocumentGenerateResult GenerateISO20022(Company company, IEnumerable <CreditorTransPayment> queryPaymentTrans, SQLCache bankAccountCache, CreditorPaymentFormat credPaymFormat, int uniqueFileId, bool doMergePayment, bool schemaValidation = true)
        {
            CreditTransferDocument  doc                     = new CreditTransferDocument();
            BankSpecificSettings    bankSpecific            = BankSpecificSettings.BankSpecTypeInstance(credPaymFormat);
            PaymentISO20022Validate paymentISO20022Validate = new PaymentISO20022Validate();

            List <PreCheckError> preCheckErrors = new List <PreCheckError>();
            List <CheckError>    checkErrors    = new List <CheckError>();

            var credCache = company.GetCache(typeof(Uniconta.DataModel.Creditor));

            bankSpecific.AllowedCharactersRegEx(false);
            doc.ReplaceCharactersRegExDict = bankSpecific.ReplaceCharactersRegEx();

            doc.CompanyBank         = bankSpecific.CompanyBank();
            doc.BatchBooking        = bankSpecific.BatchBooking();
            doc.AuthstnCodeTest     = bankSpecific.TestMarked();
            doc.AuthstnCodeFeedback = bankSpecific.AuthstnCodeFeedback();

            var bankAccount = (BankStatement)bankAccountCache.Get(credPaymFormat._BankAccount);

            doc.CreDtTm                  = bankSpecific.CreDtTim();
            doc.NumberDecimalDigits      = 2;
            doc.IdentificationId         = bankSpecific.IdentificationId(bankAccount._ContractId, company._Id); //Field Bank "Identifikation af aftalen"
            doc.DebtorIdentificationCode = bankSpecific.DebtorIdentificationCode(bankAccount._BankCompanyId);   //Field Bank "Kunde-Id"

            doc.IdentificationCode = bankSpecific.IdentificationCode();
            doc.CompanyName        = bankSpecific.CompanyName(company.Name);
            doc.CompanyBBAN        = bankSpecific.CompanyBBAN(bankAccount._BankAccountPart1, bankAccount._BankAccountPart2);
            doc.CompanyIBAN        = bankSpecific.CompanyIBAN(bankAccount._IBAN);
            doc.CompanyCcy         = UnicontaCurrencyISO(company, bankAccount);

            doc.CompanyBIC                = bankSpecific.CompanyBIC(bankAccount._SWIFT);
            doc.CompanyBankName           = bankSpecific.CompanyBankName();
            doc.CompanyCountryId          = UnicontaCountryToISO(company._CountryId);
            bankSpecific.CompanyCountryId = doc.CompanyCountryId;
            doc.EncodingFormat            = bankSpecific.EncodingFormat();

            doc.XMLAttributeNS = bankSpecific.XMLAttributeNS();

            doc.ChargeBearer = bankSpecific.ChargeBearerDebtor();

            doc.CompanyID = company.CompanyId;
            doc.NumberSeqPaymentFileId = uniqueFileId;

            string companyAccountId = string.Empty;
            string companyBIC       = string.Empty;

            if (doc.CompanyIBAN != string.Empty && doc.CompanyBIC != string.Empty)
            {
                companyAccountId         = doc.CompanyIBAN;
                companyBIC               = doc.CompanyBIC;
                doc.CompanyPaymentMethod = "IBAN";
            }
            else
            {
                companyAccountId         = doc.CompanyBBAN;
                doc.CompanyPaymentMethod = "BBAN";
            }

            doc.InitgPty = new InitgPty(doc.CompanyName, doc.IdentificationId, doc.IdentificationCode);

            //Update ISO PaymentType >>
            foreach (var rec in queryPaymentTrans)
            {
                var    currency = rec.CurrencyLocalStr;
                double amount   = 0;
                amount = rec.PaymentAmount;

                var BICnumber  = "";
                var IBANnumber = "";
                if (rec._PaymentMethod == PaymentTypes.IBAN)
                {
                    IBANnumber = rec._PaymentId == null ? "" : rec._PaymentId;
                    IBANnumber = Regex.Replace(IBANnumber, "[^\\w\\d]", "");

                    BICnumber = rec._SWIFT == null ? "" : rec._SWIFT;
                    BICnumber = Regex.Replace(BICnumber, "[^\\w\\d]", "");
                }

                var creditor = (Creditor)credCache.Get(rec.Account);

                rec.internationalPayment = bankSpecific.InternationalPayment(bankAccount._IBAN, IBANnumber, BICnumber, UnicontaCountryToISO(creditor._Country), doc.CompanyCountryId);
                doc.ISOPaymentType       = bankSpecific.ISOPaymentType(currency, bankAccount._IBAN, IBANnumber, BICnumber, UnicontaCountryToISO(creditor._Country), doc.CompanyCountryId);
                rec.ISOPaymentType       = doc.ISOPaymentType.ToString();
                bankSpecific.paymentType = doc.ISOPaymentType;
            }
            //Update ISO PaymentType <<

            IOrderedEnumerable <CreditorTransPayment> queryPaymentTransSorted;

            if (doMergePayment)
            {
                queryPaymentTransSorted = from s in queryPaymentTrans orderby s._PaymentRefId select s;
            }
            else
            {
                queryPaymentTransSorted = from s in queryPaymentTrans orderby s._PaymentDate, s.ISOPaymentType, s._PaymentMethod, s.Currency select s;
            }

            paymentISO20022Validate.CompanyBank(credPaymFormat);

            List <string> paymentInfoIdLst = new List <string>();

            foreach (var rec in queryPaymentTransSorted)
            {
                bankSpecific.AllowedCharactersRegEx(rec.internationalPayment);

                doc.HeaderNumberOfTrans++;
                doc.PmtInfNumberOfTransActive = bankSpecific.PmtInfNumberOfTransActive();

                doc.HeaderCtrlSum += bankSpecific.HeaderCtrlSum(rec.PaymentAmount);

                doc.PmtInfCtrlSumActive = bankSpecific.PmtInfCtrlSumActive();

                doc.RequestedExecutionDate = bankSpecific.RequestedExecutionDate(doc.CompanyIBAN, rec._PaymentDate);

                string currency = rec.CurrencyLocalStr;
                currency = string.IsNullOrEmpty(currency) ? doc.CompanyCcy : currency;

                doc.EndToEndId = bankSpecific.EndtoendId(rec.PaymentEndToEndId);

                if (doMergePayment && rec.MergePaymId != UnicontaClient.Pages.Creditor.Payments.StandardPaymentFunctions.MERGEID_SINGLEPAYMENT)
                {
                    doc.PaymentInfoId = bankSpecific.PaymentInfoId(doc.NumberSeqPaymentFileId, doc.RequestedExecutionDate, rec._PaymentMethod, rec.Currency, true);
                }
                else
                {
                    doc.PaymentInfoId = bankSpecific.PaymentInfoId(doc.NumberSeqPaymentFileId, doc.RequestedExecutionDate, rec._PaymentMethod, rec.Currency);
                }

                doc.PaymentMethod = BaseDocument.PAYMENTMETHOD_TRF;

                PostalAddress debtorAddress = new PostalAddress();
                debtorAddress = bankSpecific.DebtorAddress(company, debtorAddress);

                string chargeBearer = bankSpecific.ChargeBearer(rec.ISOPaymentType);

                var creditor = (Creditor)credCache.Get(rec.Account);

                string credName = bankSpecific.CreditorName(creditor._Name);

                var    internalAdvText = UnicontaClient.Pages.Creditor.Payments.StandardPaymentFunctions.InternalMessage(credPaymFormat._OurMessage, rec, company, creditor);
                string instructionId   = bankSpecific.InstructionId(internalAdvText);

                PostalAddress creditorAddress = new PostalAddress();
                creditorAddress = bankSpecific.CreditorAddress(creditor, creditorAddress);

                string credBankName         = string.Empty;
                string credBankCountryId    = UnicontaCountryToISO(creditor._Country);
                string creditorAcc          = string.Empty;
                string creditorBIC          = string.Empty;
                string creditorOCRPaymentId = string.Empty;
                bool   isPaymentTypeIBAN    = false;
                bool   isOCRPayment         = false;

                switch (rec._PaymentMethod)
                {
                case PaymentTypes.VendorBankAccount:
                    creditorAcc          = bankSpecific.CreditorBBAN(rec._PaymentId, creditor._PaymentId, rec._SWIFT);
                    creditorOCRPaymentId = bankSpecific.CreditorRefNumber(rec._PaymentId);

                    creditorBIC = bankSpecific.CreditorBIC(rec._SWIFT);

                    if (creditorBIC.Length > 6)
                    {
                        credBankCountryId = creditorBIC.Substring(4, 2);
                    }

                    break;

                case PaymentTypes.IBAN:
                    isPaymentTypeIBAN    = true;
                    creditorAcc          = bankSpecific.CreditorIBAN(rec._PaymentId, creditor._PaymentId, company._CountryId, creditor._Country);
                    creditorBIC          = bankSpecific.CreditorBIC(rec._SWIFT);
                    creditorOCRPaymentId = bankSpecific.CreditorRefNumberIBAN(rec._PaymentId, company._CountryId, creditor._Country);

                    credBankCountryId = creditorAcc.Substring(0, 2);
                    break;

                case PaymentTypes.PaymentMethod3:     //FIK71
                    var tuple71 = bankSpecific.CreditorFIK71(rec._PaymentId);
                    creditorOCRPaymentId = tuple71.Item1;
                    creditorOCRPaymentId = BaseDocument.FIK71 + "/" + creditorOCRPaymentId;
                    creditorAcc          = tuple71.Item2;
                    break;

                case PaymentTypes.PaymentMethod5:     //FIK75
                    var tuple75 = bankSpecific.CreditorFIK75(rec._PaymentId);
                    creditorOCRPaymentId = tuple75.Item1;
                    creditorOCRPaymentId = BaseDocument.FIK75 + "/" + creditorOCRPaymentId;
                    creditorAcc          = tuple75.Item2;
                    break;

                case PaymentTypes.PaymentMethod4:     //FIK73
                    creditorOCRPaymentId = BaseDocument.FIK73 + "/";
                    creditorAcc          = bankSpecific.CreditorFIK73(rec._PaymentId);
                    break;

                case PaymentTypes.PaymentMethod6:     //FIK04
                    var tuple04 = bankSpecific.CreditorFIK04(rec._PaymentId);
                    creditorOCRPaymentId = tuple04.Item1;
                    creditorOCRPaymentId = BaseDocument.FIK04 + "/" + creditorOCRPaymentId;
                    creditorAcc          = tuple04.Item2;
                    break;
                }

                double amount = 0;
                amount = rec.PaymentAmount;

                doc.ISOPaymentType          = bankSpecific.ISOPaymentType(currency, bankAccount._IBAN, isPaymentTypeIBAN ? creditorAcc : string.Empty, creditorBIC, credBankCountryId, doc.CompanyCountryId);
                doc.ExtServiceCode          = bankSpecific.ExtServiceCode(doc.ISOPaymentType);
                doc.ExternalLocalInstrument = bankSpecific.ExternalLocalInstrument(currency, doc.RequestedExecutionDate);
                doc.InstructionPriority     = bankSpecific.InstructionPriority();
                doc.ExtCategoryPurpose      = bankSpecific.ExtCategoryPurpose(doc.ISOPaymentType);
                doc.ExtProprietaryCode      = bankSpecific.ExtProprietaryCode();
                doc.ExcludeSectionCdtrAgt   = bankSpecific.ExcludeSectionCdtrAgt(doc.ISOPaymentType, creditorBIC);

                isOCRPayment = string.IsNullOrEmpty(creditorOCRPaymentId) ? false : true;

                var externalAdvText = UnicontaClient.Pages.Creditor.Payments.StandardPaymentFunctions.ExternalMessage(credPaymFormat._Message, rec, company, creditor);

                string remittanceInfo = bankSpecific.RemittanceInfo(externalAdvText, doc.ISOPaymentType, rec._PaymentMethod);

                List <string> unstructuredPaymInfoList = bankSpecific.Ustrd(externalAdvText, doc.ISOPaymentType, rec._PaymentMethod, credPaymFormat._ExtendedText);

                if (!paymentInfoIdLst.Contains(doc.PaymentInfoId))
                {
                    paymentInfoIdLst.Add(doc.PaymentInfoId);
                    doc.PmtInfList.Add(new PmtInf(doc,
                                                  new PmtTpInf(doc.ExtServiceCode, doc.ExternalLocalInstrument, doc.ExtCategoryPurpose, doc.InstructionPriority, doc.ExtProprietaryCode),
                                                  new Dbtr(doc.CompanyName, debtorAddress, doc.DebtorIdentificationCode),
                                                  new DbtrAcct(doc.CompanyCcy, companyAccountId, companyBIC),
                                                  new DbtrAgt(doc.CompanyBIC, doc.CompanyBankName), doc.ChargeBearer));
                }

                var cdtrAgtCountryId = bankSpecific.CdtrAgtCountryId(credBankCountryId);

                doc.CdtTrfTxInfList.Add(new CdtTrfTxInf(doc.PaymentInfoId, instructionId, doc.EndToEndId, amount, currency,
                                                        new CdtrAgt(creditorBIC, credBankName, cdtrAgtCountryId, doc.ExcludeSectionCdtrAgt),
                                                        new Cdtr(credName, creditorAddress),
                                                        new CdtrAcct(creditorAcc, isPaymentTypeIBAN, isOCRPayment, doc.CompanyCountryId),
                                                        new RmtInf(unstructuredPaymInfoList, remittanceInfo, creditorOCRPaymentId, isOCRPayment), chargeBearer));
            }

            var generatedFileName = bankSpecific.GenerateFileName(doc.NumberSeqPaymentFileId, doc.CompanyID);

            doc.Validate = schemaValidation;

            XmlDocument creditTransferDoc = doc.CreateXmlDocument();

            return(new XMLDocumentGenerateResult(creditTransferDoc, (preCheckErrors.Count > 0 || checkErrors.Count > 0), doc, checkErrors, generatedFileName));
        }
Exemplo n.º 50
0
        private void UpdateContactDataFromOutlook(ContactItem oContact, Contact gContact)
        {
            var BusinessAddressQuery = gContact.PostalAddresses.Where(a => a.Work);

            if (BusinessAddressQuery.Count() > 0)
            {
                gContact.PostalAddresses.Remove(BusinessAddressQuery.First());
            }
            if (oContact.BusinessAddress != null)
            {
                PostalAddress BusinessAddress = new PostalAddress();
                BusinessAddress.Rel   = ContactsRelationships.IsWork;
                BusinessAddress.Value = oContact.BusinessAddress;
                gContact.PostalAddresses.Add(BusinessAddress);
            }

            var HomeAddressQuery = gContact.PostalAddresses.Where(a => a.Home);

            if (HomeAddressQuery.Count() > 0)
            {
                gContact.PostalAddresses.Remove(HomeAddressQuery.First());
            }
            if (oContact.HomeAddress != null)
            {
                PostalAddress HomeAddress = new PostalAddress();
                HomeAddress.Rel   = ContactsRelationships.IsHome;
                HomeAddress.Value = oContact.HomeAddress;
                gContact.PostalAddresses.Add(HomeAddress);
            }
            gContact.Emails.Clear();
            if (oContact.Email1Address != null)
            {
                EMail email = new EMail(oContact.Email1Address);
                email.Rel = ContactsRelationships.IsOther;
                gContact.Emails.Add(email);
            }
            if (oContact.Email2Address != null)
            {
                EMail email = new EMail(oContact.Email2Address);
                email.Rel = ContactsRelationships.IsOther;
                gContact.Emails.Add(email);
            }
            if (oContact.Email3Address != null)
            {
                EMail email = new EMail(oContact.Email3Address);
                email.Rel = ContactsRelationships.IsOther;
                gContact.Emails.Add(email);
            }
            gContact.Title = oContact.FullName;


            var BusinessPhoneQuery = gContact.Phonenumbers.Where(a => a.Rel == ContactsRelationships.IsWork);

            if (BusinessPhoneQuery.Count() > 0)
            {
                gContact.Phonenumbers.Remove(BusinessPhoneQuery.First());
            }
            if (oContact.BusinessTelephoneNumber != null)
            {
                PhoneNumber BusinessPhone = new PhoneNumber();
                BusinessPhone.Rel   = ContactsRelationships.IsWork;
                BusinessPhone.Value = oContact.BusinessTelephoneNumber;
                gContact.Phonenumbers.Add(BusinessPhone);
            }
            var HomePhoneQuery = gContact.Phonenumbers.Where(a => a.Rel == ContactsRelationships.IsHome);

            if (HomePhoneQuery.Count() > 0)
            {
                gContact.Phonenumbers.Remove(HomePhoneQuery.First());
            }
            if (oContact.HomeTelephoneNumber != null)
            {
                PhoneNumber HomePhone = new PhoneNumber();
                HomePhone.Rel   = ContactsRelationships.IsHome;
                HomePhone.Value = oContact.HomeTelephoneNumber;
                gContact.Phonenumbers.Add(HomePhone);
            }
            var MobilePhoneQuery = gContact.Phonenumbers.Where(a => a.Rel == ContactsRelationships.IsMobile);

            if (MobilePhoneQuery.Count() > 0)
            {
                gContact.Phonenumbers.Remove(MobilePhoneQuery.First());
            }
            if (oContact.MobileTelephoneNumber != null)
            {
                PhoneNumber MobilePhone = new PhoneNumber();
                MobilePhone.Rel   = ContactsRelationships.IsMobile;
                MobilePhone.Value = oContact.MobileTelephoneNumber;
                gContact.Phonenumbers.Add(MobilePhone);
            }
            var BusinessFaxQuery = gContact.Phonenumbers.Where(a => a.Rel == ContactsRelationships.IsWorkFax);

            if (BusinessFaxQuery.Count() > 0)
            {
                gContact.Phonenumbers.Remove(BusinessFaxQuery.First());
            }
            if (oContact.BusinessFaxNumber != null)
            {
                PhoneNumber BusinessFaxPhone = new PhoneNumber();
                BusinessFaxPhone.Rel   = ContactsRelationships.IsWorkFax;
                BusinessFaxPhone.Value = oContact.BusinessFaxNumber;
                gContact.Phonenumbers.Add(BusinessFaxPhone);
            }
            var HomeFaxQuery = gContact.Phonenumbers.Where(a => a.Rel == ContactsRelationships.IsHomeFax);

            if (HomeFaxQuery.Count() > 0)
            {
                gContact.Phonenumbers.Remove(HomeFaxQuery.First());
            }
            if (oContact.HomeFaxNumber != null)
            {
                PhoneNumber HomeFaxPhone = new PhoneNumber();
                HomeFaxPhone.Rel   = ContactsRelationships.IsHomeFax;
                HomeFaxPhone.Value = oContact.HomeFaxNumber;
                gContact.Phonenumbers.Add(HomeFaxPhone);
            }
            gContact.Organizations.Clear();
            if (oContact.CompanyName != null)
            {
                Organization org = new Organization();
                org.Name = oContact.CompanyName;
                org.Rel  = ContactsRelationships.IsWork;
                if (oContact.JobTitle != null)
                {
                    org.Title = oContact.JobTitle;
                }
                gContact.Organizations.Add(org);
            }
            else
            {
                gContact.Organizations.Clear();
            }
            gContact.Title = oContact.FullName;
        }