private void OnTaxableIncomeRowEditEnded() { decimal itemAmount = AmountToBeSplit; DatevTransactionType transactionType = dbAccess.GetTransactionById(currentTravelExpenseItem.DatevTransactionTypeId); TaxableIncomeItem currentTaxableIncomeItem = ListOfTaxableItems.CurrentItem as TaxableIncomeItem; if (currentTaxableIncomeItem == null) { return; } // if transactionTye.IsTaxableIncome AdjustGrossIncome must be false; if (transactionType.IsTaxableIncome) { currentTaxableIncomeItem.AdjustGrossIncome = false; } CanSaveTaxableIncome = false; // if (SplitTotalAmount) { int nrOfItems = currentTravelExpenseItem.TaxableIncomeItems.Where(t => t.Status != DBStatus.Removed).Count(); decimal equalAmount = Math.Round(itemAmount / nrOfItems, 2); decimal roundingDifference = itemAmount - (equalAmount * nrOfItems); foreach (TaxableIncomeItem item in currentTravelExpenseItem.TaxableIncomeItems) { item.TaxableAmount = equalAmount; } // add roundingDifference to first item currentTravelExpenseItem.TaxableIncomeItems[0].TaxableAmount += roundingDifference; } foreach (TaxableIncomeItem item in currentTravelExpenseItem.TaxableIncomeItems) { if (item.Status == DBStatus.Removed) { continue; } itemAmount -= item.TaxableAmount; } if (itemAmount != 0) { if (AcceptLowerTaxableAmount) { CanSaveTaxableIncome = true; } } else { CanSaveTaxableIncome = true; } }
private void OnAddingNewRowCommand(object obj) { GridViewAddingNewEventArgs e = obj as GridViewAddingNewEventArgs; if (e == null) { return; } TravelExpenseItem item = new TravelExpenseItem(); item.Status = DBStatus.Added; item.TravelExpenseId = TravelExpense.Id; e.NewObject = item; //this will ensure selectedTransactionType is newly set in OnCellValidated selectedTransactionType = null; }
public override void OnNavigatedTo(NavigationContext navigationContext) { //base.OnNavigatedTo(navigationContext); transactionTypes = new ObservableCollection <DatevTransactionType>(dbAccess.GetAllTransactionTypes()); // insert a new item to transactionTypes if the Collection is empty if (transactionTypes.Count == 0) { transactionTypes.Add(new DatevTransactionType()); } ListOfDatevTransactionTypes = CollectionViewSource.GetDefaultView(transactionTypes); ListOfDatevTransactionTypes.CurrentChanged -= ListOfDatevTransactionTypes_CurrentChanged; ListOfDatevTransactionTypes.CurrentChanged += ListOfDatevTransactionTypes_CurrentChanged; selectedTransaction = ListOfDatevTransactionTypes.CurrentItem as DatevTransactionType; RaisePropertyChanged("ListOfDatevTransactionTypes"); }
private void ListOfTravelExpenseItems_CurrentChanged(object sender, EventArgs e) { currentTravelExpenseItem = ListOfTravelExpenseItems.CurrentItem as TravelExpenseItem; if (currentTravelExpenseItem == null) { return; } if (currentTravelExpenseItem.TravelExpenseId != 0) { selectedTransactionType = dbAccess.GetTransactionById(currentTravelExpenseItem.DatevTransactionTypeId); } CanEditTaxableIncome = currentTravelExpenseItem.IsTaxableIncome; // set new ListOfTaxableItems ListOfTaxableItems = CollectionViewSource.GetDefaultView(currentTravelExpenseItem.TaxableIncomeItems); ListOfTaxableItems.CurrentChanged -= ListOfTaxableItems_CurrentChanged; ListOfTaxableItems.CurrentChanged += ListOfTaxableItems_CurrentChanged; RaisePropertyChanged("ListOfTaxableItems"); }
private void OnRowEditEnded() { if (selectedTransaction.Id == 0) { DatevTransactionType returnValue = dbAccess.InsertTransactionType(selectedTransaction); if (returnValue == null) { // Fehler } selectedTransaction.Id = returnValue.Id; } else { DatevTransactionType returnValue = dbAccess.UpdateTransactionType(selectedTransaction); if (returnValue == null) { // Fehler } } }
private void OnCellValidated() { TravelExpenseItem item = ListOfTravelExpenseItems.CurrentItem as TravelExpenseItem; if (item == null) { return; } if (selectedTransactionType == null) { if (item.DatevTransactionTypeId > 0) { selectedTransactionType = dbAccess.GetTransactionById(item.DatevTransactionTypeId); } if (selectedTransactionType != null) { item.IsTaxableIncome = selectedTransactionType.IsTaxableIncome; } } else { if (item.DatevTransactionTypeId > 0 && selectedTransactionType.Id != item.DatevTransactionTypeId) { selectedTransactionType = dbAccess.GetTransactionById(item.DatevTransactionTypeId); item.IsTaxableIncome = selectedTransactionType.IsTaxableIncome; } } if (string.IsNullOrEmpty(item.Description) && selectedTransactionType != null) { item.Description = selectedTransactionType.TransactionType; } item.TotalAmount = item.Amount00 + item.Amount07 + item.Amount19; if (item.Status == DBStatus.Unchanged) { item.Status = DBStatus.Updated; } CanEditTaxableIncome = item.TotalAmount != 0 ? item.IsTaxableIncome : false; }
private void ListOfDatevTransactionTypes_CurrentChanged(object sender, EventArgs e) { selectedTransaction = ListOfDatevTransactionTypes.CurrentItem as DatevTransactionType; }
private void PrepareCsvFile(List <TravelExpense> travelExpensesToBeMoved) { csvDatevTransactions.Clear(); foreach (TravelExpense te in travelExpensesToBeMoved) { TravelExpense travelExpense = dbAccess.GetTravelExpenseById(te.Id); foreach (TravelExpenseItem item in travelExpense.TravelExpenseItems) { DatevTransactionType type = dbAccess.GetTransactionById(item.DatevTransactionTypeId); if (item.Amount00 != 0) { DatevTransaction datevItem = new DatevTransaction(); //Datum datevItem.TransactionDate = travelExpense.ExpenseDate; if (item.PerformanceDate == null) { datevItem.ExpenseDate = datevItem.TransactionDate; } else { datevItem.ExpenseDate = (DateTime)item.PerformanceDate; } //Buchungstext datevItem.TransactionDescription = $"RK {travelExpense.EmployeeName} {item.Description}"; //Belegfeld datevItem.TransactionReceipt = (travelExpense.ExpenseDate.Month * 10000 + travelExpense.ExpenseDate.Year).ToString(); // Steuersatz datevItem.TransactionVatRate = type.DatevVat07; //Umsatz datevItem.TransactionAmountDatev = item.Amount00; // Soll / Haben if (datevItem.TransactionAmountDatev > 0) { datevItem.TransactionBalancePosition = "H"; } else { datevItem.TransactionBalancePosition = "S"; } //konto datevItem.TransactionAccount = type.DatevAccount; // gegenkonto datevItem.TransactionContraAccount = travelExpense.EmployeesForTravelExpenses.DatevAccount + type.SubAccount; if (datevItem.TransactionDate < new DateTime(2020, 1, 1)) { datevItem.TransactionAccount = datevItem.TransactionAccount / 100; datevItem.TransactionContraAccount = datevItem.TransactionContraAccount / 100; } csvDatevTransactions.Add(datevItem); } if (item.Amount07 != 0) { DatevTransaction datevItem = new DatevTransaction(); //Datum datevItem.TransactionDate = travelExpense.ExpenseDate; if (item.PerformanceDate == null) { datevItem.ExpenseDate = datevItem.TransactionDate; } else { datevItem.ExpenseDate = (DateTime)item.PerformanceDate; } //Buchungstext datevItem.TransactionDescription = $"RK {travelExpense.EmployeeName} {item.Description}"; //Belegfeld datevItem.TransactionReceipt = (travelExpense.ExpenseDate.Month * 10000 + travelExpense.ExpenseDate.Year).ToString(); // Steuersatz datevItem.TransactionVatRate = type.DatevVat19; //Umsatz datevItem.TransactionAmountDatev = item.Amount07; // Soll / Haben if (datevItem.TransactionAmountDatev > 0) { datevItem.TransactionBalancePosition = "H"; } else { datevItem.TransactionBalancePosition = "S"; } //konto datevItem.TransactionAccount = type.DatevAccount; // gegenkonto datevItem.TransactionContraAccount = travelExpense.EmployeesForTravelExpenses.DatevAccount + type.SubAccount; if (datevItem.TransactionDate < new DateTime(2020, 1, 1)) { datevItem.TransactionAccount = datevItem.TransactionAccount / 100; datevItem.TransactionContraAccount = datevItem.TransactionContraAccount / 100; } csvDatevTransactions.Add(datevItem); } if (item.Amount19 != 0) { DatevTransaction datevItem = new DatevTransaction(); //Datum datevItem.TransactionDate = travelExpense.ExpenseDate; if (item.PerformanceDate == null) { datevItem.ExpenseDate = datevItem.TransactionDate; } else { datevItem.ExpenseDate = (DateTime)item.PerformanceDate; } //Buchungstext datevItem.TransactionDescription = $"RK {travelExpense.EmployeeName} {item.Description}"; //Belegfeld datevItem.TransactionReceipt = (travelExpense.ExpenseDate.Month * 10000 + travelExpense.ExpenseDate.Year).ToString(); // Steuersatz datevItem.TransactionVatRate = type.DatevVat00; //Umsatz datevItem.TransactionAmountDatev = item.Amount19; // Soll / Haben if (datevItem.TransactionAmountDatev > 0) { datevItem.TransactionBalancePosition = "H"; } else { datevItem.TransactionBalancePosition = "S"; } //konto datevItem.TransactionAccount = type.DatevAccount; // gegenkonto datevItem.TransactionContraAccount = travelExpense.EmployeesForTravelExpenses.DatevAccount + type.SubAccount; if (datevItem.TransactionDate < new DateTime(2020, 1, 1)) { datevItem.TransactionAccount = datevItem.TransactionAccount / 100; datevItem.TransactionContraAccount = datevItem.TransactionContraAccount / 100; } csvDatevTransactions.Add(datevItem); } } } }