public OffhireApplicationService(
            IOffhireFactory offhireFactory,
            IOffhireRepository offhireRepository,
            IUnitOfWorkScope unitOfWorkScope,
            IOffhireDomainService offhireDomainService,
            IEntityConfigurator<Offhire> offhireConfigurator,
            IVesselInCompanyDomainService vesselDomianService,
            IVoyageDomainService voyageDomianService,
            ICompanyDomainService companyDomainService,
            ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService,
            IGoodUnitDomainService goodUnitDomainService,
            ITankDomainService tankDomainService,
            IActivityLocationDomainService activityLocationDomainService,
            IOffhireManagementSystemDomainService offhireManagementSystemDomainService)
        {
            this.offhireFactory = offhireFactory;
            this.offhireRepository = offhireRepository;
            this.unitOfWorkScope = unitOfWorkScope;

            this.offhireDomainService = offhireDomainService;
            this.vesselDomianService = vesselDomianService;
            this.companyDomainService = companyDomainService;
            this.currencyDomainService = currencyDomainService;
            this.goodDomainService = goodDomainService;
            this.goodUnitDomainService = goodUnitDomainService;
            this.tankDomainService = tankDomainService;
            this.activityLocationDomainService = activityLocationDomainService;
            this.offhireManagementSystemDomainService = offhireManagementSystemDomainService;
            this.voyageDomianService = voyageDomianService;

            this.offhireDomainService.SetConfigurator(offhireConfigurator);
        }
Ejemplo n.º 2
0
 public OffhireFactory(
     IEntityConfigurator<Offhire> offhireConfigurator,
     IWorkflowRepository workflowRepository,
     IOffhireDomainService offhireDomainService,
     IVesselInCompanyDomainService vesselDomainService,
     ICompanyDomainService companyDomainService,
     ITankDomainService tankDomainService,
     ICurrencyDomainService currencyDomainService,
     IGoodDomainService goodDomainService,
     IGoodUnitDomainService goodUnitDomainService,
     IOffhireManagementSystemDomainService offhireManagementSystemDomainService,
     IVoyageDomainService voyageDomainService,
     IActivityLocationDomainService activityLocationDomainService)
 {
     this.offhireConfigurator = offhireConfigurator;
     this.workflowRepository = workflowRepository;
     this.offhireDomainService = offhireDomainService;
     this.vesselDomainService = vesselDomainService;
     this.companyDomainService = companyDomainService;
     this.tankDomainService = tankDomainService;
     this.currencyDomainService = currencyDomainService;
     this.goodDomainService = goodDomainService;
     this.goodUnitDomainService = goodUnitDomainService;
     this.offhireManagementSystemDomainService = offhireManagementSystemDomainService;
     this.voyageDomainService = voyageDomainService;
     this.activityLocationDomainService = activityLocationDomainService;
 }
Ejemplo n.º 3
0
        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 FuelReportApplicationService(
     IUnitOfWorkScope unitOfWorkScope,
     ICurrencyDomainService currencyDomainService,
     IVoyageDomainService voyageDomainService,
     IFuelReportDomainService fuelReportDomainService,
     IApproveFlowApplicationService approveFlowApplicationService)
 {
     this.unitOfWorkScope = unitOfWorkScope;
     this.currencyDomainService = currencyDomainService;
     this.voyageDomainService = voyageDomainService;
     this.fuelReportDomainService = fuelReportDomainService;
     this.approveFlowApplicationService = approveFlowApplicationService;
 }
 public ApprovableFuelReportDomainService(
     IVoyageDomainService voyageDomainService,
     IFuelReportDomainService fuelReportDomainService,
     IInventoryOperationDomainService inventoryOperationDomainService,
     IGoodDomainService goodDomainService,
     IOrderDomainService orderDomainService,
     ICurrencyDomainService currencyDomainService,
     IBalanceDomainService balanceDomainService,
     IInventoryManagementDomainService inventoryManagementDomainService,
     IInventoryOperationNotifier inventoryOperationNotifier)
 {
     this.voyageDomainService = voyageDomainService;
     this.fuelReportDomainService = fuelReportDomainService;
     this.inventoryOperationDomainService = inventoryOperationDomainService;
     this.goodDomainService = goodDomainService;
     this.orderDomainService = orderDomainService;
     this.inventoryOperationNotifier = inventoryOperationNotifier;
     this.currencyDomainService = currencyDomainService;
     this.balanceDomainService = balanceDomainService;
     this.inventoryManagementDomainService = inventoryManagementDomainService;
 }
Ejemplo n.º 6
0
 public VoyageFacadeService(
     IVoyageDomainService voyageDomainService,
     IVoyageToVoyageDtoMapper voyageDtoMapper,
     IFuelReportDomainService fuelReportDomainService,
     IFuelReportFuelReportDtoMapper fuelReportDtoMapper,
     IInventoryOperationDomainService inventoryOperationDomainService,
     IInventoryOperationToInventoryOperationDtoMapper inventoryOperationDtoMapper,
     IVoyageLogDomainService voyageLogDomainService,
     IVoyageLogToVoyageLogDtoMapper voyageLogDtoMapper,
     IGoodToGoodDtoMapper goodDtoMapper)
 {
     this.voyageDomainService = voyageDomainService;
     this.voyageDtoMapper = voyageDtoMapper;
     //this.fuelReportDomainService = fuelReportDomainService;
     this.fuelReportDtoMapper = fuelReportDtoMapper;
     this.inventoryOperationDomainService = inventoryOperationDomainService;
     this.inventoryOperationDtoMapper = inventoryOperationDtoMapper;/**/
     this.voyageLogDtoMapper = voyageLogDtoMapper;
     this.goodDtoMapper = goodDtoMapper;
     this.voyageLogDomainService = voyageLogDomainService;
 }
Ejemplo n.º 7
0
        public OffhireDomainService(
            IOffhireRepository offhireRepository,
            IRepository<OffhireDetail> offhireDetailRepository,
            ICharteringDomainService charteringDomainService,
            IInventoryManagementDomainService inventoryManagementDomainService,
            IFuelReportDomainService fuelReportDomainService,
            IVesselInCompanyDomainService vesselDomainService, IVoyageDomainService voyageDomainService,
            ICurrencyDomainService currencyDomainService)
        {
            this.offhireRepository = offhireRepository;
            this.offhireDetailRepository = offhireDetailRepository;
            this.charteringDomainService = charteringDomainService;
            this.inventoryManagementDomainService = inventoryManagementDomainService;
            this.fuelReportDomainService = fuelReportDomainService;
            this.vesselDomainService = vesselDomainService;
            this.voyageDomainService = voyageDomainService;
            this.currencyDomainService = currencyDomainService;

            this.isOffhireOpen = new IsOffhireOpen();
            this.isOffhireSubmitted = new IsOffhireSubmitted();
            this.isOffhireSubmitRejected = new IsOffhireSubmitRejected();
            this.isOffhireCancelled = new IsOffhireCancelled();
        }
 public FuelReportDomainService(
     IFuelReportRepository fuelReportRepository,
     IVoyageDomainService voyageDomainService,
     IInventoryOperationDomainService inventoryOperationDomainService,
     IInventoryOperationRepository inventoryOperationRepository,
     IInventoryOperationFactory inventoryOperationFactory,
     IOrderDomainService orderDomainService,
     IInventoryManagementDomainService inventoryManagementDomainService,
     ICharteringDomainService charteringDomainService)
 {
     this.fuelReportRepository = fuelReportRepository;
     this.voyageDomainService = voyageDomainService;
     this.inventoryOperationDomainService = inventoryOperationDomainService;
     this.inventoryOperationRepository = inventoryOperationRepository;
     this.inventoryOperationFactory = inventoryOperationFactory;
     this.orderDomainService = orderDomainService;
     this.inventoryManagementDomainService = inventoryManagementDomainService;
     this.charteringDomainService = charteringDomainService;
     this.isFuelReportNotCancelled = new IsFuelReportNotCancelled();
     this.isFuelReportIssued = new IsFuelReportIssued(inventoryOperationDomainService);
     this.isFuelReportInFinalApprovedState = new IsFuelReportClosed();
     this.isFuelReportOperational = new IsFuelReportOperational();
     isFuelReportSubmitted = new IsFuelReportSubmitted();
 }
Ejemplo n.º 9
0
        //===================================================================================
        public void UpdateVoyageId(long? voyageId, IVoyageDomainService voyageDomainService)
        {
            this.CheckToBeOperational();

            //BR_FR1
            this.validateToBeInOpenState();

            validateVoyageId(voyageId, voyageDomainService);

            VoyageId = voyageId;
        }
Ejemplo n.º 10
0
 //===================================================================================
 /// <summary>
 /// BR_FR2
 /// </summary>
 private void validateVoyageValue(long? voyageId, IVoyageDomainService voyageDomainService)
 {
     if (!voyageId.HasValue ||
         !(
             voyageDomainService.IsVoyageAvailable(voyageId.Value) &&
             isVoyageDurationAndVesselValid(voyageId, voyageDomainService)
         )
     )
         throw new BusinessRuleException("BR_FR2", "Voyage is not Valid.");
 }
Ejemplo n.º 11
0
        //===================================================================================
        //private void validateVoyageExistance(long? voyageId)
        //{
        //    if (FuelReportType == FuelReportTypes.EndOfVoyage &&
        //        !voyageId.HasValue)
        //        throw new BusinessRuleException("BR_FR35", "Voyage is mandatory for EOV Fuel Report.");
        //}
        //===================================================================================
        /// <summary>
        /// BR_FR36
        /// </summary>
        private void validateVoyageEndDateForEndOfVoyageReportType(
            long? voyageId,
            IVoyageDomainService voyageDomainService)
        {
            if (FuelReportType == FuelReportTypes.EndOfVoyage &&
                voyageId.HasValue)
            {
                var givenVoyage = voyageDomainService.Get(voyageId.Value);

                if (!givenVoyage.EndDate.HasValue)
                    throw new BusinessRuleException("", "Voyage has not ended or its EndDate is not reported yet.");

                if (!(
                        givenVoyage.VesselInCompany.Id == this.VesselInCompanyId && //This is already checked in BR_FR2, but implemented due to Analysis indication.
                        (//Compare found voyage End Date with current fuel Report Date with the resolution of hour.
                        //TODO: value
                            EventDate.Date == givenVoyage.EndDate.Value.Date &&
                            EventDate.Hour == givenVoyage.EndDate.Value.Hour
                        )
                    )
                )
                {
                    throw new BusinessRuleException("BR_FR36", "Given Voyage is not match with Fuel Report Date and Vessel.");
                }
            }
        }
Ejemplo n.º 12
0
        //===================================================================================
        private void validateVoyageId(long? voyageId, IVoyageDomainService voyageDomainService)
        {
            //BR_FR2
            validateVoyageValue(voyageId, voyageDomainService);

            //BR_FR35
            validateVoyageForEndOfVoyageCondition(voyageId);

            //BR_FR36
            validateVoyageEndDateForEndOfVoyageReportType(voyageId, voyageDomainService);
        }
Ejemplo n.º 13
0
        //===================================================================================
        private void validateSubmittingState(IVoyageDomainService voyageDomainService,
            IFuelReportDomainService fuelReportDomainService, IInventoryOperationDomainService inventoryOperationDomainService, IGoodDomainService goodDomainService,
            IOrderDomainService orderDomainService, ICurrencyDomainService currencyDomainService,
            IInventoryManagementDomainService inventoryManagementDomainService)
        {
            validateToBeOpenOrSubmitRejected();

            validateVoyageId(this.VoyageId, voyageDomainService);

            //BR_FR37
            validatePreviousEndedVoyagesToBeIssued(
                voyageDomainService,
                fuelReportDomainService,
                inventoryOperationDomainService);

            //BR_FR38
            validatePreviousFuelReportsToBeFinalApproved(fuelReportDomainService);

            //BR_FR39
            validateFuelReportsOfPreviousDayForMandatoryType(
                fuelReportDomainService,
                goodDomainService);

            var isTheFirstReport = isCurrentFuelReportTheFirstOne(fuelReportDomainService);

            FuelReport previousFuelReport = getYesterdayLastFuelReport(fuelReportDomainService);

            validateFuelReportOfTheDayBefore(previousFuelReport, isTheFirstReport);

            foreach (var detailItem in this.FuelReportDetails)
            {
                FuelReportDetail fuelReportDetailOfYesterdayForRelevantGood =
                    getGoodRelevantFuelReportDetailOfYesterday(
                        detailItem.GoodId,
                        isTheFirstReport,
                        previousFuelReport);

                //All Edit Rules must be checked for details.
                detailItem.ValidateCurrentValues(
                    fuelReportDetailOfYesterdayForRelevantGood,
                    isTheFirstReport,
                    currencyDomainService);

                detailItem.ValidateTransferReferences(orderDomainService, inventoryManagementDomainService);
                detailItem.ValidateReceiveReferences(orderDomainService);
                detailItem.ValidateCorrectionReferences(isTheFirstReport, voyageDomainService, fuelReportDomainService);
            }
        }
Ejemplo n.º 14
0
        //===================================================================================
        /// <summary>
        /// BR_FR37
        /// </summary>
        private void validatePreviousEndedVoyagesToBeIssued(
            IVoyageDomainService voyageDomainService,
            IFuelReportDomainService fuelReportDomainService,
            IInventoryOperationDomainService inventoryOperationDomainService)
        {
            var notIssuedEOVFuelReportsOfPreviousVoyages = fuelReportDomainService.GetNotIssuedEOVFuelReportsOfPreviousVoyages(this);

            if (notIssuedEOVFuelReportsOfPreviousVoyages.Count != 0)
                throw new BusinessRuleException("BR_FR37", "There are some ended voyages before current Fuel Report with no issue for End Of Voyage Fuel Report.");
        }
Ejemplo n.º 15
0
        //================================================================================
        private void validateCreation(
            long referenceNumber,
            DateTime startDateTime,
            DateTime endDateTime,
            Company introducer,
            VesselInCompany vesselInCompany,
            Voyage voyage,
            ActivityLocation offhireLocation,
            DateTime voucherDate,
            Currency voucherCurrency,
            //OffhirePricingReference pricingReference,
            IOffhireDomainService offhireDomainService,
            IOffhireManagementSystemDomainService offhireManagementSystemDomainService,
            IVesselInCompanyDomainService vesselDomainService,
            IVoyageDomainService voyageDomainService,
            ICompanyDomainService companyDomainService,
            IActivityLocationDomainService activityLocationDomainService,
            ICurrencyDomainService currencyDomainService)
        {
            this.validateCompanyExistance(introducer, companyDomainService);

            this.validateOffhireReference(referenceNumber, introducer, offhireManagementSystemDomainService);

            this.validateOffhireUniquenessInFuelManagementDomain(referenceNumber, introducer, offhireDomainService);

            this.validateCurrency(voucherCurrency, currencyDomainService);
            this.validateVoucherDate(voucherDate);

            this.validateVesselExistance(vesselInCompany, vesselDomainService);
            this.validateVesselInCompanyExistance(vesselInCompany, introducer, companyDomainService);

            this.validateVoyageExistance(voyage, voyageDomainService);
            this.validateVoyageInVesselOfCompanyExistance(voyage, vesselInCompany);
            this.validateOffhireDurationInVoyage(startDateTime, endDateTime, voyage);

            this.validateActivityLocation(offhireLocation, activityLocationDomainService);

            CharteringPartyType charteringPartyType = offhireDomainService.GetCharteringPartyType(vesselInCompany);

            var offhirePricingType = offhireDomainService.GetPricingType(introducer, vesselInCompany, startDateTime);

            this.validateOffhirePricingType(introducer, vesselInCompany, voyage, startDateTime, charteringPartyType, offhirePricingType,
                offhireDomainService);
        }
Ejemplo n.º 16
0
 //================================================================================
 private void validateVoyageExistance(Voyage voyage, IVoyageDomainService voyageDomainService)
 {
     if (voyage == null || voyageDomainService.Get(voyage.Id) == null)
         throw new BusinessRuleException("", "The voyage not found.");
 }
Ejemplo n.º 17
0
        //===================================================================================
        public void Submit(
            FuelReportState entityNewState,
            IVoyageDomainService voyageDomainService,
            IFuelReportDomainService fuelReportDomainService,
            IInventoryOperationDomainService inventoryOperationDomainService,
            IGoodDomainService goodDomainService,
            IOrderDomainService orderDomainService,
            ICurrencyDomainService currencyDomainService,
            IBalanceDomainService balanceDomainService,
            IInventoryManagementDomainService inventoryManagementDomainService,
            IInventoryOperationNotifier inventoryOperationNotifier)
        {
            this.CheckToBeOperational();

            validateSubmittingState(
                    voyageDomainService,
                    fuelReportDomainService,
                    inventoryOperationDomainService,
                    goodDomainService,
                    orderDomainService,
                    currencyDomainService,
                    inventoryManagementDomainService);

            sendDataToBalancingDomainService(balanceDomainService);

            if (this.FuelReportType == FuelReportTypes.EndOfVoyage ||
                this.FuelReportType == FuelReportTypes.EndOfYear ||
                this.FuelReportType == FuelReportTypes.EndOfMonth)
            {
                var inventoryResult = inventoryOperationNotifier.NotifySubmittingFuelReportConsumption(this);

                this.ConsumptionInventoryOperations.Add(inventoryResult);
            }
            else
            {
                foreach (var fuelReportDetail in this.FuelReportDetails)
                {
                    var inventoryResult = inventoryOperationNotifier.NotifySubmittingFuelReportDetail(fuelReportDetail, fuelReportDomainService);

                    if (inventoryResult != null)
                        fuelReportDetail.InventoryOperations.AddRange(inventoryResult);
                }

            }

            setEntityState(entityNewState);
        }
Ejemplo n.º 18
0
        //===================================================================================
        /// <summary>
        /// This validation is part of validateVoyageValue
        /// </summary>
        private bool isVoyageDurationAndVesselValid(long? voyageId, IVoyageDomainService voyageDomainService)
        {
            if (voyageId.HasValue)
            {
                var givenVoyage = voyageDomainService.Get(voyageId.Value);

                if (!(givenVoyage.VesselInCompany.Id == this.VesselInCompanyId &&
                    (givenVoyage.StartDate <= EventDate &&
                        EventDate <= givenVoyage.EndDate))
                    )
                {
                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 19
0
        //===================================================================================
        public void ValidateCorrectionReferences(
            bool isTheFirstFuelReport,
            //IOrderDomainService orderDomainService,
            IVoyageDomainService voyageDomainService,
            IFuelReportDomainService fuelReportDomainService
            //,IInventoryOperationDomainService inventoryOperationDomainService
            )
        {
            validateEmptyCorrectionValues();

            validatePositiveCorrectionPriceAndReference();

            //validateNegativeCorrectionReferenceValue(isTheFirstFuelReport, voyageDomainService);

            validateNegativeCorrectionWithEmptyPrice();

            validatePositiveCorrectionReferenceToBeTheLastIssuedVoyage(isTheFirstFuelReport, fuelReportDomainService);
            validateNegativeCorrectionReferenceToBeTheLastIssuedVoyage(isTheFirstFuelReport, fuelReportDomainService);
        }