Skip to content

Instantly share code, notes, and snippets.

Created October 16, 2013 06:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7003337 to your computer and use it in GitHub Desktop.
Save anonymous/7003337 to your computer and use it in GitHub Desktop.
Manager.io
public override void Get()
{
using (new Template(this, "Cash Accounts", this.FileID))
{
using (base.Div(null, "panel panel-default", null, null, null))
{
using (base.Div(null, "panel-heading", null, null, null))
{
using (base.Span(null, "header", null, null, null))
{
base.Write("Cash Accounts");
}
CashAccountForm form = new CashAccountForm {
FileID = this.FileID,
Referrer = base.ToUrl()
};
using (base.A(form.ToUrl(), null, "btn btn-default btn-sm", "font-weight: bold; margin-left: 10px", null, null, null, null, null, null, null, null, null, null, new string[0]))
{
base.Write("New Cash Account");
}
}
CashAccount[] source = (from x in Objects.Get(this.FileID).OfType<CashAccount>()
orderby x.Name
select x).ToArray<CashAccount>();
if (!source.Any<CashAccount>())
{
using (base.Div(null, "well", "text-align: center; padding: 50px", null, null))
{
using (base.Span(null, null, "color: #ccc; font-size: 18px; font-weight: bold; text-shadow: 1px 1px 0px #fff", null, null))
{
base.Write("You don't have any cash accounts. Why not create the first cash account?");
}
base.Br();
base.Br();
CashAccountForm form2 = new CashAccountForm {
FileID = this.FileID,
Referrer = base.ToUrl()
};
using (base.A(form2.ToUrl(), null, "btn btn-primary btn-lg", "font-weight: bold", null, null, null, null, null, null, null, null, null, null, new string[0]))
{
base.Write("New Cash Account");
}
return;
}
}
Transactions.Transaction[] transactionArray = (from x in Objects.Get(this.FileID).GetTransactions(AccountingBasis.Accrual)
where x.Account == ChartOfAccounts.CashOnHand
select x).ToArray<Transactions.Transaction>();
using (base.Table(null, "table table-striped", null, null, null))
{
using (base.THead())
{
using (base.Tr(null, null, null, null))
{
using (base.Th(null, null, "text-align: center", null, null, null))
{
base.Img("resources/webalys/_16px/edition-35.png", null, null, null, null, null, null, null);
}
using (base.Th(null, null, null, null, null, null))
{
base.Write("Name");
}
using (base.Th(null, null, "text-align: center; width: 100px; white-space: nowrap", null, null, null))
{
base.Write("Last Transaction");
}
using (base.Th(null, null, "text-align: right; width: 100px", null, null, null))
{
base.Write("Balance");
}
}
}
CashAccount[] accountArray2 = source;
for (int i = 0; i < accountArray2.Length; i++)
{
Func<Transactions.Transaction, bool> predicate = null;
Func<Transactions.Transaction, bool> func2 = null;
Func<Transactions.Transaction, bool> func3 = null;
CashAccount e = accountArray2[i];
if (predicate == null)
{
predicate = x => x.CashAccount == e.Key;
}
decimal num = transactionArray.Where<Transactions.Transaction>(predicate).Sum<Transactions.Transaction>((Func<Transactions.Transaction, decimal>) (x => x.Amount));
using (base.Tr(null, null, null, null))
{
int? colspan = null;
int? rowspan = null;
using (base.Td(null, null, "width: 1px", null, colspan, rowspan))
{
CashAccountForm form3 = new CashAccountForm {
FileID = this.FileID,
Key = new Guid?(e.Key),
Referrer = base.ToUrl()
};
int? tabIndex = null;
using (base.A(form3.ToUrl(), null, "btn btn-default btn-xs", null, null, null, null, tabIndex, null, null, null, null, null, null, new string[0]))
{
base.Write("Edit");
}
}
int? nullable15 = null;
int? nullable16 = null;
using (base.Td(null, null, null, null, nullable15, nullable16))
{
CashAccountTransactions transactions = new CashAccountTransactions {
FileID = this.FileID,
CashAccountID = e.Key
};
int? nullable17 = null;
using (base.A(transactions.ToUrl(), null, null, "font-weight: bold", null, null, null, nullable17, null, null, null, null, null, null, new string[0]))
{
base.Write(e.Name);
}
}
int? nullable18 = null;
int? nullable19 = null;
using (base.Td(null, null, "text-align: center", null, nullable18, nullable19))
{
if (func2 == null)
{
func2 = x => x.CashAccount == e.Key;
}
if (transactionArray.Where<Transactions.Transaction>(func2).Any<Transactions.Transaction>())
{
if (func3 == null)
{
func3 = x => x.CashAccount == e.Key;
}
DateTime date = (from x in transactionArray.Where<Transactions.Transaction>(func3)
orderby x.Date descending
select x).First<Transactions.Transaction>().Date;
if (date == DateTime.Today)
{
base.Write("Today");
}
else if (date == DateTime.Today.AddDays(-1.0))
{
base.Write("Yesterday");
}
else
{
TimeSpan span3 = (TimeSpan) (DateTime.Today - date);
base.Write(((int) span3.TotalDays) + " days ago");
}
}
else
{
base.Write("-");
}
}
int? nullable20 = null;
int? nullable21 = null;
using (base.Td(null, null, "text-align: right; font-weight: bold; vertical-align: middle", null, nullable20, nullable21))
{
using (base.Span(null, null, (num < 0M) ? "color: red" : null, null, null))
{
base.Write(num.ToLocalString());
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment