public void SetCurrentVersion(DataReturnVersion version) { Guard.ArgumentNotNull(() => version, version); if (version.DataReturn != this) { string errorMessage = "The specified data return version does not relate to this data return."; throw new InvalidOperationException(errorMessage); } CurrentVersion = version; }
internal override void AddDataReturnVersion(DataReturnVersion dataReturnVersion) { var eeeOutputAmount = EeeOutputAmounts.FirstOrDefault(); if (eeeOutputAmount != null && dataReturnVersion != null) { ValidateEeeOutputAmountAndDataReturnVersion(eeeOutputAmount, dataReturnVersion); } base.AddDataReturnVersion(dataReturnVersion); }
internal virtual void AddDataReturnVersion(DataReturnVersion dataReturnVersion) { Guard.ArgumentNotNull(() => dataReturnVersion, dataReturnVersion); var existingDataReturnVersion = DataReturnVersions.FirstOrDefault(); if (existingDataReturnVersion != null && dataReturnVersion.DataReturn != existingDataReturnVersion.DataReturn) { throw new InvalidOperationException("The data return version does not belong to the current data return"); } DataReturnVersions.Add(dataReturnVersion); }
public virtual void SetDataReturnVersion(DataReturnVersion returnVersion) { Guard.ArgumentNotNull(() => returnVersion, returnVersion); DataReturnVersion = returnVersion; }
private static void ValidateEeeOutputAmountAndDataReturnVersion(EeeOutputAmount eeeOutputAmount, DataReturnVersion dataReturnVersion) { if (eeeOutputAmount.RegisteredProducer.Scheme.ApprovalNumber != dataReturnVersion.DataReturn.Scheme.ApprovalNumber) { string errorMesage = "The producer for the EEE output amount and the data return do not belong to the same scheme."; throw new InvalidOperationException(errorMesage); } if (eeeOutputAmount.RegisteredProducer.ComplianceYear != dataReturnVersion.DataReturn.Quarter.Year) { string errorMesage = "The producer for the EEE output amount and the data return do not have a matching compliance year."; throw new InvalidOperationException(errorMesage); } }