Esempio n. 1
0
 public OffhireWorkflowLog(
     Offhire offhire,
     WorkflowEntities actionEntity,
     DateTime actionDate,
     WorkflowActions? workflowAction,
     long actorUserId,
     string remark, long currentWorkflowStepId, bool active)
     : base(actionEntity, workflowAction, actorUserId, actionDate, remark, currentWorkflowStepId, active)
 {
     Offhire = offhire;
 }
Esempio n. 2
0
        internal OffhireDetail(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
            : this()
        {
            this.validateOffhire(offhire, offhireDomainService);

            this.validateValues(quantity, feeInVoucherCurrency, feeInMainCurrency, good, unit, tank, offhire, offhireDomainService,
                tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.Quantity = quantity;
            this.FeeInVoucherCurrency = feeInVoucherCurrency;
            this.FeeInMainCurrency = feeInMainCurrency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Offhire = offhire;
        }
Esempio n. 3
0
 //================================================================================
 private OffhireDetail(
     decimal quantity,
     decimal feeInVoucherCurrency,
     decimal feeInMainCurrency,
     Good good,
     GoodUnit unit,
     Tank tank,
     Offhire offhire)
     : this()
 {
     //This constructor added to be used for insert into DB.
     this.Quantity = quantity;
     this.FeeInVoucherCurrency = feeInVoucherCurrency;
     this.FeeInMainCurrency = feeInMainCurrency;
     this.Good = good;
     this.Unit = unit;
     this.Tank = tank;
     this.Offhire = offhire;
 }
Esempio n. 4
0
 public void NotifyOffhireCancelled(Offhire offhire)
 {
 }
 public void ValidateMiddleApprove(Offhire offhire)
 {
     offhire.ValidateMiddleApprove(this.offhireDomainService, tankDomainService, currencyDomainService,
         goodDomainService, goodUnitDomainService);
 }
Esempio n. 6
0
 public void NotifySubmittingOffhire(Offhire offhire)
 {
 }
 public void RejectSubmittedState(Offhire offhire, SubmitRejectedState submitRejectedState)
 {
     offhire.RejectSubmittedState(submitRejectedState);
 }
 public void Submit(Offhire offhire, SubmittedState submittedState)
 {
     offhire.Submit(submittedState, this.offhireDomainService, eventNotifier,
         tankDomainService, currencyDomainService,
         goodDomainService, goodUnitDomainService);
 }
 //================================================================================
 public bool IsOffhireDeletePermitted(Offhire offhire)
 {
     return isOffhireOpen.IsSatisfiedBy(offhire);
 }
Esempio n. 10
0
        //================================================================================
        private void validateOffhire(Offhire offhire, IOffhireDomainService offhireDomainService)
        {
            if (offhire == null)
                throw new InvalidArgument("Offhire");

            //Commented intentionally due to registration of Details along with the Offhire.
            //if (offhireDomainService.Get(offhire.Id) == null)
            //    throw new ObjectNotFound("Offhire", offhire.Id);
        }
Esempio n. 11
0
        //================================================================================
        private void validateValues(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateTank(tank, offhire, tankDomainService);

            this.validateGood(good, goodDomainService);
            this.validateGoodInTank(tank, good, offhire);
            this.validateGoodToBeUniqueInDetails(good, offhire);

            this.validateQuantity(quantity);

            this.validateFeeInMainCurrency(feeInMainCurrency);

            this.validateUnit(unit, goodUnitDomainService);
            this.validateGoodUnitInCompany(offhire.Introducer, good, unit);

            this.validateFeeInVoucherCurrency(feeInVoucherCurrency, offhire, good, offhireDomainService, currencyDomainService);
        }
Esempio n. 12
0
 //================================================================================
 public void Delete(Offhire offhire)
 {
     offhireRepository.Delete(offhire);
 }
Esempio n. 13
0
        //================================================================================
        private void validateGoodInTank(Tank tank, Good good, Offhire offhire)
        {
            if (good == null)
                throw new InvalidArgument("Good");

            if (tank != null)
            {
                var registeredTanksForGoodCount = offhire.OffhireDetails.Count(od =>
                    (od.Id != this.Id || (od.Id == NOT_REGISTERED_ID && this.Id == NOT_REGISTERED_ID)) &&
                    od.Tank != null && od.Tank.Id == tank.Id && od.Good.Id == good.Id);

                if (registeredTanksForGoodCount > 0)
                    throw new BusinessRuleException("", string.Format("The same Good '{0}' in Tank is already defined.", good.Name));
            }
        }
Esempio n. 14
0
 //================================================================================
 private void validateTankToBeInVesselTanks(Tank tank, Offhire offhire)
 {
     if (offhire.VesselInCompany.Tanks.Count > 0 && tank != null && offhire.VesselInCompany.Tanks.Count(t => t.Id == tank.Id) == 0)
         throw new BusinessRuleException("", "Selected Tank is not defined for Vessel.");
 }
Esempio n. 15
0
 //================================================================================
 private void validateTankForVesselWithTanks(Tank tank, Offhire offhire)
 {
     if (offhire.VesselInCompany.Tanks.Count > 0 && tank == null)
         throw new BusinessRuleException("", "Tank must be selected.");
 }
Esempio n. 16
0
 //================================================================================
 private void validateTankForVesselWithoutTanks(Tank tank, Offhire offhire)
 {
     if (offhire.VesselInCompany.Tanks.Count == 0 && tank != null)
         throw new BusinessRuleException("", "Tank should not be selected for Vessel.");
 }
Esempio n. 17
0
        //================================================================================
        private void validateTank(Tank tank, Offhire offhire, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            //validateTankForVesselWithTanks(tank, offhire);

            //validateTankForVesselWithoutTanks(tank, offhire);

            //validateTankToBeInVesselTanks(tank, offhire);
        }
Esempio n. 18
0
 //================================================================================
 public List<PricingValue> GetCharterPartyBasedPricingValues(Offhire offhire)
 {
     return getCharterPartyBasedPricingValues(offhire.Introducer, offhire.VesselInCompany, offhire.IntroducerType, offhire.StartDateTime);
 }
Esempio n. 19
0
        //================================================================================
        private void validateFeeInVoucherCurrency(decimal feeInVoucherCurrency, Offhire offhire, Good good, IOffhireDomainService offhireDomainService, ICurrencyDomainService currencyDomainService)
        {
            if (feeInVoucherCurrency < 0)
                throw new BusinessRuleException("", string.Format("Fee In Voucher Currency is negative for '{0}'.", good.Name));

            var pricingValue = offhireDomainService.GetPricingValue(offhire.Introducer, offhire.VesselInCompany, offhire.StartDateTime, good);

            switch (offhire.PricingReference.Type)
            {
                case OffHirePricingType.CharterPartyBase:

                    if (pricingValue != null &&
                        pricingValue.Fee.HasValue && pricingValue.Currency != null)
                    {
                        var charterPartyConvertedOffhireFee = currencyDomainService.ConvertPrice(pricingValue.Fee.Value, pricingValue.Currency.Id, offhire.VoucherCurrencyId, offhire.VoucherDate);

                        if (feeInVoucherCurrency != charterPartyConvertedOffhireFee)
                            throw new BusinessRuleException("", string.Format("The Offhire Fee for Good '{0}' is invlaid.", good.Name));
                    }

                    break;

                case OffHirePricingType.IssueBase:

                    if (pricingValue == null || !pricingValue.Fee.HasValue || pricingValue.Currency == null)
                        throw new BusinessRuleException("", string.Format("IssueBased Pricing for Good '{0}' not found.", good.Name));

                    var issueBaseConvertedOffhireFee = currencyDomainService.ConvertPrice(pricingValue.Fee.Value, pricingValue.Currency.Id, offhire.VoucherCurrencyId, offhire.VoucherDate);

                    if (feeInVoucherCurrency != issueBaseConvertedOffhireFee)
                        throw new BusinessRuleException("", string.Format("The Offhire Fee for Good '{0}' is invlaid.", good.Name));

                    break;

                default:
                    throw new InvalidArgument("PricingReferenceType");
            }
        }
Esempio n. 20
0
 //================================================================================
 public Charter GetOffhireCharterContract(Offhire offhire)
 {
     return GetCharterContract(offhire.Introducer, offhire.VesselInCompany, offhire.IntroducerType, offhire.StartDateTime);
 }
 public void Close(Offhire offhire, ClosedState closedState)
 {
     offhire.Close(closedState);
 }
Esempio n. 22
0
 //================================================================================
 public bool IsOffhireEditPermitted(Offhire offhire)
 {
     return isOffhireOpen.IsSatisfiedBy(offhire) || isOffhireSubmitRejected.IsSatisfiedBy(offhire);
 }
Esempio n. 23
0
 //================================================================================
 private void validateGoodToBeUniqueInDetails(Good good, Offhire offhire)
 {
     if (offhire.OffhireDetails.Count(od =>
         (od.Id != this.Id || (od.Id == NOT_REGISTERED_ID && this.Id == NOT_REGISTERED_ID)) &&
         od.Good.Id == good.Id) != 0)
         throw new BusinessRuleException("", string.Format("The Good '{0}' has other records in Offhire Details.", good.Name));
 }
Esempio n. 24
0
 //================================================================================
 private void setEditProperties(Offhire offhire, OffhireDto offhireDto)
 {
     offhireDto.IsOffhireEditPermitted = offhireDomainService.IsOffhireEditPermitted(offhire);
     offhireDto.IsOffhireDeletePermitted = offhireDomainService.IsOffhireDeletePermitted(offhire);
 }
 public void Cancel(Offhire offhire, CancelledState cancelledState)
 {
     offhire.Cancel(cancelledState, eventNotifier);
 }