public CharterIn CreateCharterIn(long id, long chartererId, long ownerId, long vesselInCompanyId, long currencyId,
                            DateTime actionDate,
                            List<CharterItem> charterItems,
                            List<InventoryOperation> inventoryOperationItems
                           , CharterType charterType, CharterEndType charterEndType, OffHirePricingType offHirePricingType)
        {
            var charterIn = new CharterIn(id, chartererId, ownerId, vesselInCompanyId,
                               currencyId, actionDate,
                               charterItems, inventoryOperationItems
                              , charterType, charterEndType, offHirePricingType,
                              _charterInDomainService, _charterOutDomainService,
                              _eventPublisher);

            var init = this._workflowRepository.Single(c => c.WorkflowEntity == WorkflowEntities.CharterIn && c.CurrentWorkflowStage == WorkflowStages.Initial);
            if (init == null)
                throw new ObjectNotFound("CharterInitialStep");

            var charterWorkflowLog = new CharterWorkflowLog(charterIn, WorkflowEntities.CharterIn, DateTime.Now, WorkflowActions.Init,
                //TODO: Fake ActorId
                1101, "", init.Id, true);

            charterIn.ApproveWorkflows.Add(charterWorkflowLog);

            return charterIn;
        }
Exemple #2
0
        public CharterOut(long id, long chartererId, long ownerId, long vesselInCompanyId, long CurrencyId,
                          DateTime actionDate, List<CharterItem> charterItems,
                          List<InventoryOperation> inventoryOperationItems,
                          CharterType charterType, CharterEndType charterEndType,
                          OffHirePricingType offHirePricingType, ICharterInDomainService charterInDomainService
            , ICharterOutDomainService charterOutDomainService, IEventPublisher eventPublisher)
            : base(id, chartererId, ownerId, vesselInCompanyId, CurrencyId,
                  actionDate, charterItems, inventoryOperationItems,
                  charterType, charterEndType, charterInDomainService, charterOutDomainService, eventPublisher)
        {
            this.OffHirePricingType = offHirePricingType;
            this._eventPublisher.RegisterHandler<CharterOutApproveArg>(new InventorySubscriber());
            this._eventPublisher.RegisterHandler<CharterOutFinalApproveArg>(new InventorySubscriber());
            this._eventPublisher.RegisterHandler<CharterOutDisApproveArg>(new InventorySubscriber());

            #region bz

            if (this.CharterType == CharterType.Start)
            {

                //B74
                IsNotSameChatererOwner(ownerId, chartererId);
                //B29
                IsValidateCharterOutStartProp();
                //B23
                IsValidStartDate();
                //B2
                IsValidCharterInStartDate();
                //B22
                IsVesselOwnedOrCharterIn();
                //B28
                HasVesselCharterOutStart(vesselInCompanyId);
                //B59
                CompareOffhirePricing();

            }
            else
            {
                //B36
                CheckPeriodCharterInValid();
                //B37
                IsNextCharterStartDateGreaterThanActionDate();
                //B31
                ExistFinalApprove();
                //B35
                IsNotVesselCharterIn(VesselInCompanyId.Value);
                //B43
                HasVesselCharterOutEnd(VesselInCompanyId.Value);
                //B45
                IsValidEndDate();
                //51
                IsValidateCharterEnd(actionDate, CurrencyId, charterEndType);

                //B34

            }
            #endregion
        }
 public void AddEnd( long chartererId, long ownerId, long vesselInCompanyId, long currencyId,
                  DateTime actionDate
                 ,CharterEndType charterEndType ,OffHirePricingType offHirePricingType)
 {
     var entity = _charterFactory.CreateCharterOut( 0,chartererId, ownerId, vesselInCompanyId, currencyId, actionDate, null, null,
                                       CharterType.End, charterEndType, offHirePricingType);
     _charterOutRepository.Add(entity);
     _unitOfWorkScope.Commit();
 }
Exemple #4
0
        internal CharterIn(long id, long chartererId, long ownerId, long vesselInCompanyId, long CurrencyId,
                       DateTime actionDate, List<CharterItem> charterItems,
                       List<InventoryOperation> inventoryOperationItems,
                       CharterType charterType, CharterEndType charterEndType,
                       OffHirePricingType offHirePricingType,
            ICharterInDomainService charterInDomainService,
            ICharterOutDomainService charterOutDomainService,
            IEventPublisher eventPublisher
            )
            : base(id, chartererId, ownerId, vesselInCompanyId, CurrencyId,
                  actionDate, charterItems, inventoryOperationItems,
                  charterType, charterEndType, charterInDomainService, charterOutDomainService, eventPublisher)
        {
            this.OffHirePricingType = offHirePricingType;
            this._eventPublisher.RegisterHandler<CharterInApproveArg>(new InventorySubscriber());
            this._eventPublisher.RegisterHandler<CharterInFinalApproveArg>(new InventorySubscriber());
            this._eventPublisher.RegisterHandler<CharterInDisApproveArg>(new InventorySubscriber());

            #region BZ

            if (CharterType == CharterType.Start)
            {

                //B74
                IsNotSameChatererOwner(ownerId, chartererId);
                //B4
                IsValidateCharterInStartProp();
                //B17
                HasVesselCharterInStart();
                //B2
                IsValidCharterInStartDate();
                //B59
                CompareOffhirePricing();

            }
            else
            {
                //B45
                IsValidEndDate();

                //B48
                ExistFinalApprove();

                //B58
                HasVesselCharterInEnd();
                //B55
                IsVesselCharterOut();

                //B49

                //B56
                IsEndDateGreaterThanLastCharterOutEndDate();

            }
            #endregion
        }
Exemple #5
0
 //B18
 void IsValidChangeOffhirePricing(OffHirePricingType offHirePricingType)
 {
     if (_charterOutDomainService.GetCharterState(this.Id) == States.SubmitRejected)
     {
         IOffhireDomainService offhireDomainService = ServiceLocator.Current.GetInstance<IOffhireDomainService>();
         var res = _charterOutDomainService.GetCharterEnd(this.Id);
         if (res != null)
             if (offhireDomainService.
                      IsOffhireRegisteredForVessel(this.VesselInCompanyId.Value, this.ActionDate, res.ActionDate))
                 if (this.OffHirePricingType != offHirePricingType)
                     throw new BusinessRuleException("B18", "Offhire Registerd for this charter in");
     }
 }
Exemple #6
0
        public void Update(long id, long chartererId, long ownerId, long vesselInCompanyId, long CurrencyId,
                       DateTime actionDate, List<CharterItem> charterItems,
                       List<InventoryOperation> inventoryOperationItems,
                       CharterType charterType, CharterEndType charterEndType, OffHirePricingType offHirePricingType)
        {
            #region bz
            if (CharterType == CharterType.Start)
            {

                //B74
                IsNotSameChatererOwner(ownerId, chartererId);
                //B18
                IsValidChangeOffhirePricing(offHirePricingType);

                //B19
                IsNotFinalApprove();

                //B22
                IsVesselOwnedOrCharterIn();

                //B23
                IsValidStartDate();

                //B29
                IsValidateCharterOutStartProp();

                //B2
                IsValidCharterInStartDate();

                //B59
                CompareOffhirePricing();

                //B30
                IsChangePropRejectSubmitted(chartererId, vesselInCompanyId, CurrencyId,
                                            actionDate);

            }
            else
            {
                //B31
                ExistFinalApprove();
                //B35
                IsNotVesselCharterIn(VesselInCompanyId.Value);
                //B36
                CheckPeriodCharterInValid();
                //B37
                IsNextCharterStartDateGreaterThanActionDate();
                //B45
                IsValidEndDate();
                //B51
                IsValidateCharterEnd(actionDate, CurrencyId, charterEndType);
                //B33
                IsNotFinalApprove();

                //B44
                IsChangeValidForSubmitRejectedCharter(actionDate, CurrencyId, charterEndType);

                //B34
            }

            #endregion
            this.OffHirePricingType = offHirePricingType;
            this.UpdatePrivateProp(id, chartererId, ownerId, vesselInCompanyId, CurrencyId,
                          actionDate, charterItems,
                         inventoryOperationItems,
                          charterType, charterEndType);
        }
        public void UpdateStart(long id, long chartererId, long ownerId, long vesselInCompanyId, long currencyId,
                            DateTime actionDate,
                            OffHirePricingType offHirePricingType)
        {
            var entity =_charterFactory.ReCreateCharterOut(_charterOutRepository.GetCharterStartById(id));
            if (entity == null)
                throw new ObjectNotFound("Charter Out", id);
            entity.Update(id,  chartererId,  ownerId,  vesselInCompanyId,  currencyId,
                             actionDate,null,null,CharterType.Start, CharterEndType.None,
                             offHirePricingType);

            _charterOutRepository.Update(entity);
            try
            {
              _unitOfWorkScope.Commit();
            }
            catch (OptimisticConcurrencyException exception)
            {

                throw new ConcurencyException("Charter Out Start");
            }
        }
Exemple #8
0
        //================================================================================
        private Offhire(
            long referenceNumber,
            DateTime startDateTime,
            DateTime endDateTime,
            CharteringPartyType introducerType,
            Company introducer,
            VesselInCompany vesselInCompany,
            Voyage voyage,
            ActivityLocation offhireLocation,
            DateTime voucherDate,
            Currency voucherCurrency,
            string pricingReferenceNumber,
            OffHirePricingType pricingReferenceType,
            List<OffhireDetail> offhireDetails)
        {
            //This is used to create instances by reflection to Insert Seed Data into DB.
            this.ReferenceNumber = referenceNumber;
            this.StartDateTime = startDateTime;
            this.EndDateTime = endDateTime;
            this.IntroducerType = introducerType;
            this.Introducer = introducer;
            this.VesselInCompany = vesselInCompany;
            this.Voyage = voyage;
            this.OffhireLocation = offhireLocation;
            this.VoucherDate = voucherDate;
            this.VoucherCurrencyId = voucherCurrency.Id;
            this.VoucherCurrency = voucherCurrency;
            this.PricingReference = new OffhirePricingReference() { Type = pricingReferenceType, Number = pricingReferenceNumber };

            this.OffhireDetails = offhireDetails;
            this.ApproveWorkflows = new List<OffhireWorkflowLog>();
        }
Exemple #9
0
 //================================================================================
 private void validateOffhirePricingTypeForCharteredOutVessel(
     Company introducer, VesselInCompany vesselInCompany, Voyage voyage, DateTime satrtDate, OffHirePricingType offhirePricingType,
     IOffhireDomainService offhireDomainService)
 {
     switch (offhirePricingType)
     {
         case OffHirePricingType.CharterPartyBase:
             break;
         case OffHirePricingType.IssueBase:
             this.validateRelevantCharterInOffhireExistanceInChartererCompanyForCharterOutVessel(
                 introducer, vesselInCompany, satrtDate, offhireDomainService);
             break;
         default:
             throw new InvalidArgument("OffhirePricingTypeForCharteredOut");
     }
 }
Exemple #10
0
 //================================================================================
 private void validateOffhirePricingTypeForCharteredInVessel(
     Voyage voyage, OffHirePricingType offhirePricingType, IOffhireDomainService offhireDomainService)
 {
     switch (offhirePricingType)
     {
         case OffHirePricingType.CharterPartyBase:
             break;
         case OffHirePricingType.IssueBase:
             this.validateVoyagePricedIssueExistanceForCharterInIssueBasedPricingVessel(
                 voyage, offhireDomainService);
             break;
         default:
             throw new InvalidArgument("OffhirePricingTypeForCharteredIn");
     }
 }
Exemple #11
0
        //================================================================================
        private void validateOffhirePricingType(
            Company introducer, VesselInCompany vesselInCompany, Voyage voyage, DateTime satrtDate, CharteringPartyType partyType,
            OffHirePricingType offhirePricingType, IOffhireDomainService offhireDomainService)
        {
            switch (partyType)
            {
                case CharteringPartyType.Charterer:

                    this.validateOffhirePricingTypeForCharteredInVessel(
                        voyage, offhirePricingType, offhireDomainService);

                    break;

                case CharteringPartyType.ShipOwner:

                    this.validateOffhirePricingTypeForCharteredOutVessel(
                        introducer, vesselInCompany, voyage, satrtDate, offhirePricingType, offhireDomainService);

                    break;
            }
        }
Exemple #12
0
        public void Update(long id, long chartererId, long ownerId, long vesselInCompanyId, long currencyId,
                       DateTime actionDate, List<CharterItem> charterItems,
                       List<InventoryOperation> inventoryOperationItems,
                       CharterType charterType, CharterEndType charterEndType, OffHirePricingType offHirePricingType)
        {
            #region bz

            if (CharterType == CharterType.Start)
            {

                //B74
                IsNotSameChatererOwner(ownerId, chartererId);
                //B4
                IsValidateCharterInStartProp();
                //B13
                IsChangePropRejectSubmitted(ownerId, vesselInCompanyId, currencyId, actionDate);
                //B1
                IsNotFinalApprove();

                //B2
                IsValidCharterInStartDate();
                //B18
                IsValidChangeOffhirePricing(offHirePricingType);
                //B59
                CompareOffhirePricing();
            }
            else
            {
                //B32
                IsValidateCharterEnd(actionDate, currencyId, charterEndType);

                //B45
                IsValidEndDate();

                //B46
                IsNotFinalApprove();

                //B48
                ExistFinalApprove();

                //B53
                IsChangeValidForSubmitRejectedCharter(actionDate, currencyId, charterEndType);
                //B55
                IsVesselCharterOut();

                //B56
                IsEndDateGreaterThanLastCharterOutEndDate();

            }

            #endregion

            this.OffHirePricingType = offHirePricingType;
            this.UpdatePrivateProp(id, chartererId, ownerId, vesselInCompanyId, currencyId,
                        actionDate, charterItems,
                       inventoryOperationItems,
                        charterType, charterEndType);
        }