private PartyContactMechanism CreateShipTo(ContactMechanism mechanism, ContactMechanismPurpose purpose, bool isDefault) => new PartyContactMechanismBuilder(this.Session).WithContactMechanism(mechanism).WithContactPurpose(purpose).WithUseAsDefault(isDefault).Build();
public static Organisation CreateInternalOrganisation( ISession session, string name, string address, string postalCode, string locality, Country country, string phone1CountryCode, string phone1, ContactMechanismPurpose phone1Purpose, string phone2CountryCode, string phone2, ContactMechanismPurpose phone2Purpose, string emailAddress, string websiteAddress, string taxNumber, string bankName, string facilityName, string bic, string iban, Currency currency, string logo, string storeName, BillingProcess billingProcess, string outgoingShipmentNumberPrefix, string salesInvoiceNumberPrefix, string salesOrderNumberPrefix, string requestNumberPrefix, string quoteNumberPrefix, string productNumberPrefix, int?requestCounterValue, int?quoteCounterValue, int?orderCounterValue, int?invoiceCounterValue) { var postalAddress1 = new PostalAddressBuilder(session) .WithAddress1(address) .WithPostalBoundary(new PostalBoundaryBuilder(session).WithPostalCode(postalCode).WithLocality(locality).WithCountry(country).Build()) .Build(); var email = new EmailAddressBuilder(session) .WithElectronicAddressString(emailAddress) .Build(); var webSite = new WebAddressBuilder(session) .WithElectronicAddressString(websiteAddress) .Build(); var bank = new BankBuilder(session).WithName(bankName).WithBic(bic).WithCountry(country).Build(); var bankaccount = new BankAccountBuilder(session) .WithBank(bank) .WithIban(iban) .WithNameOnAccount(name) .WithCurrency(currency) .Build(); var organisation = new OrganisationBuilder(session) .WithIsInternalOrganisation(true) .WithTaxNumber(taxNumber) .WithName(name) .WithBankAccount(bankaccount) .WithDefaultCollectionMethod(new OwnBankAccountBuilder(session).WithBankAccount(bankaccount).WithDescription("Huisbank").Build()) .WithPreferredCurrency(new Currencies(session).FindBy(M.Currency.IsoCode, "EUR")) .WithInvoiceSequence(new InvoiceSequences(session).EnforcedSequence) .WithFiscalYearStartMonth(01) .WithFiscalYearStartDay(01) .WithDoAccounting(false) .WithRequestNumberPrefix(requestNumberPrefix) .WithQuoteNumberPrefix(quoteNumberPrefix) .Build(); if (requestCounterValue != null) { organisation.RequestCounter = new CounterBuilder(session).WithValue(requestCounterValue).Build(); } if (quoteCounterValue != null) { organisation.QuoteCounter = new CounterBuilder(session).WithValue(quoteCounterValue).Build(); } organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(email) .WithContactPurpose(new ContactMechanismPurposes(session).GeneralEmail) .Build()); organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(postalAddress1) .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence) .Build()); organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(webSite) .WithContactPurpose(new ContactMechanismPurposes(session).InternetAddress) .Build()); TelecommunicationsNumber phoneNumber1 = null; if (!string.IsNullOrEmpty(phone1)) { phoneNumber1 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone1).Build(); if (!string.IsNullOrEmpty(phone1CountryCode)) { phoneNumber1.CountryCode = phone1CountryCode; } } if (phoneNumber1 != null) { organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(phoneNumber1) .WithContactPurpose(phone1Purpose) .Build()); } TelecommunicationsNumber phoneNumber2 = null; if (!string.IsNullOrEmpty(phone2)) { phoneNumber2 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone2).Build(); if (!string.IsNullOrEmpty(phone2CountryCode)) { phoneNumber2.CountryCode = phone2CountryCode; } } if (phoneNumber2 != null) { organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(phoneNumber2) .WithContactPurpose(phone2Purpose) .Build()); } if (File.Exists(logo)) { var fileInfo = new FileInfo(logo); var fileName = System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName).ToLowerInvariant(); var content = File.ReadAllBytes(fileInfo.FullName); var image = new MediaBuilder(session).WithFileName(fileName).WithInData(content).Build(); organisation.LogoImage = image; } Facility facility = null; if (facilityName != null) { facility = new FacilityBuilder(session) .WithName(facilityName) .WithFacilityType(new FacilityTypes(session).Warehouse) .WithOwner(organisation) .Build(); } var paymentMethod = new OwnBankAccountBuilder(session).WithBankAccount(bankaccount).WithDescription("Hoofdbank").Build(); var store = new StoreBuilder(session) .WithName(storeName) .WithOutgoingShipmentNumberPrefix(outgoingShipmentNumberPrefix) .WithSalesInvoiceNumberPrefix(salesInvoiceNumberPrefix) .WithSalesOrderNumberPrefix(salesOrderNumberPrefix) .WithDefaultCollectionMethod(paymentMethod) .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground) .WithDefaultCarrier(new Carriers(session).Fedex) .WithBillingProcess(billingProcess) .WithSalesInvoiceCounter(new CounterBuilder(session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build()) .WithIsImmediatelyPicked(true) .WithIsAutomaticallyShipped(true) .WithInternalOrganisation(organisation) .Build(); if (facility != null) { store.DefaultFacility = facility; } if (orderCounterValue != null) { store.SalesOrderCounter = new CounterBuilder(session).WithValue(orderCounterValue).Build(); } if (invoiceCounterValue != null) { store.SalesInvoiceCounter = new CounterBuilder(session).WithValue(invoiceCounterValue).Build(); } return(organisation); }
private PartyContactMechanism CreatePartyContactMechanism(ContactMechanismPurpose purpose, ContactMechanism mechanism) => new PartyContactMechanismBuilder(this.Session) .WithContactPurpose(purpose) .WithContactMechanism(mechanism) .WithUseAsDefault(true) .Build();
public static Organisation CreateInternalOrganisation( ISession session, string name, string address, string postalCode, string locality, Country country, string phone1CountryCode, string phone1, ContactMechanismPurpose phone1Purpose, string phone2CountryCode, string phone2, ContactMechanismPurpose phone2Purpose, string emailAddress, string websiteAddress, string taxNumber, string bankName, string facilityName, string bic, string iban, Currency currency, string logo, string storeName, BillingProcess billingProcess, string outgoingShipmentNumberPrefix, string salesInvoiceNumberPrefix, string salesOrderNumberPrefix, string purchaseOrderNumberPrefix, string purchaseInvoiceNumberPrefix, string requestNumberPrefix, string quoteNumberPrefix, string productNumberPrefix, string workEffortPrefix, string creditNoteNumberPrefix, bool isImmediatelyPicked, bool autoGenerateShipmentPackage, bool isImmediatelyPacked, bool isAutomaticallyShipped, bool autoGenerateCustomerShipment, bool isAutomaticallyReceived, bool autoGeneratePurchaseShipment, bool useCreditNoteSequence, int?requestCounterValue, int?quoteCounterValue, int?orderCounterValue, int?purchaseOrderCounterValue, int?invoiceCounterValue, int?purchaseInvoiceCounterValue, bool purchaseOrderNeedsApproval, decimal?purchaseOrderApprovalThresholdLevel1, decimal?purchaseOrderApprovalThresholdLevel2, SerialisedItemSoldOn[] serialisedItemSoldOns, bool collectiveWorkEffortInvoice) { var postalAddress1 = new PostalAddressBuilder(session) .WithAddress1(address) .WithPostalCode(postalCode) .WithLocality(locality) .WithCountry(country) .Build(); var webSite = new WebAddressBuilder(session) .WithElectronicAddressString(websiteAddress) .Build(); BankAccount bankAccount = null; if (!string.IsNullOrEmpty(bic) && !string.IsNullOrEmpty(iban)) { var bank = new BankBuilder(session).WithName(bankName).WithBic(bic).WithCountry(country).Build(); bankAccount = new BankAccountBuilder(session) .WithBank(bank) .WithIban(iban) .WithNameOnAccount(name) .WithCurrency(currency) .Build(); } var internalOrganisation = new OrganisationBuilder(session) .WithIsInternalOrganisation(true) .WithTaxNumber(taxNumber) .WithName(name) .WithPreferredCurrency(new Currencies(session).FindBy(M.Currency.IsoCode, "EUR")) .WithInvoiceSequence(new InvoiceSequences(session).EnforcedSequence) .WithFiscalYearStartMonth(01) .WithFiscalYearStartDay(01) .WithDoAccounting(false) .WithRequestNumberPrefix(requestNumberPrefix) .WithQuoteNumberPrefix(quoteNumberPrefix) .WithWorkEffortPrefix(workEffortPrefix) .WithPurchaseOrderNumberPrefix(purchaseOrderNumberPrefix) .WithPurchaseInvoiceNumberPrefix(purchaseInvoiceNumberPrefix) .WithPurchaseOrderNeedsApproval(purchaseOrderNeedsApproval) .WithPurchaseOrderApprovalThresholdLevel1(purchaseOrderApprovalThresholdLevel1) .WithPurchaseOrderApprovalThresholdLevel2(purchaseOrderApprovalThresholdLevel2) .WithAutoGeneratePurchaseShipment(autoGeneratePurchaseShipment) .WithIsAutomaticallyReceived(isAutomaticallyReceived) .WithCollectiveWorkEffortInvoice(collectiveWorkEffortInvoice) .Build(); internalOrganisation.SerialisedItemSoldOns = serialisedItemSoldOns; if (purchaseOrderCounterValue != null) { internalOrganisation.PurchaseOrderCounter = new CounterBuilder(session).WithValue(purchaseOrderCounterValue).Build(); } if (purchaseInvoiceCounterValue != null) { internalOrganisation.PurchaseInvoiceCounter = new CounterBuilder(session).WithValue(purchaseInvoiceCounterValue).Build(); } OwnBankAccount defaultCollectionMethod = null; if (bankAccount != null) { internalOrganisation.AddBankAccount(bankAccount); defaultCollectionMethod = new OwnBankAccountBuilder(session).WithBankAccount(bankAccount).WithDescription("Huisbank").Build(); internalOrganisation.DefaultCollectionMethod = defaultCollectionMethod; } if (requestCounterValue != null) { internalOrganisation.RequestCounter = new CounterBuilder(session).WithValue(requestCounterValue).Build(); } if (quoteCounterValue != null) { internalOrganisation.QuoteCounter = new CounterBuilder(session).WithValue(quoteCounterValue).Build(); } if (!string.IsNullOrEmpty(emailAddress)) { var email = new EmailAddressBuilder(session) .WithElectronicAddressString(emailAddress) .Build(); internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(email) .WithContactPurpose(new ContactMechanismPurposes(session).GeneralEmail) .Build()); } internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(postalAddress1) .WithContactPurpose(new ContactMechanismPurposes(session).RegisteredOffice) .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence) .WithContactPurpose(new ContactMechanismPurposes(session).BillingAddress) .WithContactPurpose(new ContactMechanismPurposes(session).ShippingAddress) .Build()); internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(webSite) .WithContactPurpose(new ContactMechanismPurposes(session).InternetAddress) .Build()); TelecommunicationsNumber phoneNumber1 = null; if (!string.IsNullOrEmpty(phone1)) { phoneNumber1 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone1).Build(); if (!string.IsNullOrEmpty(phone1CountryCode)) { phoneNumber1.CountryCode = phone1CountryCode; } } if (phoneNumber1 != null) { internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(phoneNumber1) .WithContactPurpose(phone1Purpose) .Build()); } TelecommunicationsNumber phoneNumber2 = null; if (!string.IsNullOrEmpty(phone2)) { phoneNumber2 = new TelecommunicationsNumberBuilder(session).WithContactNumber(phone2).Build(); if (!string.IsNullOrEmpty(phone2CountryCode)) { phoneNumber2.CountryCode = phone2CountryCode; } } if (phoneNumber2 != null) { internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(phoneNumber2) .WithContactPurpose(phone2Purpose) .Build()); } if (!string.IsNullOrWhiteSpace(logo)) { var singleton = session.GetSingleton(); internalOrganisation.LogoImage = new MediaBuilder(session).WithInFileName(logo).WithInData(singleton.GetResourceBytes(logo)).Build(); } Facility facility = null; if (facilityName != null) { facility = new FacilityBuilder(session) .WithName(facilityName) .WithFacilityType(new FacilityTypes(session).Warehouse) .WithOwner(internalOrganisation) .Build(); } var store = new StoreBuilder(session) .WithName(storeName) .WithOutgoingShipmentNumberPrefix(outgoingShipmentNumberPrefix) .WithSalesInvoiceNumberPrefix(salesInvoiceNumberPrefix) .WithSalesOrderNumberPrefix(salesOrderNumberPrefix) .WithDefaultCollectionMethod(defaultCollectionMethod) .WithCreditNoteNumberPrefix(creditNoteNumberPrefix) .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground) .WithDefaultCarrier(new Carriers(session).Fedex) .WithBillingProcess(billingProcess) .WithSalesInvoiceCounter(new CounterBuilder(session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build()) .WithIsImmediatelyPicked(isImmediatelyPicked) .WithAutoGenerateShipmentPackage(autoGenerateShipmentPackage) .WithIsImmediatelyPacked(isImmediatelyPacked) .WithIsAutomaticallyShipped(isAutomaticallyShipped) .WithAutoGenerateCustomerShipment(autoGenerateCustomerShipment) .WithUseCreditNoteSequence(useCreditNoteSequence) .WithInternalOrganisation(internalOrganisation) .Build(); if (defaultCollectionMethod == null) { store.DefaultCollectionMethod = new CashBuilder(session).Build(); } else { store.DefaultCollectionMethod = defaultCollectionMethod; } if (facility != null) { store.DefaultFacility = facility; } if (orderCounterValue != null) { store.SalesOrderCounter = new CounterBuilder(session).WithValue(orderCounterValue).Build(); } if (invoiceCounterValue != null) { store.SalesInvoiceCounter = new CounterBuilder(session).WithValue(invoiceCounterValue).Build(); } return(internalOrganisation); }