public Order CreateFactoryOrderObject(string description, long ownerId, long? transporter, long? supplier, long? receiver, OrderTypes orderType, DateTime orderDate, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { var code = _iOrderCodeGenerator.GenerateNewCode(); var order = new Order( code, description, ownerId, transporter, supplier, receiver, orderType, orderDate, fromVesselInCompany, toVesselInCompany, States.Open, _orderConfigurator ); var init = _workflowRepository.Single(c => c.WorkflowEntity == WorkflowEntities.Order && c.CurrentWorkflowStage == WorkflowStages.Initial); var orderWorkflow = new OrderWorkflowLog(order.Id, WorkflowEntities.Order, DateTime.Now, WorkflowActions.Init, //TODO: Fake ActorId 1101, "", init.Id, true); order.ApproveWorkFlows.Add(orderWorkflow); return order; }
//BR_PO26 protected override void CompanyHaveValidVessel(Order order, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { if (fromVesselInCompany.CompanyId != order.OwnerId) throw new BusinessRuleException("", "Vessel Not In Enterprise Party"); if (toVesselInCompany.CompanyId != order.ReceiverId) throw new BusinessRuleException("", "Vessel Not In Enterprise Party"); }
protected internal override void Update(Order order, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { var isTransferValid = new IsTransferValid(); if (!isTransferValid.IsSatisfiedBy(order)) throw new BusinessRuleException("BR_PO2", "transfer is not valid"); CompanyHaveValidVessel(order, fromVesselInCompany, toVesselInCompany); }
void ValidateCommonRule(Order order, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { var isInternalTransferValid = new IsInternalTransferValid(); if (!isInternalTransferValid.IsSatisfiedBy(order)) throw new BusinessRuleException("", "internal trasfer is not valid"); CompanyHaveValidVessel(order, fromVesselInCompany, toVesselInCompany); TwoCompanyNotSame(fromVesselInCompany, toVesselInCompany); }
internal Offhire( long referenceNumber, DateTime startDateTime, DateTime endDateTime, Company introducer, VesselInCompany vesselInCompany, Voyage voyage, ActivityLocation offhireLocation, DateTime voucherDate, Currency voucherCurrency, //string pricingReferenceNumber, //OffHirePricingType pricingReferenceType, IOffhireDomainService offhireDomainService, IOffhireManagementSystemDomainService offhireManagementSystemDomainService, IVesselInCompanyDomainService vesselDomainService, IVoyageDomainService voyageDomainService, ICompanyDomainService companyDomainService, IActivityLocationDomainService activityLocationDomainService, ICurrencyDomainService currencyDomainService) : this() { //var pricingReference = new OffhirePricingReference() { Type = pricingReferenceType, Number = pricingReferenceNumber }; this.validateCreation( referenceNumber, startDateTime, endDateTime, introducer, vesselInCompany, voyage, offhireLocation, voucherDate, voucherCurrency, //pricingReference, offhireDomainService, offhireManagementSystemDomainService, vesselDomainService, voyageDomainService, companyDomainService, activityLocationDomainService, currencyDomainService); this.ReferenceNumber = referenceNumber; this.StartDateTime = startDateTime; this.EndDateTime = endDateTime; this.IntroducerType = offhireDomainService.GetCharteringPartyType(vesselInCompany); this.Introducer = introducer; this.VesselInCompany = vesselInCompany; this.Voyage = voyage; this.OffhireLocation = offhireLocation; this.VoucherDate = voucherDate; this.VoucherCurrencyId = voucherCurrency.Id; this.VoucherCurrency = voucherCurrency; this.PricingReference = this.createPricingReference(introducer, vesselInCompany, this.IntroducerType, voyage, startDateTime, offhireDomainService); }
public override void EndCharterOut(VesselInCompany vesselInCompany) { if (vesselInCompany.CompanyId == vesselInCompany.Vessel.OwnerId) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.Owned)); } else { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.CharterIn)); } }
public CharterOut GetCharterOutStart(Company company, VesselInCompany vesselInCompany, DateTime date) { IListFetchStrategy<Charter> fetchStrategy = new ListFetchStrategy<Charter>() .Include(c => c.CharterItems).OrderBy(c => c.ActionDate); var foundCharterOut = charterOutRepository .Find(cho => cho.CharterType == CharterType.Start && date >= cho.ActionDate && cho.OwnerId == company.Id && cho.VesselInCompanyId == vesselInCompany.Id, fetchStrategy).LastOrDefault() as CharterOut; return foundCharterOut; }
public Scrap CreateScrap(VesselInCompany vesselInCompany, Company secondParty, DateTime scrapDate, List<ScrapDetail> scrapDetails) { var scrap = this.CreateScrap(vesselInCompany, secondParty, scrapDate); foreach (var scrapDetail in scrapDetails) { scrap.AddDetail(scrapDetail); } return scrap; }
public override void Activate(VesselInCompany vesselInCompany) { if (vesselInCompany.CompanyId == vesselInCompany.Vessel.OwnerId) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.Owned)); } else { throw new InvalidStateException("Activate", string.Format("Cannot activate the vessel.")); } }
public override void StartCharterIn(VesselInCompany vesselInCompany) { { if (vesselInCompany.CompanyId != vesselInCompany.Vessel.OwnerId) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.CharterIn)); } else { throw new InvalidStateException("StartCharterIn", string.Format("Cannot start the Charter In of the vessel.")); } } }
//================================================================================ public List<Scrap> GetNotCancelledScrapsForVessel(VesselInCompany vesselInCompany, params long[] excludeIds) { IsScrapCancelled isScrapCancelled = new IsScrapCancelled(); var result = scrapRepository.Find(isScrapCancelled.Predicate.Not().And(s => s.VesselInCompany.Id == vesselInCompany.Id)); if (excludeIds != null) { result = result.Where(s => !excludeIds.Contains(s.Id)).ToList(); } return result.ToList(); }
//================================================================================ private Scrap( VesselInCompany vesselInCompany, Company secondParty, DateTime scrapDate) { //This is used to create instances by reflection to Insert Seed Data into DB. this.VesselInCompany = vesselInCompany; this.SecondParty = secondParty; this.ScrapDate = scrapDate; this.ApproveWorkflows = new List<ScrapWorkflowLog>(); this.ScrapDetails = new List<ScrapDetail>(); this.InventoryOperations = new List<InventoryOperation>(); }
internal Scrap( VesselInCompany vesselInCompany, Company secondParty, DateTime scrapDate, IScrapDomainService scrapDomainService, IVesselInCompanyDomainService vesselDomainService, ICompanyDomainService companyDomainService) : this() { this.validateCreation(vesselInCompany, secondParty, scrapDate, scrapDomainService, vesselDomainService, companyDomainService); this.ScrapDate = scrapDate; this.VesselInCompany = vesselInCompany; this.SecondParty = secondParty; this.ScrapDetails = new List<ScrapDetail>(); this.ApproveWorkflows = new List<ScrapWorkflowLog>(); }
public Scrap CreateScrap(VesselInCompany vesselInCompany, Company secondParty, DateTime scrapDate) { var scrap = new Scrap(vesselInCompany, secondParty, scrapDate, scrapDomainService, vesselDomainService, companyDomainService); var init = this.workflowRepository.Single(c => c.WorkflowEntity == WorkflowEntities.Scrap && c.CurrentWorkflowStage == WorkflowStages.Initial); if (init == null) throw new ObjectNotFound("ScrapInitialStep"); var scrapWorkflow = new ScrapWorkflowLog(scrap, WorkflowEntities.Scrap, DateTime.Now, WorkflowActions.Init, //TODO: Fake ActorId 1101, "", init.Id, true); scrap.ApproveWorkflows.Add(scrapWorkflow); scrapConfigurator.Configure(scrap); return scrap; }
public Order(string code, string description, long ownerId, long? transporterId, long? supplierId, long? receiverId, OrderTypes _orderTypeClass, DateTime orderDate, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany, States state, IEntityConfigurator<Order> orderConfigurator) { Code = code; Description = description; SupplierId = supplierId; OwnerId = ownerId; TransporterId = transporterId; ReceiverId = receiverId; OrderDate = orderDate; FromVesselInCompanyId = fromVesselInCompany == null ? (long?)null : fromVesselInCompany.Id; ToVesselInCompanyId = toVesselInCompany == null ? (long?)null : toVesselInCompany.Id; this.OrderType = _orderTypeClass; State = state; orderConfigurator.Configure(this); _orderBaseType.Add(this, fromVesselInCompany, toVesselInCompany); ApproveWorkFlows = new List<OrderWorkflowLog>(); }
public Offhire CreateOffhire( long referenceNumber, DateTime startDateTime, DateTime endDateTime, Company introducer, VesselInCompany vesselInCompany, Voyage voyage, ActivityLocation offhireLocation, DateTime voucherDate, Currency voucherCurrency) { var offhire = new Offhire( referenceNumber, startDateTime, endDateTime, introducer, vesselInCompany, voyage, offhireLocation, voucherDate, voucherCurrency, this.offhireDomainService, this.offhireManagementSystemDomainService, this.vesselDomainService, this.voyageDomainService, this.companyDomainService, this.activityLocationDomainService, this.currencyDomainService); var init = this.workflowRepository.Single(c => c.WorkflowEntity == WorkflowEntities.Offhire && c.CurrentWorkflowStage == WorkflowStages.Initial); if (init == null) throw new ObjectNotFound("OffhireInitialStep"); var offhireWorkflow = new OffhireWorkflowLog(offhire, WorkflowEntities.Offhire, DateTime.Now, WorkflowActions.Init, //TODO: Fake ActorId 1101, "", init.Id, true); offhire.ApproveWorkflows.Add(offhireWorkflow); offhireConfigurator.Configure(offhire); return offhire; }
public VoyageLog( long id, long referencedVoyageId, DateTime changeDate, string voyageNumber, string description, VesselInCompany vesselInCompany, Company company, DateTime startDate, DateTime endDate, bool isActive) { Id = id; ReferencedVoyageId = referencedVoyageId; ChangeDate = changeDate; VoyageNumber = voyageNumber; Description = description; this.VesselInCompany = vesselInCompany; Company = company; StartDate = startDate; EndDate = endDate; IsActive = isActive; }
public virtual void Deactivate(VesselInCompany vesselInCompany) { throw new InvalidStateException("Deactivate", string.Format("Cannot deactivate the vessel as it is in '{0}' state.", this.State)); }
public virtual void EndCharterIn(VesselInCompany vesselInCompany) { throw new InvalidStateException("EndCharterIn", string.Format("Cannot end the Charter In of the vessel as it is in '{0}' state.", this.State)); }
protected internal override void Update(Order order, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { var isPurchaseWithTransferValid = new IsPurchaseWithTransferValid(); if (!isPurchaseWithTransferValid.IsSatisfiedBy(order)) throw new BusinessRuleException("", "purchase with transfer is not valid "); }
protected override void CompanyHaveValidVessel(Order order, VesselInCompany fromVesselInCompany, VesselInCompany toVesselInCompany) { }
public override void Scrap(VesselInCompany vesselInCompany) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.Scrapped)); }
public override void StartCharterOut(VesselInCompany vesselInCompany) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.CharterOut)); }
public override void Deactivate(VesselInCompany vesselInCompany) { vesselInCompany.SetState(this.VesselInCompanyStateFactory.CreatState(VesselStates.Inactive)); }
public virtual void Scrap(VesselInCompany vesselInCompany) { throw new InvalidStateException("Scrap", string.Format("Cannot scrap the vessel as it is in '{0}' state.", this.State)); }
//================================================================================ public Offhire GetRelevantCharterInOffhire(Company shipOwner, VesselInCompany vesselInCompany, DateTime startDate) { var charterOutContract = GetCharterContract(shipOwner, vesselInCompany, CharteringPartyType.ShipOwner, startDate) as CharterOut; var charterInCompanyOffhire = GetCompanyValidOffhire(charterOutContract.Charterer, vesselInCompany, startDate); return charterInCompanyOffhire; }
//================================================================================ public Charter GetCharterContract(Company introducer, VesselInCompany vesselInCompany, CharteringPartyType introducerType, DateTime stratDate) { switch (introducerType) { case CharteringPartyType.ShipOwner: //If the given company is in the role of ShipOwner, it will be inferred that //the pricing type must be fetched from Charter-Out contract. var foundCharterOut = charteringDomainService.GetCharterOutStart(introducer, vesselInCompany, stratDate); //TODO: State of CharterOut must be submitted. if (foundCharterOut == null /*|| foundCharterOut.State != States.Submitted*/) throw new BusinessRuleException("CharterOutForPricingType", "Charter-Out contract not found."); return foundCharterOut; case CharteringPartyType.Charterer: //If the given company is in the role of Charterer, it will be inferred that //the pricing type must be fetched from Charter-In contract. var foundCharterIn = charteringDomainService.GetCharterInStart(introducer, vesselInCompany, stratDate); if (foundCharterIn == null /*|| foundCharterIn.State != States.Submitted*/) throw new BusinessRuleException("CharterInForPricingType", "Charter-In contract not found."); return foundCharterIn; default: throw new InvalidArgument("IntroducerType"); } }
//================================================================================ private List<PricingValue> getCharterPartyBasedPricingValues(Company introducer, VesselInCompany vesselInCompany, CharteringPartyType introducerType, DateTime stratDate) { var charterContract = this.GetCharterContract(introducer, vesselInCompany, introducerType, stratDate); //TODO: OffhireFee might not be set. return charterContract.CharterItems.Select(ci => new PricingValue() { Good = ci.Good, Currency = ci.OffhireFee == 0 ? null : charterContract.Currency, Fee = ci.OffhireFee == 0 ? null : (decimal?)ci.OffhireFee }).ToList(); }
public virtual void StartCharterOut(VesselInCompany vesselInCompany) { throw new InvalidStateException("StartCharterOut", string.Format("Cannot start the Charter Out of the vessel as it is in '{0}' state.", this.State)); }
//================================================================================ public List<PricingValue> GetPricingValues(Company introducer, VesselInCompany vesselInCompany, DateTime startDateTime, Currency currency, DateTime currencyDateTime) { var pricingValues = GetPricingValues(introducer, vesselInCompany, startDateTime); var result = new List<PricingValue>(); foreach (var pricingValue in pricingValues) { decimal? feeInVoucherCurrency = null; if (pricingValue.Fee.HasValue && pricingValue.Currency != null) feeInVoucherCurrency = currencyDomainService.ConvertPrice(pricingValue.Fee.Value, pricingValue.Currency, currency, currencyDateTime); result.Add(new PricingValue() { Currency = currency, Good = pricingValue.Good, Fee = feeInVoucherCurrency }); } return result; }