private static Template CreateOpenDocumentTemplate <T>(this InternalOrganisation @this, byte[] content) { var media = new MediaBuilder(@this.Strategy.Session).WithInData(content).Build(); var templateType = new TemplateTypes(@this.Strategy.Session).OpenDocumentType; var template = new TemplateBuilder(@this.Strategy.Session).WithMedia(media).WithTemplateType(templateType).WithArguments <T>().Build(); return(template); }
public static void BaseOnPostBuild(this InternalOrganisation @this, ObjectOnPostBuild method) { var singleton = @this.Session().GetSingleton(); if (@this.IsInternalOrganisation) { if ([email protected]) { @this.ProductQuoteTemplate = singleton.CreateOpenDocumentTemplate <Print.ProductQuoteModel.Model>("ProductQuote.odt", singleton.GetResourceBytes("Templates.ProductQuote.odt")); } if ([email protected]) { @this.SalesOrderTemplate = singleton.CreateOpenDocumentTemplate <Print.SalesOrderModel.Model>("SalesOrder.odt", singleton.GetResourceBytes("Templates.SalesOrder.odt")); } if ([email protected]) { @this.PurchaseOrderTemplate = singleton.CreateOpenDocumentTemplate <Print.PurchaseOrderModel.Model>("PurchaseOrder.odt", singleton.GetResourceBytes("Templates.PurchaseOrder.odt")); } if ([email protected]) { @this.PurchaseInvoiceTemplate = singleton.CreateOpenDocumentTemplate <Print.PurchaseInvoiceModel.Model>("PurchaseInvoice.odt", singleton.GetResourceBytes("Templates.PurchaseInvoice.odt")); } if ([email protected]) { @this.SalesInvoiceTemplate = singleton.CreateOpenDocumentTemplate <Print.SalesInvoiceModel.Model>("SalesInvoice.odt", singleton.GetResourceBytes("Templates.SalesInvoice.odt")); } if ([email protected]) { @this.WorkTaskTemplate = singleton.CreateOpenDocumentTemplate <Print.WorkTaskModel.Model>("WorkTask.odt", singleton.GetResourceBytes("Templates.WorkTask.odt")); } if ([email protected]) { @this.WorkTaskWorkerTemplate = singleton.CreateOpenDocumentTemplate <Print.WorkTaskModel.Model>("WorkTaskWorker.odt", singleton.GetResourceBytes("Templates.WorkTaskWorker.odt")); } } }
public static void BaseStartNewFiscalYear(this InternalOrganisation @this, InternalOrganisationStartNewFiscalYear method) { var organisation = (Organisation)@this; if (organisation.IsInternalOrganisation) { if (@this.ExistActualAccountingPeriod && @this.ActualAccountingPeriod.Active) { return; } var year = @this.Strategy.Session.Now().Year; if (@this.ExistActualAccountingPeriod) { year = @this.ActualAccountingPeriod.FromDate.Date.Year + 1; } var fromDate = DateTimeFactory .CreateDate(year, @this.FiscalYearStartMonth.Value, @this.FiscalYearStartDay.Value).Date; var yearPeriod = new AccountingPeriodBuilder(@this.Strategy.Session) .WithPeriodNumber(1) .WithFrequency(new TimeFrequencies(@this.Strategy.Session).Year) .WithFromDate(fromDate) .WithThroughDate(fromDate.AddYears(1).AddSeconds(-1).Date) .Build(); var semesterPeriod = new AccountingPeriodBuilder(@this.Strategy.Session) .WithPeriodNumber(1) .WithFrequency(new TimeFrequencies(@this.Strategy.Session).Semester) .WithFromDate(fromDate) .WithThroughDate(fromDate.AddMonths(6).AddSeconds(-1).Date) .WithParent(yearPeriod) .Build(); var trimesterPeriod = new AccountingPeriodBuilder(@this.Strategy.Session) .WithPeriodNumber(1) .WithFrequency(new TimeFrequencies(@this.Strategy.Session).Trimester) .WithFromDate(fromDate) .WithThroughDate(fromDate.AddMonths(3).AddSeconds(-1).Date) .WithParent(semesterPeriod) .Build(); var monthPeriod = new AccountingPeriodBuilder(@this.Strategy.Session) .WithPeriodNumber(1) .WithFrequency(new TimeFrequencies(@this.Strategy.Session).Month) .WithFromDate(fromDate) .WithThroughDate(fromDate.AddMonths(1).AddSeconds(-1).Date) .WithParent(trimesterPeriod) .Build(); @this.ActualAccountingPeriod = monthPeriod; } }
private SalesOrder CreateSalesOrder(Party customer, InternalOrganisation takenBy) => new SalesOrderBuilder(this.Session) .WithShipToCustomer(customer) .WithTakenBy(takenBy) .WithSalesOrderItem(new SalesOrderItemBuilder(this.Session) .WithInvoiceItemType(new InvoiceItemTypes(this.Session).MiscCharge) .Build()) .WithSalesTerm(new OrderTermBuilder(this.Session) .WithDescription("Net 30") .WithTermType(new InvoiceTermTypes(this.Session).PaymentNetDays) .Build()) .Build();
public static bool BaseIsActiveCustomer(this Party @this, InternalOrganisation internalOrganisation, DateTime?date) { if (date == DateTime.MinValue || internalOrganisation == null) { return(false); } var customerRelationships = @this.CustomerRelationshipsWhereCustomer; customerRelationships.Filter.AddEquals(M.CustomerRelationship.InternalOrganisation, internalOrganisation); return(customerRelationships.Any(relationship => relationship.FromDate.Date <= date && (!relationship.ExistThroughDate || relationship.ThroughDate >= date))); }
private static byte[] GetResourceBytes(this InternalOrganisation @this, string name) { var assembly = @this.GetType().GetTypeInfo().Assembly; var manifestResourceName = assembly.GetManifestResourceNames().First(v => v.Contains(name)); var resource = assembly.GetManifestResourceStream(manifestResourceName); if (resource != null) { using (var ms = new MemoryStream()) { resource.CopyTo(ms); return(ms.ToArray()); } } return(null); }
public static void AppsOnPreDerive(this InternalOrganisation @this, ObjectOnPreDerive method) { var derivation = method.Derivation; if (derivation.HasChangedRole(@this, M.InternalOrganisation.DoAccounting)) { foreach (PaymentMethod collectionMethod in @this.ActiveCollectionMethods) { derivation.AddDependency(collectionMethod, @this); } foreach (PaymentMethod paymentMethod in @this.PaymentMethods) { derivation.AddDependency(paymentMethod, @this); } } }
public static void BaseOnPreDerive(this InternalOrganisation @this, ObjectOnPreDerive method) { var(iteration, changeSet, derivedObjects) = method; if (iteration.IsMarked(@this) || changeSet.IsCreated(@this) || changeSet.HasChangedRole(@this, M.InternalOrganisation.DoAccounting)) { foreach (PaymentMethod collectionMethod in @this.ActiveCollectionMethods) { iteration.AddDependency(collectionMethod, @this); iteration.Mark(collectionMethod); } foreach (PaymentMethod paymentMethod in @this.PaymentMethods) { iteration.AddDependency(paymentMethod, @this); iteration.Mark(paymentMethod); } } }
public static string NextWorkEffortNumber(this InternalOrganisation @this, int year) { if (@this.WorkEffortSequence.Equals(new WorkEffortSequences(@this.Session()).EnforcedSequence)) { return(string.Concat(@this.WorkEffortNumberPrefix, @this.WorkEffortNumberCounter.NextValue()).Replace("{year}", year.ToString())); } else { var fiscalYearInternalOrganisationSequenceNumbers = @this.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == year); if (fiscalYearInternalOrganisationSequenceNumbers == null) { fiscalYearInternalOrganisationSequenceNumbers = new FiscalYearInternalOrganisationSequenceNumbersBuilder(@this.Session()).WithFiscalYear(year).Build(); @this.AddFiscalYearsInternalOrganisationSequenceNumber(fiscalYearInternalOrganisationSequenceNumbers); } return(fiscalYearInternalOrganisationSequenceNumbers.NextWorkEffortNumber(year)); } }
public static bool AppsIsActiveCustomer(this Party party, InternalOrganisation internalOrganisation, DateTime?date) { if (date == DateTime.MinValue) { return(false); } var customerRelationships = party.CustomerRelationshipsWhereCustomer; customerRelationships.Filter.AddEquals(M.CustomerRelationship.InternalOrganisation, internalOrganisation); foreach (CustomerRelationship relationship in customerRelationships) { if (relationship.FromDate.Date <= date && (!relationship.ExistThroughDate || relationship.ThroughDate >= date)) { return(true); } } return(false); }
public static void AppsOnBuild(this InternalOrganisation @this, ObjectOnBuild method) { if ([email protected]) { @this.ProductQuoteTemplate = @this.CreateOpenDocumentTemplate <Print.ProductQuoteModel.Model>(@this.GetResourceBytes("Templates.ProductQuote.odt")); } if ([email protected]) { @this.SalesOrderTemplate = @this.CreateOpenDocumentTemplate <Print.SalesOrderModel.Model>(@this.GetResourceBytes("Templates.SalesOrder.odt")); } if ([email protected]) { @this.SalesInvoiceTemplate = @this.CreateOpenDocumentTemplate <Print.SalesInvoiceModel.Model>(@this.GetResourceBytes("Templates.SalesInvoice.odt")); } if ([email protected]) { @this.WorkTaskTemplate = @this.CreateOpenDocumentTemplate <Print.WorkTaskModel.Model>(@this.GetResourceBytes("Templates.WorkTask.odt")); } }
public static string NextPurchaseOrderNumber(this InternalOrganisation @this) { var purchaseOrderNumber = @this.PurchaseOrderCounter.NextValue(); return(string.Concat(@this.ExistPurchaseOrderNumberPrefix? @this.PurchaseOrderNumberPrefix : string.Empty, purchaseOrderNumber)); }
public static string NextShipmentNumber(this InternalOrganisation @this, int year) { var shipmentNumber = @this.IncomingShipmentCounter.NextValue(); return(string.Concat(@this.ExistIncomingShipmentNumberPrefix ? @this.IncomingShipmentNumberPrefix.Replace("{year}", year.ToString()) : string.Empty, shipmentNumber)); }
public static int NextSubAccountNumber(this InternalOrganisation @this) { var next = @this.SubAccountCounter.NextElfProefValue(); return(next); }
public static void BaseOnDerive(this InternalOrganisation @this, ObjectOnDerive method) { var derivation = method.Derivation; var organisation = (Organisation)@this; if (organisation.IsInternalOrganisation) { if ([email protected] && @this.Strategy.Session.Extent <PaymentMethod>().Count == 1) { @this.DefaultCollectionMethod = @this.Strategy.Session.Extent <PaymentMethod>().First; } if ([email protected]) { @this.SubAccountCounter = new CounterBuilder(@this.Strategy.Session).WithUniqueId(Guid.NewGuid()) .WithValue(0).Build(); } if ([email protected]) { @this.InvoiceSequence = new InvoiceSequences(@this.Strategy.Session).RestartOnFiscalYear; } if ([email protected]) { @this.RequestSequence = new RequestSequences(@this.Strategy.Session).EnforcedSequence; } if ([email protected]) { @this.QuoteSequence = new QuoteSequences(@this.Strategy.Session).EnforcedSequence; } if ([email protected]) { @this.CustomerShipmentSequence = new CustomerShipmentSequences(@this.Strategy.Session).EnforcedSequence; } if ([email protected]) { @this.PurchaseShipmentSequence = new PurchaseShipmentSequences(@this.Strategy.Session).EnforcedSequence; } if ([email protected]) { @this.WorkEffortSequence = new WorkEffortSequences(@this.Strategy.Session).EnforcedSequence; } if ([email protected]) { @this.FiscalYearStartMonth = 1; } if ([email protected]) { @this.FiscalYearStartDay = 1; } if (@this.InvoiceSequence != new InvoiceSequences(@this.Strategy.Session).RestartOnFiscalYear) { if ([email protected]) { @this.PurchaseInvoiceNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } if ([email protected]) { @this.PurchaseOrderNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } } if (@this.RequestSequence != new RequestSequences(@this.Strategy.Session).RestartOnFiscalYear) { if ([email protected]) { @this.RequestNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } } if (@this.QuoteSequence != new QuoteSequences(@this.Strategy.Session).RestartOnFiscalYear) { if ([email protected]) { @this.QuoteNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } } if (@this.WorkEffortSequence != new WorkEffortSequences(@this.Strategy.Session).RestartOnFiscalYear) { if ([email protected]) { @this.WorkEffortNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } } if (@this.PurchaseShipmentSequence != new PurchaseShipmentSequences(@this.Strategy.Session).RestartOnFiscalYear) { if ([email protected]) { @this.IncomingShipmentNumberCounter = new CounterBuilder(@this.Strategy.Session).Build(); } } } }
public static string NextPurchaseOrderNumber(this InternalOrganisation @this, int year) { var purchaseOrderNumber = @this.PurchaseOrderCounter.NextValue(); return(string.Concat(@this.ExistPurchaseOrderNumberPrefix ? @this.PurchaseOrderNumberPrefix.Replace("{year}", year.ToString()) : string.Empty, purchaseOrderNumber)); }
private Facility CreateFacility(string name, FacilityType type, InternalOrganisation owner) => new FacilityBuilder(this.Session).WithName(name).WithFacilityType(type).WithOwner(owner).Build();
public static string NextQuoteNumber(this InternalOrganisation @this) { var quoteNumber = @this.QuoteCounter.NextValue(); return(string.Concat(@this.ExistQuoteNumberPrefix ? @this.QuoteNumberPrefix : string.Empty, quoteNumber)); }
public static string NextRequestNumber(this InternalOrganisation @this) { var requestNumber = @this.RequestCounter.NextValue(); return(string.Concat(@this.ExistRequestNumberPrefix ? @this.RequestNumberPrefix : string.Empty, requestNumber)); }
public static string NextRequestNumber(this InternalOrganisation @this, int year) { var requestNumber = @this.RequestCounter.NextValue(); return(string.Concat(@this.ExistRequestNumberPrefix ? @this.RequestNumberPrefix.Replace("{year}", year.ToString()) : string.Empty, requestNumber)); }
public static string NextShipmentNumber(this InternalOrganisation @this) { var shipmentNumber = @this.IncomingShipmentCounter.NextValue(); return(string.Concat(@this.ExistIncomingShipmentNumberPrefix ? @this.IncomingShipmentNumberPrefix : string.Empty, shipmentNumber)); }
private void InstantiateObjects(ISession session) { this.employee = (Person)session.Instantiate(this.employee); this.internalOrganisation = (InternalOrganisation)session.Instantiate(this.internalOrganisation); this.employment = (Employment)session.Instantiate(this.employment); }
public static string NextWorkEffortNumber(this InternalOrganisation @this) => string.Concat(@this.WorkEffortPrefix, @this.WorkEffortCounter.NextValue());