public async Task UpdateAsync(string assetId, decimal amount, string comment, string userId) { Credit credit = await GetByAssetIdAsync(assetId); credit.Add(amount); string walletId = await _settingsService.GetWalletIdAsync(); if (amount > 0) { await _lykkeExchangeService.CashInAsync(walletId, assetId, Math.Abs(amount), userId, comment); } else { await _lykkeExchangeService.CashOutAsync(walletId, assetId, Math.Abs(amount), userId, comment); } await _creditRepository.InsertOrReplaceAsync(credit); _cache.Set(credit); var balanceOperation = new BalanceOperation { Time = DateTime.UtcNow, AssetId = assetId, Type = "Credit", Amount = amount, Comment = comment, UserId = userId }; await _balanceOperationService.AddAsync(balanceOperation); _log.InfoWithDetails("Credit was updated", balanceOperation); }
private void ReadBody() { int i = (_invoice.IsRub) ? 12 : 11; //первая строка с данными int incement = (_invoice.IsRub) ? 7 : 4; int readBlocks = 0; int countBlocks = GetCountBlocks(); while (readBlocks < countBlocks) { currentCell = (_invoice.IsRub) ? "Q" + i : "D" + i; while (_excelBook.getValue(currentCell, currentCell) != null) { DCRow dcRow = new DCRow(); currentCell = (_invoice.IsRub) ? "Q" + i : "D" + i; //№ документа dcRow.SetNumber(_excelBook.getValue(currentCell, currentCell)); currentCell = (_invoice.IsRub) ? "F" + i : "E" + i; //Счёт дебет dcRow.SetOrdp(_excelBook.getValue(currentCell, currentCell)); currentCell = (_invoice.IsRub) ? "J" + i : "G" + i; //Счёт кредит dcRow.SetBenm(_excelBook.getValue(currentCell, currentCell)); currentCell = (_invoice.IsRub) ? "AA" + i : "Y" + i; //Назначение платежа dcRow.SetCom(_excelBook.getValue(currentCell, currentCell)); currentCell = (_invoice.IsRub) ? "L" + i : "I" + i; //Сумма по дебету if ((_excelBook.getValue(currentCell, currentCell) != null) && (_excelBook.getValue(currentCell, currentCell).ToString() != string.Empty)) { dcRow.SetSum(_excelBook.getValue(currentCell, currentCell)); if (dcRow.Sum != 0.0) { Debet.Add(dcRow); } } else { currentCell = (_invoice.IsRub) ? "P" + i : "O" + i; //Сумма по кредиту dcRow.SetSum(_excelBook.getValue(currentCell, currentCell)); if (dcRow.Sum != 0.0) { Credit.Add(dcRow); } } i++; currentCell = (_invoice.IsRub) ? "Q" + i : "D" + i; } i += incement; readBlocks++; } ReadTails(i - incement); }
public void Add_method_adds_credit_to_total() { credit.Add(0.5m); Assert.AreEqual(credit.total, 0.50); }