/// <summary>
            /// 
            /// </summary>
            /// <param name="wantedType"></param>
            /// <param name="includedIn"></param>
            /// <param name="persistentObject"></param>
            /// <param name="percent"></param>
            /// <param name="quantity"></param>
            /// <param name="validFrom"></param>
            /// <param name="validTo"></param>
            /// <returns></returns>
            public CompensationProvision NewRelativeDeduction(
                CompensationProvision.Kind wantedType,
                AgreedCompensation includedIn,
                Something persistentObject,
                Decimal percent,
                Decimal quantity,
                DateTime validFrom,
                DateTime validTo)
            {
                //Instantiate the new charge.
                CompensationProvision compensationProvision = NewCompensationProvision(
                    wantedType,
                    persistentObject,
                    quantity,
                    validFrom,
                    validTo);

                //Initiate
                compensationProvision.SetAppliesTo(persistentObject);
                compensationProvision.SetAgreedCompensation(includedIn);
                compensationProvision.AddPercent = -percent;
                compensationProvision.IsRelative = true;
                return compensationProvision;
            }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="wantedType"></param>
            /// <param name="includedIn"></param>
            /// <param name="persistentObject"></param>
            /// <param name="amount"></param>
            /// <param name="quantity"></param>
            /// <param name="currencyKind"></param>
            /// <param name="validFrom"></param>
            /// <param name="validTo"></param>
            /// <returns></returns>
            public CompensationProvision NewCharge(
                CompensationProvision.Kind wantedType,
                AgreedCompensation includedIn,
                Something persistentObject,
                Decimal amount,
                Decimal quantity,
                Currency.Kind currencyKind,
                DateTime validFrom,
                DateTime validTo)
            {
                //Instantiate the new charge.
                CompensationProvision compensationProvision = NewCompensationProvision(wantedType, persistentObject, quantity, validFrom, validTo);

                //Initiate
                compensationProvision.CurrencyKind = currencyKind;
                compensationProvision.SetAppliesTo(persistentObject);
                compensationProvision.SetAgreedCompensation(includedIn);
                compensationProvision.Amount = amount;
                compensationProvision.IsRelative = false;
                return compensationProvision;
            }
 /// <summary>
 /// Updates the agreement.
 /// </summary>
 /// <param name="agreedCompensation"></param>
 public void SetAgreedCompensation(AgreedCompensation agreedCompensation)
 {
     UpdateCombinedIndex(AppliesTo, agreedCompensation);
     _agreedCompensation = agreedCompensation;
 }
 private void UpdateCombinedIndex(Something appliesTo, AgreedCompensation agreedCompensation)
 {
     int combinedIndex;
     CombinedIndexHelper.TryGet(appliesTo, agreedCompensation, true, out combinedIndex);/*Ok*/
     _combinedIndex = combinedIndex;
 }
 /// <summary>
 /// Validates if a trade agreement is valid in time.
 /// </summary>
 /// <param name="agreement"></param>
 /// <returns></returns>
 protected Boolean IsValidInTime(AgreedCompensation agreement)
 {
     return (agreement.ValidFrom < DateTime.Now) && (agreement.ValidTo > DateTime.Now);
 }