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
 public Charter(long id, long chartererId, long ownerId, long vesselInCompanyId, long CurrencyId,
                    DateTime actionDate, List<CharterItem> charterItems,
                    List<InventoryOperation> inventoryOperationItems,
                    CharterType charterType, CharterEndType charterEndType,
     ICharterInDomainService charterInDomainService, ICharterOutDomainService charterOutDomainService
     , IEventPublisher eventPublisher)
     : this()
 {
     this.Id = id;
     this.ChartererId = chartererId;
     this.OwnerId = ownerId;
     this.VesselInCompanyId = vesselInCompanyId;
     this.CurrencyId = CurrencyId;
     this.ActionDate = actionDate;
     this.CharterItems = charterItems;
     this.InventoryOperationItems = inventoryOperationItems;
     this.CharterType = charterType;
     this.CharterEndType = charterEndType;
     _charterInDomainService = charterInDomainService;
     _charterOutDomainService = charterOutDomainService;
     _eventPublisher = eventPublisher;
 }
Exemple #6
0
 //B44
 void IsChangeValidForSubmitRejectedCharter(DateTime actionDate, long currencyId, CharterEndType charterEndType)
 {
     if (_charterOutDomainService.GetCharterState(this.Id) == States.SubmitRejected)
         if (!(actionDate == this.ActionDate
             && currencyId == this.CurrencyId
             && charterEndType == this.CharterEndType))
             throw new BusinessRuleException("B53", "Charter End Invalid");
 }
Exemple #7
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 UpdateEnd(long id, long chartererId, long ownerId, long vesselInCompanyId, long currencyId,
                           DateTime actionDate,
                           CharterEndType charterEndType)
        {
            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.End, charterEndType,OffHirePricingType.IssueBase);

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

                throw new ConcurencyException("Charter Out Start");
            }
        }
Exemple #9
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);
        }
Exemple #10
0
        protected void UpdatePrivateProp(long id, long chartererId, long ownerId, long vesselInCompanyId, long CurrencyId,
                         DateTime actionDate, List<CharterItem> charterItems,
                         List<InventoryOperation> inventoryOperationItems,
                         CharterType charterType, CharterEndType charterEndType
                         )
        {
            this.Id = id;
            this.ChartererId = chartererId;
            this.CurrencyId = CurrencyId;

            this.OwnerId = ownerId;
            this.VesselInCompanyId = vesselInCompanyId;
            this.ActionDate = actionDate;
            this.CharterType = charterType;
            this.CharterEndType = charterEndType;
        }
Exemple #11
0
 //B32,B51
 protected void IsValidateCharterEnd(DateTime actionDate, long currencyId, CharterEndType charterEndType)
 {
     if (!(actionDate != null
         && currencyId > 0
         && charterEndType != CharterEndType.None))
         throw new BusinessRuleException("B32", "Charter End Invalid");
 }