Пример #1
0
        //================================================================================
        public Charter GetCharterContract(Company introducer, VesselInCompany vesselInCompany, CharteringPartyType introducerType, DateTime stratDate)
        {
            switch (introducerType)
            {
                case CharteringPartyType.ShipOwner:

                    //If the given company is in the role of ShipOwner, it will be inferred that
                    //the pricing type must be fetched from Charter-Out contract.

                    var foundCharterOut = charteringDomainService.GetCharterOutStart(introducer, vesselInCompany, stratDate);

                    //TODO: State of CharterOut must be submitted.
                    if (foundCharterOut == null /*|| foundCharterOut.State != States.Submitted*/)
                        throw new BusinessRuleException("CharterOutForPricingType", "Charter-Out contract not found.");

                    return foundCharterOut;

                case CharteringPartyType.Charterer:

                    //If the given company is in the role of Charterer, it will be inferred that
                    //the pricing type must be fetched from Charter-In contract.

                    var foundCharterIn = charteringDomainService.GetCharterInStart(introducer, vesselInCompany, stratDate);

                    if (foundCharterIn == null /*|| foundCharterIn.State != States.Submitted*/)
                        throw new BusinessRuleException("CharterInForPricingType", "Charter-In contract not found.");

                    return foundCharterIn;

                default:
                    throw new InvalidArgument("IntroducerType");
            }
        }
Пример #2
0
 //================================================================================
 private List<PricingValue> getCharterPartyBasedPricingValues(Company introducer, VesselInCompany vesselInCompany, CharteringPartyType introducerType, DateTime stratDate)
 {
     var charterContract = this.GetCharterContract(introducer, vesselInCompany, introducerType, stratDate);
     //TODO: OffhireFee might not be set.
     return charterContract.CharterItems.Select(ci => new PricingValue()
                                                      {
                                                          Good = ci.Good,
                                                          Currency = ci.OffhireFee == 0 ? null : charterContract.Currency,
                                                          Fee = ci.OffhireFee == 0 ? null : (decimal?)ci.OffhireFee
                                                      }).ToList();
 }
Пример #3
0
        //================================================================================
        public string GetCharteringReferenceNumber(Company company, VesselInCompany vesselInCompany, CharteringPartyType partyType, DateTime date)
        {
            var charterContract = this.GetCharterContract(company, vesselInCompany, partyType, date);

            switch (partyType)
            {
                case CharteringPartyType.ShipOwner:

                    //If the given company is in the role of ShipOwner, it will be inferred that
                    //the pricing type must be fetched from Charter-Out contract.

                    return charterContract.Id.ToString();

                case CharteringPartyType.Charterer:

                    //If the given company is in the role of Charterer, it will be inferred that
                    //the pricing type must be fetched from Charter-In contract.

                    return charterContract.Id.ToString();

                default:
                    throw new ArgumentOutOfRangeException("partyType");
            }
        }
Пример #4
0
        //================================================================================
        private Offhire(
            long referenceNumber,
            DateTime startDateTime,
            DateTime endDateTime,
            CharteringPartyType introducerType,
            Company introducer,
            VesselInCompany vesselInCompany,
            Voyage voyage,
            ActivityLocation offhireLocation,
            DateTime voucherDate,
            Currency voucherCurrency,
            string pricingReferenceNumber,
            OffHirePricingType pricingReferenceType,
            List<OffhireDetail> offhireDetails)
        {
            //This is used to create instances by reflection to Insert Seed Data into DB.
            this.ReferenceNumber = referenceNumber;
            this.StartDateTime = startDateTime;
            this.EndDateTime = endDateTime;
            this.IntroducerType = introducerType;
            this.Introducer = introducer;
            this.VesselInCompany = vesselInCompany;
            this.Voyage = voyage;
            this.OffhireLocation = offhireLocation;
            this.VoucherDate = voucherDate;
            this.VoucherCurrencyId = voucherCurrency.Id;
            this.VoucherCurrency = voucherCurrency;
            this.PricingReference = new OffhirePricingReference() { Type = pricingReferenceType, Number = pricingReferenceNumber };

            this.OffhireDetails = offhireDetails;
            this.ApproveWorkflows = new List<OffhireWorkflowLog>();
        }
Пример #5
0
        //================================================================================
        private void validateOffhirePricingType(
            Company introducer, VesselInCompany vesselInCompany, Voyage voyage, DateTime satrtDate, CharteringPartyType partyType,
            OffHirePricingType offhirePricingType, IOffhireDomainService offhireDomainService)
        {
            switch (partyType)
            {
                case CharteringPartyType.Charterer:

                    this.validateOffhirePricingTypeForCharteredInVessel(
                        voyage, offhirePricingType, offhireDomainService);

                    break;

                case CharteringPartyType.ShipOwner:

                    this.validateOffhirePricingTypeForCharteredOutVessel(
                        introducer, vesselInCompany, voyage, satrtDate, offhirePricingType, offhireDomainService);

                    break;
            }
        }
Пример #6
0
        //================================================================================
        private OffhirePricingReference createPricingReference(Company introducer, VesselInCompany vesselInCompany, CharteringPartyType partyType, Voyage voyage, DateTime startDateTime, IOffhireDomainService offhireDomainService)
        {
            var pricingType = offhireDomainService.GetPricingType(introducer, vesselInCompany, startDateTime);

            switch (pricingType)
            {
                case OffHirePricingType.CharterPartyBase:

                    var charteringReferenceNumber = offhireDomainService.GetCharteringReferenceNumber(introducer, vesselInCompany, partyType, startDateTime);

                    return new OffhirePricingReference() { Number = charteringReferenceNumber, Type = OffHirePricingType.CharterPartyBase };

                case OffHirePricingType.IssueBase:

                    var issueReferenceNumber = offhireDomainService.GetVoyageConsumptionIssueOperation(voyage.Id).ActionNumber;

                    return new OffhirePricingReference() { Number = issueReferenceNumber, Type = OffHirePricingType.IssueBase };

                default:
                    throw new InvalidArgument("Pricing Type could not be retrieved.", "PricingType");
            }
        }