public static WorkEffortInventoryAssignment CreateInventoryAssignment(this WorkEffort @this, Part part, int quantity) { new InventoryItemTransactionBuilder(@this.Session()) .WithPart(part) .WithReason(new InventoryTransactionReasons(@this.Session()).IncomingShipment) .WithQuantity(quantity) .Build(); @this.Session().Derive(); return(new WorkEffortInventoryAssignmentBuilder(@this.Session()) .WithAssignment(@this) .WithInventoryItem(part.InventoryItemsWherePart.First) .WithQuantity(quantity) .Build()); }
public static void BaseOnDerive(this WorkEffort @this, ObjectOnDerive method) { var derivation = method.Derivation; if ([email protected]) { @this.DerivationTrigger = Guid.NewGuid(); } var internalOrganisations = new Organisations(@this.Strategy.Session).Extent().Where(v => Equals(v.IsInternalOrganisation, true)).ToArray(); if ([email protected] && internalOrganisations.Count() == 1) { @this.TakenBy = internalOrganisations.First(); } if ([email protected] && @this.ExistTakenBy) { var year = @this.CreationDate.Value.Year; @this.DerivedRoles.WorkEffortNumber = @this.TakenBy.NextWorkEffortNumber(year); var fiscalYearInternalOrganisationSequenceNumbers = @this.TakenBy.FiscalYearsInternalOrganisationSequenceNumbers.FirstOrDefault(v => v.FiscalYear == year); var prefix = @this.TakenBy.WorkEffortSequence.IsEnforcedSequence ? @this.TakenBy.WorkEffortNumberPrefix : fiscalYearInternalOrganisationSequenceNumbers.WorkEffortNumberPrefix; @this.DerivedRoles.SortableWorkEffortNumber = @this.Session().GetSingleton().SortableNumber(prefix, @this.WorkEffortNumber, year.ToString()); } if ([email protected] && @this.ExistTakenBy) { @this.ExecutedBy = @this.TakenBy; } @this.VerifyWorkEffortPartyAssignments(derivation); @this.DeriveActualHoursAndDates(); if (@this.ExistActualStart && @this.WorkEffortState.IsCreated) { @this.WorkEffortState = new WorkEffortStates(@this.Strategy.Session).InProgress; } @this.DeriveCanInvoice(); if (@this.WorkEffortState.IsFinished && @this.CanInvoice) { @this.WorkEffortState = new WorkEffortStates(@this.Strategy.Session).Completed; } foreach (WorkEffortInventoryAssignment inventoryAssignment in @this.WorkEffortInventoryAssignmentsWhereAssignment) { foreach (InventoryTransactionReason createReason in @this.WorkEffortState.InventoryTransactionReasonsToCreate) { inventoryAssignment.SyncInventoryTransactions(derivation, inventoryAssignment.InventoryItem, inventoryAssignment.Quantity, createReason, false); } foreach (InventoryTransactionReason cancelReason in @this.WorkEffortState.InventoryTransactionReasonsToCancel) { inventoryAssignment.SyncInventoryTransactions(derivation, inventoryAssignment.InventoryItem, inventoryAssignment.Quantity, cancelReason, true); } } }
public static TimeEntry CreateTimeEntry(this WorkEffort @this, DateTime fromDate, DateTime throughDate, TimeFrequency frequency, RateType rateType) => new TimeEntryBuilder(@this.Session()) .WithRateType(rateType) .WithFromDate(fromDate) .WithThroughDate(throughDate) .WithTimeFrequency(frequency) .WithWorkEffort(@this) .Build();