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); }
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; }
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; }
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; }
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(); }
//=================================================================================== public void UpdateVoyageId(long? voyageId, IVoyageDomainService voyageDomainService) { this.CheckToBeOperational(); //BR_FR1 this.validateToBeInOpenState(); validateVoyageId(voyageId, voyageDomainService); VoyageId = voyageId; }
//=================================================================================== /// <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."); }
//=================================================================================== //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."); } } }
//=================================================================================== private void validateVoyageId(long? voyageId, IVoyageDomainService voyageDomainService) { //BR_FR2 validateVoyageValue(voyageId, voyageDomainService); //BR_FR35 validateVoyageForEndOfVoyageCondition(voyageId); //BR_FR36 validateVoyageEndDateForEndOfVoyageReportType(voyageId, voyageDomainService); }
//=================================================================================== 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); } }
//=================================================================================== /// <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."); }
//================================================================================ 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); }
//================================================================================ private void validateVoyageExistance(Voyage voyage, IVoyageDomainService voyageDomainService) { if (voyage == null || voyageDomainService.Get(voyage.Id) == null) throw new BusinessRuleException("", "The voyage not found."); }
//=================================================================================== 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); }
//=================================================================================== /// <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; }
//=================================================================================== 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); }