Example #1
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistShipToAddress && this.ExistShipToParty)
            {
                this.ShipToAddress = this.ShipToParty.ShippingAddress;
            }

            if (!this.ExistShipFromAddress && this.ExistShipFromParty)
            {
                this.ShipFromAddress = this.ShipFromParty.ShippingAddress;
            }

            if (this.ExistCurrentObjectState &&
                this.CurrentObjectState.UniqueId.Equals(PurchaseShipmentObjectStates.CompletedId) &&
                !this.CurrentObjectState.Equals(this.LastObjectState))
            {

                this.AppsOnDeriveOrderItemQuantityReceived(derivation);
            }

            this.AppsOnDeriveCurrentObjectState(derivation);

            foreach (ShipmentItem shipmentItem in this.ShipmentItems)
            {
                shipmentItem.OnDerive(x => x.WithDerivation(derivation));
            }
        }
Example #2
0
        public void TestOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Log.AssertExists(this, HomeAddresses.Meta.Street);
            derivation.Log.AssertNonEmptyString(this, HomeAddresses.Meta.Street);
        }
Example #3
0
        public void TestOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistOwnerSecurityToken)
            {
                var mySecurityToken = new SecurityTokenBuilder(this.Strategy.Session).Build();
                this.OwnerSecurityToken = mySecurityToken;
            }

            if (!Users.GuestUserName.Equals(this.UserName) && !Users.AdministratorUserName.Equals(this.UserName))
            {
                derivation.Log.AssertExists(this, Persons.Meta.LastName);
            }

            if (this.ExistFirstName && this.ExistLastName)
            {
                this.FullName = this.FirstName + " " + this.LastName;
            }
            else if (this.ExistFirstName)
            {
                this.FullName = this.FirstName;
            }
            else
            {
                this.FullName = this.LastName;
            }

            var template = Singleton.Instance(this.Strategy.Session).PersonTemplate;
            this.PrintContent = template.Apply(new Dictionary<string, object> { { "this", this } });
        }
Example #4
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.ReceivedDateTime = this.ReceivedDateTime.Date;

            if (this.ExistOrderItem && this.ExistShipmentItem)
            {
                var orderShipmentsWhereShipmentItem = this.ShipmentItem.OrderShipmentsWhereShipmentItem;
                orderShipmentsWhereShipmentItem.Filter.AddEquals(OrderShipments.Meta.SalesOrderItem, this.OrderItem);

                if (orderShipmentsWhereShipmentItem.First == null)
                {
                    new OrderShipmentBuilder(this.Strategy.Session)
                        .WithPurchaseOrderItem((Allors.Domain.PurchaseOrderItem)this.OrderItem)
                        .WithShipmentItem(this.ShipmentItem)
                        .WithQuantity(this.QuantityAccepted)
                        .Build();
                }
                else
                {
                    orderShipmentsWhereShipmentItem.First.Quantity += this.QuantityAccepted;
                }
            }

            this.AppsOnDeriveInventoryItem(derivation);
        }
Example #5
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveContraAccount(derivation);
            this.AppsOnDerivePreviousJournalType(derivation);
        }
Example #6
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveMembership(derivation);
            this.AppsOnDeriveInternalOrganisationSupplier(derivation);

            var supplierRelationships = this.InternalOrganisation.SupplierRelationshipsWhereInternalOrganisation;
            supplierRelationships.Filter.AddEquals(SupplierRelationships.Meta.SubAccountNumber, this.SubAccountNumber);
            if (supplierRelationships.Count == 1)
            {
                if (!supplierRelationships[0].Equals(this))
                {
                    derivation.Validation.AddError(new DerivationErrorUnique(derivation.Log, this, SupplierRelationships.Meta.SubAccountNumber));
                }
            }
            else if (supplierRelationships.Count > 1)
            {
                derivation.Validation.AddError(new DerivationErrorUnique(derivation.Log, this, SupplierRelationships.Meta.SubAccountNumber));
            }

            this.Parties = new Party[] { this.Supplier, this.InternalOrganisation};

            if (!this.ExistInternalOrganisation | !this.ExistSupplier)
            {
                this.Delete();
            }
        }
Example #7
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            var customerRelationships = this.InternalOrganisation.CustomerRelationshipsWhereInternalOrganisation;
            customerRelationships.Filter.AddEquals(CustomerRelationships.Meta.SubAccountNumber, this.SubAccountNumber);
            if (customerRelationships.Count == 1)
            {
                if (!customerRelationships[0].Equals(this))
                {
                    derivation.Validation.AddError(new DerivationErrorUnique(derivation.Log, this, CustomerRelationships.Meta.SubAccountNumber));
                }
            }
            else if (customerRelationships.Count > 1)
            {
                derivation.Validation.AddError(new DerivationErrorUnique(derivation.Log, this, CustomerRelationships.Meta.SubAccountNumber));
            }

            this.AppsOnDeriveInternalOrganisationCustomer(derivation);
            this.AppsOnDeriveMembership(derivation);

            this.AppsOnDeriveAmountDue(derivation);
            this.AppsOnDeriveAmountOverDue(derivation);
            this.AppsOnDeriveRevenue(derivation);

            this.Parties = new Party[] { this.Customer, this.InternalOrganisation };

            if (!this.ExistCustomer || !this.ExistInternalOrganisation)
            {
                this.Delete();
            }
        }
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveCustomerContactMemberShip(derivation);
            this.AppsOnDeriveSupplierContactMemberShip(derivation);
            this.AppsOnDerivePartnerContactMemberShip(derivation);

            ////Before deriving this.Contact
            if (this.ExistOrganisation)
            {
                this.Organisation.AppsOnDeriveCurrentContacts(derivation);
            }

            ////After deriving this.Organisation
            if (this.ExistContact)
            {
                this.Contact.OnDerive(x => x.WithDerivation(derivation));
            }

            this.Parties = new Party[] { this.Contact, this.Organisation };

            if (!this.ExistContact || !this.ExistOrganisation)
            {
                this.Delete();
            }
        }
Example #9
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.StoreName = this.Store.Name;

            this.AppsOnDeriveRevenue(derivation);
        }
Example #10
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.SalesChannelName = this.SalesChannel.Name;

            this.AppsOnDeriveRevenue();
        }
Example #11
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.ProductName = this.Product.Description;

            this.AppsOnDeriveRevenue(derivation);
        }
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.PartyProductCategoryName = string.Concat(this.Party.PartyName, "/", this.ProductCategory.Description);

            this.AppsOnDeriveRevenue(derivation);
        }
Example #13
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.SalesRepName = this.SalesRep.PartyName;

            this.AppsOnDeriveRevenue(derivation);
        }
Example #14
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistName && this.ExistLanguage && this.ExistCountry)
            {
                this.Name = this.Language.IsoCode + "-" + this.Country.IsoCode;
            }
        }
Example #15
0
        protected void BaseOnPreDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            foreach (Object member in this.Members)
            {
                derivation.AddDependency(member, this);
            }
        }
Example #16
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveAmountPaid(derivation);

            derivation.Validation.AssertAtLeastOne(this, this.Meta.Product, this.Meta.ProductFeature, this.Meta.TimeEntries);
            derivation.Validation.AssertExistsAtMostOne(this, this.Meta.Product, this.Meta.ProductFeature, this.Meta.TimeEntries);
        }
Example #17
0
        public void TestOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Log.AssertExists(this, MailboxAddresses.Meta.PoBox);
            derivation.Log.AssertNonEmptyString(this, MailboxAddresses.Meta.PoBox);

            derivation.Log.AssertExists(this, MailboxAddresses.Meta.Place);
        }
Example #18
0
File: C1.cs Project: whesius/allors
 public void TestOnDerive(ObjectOnDerive method)
 {
     var derivation = method.Derivation;
     var sequence = (IList<IObject>)derivation["sequence"];
     if (sequence != null)
     {
         sequence.Add(this);
     }
 }
        public static void AppsOnDerive(this CommunicationEvent @this, ObjectOnDerive method)
        {
            if ([email protected])
            {
                @this.Owner = (Person)new Users(@this.Strategy.Session).GetCurrentAuthenticatedUser();
            }

            if ([email protected])
            {
                if ([email protected] || (@this.ExistActualStart && @this.ActualStart > DateTime.UtcNow))
                {
                    @this.CurrentObjectState = new CommunicationEventObjectStates(@this.Strategy.Session).Scheduled;
                    @this.CurrentCommunicationEventStatus = new CommunicationEventStatusBuilder(@this.Strategy.Session)
                        .WithCommunicationEventObjectState(@this.CurrentObjectState)
                        .WithStartDateTime(@this.ActualStart)
                        .Build();
                }

                if (@this.ExistActualStart && @this.ActualStart <= DateTime.UtcNow &&
                    (@this.ExistActualEnd && @this.ActualEnd > DateTime.UtcNow || [email protected]))
                {
                    @this.CurrentObjectState = new CommunicationEventObjectStates(@this.Strategy.Session).InProgress;
                    @this.CurrentCommunicationEventStatus = new CommunicationEventStatusBuilder(@this.Strategy.Session)
                        .WithCommunicationEventObjectState(@this.CurrentObjectState)
                        .WithStartDateTime(@this.ActualStart)
                        .Build();
                }

                if (@this.ExistActualEnd && @this.ActualEnd <= DateTime.UtcNow)
                {
                    @this.CurrentObjectState = new CommunicationEventObjectStates(@this.Strategy.Session).Completed;
                    @this.CurrentCommunicationEventStatus = new CommunicationEventStatusBuilder(@this.Strategy.Session)
                        .WithCommunicationEventObjectState(@this.CurrentObjectState)
                        .WithStartDateTime(@this.ActualEnd)
                        .Build();
                }
            }

            if (@this.ExistCurrentObjectState && [email protected](@this.LastObjectState))
            {
                var currentStatus = new CommunicationEventStatusBuilder(@this.Strategy.Session).WithCommunicationEventObjectState(@this.CurrentObjectState).Build();
                @this.AddCommunicationEventStatus(currentStatus);
                @this.CurrentCommunicationEventStatus = currentStatus;
            }

            if ([email protected] && @this.ExistScheduledStart)
            {
                @this.InitialScheduledStart = @this.ScheduledStart;
            }

            if ([email protected] && @this.ExistScheduledEnd)
            {
                @this.InitialScheduledEnd = @this.ScheduledEnd;
            }
        }
Example #20
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            this.AppsOnDeriveFromParties();
            this.AppsOnDeriveToParties();
            this.AppsOnDeriveInvolvedParties();

            if (this.Callers.Count == 0 || this.Receivers.Count == 0)
            {
                this.Delete();
            }
        }
Example #21
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistActualQuantity && this.ActualQuantity > this.RequestedQuantity)
            {
                derivation.Validation.AddError(this, PickListItems.Meta.ActualQuantity, ErrorMessages.PickListItemQuantityMoreThanAllowed);
            }

            this.AppsOnDeriveOrderItemAdjustment(derivation);
        }
Example #22
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            this.AppsOnDeriveFromParties();
            this.AppsOnDeriveToParties();
            this.AppsOnDeriveInvolvedParties();

            if (!this.ExistOriginator || this.Addressees.Count == 0)
            {
                this.Delete();
            }
        }
Example #23
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveSequenceNumber(derivation);

            if (!this.ExistDocuments)
            {
                var name = string.Format("Package {0}", this.ExistSequenceNumber ? this.SequenceNumber.ToString(CultureInfo.InvariantCulture) : string.Empty);
                this.AddDocument(new PackagingSlipBuilder(this.Strategy.Session).WithName(name).Build());
            }
        }
Example #24
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistInternalOrganisationWherePaymentMethod && this.InternalOrganisationWherePaymentMethod.DoAccounting)
            {
                derivation.Validation.AssertExists(this, this.Meta.Creditor);
                derivation.Validation.AssertAtLeastOne(this, M.Cash.GeneralLedgerAccount, M.Cash.Journal);
            }

            derivation.Validation.AssertExistsAtMostOne(this, M.Cash.GeneralLedgerAccount, M.Cash.Journal);
        }
Example #25
0
 public static void AppsOnDerive(this Requirement @this, ObjectOnDerive method)
 {
     if (@this.ExistCurrentObjectState && [email protected](@this.LastObjectState))
     {
         var currentStatus = new RequirementStatusBuilder(@this.Strategy.Session)
             .WithRequirementObjectState(@this.CurrentObjectState)
             .WithStartDateTime(DateTime.UtcNow)
             .Build();
         @this.AddRequirementStatus(currentStatus);
         @this.CurrentRequirementStatus = currentStatus;
     }
 }
Example #26
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            if (this.ExistParent)
            {
                // TODO: members should be added to ancestor groups
            }

            foreach (AccessControl accessControl in this.AccessControlsWhereSubjectGroup)
            {
                accessControl.CacheId = Guid.NewGuid();
            }
        }
Example #27
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistOwnBankAccountsWhereBankAccount)
            {
                derivation.Validation.AssertExists(this, this.Meta.Bank);
                derivation.Validation.AssertExists(this, this.Meta.Currency);
                derivation.Validation.AssertExists(this, this.Meta.NameOnAccount);
            }

            this.DeriveIban(derivation);
        }
Example #28
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistQuantity && this.ExistShipmentItem)
            {
                var maxQuantity = this.ShipmentItem.Quantity - this.ShipmentItem.QuantityShipped;
                if (this.Quantity == 0 || this.Quantity > maxQuantity)
                {
                    derivation.Validation.AddError(this, PackagingContents.Meta.Quantity, ErrorMessages.PackagingContentMaximum);
                }
            }
        }
Example #29
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.FromParties = this.Participants;
            this.ToParties = this.Participants;
            this.AppsOnDeriveInvolvedParties(derivation);

            if (this.Participants.Count <= 1)
            {
                this.Delete();
            }
        }
Example #30
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveMembership();
            this.AppsOnDerivePartnerContacts(derivation);

            this.Parties = new Party[] { this.Partner, this.InternalOrganisation };

            if (!this.ExistInternalOrganisation | !this.ExistPartner)
            {
                this.Delete();
            }
        }
Example #31
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!string.IsNullOrEmpty(this.Bic))
            {
                if (!Regex.IsMatch(this.Bic, "^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$"))
                {
                    derivation.Validation.AddError(this, this.Meta.Bic, ErrorMessages.NotAValidBic);
                }

                var country = new Countries(this.Strategy.Session).FindBy(M.Country.IsoCode, this.Bic.Substring(4, 2));
                if (country == null)
                {
                    derivation.Validation.AddError(this, this.Meta.Bic, ErrorMessages.NotAValidBic);
                }
            }
        }
        public static void BaseOnDerive(this InventoryItem @this, ObjectOnDerive method)
        {
            var session = @this.Strategy.Session;
            var now     = session.Now();

            ((InventoryItemDerivedRoles)@this).PartDisplayName = @this.Part?.DisplayName;

            if ([email protected] && @this.ExistPart && @this.Part.ExistDefaultFacility)
            {
                @this.Facility = @this.Part.DefaultFacility;
            }

            // TODO: Let Sync set Unit of Measure
            if ([email protected])
            {
                @this.UnitOfMeasure = @this.Part?.UnitOfMeasure;
            }
        }
Example #33
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertAtLeastOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.SerialisedItem, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.SerialisedItem, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);

            if (!this.ExistUnitOfMeasure)
            {
                this.UnitOfMeasure = new UnitsOfMeasure(this.strategy.Session).Piece;
            }

            if (this.RequestWhereRequestItem.RequestState.Equals(new RequestStates(this.Strategy.Session).Cancelled))
            {
                this.Cancel();
            }
        }
Example #34
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.Strategy.Session.Prefetch(this.PrefetchPolicy);

            this.PartyName = this.DerivePartyName();

            var allOrganisationContactRelationships = this.OrganisationContactRelationshipsWhereContact;

            this.CurrentOrganisationContactRelationships = allOrganisationContactRelationships
                                                           .Where(v => v.FromDate <= DateTime.UtcNow && (!v.ExistThroughDate || v.ThroughDate >= DateTime.UtcNow))
                                                           .ToArray();

            this.InactiveOrganisationContactRelationships = allOrganisationContactRelationships
                                                            .Except(this.CurrentOrganisationContactRelationships)
                                                            .ToArray();

            this.CurrentPartyContactMechanisms = this.PartyContactMechanisms
                                                 .Where(v => v.FromDate > DateTime.UtcNow || (v.ExistThroughDate && v.ThroughDate < DateTime.UtcNow))
                                                 .ToArray();

            this.InactivePartyContactMechanisms = this.PartyContactMechanisms
                                                  .Except(this.CurrentPartyContactMechanisms).ToArray();

            if (!this.ExistTimeSheetWhereWorker &&
                (this.ExistEmploymentsWhereEmployee ||
                 this.ExistSubContractorRelationshipsWhereContractor ||
                 this.ExistSubContractorRelationshipsWhereSubContractor))
            {
                new TimeSheetBuilder(this.strategy.Session).WithWorker(this).Build();
            }

            var deletePermission = new Permissions(this.strategy.Session).Get(this.Meta.ObjectType, this.Meta.Delete, Operations.Execute);

            if (this.IsDeletable)
            {
                this.RemoveDeniedPermission(deletePermission);
            }
            else
            {
                this.AddDeniedPermission(deletePermission);
            }
        }
Example #35
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation    = method.Derivation;
            var defaultLocale = this.Strategy.Session.GetSingleton().DefaultLocale;
            var settings      = this.Strategy.Session.GetSingleton().Settings;

            var identifications = this.ProductIdentifications;

            identifications.Filter.AddEquals(M.ProductIdentification.ProductIdentificationType, new ProductIdentificationTypes(this.Strategy.Session).Good);
            var goodIdentification = identifications.FirstOrDefault();

            if (goodIdentification == null && settings.UseProductNumberCounter)
            {
                goodIdentification = new ProductNumberBuilder(this.Strategy.Session)
                                     .WithIdentification(settings.NextProductNumber())
                                     .WithProductIdentificationType(new ProductIdentificationTypes(this.Strategy.Session).Good).Build();

                this.AddProductIdentification(goodIdentification);
            }

            this.ProductNumber = goodIdentification.Identification;

            if (!this.ExistProductIdentifications)
            {
                derivation.Validation.AssertExists(this, M.Good.ProductIdentifications);
            }

            if (!this.ExistVariants)
            {
                derivation.Validation.AssertExists(this, M.NonUnifiedGood.Part);
            }

            if (this.LocalisedNames.Any(x => x.Locale.Equals(defaultLocale)))
            {
                this.Name = this.LocalisedNames.First(x => x.Locale.Equals(defaultLocale)).Text;
            }

            if (this.LocalisedDescriptions.Any(x => x.Locale.Equals(defaultLocale)))
            {
                this.Description = this.LocalisedDescriptions.First(x => x.Locale.Equals(defaultLocale)).Text;
            }

            this.DeriveVirtualProductPriceComponent();
        }
Example #36
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistInternalOrganisationWherePaymentMethod && this.InternalOrganisationWherePaymentMethod.DoAccounting)
            {
                derivation.Validation.AssertAtLeastOne(this, M.Cash.GeneralLedgerAccount, M.Cash.Journal);
            }

            if (this.ExistCreditCard)
            {
                if (this.CreditCard.ExpirationYear <= this.Session().Now().Year&& this.CreditCard.ExpirationMonth <= this.Session().Now().Month)
                {
                    this.IsActive = false;
                }
            }

            derivation.Validation.AssertExistsAtMostOne(this, M.Cash.GeneralLedgerAccount, M.Cash.Journal);
        }
Example #37
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistWorkEffort && this.ExistWorkEffortPartyAssignment)
            {
                this.WorkEffort = this.WorkEffortPartyAssignment.Assignment;
            }

            if (this.ExistRateType)
            {
                var extent = this.WorkEffort.WorkEffortAssignmentRatesWhereWorkEffort;
                extent.Filter.AddEquals(M.WorkEffortAssignmentRate.RateType, this.RateType);
                if (extent.Count > 1)
                {
                    derivation.Validation.AddError(this, this.Meta.RateType, ErrorMessages.WorkEffortRateError);
                }
            }
        }
Example #38
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var stringBuilder = new StringBuilder();

            if (this.ExistFromDate)
            {
                stringBuilder.AppendFormat("{0:d}", this.FromDate);
            }

            if (this.ExistThroughDate)
            {
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append(" through ");
                }

                stringBuilder.AppendFormat("{0:d}", this.ThroughDate);
            }
        }
Example #39
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            this.AppsOnDeriveAmountPaid(derivation);

            derivation.Validation.AssertExistsAtMostOne(this, M.SalesInvoiceItem.Product, M.SalesInvoiceItem.ProductFeature, M.SalesInvoiceItem.Part);
            derivation.Validation.AssertExistsAtMostOne(this, M.SalesInvoiceItem.SerialisedItem, M.SalesInvoiceItem.ProductFeature, M.SalesInvoiceItem.Part);

            if (this.ExistInvoiceItemType && this.Quantity == 0)
            {
                this.Quantity = 1;
            }

            if (this.ExistInvoiceItemType && this.IsSubTotalItem && this.Quantity <= 0)
            {
                derivation.Validation.AssertExists(this, this.Meta.Quantity);
            }
        }
        public static void BaseOnDerive(this InventoryItem @this, ObjectOnDerive method)
        {
            var session = @this.Strategy.Session;
            var now     = session.Now();

            ((InventoryItemDerivedRoles)@this).PartDisplayName = @this.Part?.DisplayName;

            if ([email protected] && @this.ExistPart && @this.Part.ExistDefaultFacility)
            {
                @this.Facility = @this.Part.DefaultFacility;
            }

            Party owner = (Organisation)@this.Facility.Owner;

            if (@this is SerialisedInventoryItem item)
            {
                owner = item.SerialisedItem?.Seller ?? item.SerialisedItem?.Buyer;
            }

            foreach (var inventoryOwnership in @this.InventoryOwnershipsWhereInventoryItem.Where(v => v.FromDate < now && (!v.ExistThroughDate || v.ThroughDate >= now)))
            {
                if (!Equals(inventoryOwnership.Owner, owner))
                {
                    inventoryOwnership.ThroughDate = now;
                }
            }

            var ownerInventoryOwnership = @this.InventoryOwnershipsWhereInventoryItem.FirstOrDefault(v => v.Owner.Equals(owner) && v.FromDate < now && (!v.ExistThroughDate || v.ThroughDate >= now));

            if (ownerInventoryOwnership == null && owner != null)
            {
                new InventoryOwnershipBuilder(session)
                .WithInventoryItem(@this)
                .WithOwner(owner)
                .Build();
            }

            // TODO: Let Sync set Unit of Measure
            if ([email protected])
            {
                @this.UnitOfMeasure = @this.Part?.UnitOfMeasure;
            }
        }
Example #41
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertAtLeastOne(this, M.SurchargeComponent.Price, M.SurchargeComponent.Percentage);
            derivation.Validation.AssertExistsAtMostOne(this, M.SurchargeComponent.Price, M.SurchargeComponent.Percentage);

            if (this.ExistPrice)
            {
                if (!this.ExistCurrency)
                {
                    this.Currency = this.PricedBy.PreferredCurrency;
                }

                derivation.Validation.AssertExists(this, M.BasePrice.Currency);
            }

            this.AppsOnDeriveVirtualProductPriceComponent();
        }
Example #42
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertExists(this, this.Meta.ShipFromParty);

            var internalOrganisations = new Organisations(this.Strategy.Session).Extent().Where(v => Equals(v.IsInternalOrganisation, true)).ToArray();
            var shipToParty           = this.ShipToParty as InternalOrganisation;

            if (!this.ExistShipToParty && internalOrganisations.Count() == 1)
            {
                this.ShipToParty = internalOrganisations.First();
                shipToParty      = internalOrganisations.First();
            }

            this.ShipToAddress = this.ShipToAddress ?? this.ShipToParty?.ShippingAddress ?? this.ShipToParty?.GeneralCorrespondence as PostalAddress;

            if (!this.ExistShipToFacility && shipToParty != null && shipToParty.StoresWhereInternalOrganisation.Count == 1)
            {
                this.ShipToFacility = shipToParty.StoresWhereInternalOrganisation.Single().DefaultFacility;
            }

            if (!this.ExistShipmentNumber && shipToParty != null)
            {
                this.ShipmentNumber         = shipToParty.NextShipmentNumber(this.Strategy.Session.Now().Year);
                this.SortableShipmentNumber = this.Session().GetSingleton().SortableNumber(((InternalOrganisation)this.ShipToParty).IncomingShipmentNumberPrefix, this.ShipmentNumber, this.CreationDate.Value.Year.ToString());
            }

            if (!this.ExistShipFromAddress && this.ExistShipFromParty)
            {
                this.ShipFromAddress = this.ShipFromParty.ShippingAddress;
            }

            if (this.ShipmentItems.Any() &&
                this.ShipmentItems.All(v => v.ExistShipmentReceiptWhereShipmentItem &&
                                       v.ShipmentReceiptWhereShipmentItem.QuantityAccepted.Equals(v.ShipmentReceiptWhereShipmentItem.OrderItem?.QuantityOrdered)) &&
                this.ShipmentItems.All(v => v.ShipmentItemState.Equals(new ShipmentItemStates(this.strategy.Session).Received)))
            {
                this.ShipmentState = new ShipmentStates(this.Strategy.Session).Received;
            }

            this.Sync(this.Session());
        }
Example #43
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.ExistChartOfAccountsWhereGeneralLedgerAccount)
            {
                var extent = this.Strategy.Session.Extent <GeneralLedgerAccount>();
                extent.Filter.AddEquals(this.Meta.ChartOfAccountsWhereGeneralLedgerAccount, this.ChartOfAccountsWhereGeneralLedgerAccount);
                extent.Filter.AddEquals(this.Meta.AccountNumber, this.AccountNumber);

                if (extent.Count > 1)
                {
                    derivation.Validation.AddError(this, this.Meta.AccountNumber, ErrorMessages.AccountNumberUniqueWithinChartOfAccounts);
                }
            }

            if (!this.CostCenterAccount && this.CostCenterRequired)
            {
                derivation.Validation.AddError(this, this.Meta.CostCenterRequired, ErrorMessages.NotACostCenterAccount);
            }

            if (this.CostCenterAccount && this.ExistDefaultCostCenter)
            {
                if (!this.CostCentersAllowed.Contains(this.DefaultCostCenter))
                {
                    derivation.Validation.AddError(this, this.Meta.DefaultCostCenter, ErrorMessages.CostCenterNotAllowed);
                }
            }

            if (!this.CostUnitAccount && this.CostUnitRequired)
            {
                derivation.Validation.AddError(this, this.Meta.CostCenterRequired, ErrorMessages.NotACostUnitAccount);
            }

            if (this.CostUnitAccount && this.ExistDefaultCostUnit)
            {
                if (!this.CostUnitsAllowed.Contains(this.DefaultCostUnit))
                {
                    derivation.Validation.AddError(this, this.Meta.DefaultCostUnit, ErrorMessages.CostUnitNotAllowed);
                }
            }
        }
Example #44
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            this.Parties = new[] { this.Contractor, this.SubContractor };

            if (this.ExistContractor && this.ExistSubContractor)
            {
                // HACK: DerivedRoles
                var internalOrganisationDerivedRoles = (OrganisationDerivedRoles)this.Contractor;

                if (this.FromDate <= this.Session().Now() && (!this.ExistThroughDate || this.ThroughDate >= this.Session().Now()))
                {
                    internalOrganisationDerivedRoles.AddActiveSubContractor(this.SubContractor);
                }

                if (this.FromDate > this.Session().Now() || (this.ExistThroughDate && this.ThroughDate < this.Session().Now()))
                {
                    internalOrganisationDerivedRoles.RemoveActiveSubContractor(this.SubContractor);
                }

                if (this.SubContractor?.ContactsUserGroup != null)
                {
                    foreach (OrganisationContactRelationship contactRelationship in this.SubContractor.OrganisationContactRelationshipsWhereOrganisation)
                    {
                        if (contactRelationship.FromDate <= this.Session().Now() &&
                            (!contactRelationship.ExistThroughDate || this.ThroughDate >= this.Session().Now()))
                        {
                            if (!this.SubContractor.ContactsUserGroup.Members.Contains(contactRelationship.Contact))
                            {
                                this.SubContractor.ContactsUserGroup.AddMember(contactRelationship.Contact);
                            }
                        }
                        else
                        {
                            if (this.SubContractor.ContactsUserGroup.Members.Contains(contactRelationship.Contact))
                            {
                                this.SubContractor.ContactsUserGroup.RemoveMember(contactRelationship.Contact);
                            }
                        }
                    }
                }
            }
        }
Example #45
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertAtLeastOne(this, M.BasePrice.Part, M.BasePrice.Product, M.BasePrice.ProductFeature);

            if (this.ExistOrderQuantityBreak)
            {
                derivation.Validation.AddError(this, M.BasePrice.OrderQuantityBreak, ErrorMessages.BasePriceOrderQuantityBreakNotAllowed);
            }

            if (this.ExistOrderValue)
            {
                derivation.Validation.AddError(this, M.BasePrice.OrderValue, ErrorMessages.BasePriceOrderValueNotAllowed);
            }

            if (this.ExistPrice)
            {
                if (!this.ExistCurrency)
                {
                    this.Currency = this.PricedBy.PreferredCurrency;
                }

                derivation.Validation.AssertExists(this, M.BasePrice.Currency);
            }

            if (this.ExistProduct && !this.ExistProductFeature)
            {
                // HACK: DerivedRoles
                ((ProductDerivedRoles)this.Product).AddBasePrice(this);
            }

            if (this.ExistProductFeature)
            {
                this.ProductFeature.AddToBasePrice(this);
            }

            if (this.ExistProduct)
            {
                this.Product.BaseOnDeriveVirtualProductPriceComponent();
            }
        }
Example #46
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation    = method.Derivation;
            var defaultLocale = this.strategy.Session.GetSingleton().DefaultLocale;

            if (this.LocalisedNames.Any(x => x.Locale.Equals(defaultLocale)))
            {
                this.Name = this.LocalisedNames.First(x => x.Locale.Equals(defaultLocale)).Text;
            }

            if (this.LocalisedDescriptions.Any(x => x.Locale.Equals(defaultLocale)))
            {
                this.Description = this.LocalisedDescriptions.First(x => x.Locale.Equals(defaultLocale)).Text;
            }

            if (!this.ExistCatalogueImage)
            {
                this.CatalogueImage = this.strategy.Session.GetSingleton().Settings.NoImageAvailableImage;
            }
        }
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistName)
            {
                this.Name = $"{this.Part?.Name} at {this.Facility?.Name} with state {this.SerialisedInventoryItemState?.Name}";
            }

            this.BaseOnDeriveQuantity(derivation);

            if (this.Quantity < 0 || this.Quantity > 1)
            {
                var message = "Invalid transaction";
                derivation.Validation.AddError(this, this.Meta.Quantity, message);
            }

            // TODO: Remove OnDerive
            this.Part.OnDerive(x => x.WithDerivation(derivation));
        }
Example #48
0
        public static void AppsOnDerive(this Request @this, ObjectOnDerive method)
        {
            if ([email protected])
            {
                var internalOrganisations = new Organisations(@this.Strategy.Session).Extent();
                internalOrganisations.Filter.AddEquals(M.Organisation.IsInternalOrganisation, true);

                if (internalOrganisations.Count() == 1)
                {
                    @this.Recipient = internalOrganisations.Single();
                }
            }

            if (@this.ExistRecipient && [email protected])
            {
                @this.RequestNumber = @this.Recipient.NextRequestNumber();
            }

            @this.DeriveInitialObjectState();
        }
Example #49
0
        public static void DipuOnDerive(this Auditable @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;
            var user       = new Users(@this.Strategy.Session).GetCurrentAuthenticatedUser();

            if (user != null)
            {
                var changeSet = derivation.ChangeSet;
                if (changeSet.Created.Contains(@this.Id))
                {
                    @this.CreationDate = DateTime.UtcNow;
                    @this.CreatedBy    = user;
                }

                if (changeSet.Associations.Contains(@this.Id))
                {
                    @this.LastModifiedDate = DateTime.UtcNow;
                    @this.LastModifiedBy   = user;
                }
            }
        }
Example #50
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            this.Title = "Approval of " + this.PurchaseOrder.WorkItemDescription;

            this.WorkItem = this.PurchaseOrder;

            // Lifecycle
            if (!this.ExistDateClosed && !this.PurchaseOrder.PurchaseOrderState.IsAwaitingApprovalLevel1)
            {
                this.DateClosed = this.Session().Now();
            }

            if (this.Participants.Count == 0)
            {
                // Assignments
                var participants = this.ExistDateClosed
                                       ? (IEnumerable <Person>)Array.Empty <Person>()
                                       : new UserGroups(this.Strategy.Session).Administrators.Members.Select(v => (Person)v).ToArray();
                this.AssignParticipants(participants);
            }
        }
Example #51
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertExistsAtMostOne(this, M.PaymentApplication.Invoice, M.PaymentApplication.InvoiceItem);

            if (this.ExistPaymentWherePaymentApplication && this.AmountApplied > this.PaymentWherePaymentApplication.Amount)
            {
                derivation.Validation.AddError(this, M.PaymentApplication.AmountApplied, ErrorMessages.PaymentApplicationNotLargerThanPaymentAmount);
            }

            if (this.ExistInvoice && this.Invoice.AmountPaid > this.Invoice.TotalIncVat)
            {
                derivation.Validation.AddError(this, M.PaymentApplication.AmountApplied, ErrorMessages.PaymentApplicationNotLargerThanInvoiceAmount);
            }

            if (this.ExistInvoiceItem && this.InvoiceItem.AmountPaid > this.InvoiceItem.TotalIncVat)
            {
                derivation.Validation.AddError(this, M.PaymentApplication.AmountApplied, ErrorMessages.PaymentApplicationNotLargerThanInvoiceItemAmount);
            }
        }
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (this.Part.InventoryItemKind.Serialised)
            {
                if (this.Quantity != 1 && this.Quantity != -1 && this.Quantity != 0)
                {
                    var message = "Serialised Inventory Items only accept Quantities of -1, 0, and 1.";
                    derivation.Validation.AddError(this, this.Meta.Quantity, message);
                }

                if (!this.ExistSerialisedItem)
                {
                    var message = "The Serial Number is required for Inventory Item Transactions involving Serialised Inventory Items.";
                    derivation.Validation.AddError(this, this.Meta.SerialisedItem, message);
                }

                if (this.Reason.IncreasesQuantityOnHand == true && this.Quantity <= 0)
                {
                    var message = "Invalid transaction";
                    derivation.Validation.AddError(this, this.Meta.Reason, message);
                }

                if (this.Reason.IncreasesQuantityOnHand == false && this.Quantity <= 0)
                {
                    var message = "Invalid transaction";
                    derivation.Validation.AddError(this, this.Meta.Reason, message);
                }

                if (this.Quantity == 1 &&
                    this.SerialisedItem.ExistSerialisedInventoryItemsWhereSerialisedItem &&
                    this.SerialisedItem.SerialisedInventoryItemsWhereSerialisedItem.Any(v => v.Quantity == 1) &&
                    this.Reason.IncreasesQuantityOnHand == true)
                {
                    var message = "Serialised item already in inventory";
                    derivation.Validation.AddError(this, this.Meta.SerialisedItem, message);
                }
            }
        }
Example #53
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if (!this.ExistFacility && this.ExistPart && this.Part.ExistDefaultFacility)
            {
                this.Facility = this.Part.DefaultFacility;
            }

            if (!this.ExistName && this.ExistPart && this.Part.ExistName)
            {
                this.Name = this.Part.Name;
            }

            this.AppsOnDeriveQuantity(derivation);

            if (this.Quantity < 0 || this.Quantity > 1)
            {
                var message = "Invalid transaction";
                derivation.Validation.AddError(this, this.Meta.Quantity, message);
            }
        }
Example #54
0
        public void AppsOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            var internalOrganisations = new Organisations(this.strategy.Session).Extent().Where(v => Equals(v.IsInternalOrganisation, true)).ToArray();

            if (!this.ExistShipFromParty && internalOrganisations.Count() == 1)
            {
                this.ShipFromParty = internalOrganisations.First();
            }

            derivation.Validation.AssertExists(this, this.Meta.ShipToParty);

            if (!this.ExistShipToAddress && this.ExistShipToParty)
            {
                this.ShipToAddress = this.ShipToParty.ShippingAddress;
            }

            if (!this.ExistShipFromAddress)
            {
                this.ShipFromAddress = this.ShipFromParty?.ShippingAddress;
            }

            if (!this.ExistBillFromContactMechanism)
            {
                this.BillFromContactMechanism = this.ShipFromParty?.BillingAddress;
            }

            this.CreatePickList(derivation);
            this.AppsOnDeriveShipmentValue(derivation);
            this.AppsOnDeriveCurrentShipmentState(derivation);

            if (this.CanShip && this.Store.IsAutomaticallyShipped)
            {
                this.Ship();
            }

            this.AppsOnDeriveCurrentObjectState(derivation);
        }
Example #55
0
        public static void BaseOnDerive(this Quote @this, ObjectOnDerive method)
        {
            var session    = @this.Strategy.Session;
            var derivation = method.Derivation;

            if ([email protected])
            {
                var internalOrganisations = new Organisations(session).InternalOrganisations();

                if (internalOrganisations.Count() == 1)
                {
                    @this.Issuer = internalOrganisations.First();
                }
            }

            if ([email protected] && @this.ExistIssuer)
            {
                @this.QuoteNumber = @this.Issuer.NextQuoteNumber(session.Now().Year);
                ((QuoteDerivedRoles)@this).SortableQuoteNumber = @this.Session().GetSingleton().SortableNumber(@this.Issuer.QuoteNumberPrefix, @this.QuoteNumber, @this.IssueDate.Year.ToString());
            }

            @this.Currency ??= @this.Receiver?.PreferredCurrency ?? @this.Issuer?.PreferredCurrency;

            foreach (QuoteItem quoteItem in @this.QuoteItems)
            {
                var quoteItemDerivedRoles = (QuoteItemDerivedRoles)quoteItem;

                quoteItemDerivedRoles.VatRegime = quoteItem.AssignedVatRegime ?? @this.VatRegime;
                quoteItemDerivedRoles.VatRate   = quoteItem.VatRegime?.VatRate;

                quoteItemDerivedRoles.IrpfRegime = quoteItem.AssignedIrpfRegime ?? @this.IrpfRegime;
                quoteItemDerivedRoles.IrpfRate   = quoteItem.IrpfRegime?.IrpfRate;
            }

            @this.AddSecurityToken(new SecurityTokens(session).DefaultSecurityToken);

            @this.Sync(derivation);
        }
Example #56
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            switch (this.Operation)
            {
            case Operations.Read:
                // Read Operations should only be allowed on AssociaitonTypes && RoleTypes
                if (!(this.OperandType is RoleType || this.OperandType is AssociationType))
                {
                    derivation.Validation.AddError(this, Meta.OperationEnum, DomainErrors.PermissionOnlyReadForRoleOrAssociationType);
                }

                break;

            case Operations.Write:
                // Write Operations should only be allowed on RoleTypes
                if (!(this.OperandType is RoleType))
                {
                    derivation.Validation.AddError(this, Meta.OperationEnum, DomainErrors.PermissionOnlyWriteForRoleType);
                }

                break;

            case Operations.Execute:
                // Execute Operations should only be allowed on MethodTypes
                if (!(this.OperandType is MethodType))
                {
                    derivation.Validation.AddError(this, Meta.OperationEnum, DomainErrors.PermissionOnlyExecuteForMethodType);
                }

                break;

            default:
                derivation.Validation.AddError(this, Meta.OperationEnum, "Illegal enum");
                break;
            }
        }
Example #57
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            this.Revision = Guid.NewGuid();

            if (this.ExistInData || this.ExistInDataUri)
            {
                if (!this.ExistMediaContent)
                {
                    this.MediaContent = new MediaContentBuilder(this.Strategy.Session).Build();
                }
            }

            if (this.ExistInData)
            {
                this.MediaContent.Data = this.InData;
                this.MediaContent.Type = MediaContents.Sniff(this.InData);

                this.RemoveInData();
            }

            if (this.ExistInDataUri)
            {
                var regex = new Regex(@"data:(?<mime>[\w/\-\.]+);(?<encoding>\w+),(?<data>.*)", RegexOptions.Compiled);

                var match = regex.Match(this.InDataUri);

                var mime     = match.Groups["mime"].Value;
                var encoding = match.Groups["encoding"].Value;
                var data     = match.Groups["data"].Value;

                var binaryData = Convert.FromBase64String(data);

                this.MediaContent.Data = binaryData;
                this.MediaContent.Type = mime;

                this.RemoveInDataUri();
            }
        }
Example #58
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            var internalOrganisations = new Organisations(this.Strategy.Session).Extent().Where(v => Equals(v.IsInternalOrganisation, true)).ToArray();

            if (!this.ExistInternalOrganisation && internalOrganisations.Length == 1)
            {
                this.InternalOrganisation = internalOrganisations.First();
            }

            if (this.ExistDefaultCollectionMethod && !this.CollectionMethods.Contains(this.DefaultCollectionMethod))
            {
                this.AddCollectionMethod(this.DefaultCollectionMethod);
            }

            if (!this.ExistDefaultCollectionMethod && this.CollectionMethods.Count == 1)
            {
                this.DefaultCollectionMethod = this.CollectionMethods.First;
            }

            if (!this.ExistDefaultCollectionMethod && this.InternalOrganisation.ExistDefaultCollectionMethod)
            {
                this.DefaultCollectionMethod = this.InternalOrganisation.DefaultCollectionMethod;

                if (!this.ExistCollectionMethods || !this.CollectionMethods.Contains(this.DefaultCollectionMethod))
                {
                    this.AddCollectionMethod(this.DefaultCollectionMethod);
                }
            }

            if (!this.ExistDefaultFacility)
            {
                this.DefaultFacility = this.Strategy.Session.GetSingleton().Settings.DefaultFacility;
            }

            derivation.Validation.AssertExistsAtMostOne(this, M.Store.FiscalYearInvoiceNumbers, M.Store.SalesInvoiceCounter);
        }
Example #59
0
        public void BaseOnDerive(ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            derivation.Validation.AssertAtLeastOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.SerialisedItem, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.Product, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);
            derivation.Validation.AssertExistsAtMostOne(this, M.RequestItem.SerialisedItem, M.RequestItem.ProductFeature, M.RequestItem.Description, M.RequestItem.NeededSkill, M.RequestItem.Deliverable);

            if (!this.ExistUnitOfMeasure)
            {
                this.UnitOfMeasure = new UnitsOfMeasure(this.Strategy.Session).Piece;
            }

            if (this.ExistRequestWhereRequestItem && new RequestStates(this.Strategy.Session).Cancelled.Equals(this.RequestWhereRequestItem.RequestState))
            {
                this.Cancel();
            }

            if (this.ExistSerialisedItem && this.Quantity != 1)
            {
                derivation.Validation.AddError(this, this.Meta.Quantity, ErrorMessages.SerializedItemQuantity);
            }
        }
Example #60
0
        public static void AppsOnDerive(this WorkEffort @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if ([email protected])
            {
                if (!(@this.Strategy.Session.GetUser() is Person owner))
                {
                    owner = @this.Strategy.Session.GetSingleton().Guest as Person;
                }

                @this.Owner = owner;
            }

            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)
            {
                @this.WorkEffortNumber = @this.TakenBy.NextWorkEffortNumber();
            }

            if ([email protected] && @this.ExistTakenBy)
            {
                @this.ExecutedBy = @this.TakenBy;
            }

            @this.DeriveOwnerSecurity();
            @this.VerifyWorkEffortPartyAssignments(derivation);
            @this.DeriveActualHoursAndDates();
            @this.DeriveCanInvoice();
        }