示例#1
0
 public void UpdateCalculationTransaction(Calculation calculation, decimal amount)
 {
     TransactionDocument.UpdateSingletonTransactionAmount(calculation.AccountTransactionTypeId, calculation.Name, amount, ExchangeRate);
     if (amount == 0)
     {
         TransactionDocument.AccountTransactions.Remove(
             TransactionDocument.AccountTransactions.Single(x => x.AccountTransactionTypeId == calculation.AccountTransactionTypeId));
     }
 }
示例#2
0
 public void AddCalculation(CalculationType template, decimal amount)
 {
     var t = Calculations.SingleOrDefault(x => x.CalculationTypeId == template.Id) ??
             Calculations.SingleOrDefault(x => x.AccountTransactionTypeId == template.AccountTransactionType.Id);
     if (t == null)
     {
         t = new Calculation
                 {
                     Amount = amount,
                     Name = template.Name,
                     CalculationType = template.CalculationMethod,
                     CalculationTypeId = template.Id,
                     IncludeTax = template.IncludeTax,
                     DecreaseAmount = template.DecreaseAmount,
                     Order = template.Order,
                     AccountTransactionTypeId = template.AccountTransactionType.Id
                 };
         Calculations.Add(t);
         TransactionDocument.AddSingletonTransaction(t.AccountTransactionTypeId, template.AccountTransactionType, AccountTypeId, AccountId);
     }
     else if (t.Amount == amount)
     {
         amount = 0;
     }
     else t.Amount = amount;
     t.Name = template.Name;
     if (amount == 0)
     {
         Calculations.Remove(t);
         UpdateCalculationTransaction(t, 0);
     }
 }
示例#3
0
 public void RemoveCalculation(Calculation py)
 {
     var transactionId = py.AccountTransactionTypeId;
     Calculations.Remove(py);
     if (Calculations.All(x => x.AccountTransactionTypeId != transactionId))
     {
         TransactionDocument.AccountTransactions.Where(x => x.AccountTransactionTypeId == transactionId)
                .ToList().ForEach(x => TransactionDocument.AccountTransactions.Remove(x));
     }
 }
示例#4
0
 public ServiceViewModel(Calculation model)
 {
     Model = model;
 }
示例#5
0
 public void AddCalculation(CalculationType calculationType, decimal amount)
 {
     var calculation = Calculations.SingleOrDefault(x => x.CalculationTypeId == calculationType.Id) ??
             Calculations.SingleOrDefault(x => x.AccountTransactionTypeId == calculationType.AccountTransactionType.Id);
     if (calculation == null)
     {
         calculation = new Calculation
                 {
                     Amount = amount,
                     Name = calculationType.Name,
                     CalculationType = calculationType.CalculationMethod,
                     CalculationTypeId = calculationType.Id,
                     IncludeTax = calculationType.IncludeTax,
                     DecreaseAmount = calculationType.DecreaseAmount,
                     UsePlainSum = calculationType.UsePlainSum,
                     Order = calculationType.SortOrder,
                     AccountTransactionTypeId = calculationType.AccountTransactionType.Id
                 };
         Calculations.Add(calculation);
         TransactionDocument.AddSingletonTransaction(calculation.AccountTransactionTypeId, calculationType.AccountTransactionType, GetTicketAccounts());
     }
     else if (calculationType.ToggleCalculation && calculation.Amount == amount)
     {
         amount = 0;
     }
     else calculation.Amount = amount;
     calculation.Name = calculationType.Name;
     if (amount == 0 && calculation.CalculationType != 5)
     {
         Calculations.Remove(calculation);
         calculation.UpdateCalculationTransaction(TransactionDocument, 0, ExchangeRate);
     }
 }
示例#6
0
 public void UpdateCalculationTransaction(Calculation calculation, decimal amount)
 {
     var transaction = AccountTransactions.AccountTransactions.SingleOrDefault(x => x.AccountTransactionTemplateId == calculation.AccountTransactionTemplateId);
     if (transaction == null)
     {
         transaction = AccountTransaction.Create(calculation.AccountTransactionTemplate);
         transaction.Name = calculation.Name;
         transaction.UpdateAccounts(AccountTemplateId, AccountId);
         AccountTransactions.AccountTransactions.Add(transaction);
     }
     if (amount == 0)
     {
         AccountTransactions.AccountTransactions.Remove(
             AccountTransactions.AccountTransactions.Single(x => x.AccountTransactionTemplateId == calculation.AccountTransactionTemplateId));
     }
     transaction.Amount = amount;
 }
示例#7
0
 public void RemoveCalculation(Calculation py)
 {
     var transactionId = py.AccountTransactionTemplateId;
     Calculations.Remove(py);
     if (!Calculations.Any(x => x.AccountTransactionTemplateId == transactionId))
     {
         AccountTransactions.AccountTransactions.Where(x => x.AccountTransactionTemplateId == transactionId)
                .ToList().ForEach(x => AccountTransactions.AccountTransactions.Remove(x));
     }
 }
示例#8
0
        public void AddCalculation(CalculationTemplate template, decimal amount)
        {
            var t = Calculations.SingleOrDefault(x => x.ServiceId == template.Id) ??
                    Calculations.SingleOrDefault(x => x.AccountTransactionTemplateId == template.AccountTransactionTemplate.Id);
            if (t == null)
            {
                t = new Calculation
                        {
                            Amount = amount,
                            Name = template.Name,
                            CalculationType = template.CalculationMethod,
                            ServiceId = template.Id,
                            IncludeTax = template.IncludeTax,
                            DecreaseAmount = template.DecreaseAmount,
                            Order = template.Order,
                            AccountTransactionTemplateId = template.AccountTransactionTemplate.Id
                        };

                var transaction = AccountTransaction.Create(template.AccountTransactionTemplate);
                transaction.Name = t.Name;
                transaction.UpdateAccounts(AccountTemplateId, AccountId);
                AccountTransactions.AccountTransactions.Add(transaction);
                Calculations.Add(t);
            }
            else if (t.Amount == amount) amount = 0;

            t.Name = template.Name;

            if (amount == 0)
            {
                Calculations.Remove(t);
                AccountTransactions.AccountTransactions.Remove(
                    AccountTransactions.AccountTransactions.Single(x => t.AccountTransactionTemplateId == x.AccountTransactionTemplateId));
            }

            t.Amount = amount;
        }