本文整理汇总了C#中Samba.Domain.Models.Accounts.Account类的典型用法代码示例。如果您正苦于以下问题:C# Account类的具体用法?C# Account怎么用?C# Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于Samba.Domain.Models.Accounts命名空间,在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod)
{
var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId);
var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date);
Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
if (accountType.DefaultFilterType > 0)
{
var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
if (pastCredit > 0 || pastDebit > 0)
{
Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
var detailValue =
new AccountDetailData(
new AccountTransactionValue
{
Name = Resources.PastTransactions,
Credit = pastCredit,
Debit = pastDebit,
Exchange = pastExchange
}, selectedAccount) { IsBold = true };
Transactions.Insert(0, detailValue);
}
}
Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
for (var i = 0; i < Transactions.Count; i++)
{
Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
}
}
示例2: Update
public void Update(Account selectedAccount, DateTime? start, DateTime? end)
{
Start = start;
End = end;
var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date);
Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
if (start.HasValue)
{
var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
if (pastCredit > 0 || pastDebit > 0)
{
Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
var detailValue =
new AccountDetailData(
new AccountTransactionValue
{
Date = start.GetValueOrDefault(),
Name = Resources.BalanceBroughtForward,
Credit = pastCredit,
Debit = pastDebit,
Exchange = pastExchange
}, selectedAccount) { IsBold = true };
Transactions.Insert(0, detailValue);
}
}
if (end.HasValue && end != start)
{
var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
if (futureCredit > 0 || futureDebit > 0)
{
Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
var detailValue =
new AccountDetailData(
new AccountTransactionValue
{
Date = end.GetValueOrDefault(),
Name = Resources.BalanceAfterDate,
Credit = futureCredit,
Debit = futureDebit,
Exchange = futureExchange
}, selectedAccount) { IsBold = true };
Transactions.Add(detailValue);
}
}
Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
for (var i = 0; i < Transactions.Count; i++)
{
Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
}
}
示例3: AccountRowViewModel
public AccountRowViewModel(Account account, AccountTransactionDocumentType documentType, IAccountService accountService, ICacheService cacheService)
{
_account = account;
Amount = accountService.GetDefaultAmount(documentType, account);
Description = accountService.GetDescription(documentType, account);
TargetAccounts = GetAccountSelectors(documentType, account, accountService, cacheService).ToList();
}
示例4: CanMakeAccountTransaction
public bool CanMakeAccountTransaction(Account selectedAccount)
{
if (DefaultSourceAccountId == selectedAccount.Id || DefaultTargetAccountId == selectedAccount.Id) return true;
if (SourceAccountTypeId == selectedAccount.AccountTypeId && DefaultSourceAccountId == 0) return true;
if (TargetAccountTypeId == selectedAccount.AccountTypeId && DefaultTargetAccountId == 0) return true;
return false;
}
示例5: PrintAccountTransactions
public void PrintAccountTransactions(Account account, WorkPeriod workPeriod, Printer printer, string filter)
{
var range = _accountService.GetDateRange(filter, workPeriod);
var summary = _accountService.GetAccountTransactionSummary(account, workPeriod, range.Start, range.End);
var totalBalance = summary.Transactions.Sum(x => x.Debit - x.Credit).ToString(LocalSettings.ReportCurrencyFormat);
var report = new SimpleReport("");
report.AddParagraph("Header");
report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo);
report.AddParagraphLine("Header", Resources.AccountTransaction, true);
report.AddParagraphLine("Header", "");
report.AddParagraphLine("Header", string.Format("{0}: {1}", string.Format(Resources.Name_f, Resources.Account), account.Name));
report.AddParagraphLine("Header", string.Format("{0}: {1}", Resources.Balance, totalBalance));
report.AddParagraphLine("Header", "");
report.AddColumnLength("Transactions", "15*", "35*", "15*", "15*", "20*");
report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right);
report.AddTable("Transactions", Resources.Date, Resources.Description, Resources.Debit, Resources.Credit, Resources.Balance);
foreach (var ad in summary.Transactions)
{
report.AddRow("Transactions", ad.Date.ToShortDateString(), ad.Name, ad.DebitStr, ad.CreditStr, ad.BalanceStr);
}
foreach (var sum in summary.Summaries)
{
report.AddBoldRow("Transactions", "", sum.Caption, sum.Debit, sum.Credit, sum.Balance);
}
_printerService.PrintReport(report.Document, printer);
}
示例6: CreateDocument
public AccountTransactionDocument CreateDocument(Account account, string description, decimal amount, decimal exchangeRate, IList<AccountData> accounts, IList<ForeignCurrency> currencies)
{
var result = new AccountTransactionDocument { Name = Name, DocumentTypeId = Id };
foreach (var accountTransactionType in TransactionTypes)
{
var transaction = AccountTransaction.Create(accountTransactionType);
var amountRate = GetExchangeRate(accountTransactionType.ForeignCurrencyId, currencies);
amount = amount * amountRate;
transaction.UpdateAmount(amount, exchangeRate, accounts);
transaction.UpdateAccount(MasterAccountTypeId, account.Id);
if (accounts != null && accounts.Count > 0)
{
if (transaction.SourceAccountTypeId != MasterAccountTypeId &&
transaction.SourceTransactionValue.AccountId == 0)
{
var ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.SourceAccountTypeId);
if (ac != null) transaction.SetSourceAccount(ac.AccountTypeId, ac.AccountId);
}
if (transaction.TargetAccountTypeId != MasterAccountTypeId &&
transaction.TargetTransactionValue.AccountId == 0)
{
var ac = accounts.FirstOrDefault(x => x.AccountTypeId == transaction.TargetAccountTypeId);
if (ac != null) transaction.SetTargetAccount(ac.AccountTypeId, ac.AccountId);
}
}
if (!string.IsNullOrEmpty(description))
{
transaction.UpdateDescription(description);
}
result.AccountTransactions.Add(transaction);
}
return result;
}
示例7: GetAccountSelectors
private IEnumerable<AccountSelectViewModel> GetAccountSelectors(AccountTransactionDocumentType documentType, Account selectedAccount, IAccountService accountService, ICacheService cacheService)
{
var accountMap = documentType.AccountTransactionDocumentAccountMaps.FirstOrDefault(x => x.AccountId == selectedAccount.Id);
return accountMap != null
? documentType.GetNeededAccountTypes().Select(x => new AccountSelectViewModel(accountService, cacheService.GetAccountTypeById(x), accountMap.MappedAccountId, accountMap.MappedAccountName))
: documentType.GetNeededAccountTypes().Select(x => new AccountSelectViewModel(accountService, cacheService.GetAccountTypeById(x)));
}
示例8: AddNewTransaction
public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId, Account account, decimal amount, decimal exchangeRate)
{
var transaction = AccountTransaction.Create(template, accountTypeId, accountId);
transaction.UpdateAccounts(account.AccountTypeId, account.Id);
transaction.UpdateAmount(amount, exchangeRate);
AccountTransactions.Add(transaction);
return transaction;
}
示例9: AddAccountTransaction
public void AddAccountTransaction(Ticket ticket, Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate)
{
var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId, sourceAccount.Id, targetAccount.Id);
if (transactionType != null)
{
ticket.TransactionDocument.AddNewTransaction(transactionType, ticket.GetTicketAccounts(), amount, exchangeRate);
}
}
示例10: CreateAccountTransaction
public void CreateAccountTransaction(Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate)
{
var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId,
sourceAccount.Id, targetAccount.Id);
if (transactionType != null)
{
_accountDao.CreateAccountTransaction(transactionType, sourceAccount, targetAccount, amount, exchangeRate);
}
}
示例11: AddAccountTransaction
public void AddAccountTransaction(Ticket ticket, Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate)
{
var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId, sourceAccount.Id, targetAccount.Id);
if (transactionType != null)
{
var transaction = ticket.TransactionDocument.AddNewTransaction(transactionType, ticket.GetTicketAccounts(), amount, exchangeRate);
transaction.UpdateDescription(string.Format("{0} - {1}: {2}", transaction.Name, Resources.TicketNumber, ticket.TicketNumber));
}
}
示例12: OnDocumentCreation
private void OnDocumentCreation(EventParameters<DocumentCreationData> obj)
{
SelectedAccount = obj.Value.Account;
DocumentTemplate = obj.Value.DocumentTemplate;
Description = _accountService.GetDescription(obj.Value.DocumentTemplate, obj.Value.Account);
Amount = _accountService.GetDefaultAmount(obj.Value.DocumentTemplate, obj.Value.Account);
RaisePropertyChanged(() => Description);
RaisePropertyChanged(() => Amount);
RaisePropertyChanged(() => AccountName);
}
示例13: CreateDocument
public AccountTransactionDocument CreateDocument(Account account, string description, decimal amount)
{
Debug.Assert(account.AccountTemplateId == MasterAccountTemplateId);
var result = new AccountTransactionDocument { Name = Name };
foreach (var accountTransactionTemplate in TransactionTemplates)
{
var transaction = AccountTransaction.Create(accountTransactionTemplate);
transaction.Name = description;
transaction.Amount = amount;
if (transaction.SourceTransactionValue.AccountTemplateId == MasterAccountTemplateId)
transaction.SetSoruceAccount(account.AccountTemplateId, account.Id);
if (transaction.TargetTransactionValue.AccountTemplateId == MasterAccountTemplateId)
transaction.SetTargetAccount(account.AccountTemplateId, account.Id);
result.AccountTransactions.Add(transaction);
}
return result;
}
示例14: AddAccountTransaction
public void AddAccountTransaction(Ticket ticket, Account sourceAccount, Account targetAccount, decimal amount, decimal exchangeRate)
{
var transactionType = _cacheService.FindAccountTransactionType(sourceAccount.AccountTypeId, targetAccount.AccountTypeId, sourceAccount.Id, targetAccount.Id);
if (transactionType != null)
{
var transaction = ticket.TransactionDocument.AddNewTransaction(transactionType, ticket.GetTicketAccounts(), amount, exchangeRate);
transaction.UpdateDescription(string.Format("{0} - {1}: {2}", transaction.Name, Resources.TicketNumber, ticket.TicketNumber));
_applicationState.NotifyEvent(RuleEventNames.AccountTransactionAddedToTicket,
new
{
Ticket = ticket,
TransactionTypeName = transactionType.Name,
SourceAccountName = sourceAccount.Name,
TargetAccountName = targetAccount.Name,
Amount = amount,
ExchangeRate = exchangeRate
});
}
}
示例15: GetAccountTransactionSummary
public AccountTransactionSummary GetAccountTransactionSummary(Account selectedAccount, WorkPeriod currentWorkPeriod, DateTime? start = null, DateTime? end = null)
{
if (!start.HasValue)
{
var accountType = _cacheService.GetAccountTypeById(selectedAccount.AccountTypeId);
if (accountType != null)
{
if (accountType.DefaultFilterType == 1) start = DateTime.Now.MonthStart();
if (accountType.DefaultFilterType == 2) start = DateTime.Now.StartOfWeek();
if (accountType.DefaultFilterType == 3) start = currentWorkPeriod.StartDate;
}
}
return
AccountTransactionSummaryBuilder.Create()
.ForAccount(selectedAccount)
.WithStartDate(start)
.WithEndDate(end)
.Build();
}