private string GetDepositCounteragent(TranWithTags t) { return(t.Operation == OperationType.Доход ? "банк" : t.MyAccount == _deposit.ParentAccount ? t.MySecondAccount == null ? "" : t.MySecondAccount.Name : t.MyAccount.Name); }
private DepositTransactionTypes GetDepositOperationType(TranWithTags t, Account depositAccount) { return(t.Operation == OperationType.Доход ? DepositTransactionTypes.Проценты : t.MyAccount == depositAccount ? DepositTransactionTypes.асход : DepositTransactionTypes.Явнес); }
public string Dump(TranWithTags tranWithTags) { return(Convert.ToString(tranWithTags.Timestamp, new CultureInfo("ru-RU")) + " ; " + tranWithTags.Operation + " ; " + tranWithTags.MyAccount + " ; " + tranWithTags.DumpOfSecondAccount() + " ; " + tranWithTags.Amount.ToString(new CultureInfo("en-US")) + " ; " + tranWithTags.Currency + " ; " + tranWithTags.AmountInReturn.ToString(new CultureInfo("en-US")) + " ; " + tranWithTags.CurrencyInReturn + " ; " + Dump(tranWithTags.Tags) + " ; " + tranWithTags.Comment); }
public string GetExchangeRate(TranWithTags transactionInWork) { if (transactionInWork.Amount.Equals(0) || transactionInWork.AmountInReturn.Equals(0)) { return(""); } return(transactionInWork.Amount > transactionInWork.AmountInReturn ? $"Курс обмена {transactionInWork.Amount / transactionInWork.AmountInReturn : #,0.00###} {transactionInWork.Currency.ToString().ToLower()}/{transactionInWork.CurrencyInReturn.ToString().ToLower()}" : $"Курс обмена {transactionInWork.AmountInReturn / transactionInWork.Amount : #,0.00###} {transactionInWork.CurrencyInReturn.ToString().ToLower()}/{transactionInWork.Currency.ToString().ToLower()}"); }
private void AddOneTran(TranWithTags tran) { var tranWrappedForDatagrid = new TranWrappedForDatagrid() { Tran = tran }; _model.Rows.Add(tranWrappedForDatagrid); _model.Db.TransWithTags.Add(tran); _model.SelectedTranWrappedForDatagrid = tranWrappedForDatagrid; }
public AccNameSelectorVm ForMySecondAccount(TranWithTags tran) { switch (tran.Operation) { case OperationType.Перенос: return(Build("Куда", ButtonsForTransfer, _comboTreesCaterer.MyAccNamesForTransfer, tran.MySecondAccount?.Name, "Юлин кошелек")); case OperationType.Обмен: return(Build("Куда", ButtonsForExchange, _comboTreesCaterer.MyAccNamesForExchange, tran.MySecondAccount?.Name, "Мой кошелек")); default: return(Build("Куда", ButtonsForExchange, _comboTreesCaterer.MyAccNamesForExchange, "Мой кошелек", "Мой кошелек")); } }
public void Init(TranWithTags tran, bool AddOrEdit) { IsAddOrEdit = AddOrEdit; _caption = AddOrEdit ? "Добавить" : "Изменить"; TranInWork = tran.Clone(); SetVisibility(TranInWork.Operation); InitCorrespondingControl(); MyOpTypeChoiceControlVm.PressedButton = TranInWork.Operation; MyOpTypeChoiceControlVm.PropertyChanged += MyOpTypeChoiceControlVm_PropertyChanged; }
public string GetMyAccountBalance(TranWithTags transactionInWork) { if (transactionInWork?.MyAccount == null || !transactionInWork.MyAccount.Is("Мои")) { return("было ххх - стало ххх"); } var balanceBefore = _db.TransWithTags.Sum(a => a.AmountForAccount(transactionInWork.MyAccount, transactionInWork.Currency, transactionInWork.Timestamp.AddMilliseconds(-1))); return(BuildTip(balanceBefore, balanceBefore + transactionInWork.AmountForAccount(transactionInWork.MyAccount, transactionInWork.Currency), transactionInWork.Currency)); }
private string GetAmountActionLabel(TranWithTags tran) { switch (tran.Operation) { case OperationType.Доход: return("Получил"); case OperationType.асход: return("Заплатил"); case OperationType.Перенос: return("Перенес"); case OperationType.Обмен: default: return("Сдал"); } }
private MoneyBag ProcessOneTran(TranWithTags tran) { var result = new MoneyBag(); if (tran.MyAccount.IsDeposit()) { result = tran.MoneyBagForAccount(tran.MyAccount); } if (tran.MySecondAccount != null && tran.MySecondAccount.IsDeposit()) { result = result + tran.MoneyBagForAccount(tran.MySecondAccount); } return(result); }
public AccNameSelectorVm ForTags(TranWithTags tran) { switch (tran.Operation) { case OperationType.Доход: return(Build("Кто, за что", ButtonsForIncomeTags, _comboTreesCaterer.AccNamesForIncomeTags, tran.MyAccount.Name, "ИИТ")); case OperationType.асход: return(Build("Кому, за что", ButtonsForExpenseTags, _comboTreesCaterer.AccNamesForExpenseTags, tran.MyAccount.Name, "Прочие расходы")); case OperationType.Перенос: return(Build("Теги", ButtonsForTransferTags, _comboTreesCaterer.AccNamesForTransferTags, tran.MyAccount.Name, "Форекс")); case OperationType.Обмен: default: return(Build("Теги", ButtonsForExchangeTags, _comboTreesCaterer.AccNamesForExchangeTags, tran.MyAccount.Name, "БИБ")); } }
public AccNameSelectorVm ForMyAccount(TranWithTags tran) { switch (tran.Operation) { case OperationType.Доход: return(Build("Куда", ButtonsForIncome, _comboTreesCaterer.MyAccNamesForIncome, tran.MyAccount.Name, "Шкаф")); case OperationType.асход: return(Build("Откуда", ButtonsForExpense, _comboTreesCaterer.MyAccNamesForExpense, tran.MyAccount.Name, "Мой кошелек")); case OperationType.Перенос: return(Build("Откуда", ButtonsForTransfer, _comboTreesCaterer.MyAccNamesForTransfer, tran.MyAccount.Name, "Мой кошелек")); case OperationType.Обмен: default: return(Build("Откуда", ButtonsForExchange, _comboTreesCaterer.MyAccNamesForExchange, tran.MyAccount.Name, "Мой кошелек")); } }
public void SetTran(TranWithTags tran) { TranInWork = tran; TranInWork.PropertyChanged += TranInWork_PropertyChanged; MyAccNameSelectorVm = _accNameSelectionControlInitializer.ForMyAccount(TranInWork); MyAccNameSelectorVm.PropertyChanged += MyAccNameSelectorVm_PropertyChanged; MySecondAccNameSelectorVm = _accNameSelectionControlInitializer.ForMySecondAccount(TranInWork); MySecondAccNameSelectorVm.PropertyChanged += MySecondAccNameSelectorVm_PropertyChanged; MyAmountInputControlVm = new AmountInputControlVm { LabelContent = GetAmountActionLabel(TranInWork), AmountColor = TranInWork.Operation.FontColor(), Amount = TranInWork.Amount, Currency = TranInWork.Currency }; MyAmountInputControlVm.PropertyChanged += MyAmountInputcControlVm_PropertyChanged; MyAmountInReturnInputControlVm = new AmountInputControlVm { LabelContent = "Получил", AmountColor = TranInWork.Operation.FontColor(), Amount = TranInWork.AmountInReturn, Currency = TranInWork.CurrencyInReturn }; MyAmountInReturnInputControlVm.PropertyChanged += MyAmountInReturnInputControlVm_PropertyChanged; MyTagPickerVm = new TagPickerVm { TagSelectorVm = _accNameSelectionControlInitializer.ForTags(TranInWork) }; foreach (var tag in tran.Tags) { var alreadyChosenTag = MyTagPickerVm.TagSelectorVm.AvailableAccNames.FindThroughTheForest(tag.Name); if (alreadyChosenTag != null) { MyTagPickerVm.Tags.Add(alreadyChosenTag); } } MyTagPickerVm.Tags.CollectionChanged += Tags_CollectionChanged; MyDatePickerVm = new DatePickerWithTrianglesVm() { SelectedDate = TranInWork.Timestamp }; MyDatePickerVm.PropertyChanged += MyDatePickerVm_PropertyChanged; }
private Account GetTagToTagAssociation(TranWithTags tran, Account tag) { var association = (from a in _db.ArticlesAssociations where a.ExternalAccount == tag && a.OperationType == tran.Operation select a).FirstOrDefault(); if (association != null) { return(association.AssociatedArticle); } var reverseAssociation = (from a in _db.ArticlesAssociations where a.IsTwoWay && a.AssociatedArticle == tag && a.OperationType == tran.Operation select a).FirstOrDefault(); return(reverseAssociation?.ExternalAccount); }
public TranWithTags TranWithTagsFromString(string s, IEnumerable <Account> accountsPlaneList) { var tran = new TranWithTags(); var substrings = s.Split(';'); tran.Timestamp = Convert.ToDateTime(substrings[0], new CultureInfo("ru-RU")); tran.Operation = (OperationType)Enum.Parse(typeof(OperationType), substrings[1]); tran.MyAccount = accountsPlaneList.First(account => account.Name == substrings[2].Trim()); tran.MySecondAccount = substrings[3].Trim() != "" ? accountsPlaneList.First(account => account.Name == substrings[3].Trim()) : null; tran.Amount = Convert.ToDecimal(substrings[4], new CultureInfo("en-US")); tran.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), substrings[5]); tran.AmountInReturn = Convert.ToDecimal(substrings[6], new CultureInfo("en-US")); tran.CurrencyInReturn = substrings[7].Trim() != "" ? (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), substrings[7]) : CurrencyCodes.USD; tran.Tags = TagsFromString(substrings[8].Trim(), accountsPlaneList); tran.Comment = substrings[9].Trim(); return(tran); }
public string GetMySecondAccountBalance(TranWithTags transactionInWork) { if (transactionInWork == null || transactionInWork.MySecondAccount == null || !transactionInWork.MySecondAccount.Is("Мои")) { return("было ххх - стало ххх"); } if (transactionInWork.Operation == OperationType.Перенос) { var balanceBefore = _db.TransWithTags.Sum(a => a.AmountForAccount(transactionInWork.MySecondAccount, transactionInWork.Currency, transactionInWork.Timestamp.AddMilliseconds(-1))); return(BuildTip(balanceBefore, balanceBefore + transactionInWork.AmountForAccount(transactionInWork.MySecondAccount, transactionInWork.Currency), transactionInWork.Currency)); } else // OperationType.Обмен { var balanceBefore = _db.TransWithTags.Sum(a => a.AmountForAccount(transactionInWork.MySecondAccount, transactionInWork.CurrencyInReturn, transactionInWork.Timestamp.AddMilliseconds(-1))); return(BuildTip(balanceBefore, balanceBefore + transactionInWork.AmountForAccount(transactionInWork.MySecondAccount, transactionInWork.CurrencyInReturn), transactionInWork.CurrencyInReturn)); } }
public Account GetAssociation(TranWithTags tran, Account tag) { var associatedTag = GetTagToTagAssociation(tran, tag); return((associatedTag == null || tran.Tags.Contains(associatedTag)) ? null : associatedTag); }
public string GetAmountInReturnInUsd(TranWithTags tranInWork) { return(tranInWork.CurrencyInReturn != null ? tranInWork.CurrencyInReturn == CurrencyCodes.USD ? "" : _rateExtractor.GetUsdEquivalentString(tranInWork.AmountInReturn, (CurrencyCodes)tranInWork.CurrencyInReturn, tranInWork.Timestamp) : "не задана валюта"); }