private InvoicePartyInfo(NonNegativeInt?branch = null, TaxpayerIdentificationNumber taxIdentifier = null, string name = null, Address address = null) { Branch = branch ?? NonNegativeInt.Zero(); TaxIdentifier = taxIdentifier.ToOption(); Name = name.ToOption(); Address = address.ToOption(); }
public static ITry <LocalCompany, IEnumerable <Error> > Create(TaxpayerIdentificationNumber taxpayerId, Name name, SimpleAddress address) { var localTaxPayerId = taxpayerId.ToOption().Where(i => i.Country.Equals(Countries.Hungary)); return(localTaxPayerId.ToTry(_ => Error.Create($"{nameof(TaxpayerIdentificationNumber)} must be a Hungarian taxpayer number.")).Map( i => new LocalCompany(i, name, address) )); }
public static ITry <ForeignCompany, IEnumerable <Error> > Create(Name name, SimpleAddress address, TaxpayerIdentificationNumber taxpayerId = null) { var optionalForeignTaxPayerId = taxpayerId.ToOption().ToOption().Where(i => i.Match( identifier => !identifier.Country.Equals(Countries.Hungary), _ => true )); return(optionalForeignTaxPayerId.ToTry(_ => Error.Create($"{nameof(TaxpayerIdentificationNumber)} must be a foreign (non-Hungarian) taxpayer number.")).Map( i => new ForeignCompany(name, address, i.GetOrNull()) )); }
private ForeignCompany(Name name, SimpleAddress address, TaxpayerIdentificationNumber taxpayerId = null) { Name = name; Address = address; TaxpayerId = taxpayerId.ToOption(); }