Example #1
0
 protected IGeneralOperationsComponent clone(bool doStorno, IGeneralOperationsBooking parentBooking)
 {
     IManagementFeeComponent clone = new ManagementFeeComponent(parentBooking, this.BookingComponentType, this.Period, this.MgtFeeType);
     foreach (IJournalEntryLine line in this.Component.JournalLines)
     {
         IJournalEntryLine cloneLine = line.Clone();
         if (doStorno)
         {
             cloneLine.Balance = cloneLine.Balance.Negate();
             line.StornoedLine = cloneLine;
         }
         clone.Component.JournalLines.AddJournalEntryLine(cloneLine);
     }
     return clone;
 }
Example #2
0
        protected void createComponents(IGLLookupRecords lookups)
        {
            var fees =
                (from u in Units
                from f in u.FeeItems
                group f by new { FeeType = f.FeeType, Period = f.Parent.Period } into g
                let amounts = from pair in g select pair.Amount
                 select new { FeeTypePeriod = g.Key, Amount = amounts.Sum() })
                .Union(
                from u in Units
                from f in u.AverageHoldingFeeItems
                group f by new { FeeType = f.FeeType, Period = f.Parent.Period } into g
                let amounts = from pair in g select pair.Amount
                select new { FeeTypePeriod = g.Key, Amount = amounts.Sum() });

            if (fees != null && fees.Count() > 0)
            {
                IAccountTypeCustomer account = ((IAccountTypeCustomer)Account).ExitFeePayingAccount;
                Money taxeableAmount = null;
                foreach (var feeItem in fees.OrderBy(x => x.FeeTypePeriod.Period))
                {
                    if ((feeItem != null) && ((feeItem.Amount != null) && (feeItem.Amount.IsNotZero)))
                    {
                        IManagementFeeComponent newComponent = new ManagementFeeComponent(this, feeItem.FeeTypePeriod.FeeType.BookingComponentType, feeItem.FeeTypePeriod.Period, feeItem.FeeTypePeriod.FeeType, this.CreationDate);
                        newComponent.AddLinesToComponent(feeItem.Amount, feeItem.FeeTypePeriod.FeeType.BookingComponentType, true, false, false, lookups, account);
                        newComponent.Component.SetDescription(string.Format("{0} {1}", feeItem.FeeTypePeriod.FeeType.Description, feeItem.FeeTypePeriod.Period));
                        this.Components.Add(newComponent);

                        if (feeItem.FeeTypePeriod.FeeType.UseTax)
                            taxeableAmount += feeItem.Amount;
                    }
                }

                if (taxeableAmount != null && taxeableAmount.IsNotZero)
                {
                    if (TaxPercentage < 0 || TaxPercentage > 1)
                        throw new ApplicationException("The BTW Percentage can only be between 0 and 1");
                    Money tax = Money.Multiply(taxeableAmount, TaxPercentage);
                    if (tax != null && tax.IsNotZero)
                    {
                        IManagementFeeComponent taxComponent = new ManagementFeeComponent(this, BookingComponentTypes.Tax, 0, null, this.CreationDate);
                        taxComponent.AddLinesToComponent(tax, BookingComponentTypes.Tax, true, false, false, lookups, account);
                        taxComponent.Component.SetDescription("BTW " + getTaxDescription());
                        this.Components.Add(taxComponent);
                    }
                }
            }
        }