Exemplo n.º 1
0
        public string ValidateNlIdentity(CreateOrderBuilder order)
        {
            string errors = "";

            //Individual
            if (!order.GetIsCompanyIdentity())
            {
                if (order.GetIndividualCustomer().GetInitials() == null)
                {
                    errors +=
                        "MISSING VALUE - Initials is required for individual customers when countrycode is NL. Use SetInitials().\n";
                }
                if (order.GetIndividualCustomer().GetBirthDate() == null)
                {
                    errors +=
                        "MISSING VALUE - Birth date is required for individual customers when countrycode is NL. Use SetBirthDate().\n";
                }
                if (order.GetIndividualCustomer().GetFirstName() == null ||
                    order.GetIndividualCustomer().GetLastName() == null)
                {
                    errors +=
                        "MISSING VALUE - Name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Company
            if (order.GetIsCompanyIdentity())
            {
                if (order.GetCompanyCustomer().GetVatNumber() == null)
                {
                    errors +=
                        "MISSING VALUE - Vat number is required for company customers when countrycode is NL. Use SetVatNumber().\n";
                }
                if (order.GetCompanyCustomer().GetCompanyName() == null)
                {
                    errors +=
                        "MISSING VALUE - Company name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Individual and Company
            if (order.GetCustomerIdentity().Street == null || order.GetCustomerIdentity().HouseNumber == null)
            {
                errors +=
                    "MISSING VALUE - Street address and house number is required for all customers when countrycode is NL. Use SetStreetAddress().\n";
            }
            if (order.GetCustomerIdentity().Locality == null)
            {
                errors +=
                    "MISSING VALUE - Locality is required for all customers when countrycode is NL. Use SetLocality().\n";
            }
            if (order.GetCustomerIdentity().ZipCode == null)
            {
                errors +=
                    "MISSING VALUE - Zip code is required for all customers when countrycode is NL. Use SetZipCode().\n";
            }

            return(errors);
        }
        public string ValidateDeIdentity(CreateOrderBuilder order)
        {
            string errors = "";
            //Individual
            if (!order.GetIsCompanyIdentity())
            {
                if (order.GetIndividualCustomer().GetBirthDate() == null)
                {
                    errors +=
                        "MISSING VALUE - Birth date is required for individual customers when countrycode is DE. Use SetBirthDate().\n";
                }
                if (order.GetIndividualCustomer().GetFirstName() == null ||
                    order.GetIndividualCustomer().GetLastName() == null)
                {
                    errors +=
                        "MISSING VALUE - Name is required for individual customers when countrycode is DE. Use SetName().\n";
                }
            }

            //Company
            if (order.GetIsCompanyIdentity() &&
                order.GetCompanyCustomer().GetVatNumber() == null)
            {
                errors +=
                    "MISSING VALUE - Vat number is required for company customers when countrycode is DE. Use SetVatNumber().\n";
            }

            //Individual and Company
            if (order.GetCustomerIdentity().Street == null || order.GetCustomerIdentity().HouseNumber == null)
            {
                errors +=
                    "MISSING VALUE - Street address is required for all customers when countrycode is DE. Use SetStreetAddress().\n";
            }
            if (order.GetCustomerIdentity().Locality == null)
            {
                errors +=
                    "MISSING VALUE - Locality is required for all customers when countrycode is DE. Use SetLocality().\n";
            }
            if (order.GetCustomerIdentity().ZipCode == null)
            {
                errors +=
                    "MISSING VALUE - Zip code is required for all customers when countrycode is DE. Use SetCustomerZipCode().\n";
            }
            return errors;
        }
Exemplo n.º 3
0
        public string ValidateNordicIdentity(CreateOrderBuilder order)
        {
            //check Company identity
            if (order.GetCustomerIdentity().NationalIdNumber == null)
            {
                return(order.GetIsCompanyIdentity()
                           ? "MISSING VALUE - Organisation number is required for company customers when countrycode is SE, NO, DK or FI. Use SetNationalIdNumber(...).\n"
                           : "MISSING VALUE - National number(ssn) is required for individual customers when countrycode is SE, NO, DK or FI. Use SetNationalIdNumber(...).\n");
            }

            return("");
        }
Exemplo n.º 4
0
        public override string Validate(CreateOrderBuilder order)
        {
            if (order.GetCustomerIdentity() == null)
            {
                Errors += "MISSING VALUE - CustomerIdentity must be set.\n";
            }

            var identityValidator = new IdentityValidator();

            switch (order.GetCountryCode())
            {
            case CountryCode.NONE:
                Errors += "MISSING VALUE - CountryCode is required. Use SetCountryCode().\n";
                break;

            case CountryCode.FI:
            case CountryCode.DK:
            case CountryCode.NO:
            case CountryCode.SE:
                Errors += identityValidator.ValidateNordicIdentity(order);
                break;

            case CountryCode.DE:
                Errors += identityValidator.ValidateDeIdentity(order);
                break;

            case CountryCode.NL:
                Errors += identityValidator.ValidateNlIdentity(order);
                break;

            default:
                Errors += "NOT VALID - Given countrycode does not exist in our system.\n";
                break;
            }

            ValidateRequiredFieldsForOrder(order);
            ValidateOrderRow(order);
            if (order.GetOrderDate() == DateTime.MinValue)
            {
                Errors += "MISSING VALUE - OrderDate is required. Use SetOrderDate().\n";
            }

            if (!String.IsNullOrEmpty(order.GetPeppolId()))
            {
                Errors += ValidatePeppolId(order);
            }

            return(Errors);
        }
        public override string Validate(CreateOrderBuilder order)
        {
            if (order.GetCustomerIdentity() == null)
            {
                Errors += "MISSING VALUE - CustomerIdentity must be set.\n";
            }

            var identityValidator = new IdentityValidator();

            switch (order.GetCountryCode())
            {
                case CountryCode.NONE:
                    Errors += "MISSING VALUE - CountryCode is required. Use SetCountryCode().\n";
                    break;
                case CountryCode.FI:
                case CountryCode.DK:
                case CountryCode.NO:
                case CountryCode.SE:
                    Errors += identityValidator.ValidateNordicIdentity(order);
                    break;
                case CountryCode.DE:
                    Errors += identityValidator.ValidateDeIdentity(order);
                    break;
                case CountryCode.NL:
                    Errors += identityValidator.ValidateNlIdentity(order);
                    break;
                default:
                    Errors += "NOT VALID - Given countrycode does not exist in our system.\n";
                    break;
            }

            ValidateRequiredFieldsForOrder(order);
            ValidateOrderRow(order);
            if (order.GetOrderDate() == DateTime.MinValue)
            {
                Errors += "MISSING VALUE - OrderDate is required. Use SetOrderDate().\n";
            }

            return Errors;
        }
Exemplo n.º 6
0
        private void SerializeCustomer(CreateOrderBuilder order, XmlWriter xmlw)
        {
            if (order.GetCustomerIdentity() == null)
            {
                return;
            }

            CustomerIdentity        customer;
            Action <string, string> doWriteSimple = (name, value) => WriteSimpleElement(name, value, xmlw);

            if (order.GetIsCompanyIdentity())
            {
                customer = order.GetCompanyCustomer();
            }
            else
            {
                customer = order.GetIndividualCustomer();
            }

            xmlw.WriteStartElement("customer");

            if (customer.NationalIdNumber != null) //nordic country individual customer type
            {
                doWriteSimple("ssn", customer.NationalIdNumber);
            }
            else if (!order.GetIsCompanyIdentity()) //euro country individual
            {
                doWriteSimple("ssn", customer.IndividualIdentity.BirthDate);
            }
            else if (order.GetIsCompanyIdentity() && order.GetCountryCode() != CountryCode.SE)
            //euro country, Company customer and nationalId not set
            {
                doWriteSimple("ssn", customer.CompanyIdentity.CompanyVatNumber);
            }

            //Individual customer
            if (!order.GetIsCompanyIdentity())
            {
                var individualIdentity = customer.IndividualIdentity;
                if (individualIdentity != null)
                {
                    doWriteSimple("firstname", individualIdentity.FirstName);
                    doWriteSimple("lastname", individualIdentity.LastName);
                    doWriteSimple("initials", individualIdentity.Initials);
                }
            }
            else //Company customer
            {
                doWriteSimple("firstname", customer.FullName);
            }

            //Address
            doWriteSimple("phone", customer.PhoneNumber);
            doWriteSimple("email", customer.Email);
            doWriteSimple("address", customer.Street);
            doWriteSimple("housenumber", customer.HouseNumber);
            doWriteSimple("address2", customer.CoAddress);
            doWriteSimple("zip", customer.ZipCode);
            doWriteSimple("city", customer.Locality);

            if (order.GetCountryCode() != CountryCode.NONE)
            {
                doWriteSimple("country", order.GetCountryCode().ToString().ToUpper());
            }

            xmlw.WriteEndElement();

            doWriteSimple("ipaddress",
                          order.GetIsCompanyIdentity()
                              ? order.GetCompanyCustomer().GetIpAddress()
                              : order.GetIndividualCustomer().GetIpAddress());
        }
        private void SerializeCustomer(CreateOrderBuilder order, XmlWriter xmlw)
        {
            if (order.GetCustomerIdentity() == null)
            {
                return;
            }

            CustomerIdentity customer;
            Action<string, string> doWriteSimple = (name, value) => WriteSimpleElement(name, value, xmlw);

            if (order.GetIsCompanyIdentity())
            {
                customer = order.GetCompanyCustomer();
            }
            else
            {
                customer = order.GetIndividualCustomer();
            }

            xmlw.WriteStartElement("customer");

            if (customer.NationalIdNumber != null) //nordic country individual customer type
            {
                doWriteSimple("ssn", customer.NationalIdNumber);
            }
            else if (!order.GetIsCompanyIdentity()) //euro country individual
            {
                doWriteSimple("ssn", customer.IndividualIdentity.BirthDate);
            }
            else if (order.GetIsCompanyIdentity() && order.GetCountryCode() != CountryCode.SE)
                //euro country, Company customer and nationalId not set
            {
                doWriteSimple("ssn", customer.CompanyIdentity.CompanyVatNumber);
            }

            //Individual customer
            if (!order.GetIsCompanyIdentity())
            {
                var individualIdentity = customer.IndividualIdentity;
                if (individualIdentity != null)
                {
                    doWriteSimple("firstname", individualIdentity.FirstName);
                    doWriteSimple("lastname", individualIdentity.LastName);
                    doWriteSimple("initials", individualIdentity.Initials);
                }
            }
            else //Company customer
            {
                doWriteSimple("firstname", customer.FullName);
            }

            //Address
            doWriteSimple("phone", customer.PhoneNumber);
            doWriteSimple("email", customer.Email);
            doWriteSimple("address", customer.Street);
            doWriteSimple("housenumber", customer.HouseNumber);
            doWriteSimple("address2", customer.CoAddress);
            doWriteSimple("zip", customer.ZipCode);
            doWriteSimple("city", customer.Locality);

            if (order.GetCountryCode() != CountryCode.NONE)
            {
                doWriteSimple("country", order.GetCountryCode().ToString().ToUpper());
            }

            xmlw.WriteEndElement();

            doWriteSimple("ipaddress",
                          order.GetIsCompanyIdentity()
                              ? order.GetCompanyCustomer().GetIpAddress()
                              : order.GetIndividualCustomer().GetIpAddress());
        }
        public string ValidateNordicIdentity(CreateOrderBuilder order)
        {
            //check Company identity
            if (order.GetCustomerIdentity().NationalIdNumber == null)
            {
                return order.GetIsCompanyIdentity()
                           ? "MISSING VALUE - Organisation number is required for company customers when countrycode is SE, NO, DK or FI. Use SetNationalIdNumber(...).\n"
                           : "MISSING VALUE - National number(ssn) is required for individual customers when countrycode is SE, NO, DK or FI. Use SetNationalIdNumber(...).\n";
            }

            return "";
        }