//================================================================================ 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 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"); } }