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;
 }
示例#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;
        }
示例#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;
 }
示例#4
0
 public void NotifyOffhireCancelled(Offhire offhire)
 {
 }
 public void ValidateMiddleApprove(Offhire offhire)
 {
     offhire.ValidateMiddleApprove(this.offhireDomainService, tankDomainService, currencyDomainService,
         goodDomainService, goodUnitDomainService);
 }
示例#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);
 }
示例#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);
        }
示例#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);
        }
 //================================================================================
 public void Delete(Offhire offhire)
 {
     offhireRepository.Delete(offhire);
 }
示例#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));
            }
        }
示例#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.");
 }
示例#15
0
 //================================================================================
 private void validateTankForVesselWithTanks(Tank tank, Offhire offhire)
 {
     if (offhire.VesselInCompany.Tanks.Count > 0 && tank == null)
         throw new BusinessRuleException("", "Tank must be selected.");
 }
示例#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.");
 }
示例#17
0
        //================================================================================
        private void validateTank(Tank tank, Offhire offhire, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            //validateTankForVesselWithTanks(tank, offhire);

            //validateTankForVesselWithoutTanks(tank, offhire);

            //validateTankToBeInVesselTanks(tank, offhire);
        }
 //================================================================================
 public List<PricingValue> GetCharterPartyBasedPricingValues(Offhire offhire)
 {
     return getCharterPartyBasedPricingValues(offhire.Introducer, offhire.VesselInCompany, offhire.IntroducerType, offhire.StartDateTime);
 }
示例#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");
            }
        }
 //================================================================================
 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);
 }
 //================================================================================
 public bool IsOffhireEditPermitted(Offhire offhire)
 {
     return isOffhireOpen.IsSatisfiedBy(offhire) || isOffhireSubmitRejected.IsSatisfiedBy(offhire);
 }
示例#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));
 }
 //================================================================================
 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);
 }