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 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();
 }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
        }
        //===================================================================================
        private void validateRejectTransferReferenceValue(IInventoryManagementDomainService inventoryManagementDomainService)
        {
            if (this.Transfer.HasValue &&
                this.TransferType.Value == TransferTypes.Rejected &&
                !this.TransferReference.IsEmpty())
            {
                var purchaseReceipts = inventoryManagementDomainService.GetVesselPurchaseReceiptNumbers(this.FuelReport.VesselInCompany.CompanyId, this.FuelReport.VesselInCompanyId);

                var transferRefCount = purchaseReceipts.Count(
                    r => r.ReferenceId == this.TransferReference.ReferenceId && this.TransferReference.ReferenceType == ReferenceType.Inventory);

                if (transferRefCount != 1)
                    throw new BusinessRuleException("", string.Format("Reject Transfer Reference Value for '{0}' is invalid.", this.Good.Code));
                //throw new BusinessRuleException("BR_FR29_2", "BR_FR19 - چنانچه فیلد انتقال مقداردهی گردیده است و نوع آن فروش انتقالی می باشد مرجع آن سفارش  انتقال تائید نهایی شده می باشد");
            }
        }
        public void ValidateTransferReferences(IOrderDomainService orderDomainService,
            IInventoryManagementDomainService inventoryManagementDomainService)
        {
            validateEmptyTransferValues();

            validateNotEmptyTransferValues();

            validateNotEmptyTransferSaleValues();

            validateTransferSaleReferenceValue(orderDomainService);

            validateNotEmptyInternalTransferValues();

            validateInternalTransferReferenceValue(orderDomainService);

            validateNotEmptyRejectTransferValues();

            validateRejectTransferReferenceValue(inventoryManagementDomainService);
        }