Added ability to attest all cost types (deattesting Parleys remain, viewing docs remain, denying attestations remain).
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Swarmops.Basic.Types.Financial
|
||||
this.PersonId = personId;
|
||||
this.CreatedDateTime = createdDateTime;
|
||||
this.CreatedByPersonId = createdByPersonId;
|
||||
this.FinancialAccountId = financialAccountId;
|
||||
this.BudgetId = financialAccountId;
|
||||
this.AmountCents = amountCents;
|
||||
this.Description = description;
|
||||
this.Open = open;
|
||||
@@ -27,7 +27,7 @@ namespace Swarmops.Basic.Types.Financial
|
||||
|
||||
public BasicCashAdvance (BasicCashAdvance original):
|
||||
this(original.CashAdvanceId, original.OrganizationId, original.PersonId, original.CreatedDateTime, original.CreatedByPersonId,
|
||||
original.FinancialAccountId, original.AmountCents,original.Description, original.Open, original.Attested,
|
||||
original.BudgetId, original.AmountCents,original.Description, original.Open, original.Attested,
|
||||
original.PaidOut, original.AttestedByPersonId, original.AttestedDateTime)
|
||||
{
|
||||
// copy ctor - no action other than copying original object
|
||||
@@ -44,7 +44,7 @@ namespace Swarmops.Basic.Types.Financial
|
||||
public int PersonId { get; protected set; }
|
||||
public DateTime CreatedDateTime { get; protected set; }
|
||||
public int CreatedByPersonId { get; protected set; }
|
||||
public int FinancialAccountId { get; protected set; }
|
||||
public int BudgetId { get; protected set; }
|
||||
public Int64 AmountCents { get; protected set; }
|
||||
public string Description { get; protected set; }
|
||||
public bool Open { get; protected set; }
|
||||
|
||||
@@ -73,9 +73,9 @@ namespace Swarmops.Logic.Financial
|
||||
get { return Person.FromIdentity(this.PersonId); }
|
||||
}
|
||||
|
||||
public FinancialAccount FinancialAccount
|
||||
public FinancialAccount Budget
|
||||
{
|
||||
get { return FinancialAccount.FromIdentity(this.FinancialAccountId); }
|
||||
get { return FinancialAccount.FromIdentity(this.BudgetId); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace Swarmops.Logic.Financial
|
||||
get { return Person.FromIdentity (base.ClaimingPersonId); }
|
||||
}
|
||||
|
||||
[Obsolete("Obsolete", true)]
|
||||
public void CreateEvent (ExpenseEventType eventType, Person person)
|
||||
{
|
||||
// OBSOLETE
|
||||
|
||||
@@ -16,13 +16,7 @@ namespace Swarmops.Logic.Financial
|
||||
get
|
||||
{
|
||||
var result = new ExpenseClaims();
|
||||
foreach (ExpenseClaim expense in this)
|
||||
{
|
||||
if (expense.Open)
|
||||
{
|
||||
result.Add (expense);
|
||||
}
|
||||
}
|
||||
result.AddRange(this.Where(expense => expense.Open));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -33,13 +27,7 @@ namespace Swarmops.Logic.Financial
|
||||
get
|
||||
{
|
||||
var result = new ExpenseClaims();
|
||||
foreach (ExpenseClaim expense in this)
|
||||
{
|
||||
if (expense.Approved)
|
||||
{
|
||||
result.Add (expense);
|
||||
}
|
||||
}
|
||||
result.AddRange(this.Where(expense => expense.Approved));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -50,13 +38,7 @@ namespace Swarmops.Logic.Financial
|
||||
get
|
||||
{
|
||||
var result = new ExpenseClaims();
|
||||
foreach (ExpenseClaim expense in this)
|
||||
{
|
||||
if (!expense.Approved)
|
||||
{
|
||||
result.Add (expense);
|
||||
}
|
||||
}
|
||||
result.AddRange(this.Where(expense => !expense.Approved));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -68,7 +50,7 @@ namespace Swarmops.Logic.Financial
|
||||
get
|
||||
{
|
||||
ExpenseClaims result = new ExpenseClaims();
|
||||
result.AddRange(this.Where(expenseClaim => expenseClaim.Attested == false));
|
||||
result.AddRange(this.Where(expenseClaim => !expenseClaim.Attested));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -118,29 +100,15 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
get
|
||||
{
|
||||
decimal result = 0.0m;
|
||||
|
||||
foreach (ExpenseClaim claim in this)
|
||||
{
|
||||
result += claim.Amount;
|
||||
}
|
||||
|
||||
return result;
|
||||
return this.Sum(claim => claim.Amount);
|
||||
}
|
||||
}
|
||||
|
||||
public Int64 TotalAmountCents
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 result = 0;
|
||||
|
||||
foreach (ExpenseClaim claim in this)
|
||||
{
|
||||
result += claim.AmountCents;
|
||||
}
|
||||
|
||||
return result;
|
||||
get
|
||||
{
|
||||
return this.Sum(claim => claim.AmountCents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Database;
|
||||
@@ -10,6 +11,31 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
public class InboundInvoices: PluralBase<InboundInvoices,InboundInvoice,BasicInboundInvoice>
|
||||
{
|
||||
|
||||
public InboundInvoices WhereAttested
|
||||
{
|
||||
get
|
||||
{
|
||||
InboundInvoices result = new InboundInvoices();
|
||||
result.AddRange(this.Where(invoice => invoice.Attested == true));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public InboundInvoices WhereUnattested
|
||||
{
|
||||
get
|
||||
{
|
||||
InboundInvoices result = new InboundInvoices();
|
||||
result.AddRange(this.Where(invoice => invoice.Attested == false));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all open inbound invoices for a particular organization.
|
||||
/// </summary>
|
||||
|
||||
+32
-32
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Database;
|
||||
@@ -22,18 +23,38 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Salaries WhereAttested
|
||||
{
|
||||
get
|
||||
{
|
||||
Salaries result = new Salaries();
|
||||
result.AddRange(this.Where(salary => salary.Attested));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Salaries WhereUnattested
|
||||
{
|
||||
get
|
||||
{
|
||||
Salaries result = new Salaries();
|
||||
result.AddRange(this.Where(salary => !salary.Attested));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double TotalAmountNet
|
||||
{
|
||||
get
|
||||
{
|
||||
double result = 0.0;
|
||||
|
||||
foreach (Salary salary in this)
|
||||
{
|
||||
result += salary.NetSalaryCents / 100.0;
|
||||
}
|
||||
|
||||
return result;
|
||||
return this.Sum(salary => salary.NetSalaryCents/100.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,14 +62,7 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
get
|
||||
{
|
||||
double result = 0.0;
|
||||
|
||||
foreach (Salary salary in this)
|
||||
{
|
||||
result += salary.TaxTotalCents / 100.0;
|
||||
}
|
||||
|
||||
return result;
|
||||
return this.Sum(salary => salary.TaxTotalCents/100.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,14 +70,7 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 result = 0;
|
||||
|
||||
foreach (Salary salary in this)
|
||||
{
|
||||
result += salary.NetSalaryCents;
|
||||
}
|
||||
|
||||
return result;
|
||||
return this.Sum(salary => salary.NetSalaryCents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,14 +78,7 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 result = 0;
|
||||
|
||||
foreach (Salary salary in this)
|
||||
{
|
||||
result += salary.TaxTotalCents;
|
||||
}
|
||||
|
||||
return result;
|
||||
return this.Sum(salary => salary.TaxTotalCents);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,9 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
public void Deattest(Person deattester)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
|
||||
FinancialDependencyType.Salary, this.Identity, DateTime.Now, deattester.Identity, this.NetSalaryCents / 100.0);
|
||||
SwarmDb.GetDatabaseForWriting().SetSalaryAttested(this.Identity, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
+82
-23
@@ -132,32 +132,43 @@ namespace Swarmops.Logic.Swarm
|
||||
return;
|
||||
}
|
||||
|
||||
base.Attested = true;
|
||||
SwarmDb.GetDatabaseForWriting().SetParleyAttested(this.Identity, true);
|
||||
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
|
||||
FinancialDependencyType.Parley, this.Identity,
|
||||
DateTime.Now, attester.Identity, (double)(this.GuaranteeDecimal));
|
||||
|
||||
// If needed, create new account for parley
|
||||
|
||||
if (base.BudgetId < 0)
|
||||
FinancialAccount ourBudget;
|
||||
FinancialAccount parentBudget;
|
||||
int year = DateTime.Today.Year;
|
||||
|
||||
if (base.BudgetId < 0) // no account created yet
|
||||
{
|
||||
FinancialAccount newBudget = FinancialAccount.Create(this.Budget.OrganizationId,
|
||||
"Conf: " + this.Name,
|
||||
FinancialAccountType.Cost,
|
||||
this.BudgetId);
|
||||
ourBudget = FinancialAccount.Create(this.Budget.OrganizationId,
|
||||
"Conf: " + this.Name,
|
||||
FinancialAccountType.Cost,
|
||||
this.BudgetId);
|
||||
|
||||
int year = DateTime.Today.Year;
|
||||
FinancialAccount parentBudget = this.Budget;
|
||||
parentBudget = this.Budget;
|
||||
|
||||
base.BudgetId = newBudget.Identity;
|
||||
newBudget.Owner = this.Person;
|
||||
newBudget.SetBudget(DateTime.Today.Year, (double) -this.BudgetDecimal);
|
||||
parentBudget.SetBudget(DateTime.Today.Year,
|
||||
(double) parentBudget.GetBudget(year) + (double) this.BudgetDecimal); // cost budgets are negative
|
||||
|
||||
SwarmDb.GetDatabaseForWriting().SetParleyBudget(this.Identity, newBudget.Identity);
|
||||
base.BudgetId = ourBudget.Identity;
|
||||
ourBudget.Owner = this.Person;
|
||||
SwarmDb.GetDatabaseForWriting().SetParleyBudget(this.Identity, ourBudget.Identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The budget has been created already - we should already be initialized. Verify this
|
||||
// by checking that we were already attested once.
|
||||
|
||||
if (!this.AttestedOnce)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Budget exists despite parley not having been attested. This should not be possible.");
|
||||
}
|
||||
|
||||
ourBudget = this.Budget;
|
||||
parentBudget = this.ParentBudget;
|
||||
}
|
||||
|
||||
ourBudget.SetBudgetCents(DateTime.Today.Year, -this.BudgetCents);
|
||||
parentBudget.SetBudgetCents(DateTime.Today.Year,
|
||||
parentBudget.GetBudgetCents(year) + this.BudgetCents); // cost budgets are negative
|
||||
|
||||
// Reserve the guarantee money
|
||||
|
||||
@@ -167,9 +178,19 @@ namespace Swarmops.Logic.Swarm
|
||||
guaranteeFundsTx.AddRow(this.Budget, -this.GuaranteeCents, attester);
|
||||
guaranteeFundsTx.AddRow(this.Budget.Parent, this.GuaranteeCents, attester);
|
||||
|
||||
// Finally, set as attested
|
||||
|
||||
PWEvents.CreateEvent(
|
||||
EventSource.PirateWeb, EventType.ParleyAttested, attester.Identity,
|
||||
this.OrganizationId, 0, 0, this.Identity, string.Empty);
|
||||
|
||||
base.Attested = true;
|
||||
SwarmDb.GetDatabaseForWriting().SetParleyAttested(this.Identity, true);
|
||||
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
|
||||
FinancialDependencyType.Parley, this.Identity,
|
||||
DateTime.Now, attester.Identity, (double)(this.GuaranteeDecimal));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Deattest(Person deattester)
|
||||
@@ -188,6 +209,24 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
|
||||
|
||||
public FinancialAccount ParentBudget
|
||||
{
|
||||
get
|
||||
{
|
||||
// If the financial account for this parley is uninitialized, the BudgetId of base is negative to indicate that.
|
||||
|
||||
if (base.BudgetId < 0)
|
||||
{
|
||||
return FinancialAccount.FromIdentity(-base.BudgetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Budget.Parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public void CloseBudget(Person closingPerson)
|
||||
@@ -209,9 +248,29 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
if (this.BudgetId > 0) // Budget attested and allocated
|
||||
{
|
||||
this.Budget.Parent.SetBudget(year,
|
||||
(double)this.Budget.Parent.GetBudget(year) - (double)this.BudgetDecimal); // cost budgets are negative
|
||||
this.Budget.SetBudget(year, 0.0);
|
||||
this.Budget.Parent.SetBudgetCents(year,
|
||||
this.Budget.Parent.GetBudgetCents(year) - this.BudgetCents); // cost budgets are negative
|
||||
this.Budget.SetBudgetCents(year, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private bool AttestedOnce
|
||||
{
|
||||
get
|
||||
{
|
||||
BasicFinancialValidation[] validations =
|
||||
SwarmDb.GetDatabaseForReading().GetFinancialValidations(FinancialDependencyType.Parley,
|
||||
this.Identity);
|
||||
|
||||
foreach (BasicFinancialValidation validation in validations)
|
||||
{
|
||||
if (validation.ValidationType == FinancialValidationType.Attestation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
@@ -43,5 +45,20 @@ namespace Swarmops.Logic.Swarm
|
||||
return FromArray(SwarmDb.GetDatabaseForReading().GetParleys(person, DatabaseCondition.OpenTrue));
|
||||
}
|
||||
}
|
||||
|
||||
public Parleys WhereUnattested
|
||||
{
|
||||
get
|
||||
{
|
||||
Parleys result = new Parleys();
|
||||
result.AddRange(this.Where(parley => !parley.Attested));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,21 @@
|
||||
<data name="Financial_CashAdvance" xml:space="preserve">
|
||||
<value>Advance</value>
|
||||
</data>
|
||||
<data name="Financial_ExpenseClaim" xml:space="preserve">
|
||||
<value>Expense</value>
|
||||
</data>
|
||||
<data name="Financial_InvoiceInbound" xml:space="preserve">
|
||||
<value>Invoice</value>
|
||||
</data>
|
||||
<data name="Financial_InvoiceOutbound" xml:space="preserve">
|
||||
<value>Invoice</value>
|
||||
</data>
|
||||
<data name="Financial_Parley" xml:space="preserve">
|
||||
<value>Conference</value>
|
||||
</data>
|
||||
<data name="Financial_Salary" xml:space="preserve">
|
||||
<value>Salary</value>
|
||||
</data>
|
||||
<data name="Financial_YearlyResult" xml:space="preserve">
|
||||
<value>Yearly result</value>
|
||||
</data>
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
{
|
||||
throw new InvalidOperationException("Called to attest out-of-org line item");
|
||||
}
|
||||
if (advance.FinancialAccount.OwnerPersonId != currentUserId && advance.FinancialAccount.OwnerPersonId != Person.NobodyId)
|
||||
if (advance.Budget.OwnerPersonId != currentUserId && advance.Budget.OwnerPersonId != Person.NobodyId)
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Called without attestation privileges");
|
||||
}
|
||||
@@ -121,6 +121,78 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
beneficiary = advance.Person.Name;
|
||||
amountCents = advance.AmountCents;
|
||||
|
||||
break;
|
||||
case 'E': // Expense claim
|
||||
ExpenseClaim expense = ExpenseClaim.FromIdentity(itemId);
|
||||
if (expense.OrganizationId != currentOrganizationId)
|
||||
{
|
||||
throw new InvalidOperationException("Called to attest out-of-org line item");
|
||||
}
|
||||
if (expense.Budget.OwnerPersonId != currentUserId && expense.Budget.OwnerPersonId != Person.NobodyId)
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Called without attestation privileges");
|
||||
}
|
||||
|
||||
attestableItem = expense;
|
||||
attestedTemplate = Resources.Pages.Financial.AttestCosts_ExpenseAttested;
|
||||
deattestedTemplate = Resources.Pages.Financial.AttestCosts_ExpenseDeattested;
|
||||
beneficiary = expense.Claimer.Name;
|
||||
amountCents = expense.AmountCents;
|
||||
|
||||
break;
|
||||
case 'I': // Inbound invoice
|
||||
InboundInvoice invoice = InboundInvoice.FromIdentity(itemId);
|
||||
if (invoice.OrganizationId != currentOrganizationId)
|
||||
{
|
||||
throw new InvalidOperationException("Called to attest out-of-org line item");
|
||||
}
|
||||
if (invoice.Budget.OwnerPersonId != currentUserId && invoice.Budget.OwnerPersonId != Person.NobodyId)
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Called without attestation privileges");
|
||||
}
|
||||
|
||||
attestableItem = invoice;
|
||||
attestedTemplate = Resources.Pages.Financial.AttestCosts_InvoiceAttested;
|
||||
deattestedTemplate = Resources.Pages.Financial.AttestCosts_InvoiceDeattested;
|
||||
beneficiary = invoice.Supplier;
|
||||
amountCents = invoice.AmountCents;
|
||||
|
||||
break;
|
||||
case 'S': // Salary payout
|
||||
Salary salary = Salary.FromIdentity(itemId);
|
||||
if (salary.PayrollItem.OrganizationId != currentOrganizationId)
|
||||
{
|
||||
throw new InvalidOperationException("Called to attest out-of-org line item");
|
||||
}
|
||||
if (salary.PayrollItem.Budget.OwnerPersonId != currentUserId && salary.PayrollItem.Budget.OwnerPersonId != Person.NobodyId)
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Called without attestation privileges");
|
||||
}
|
||||
|
||||
attestableItem = salary;
|
||||
attestedTemplate = Resources.Pages.Financial.AttestCosts_SalaryAttested;
|
||||
deattestedTemplate = Resources.Pages.Financial.AttestCosts_SalaryDeattested;
|
||||
beneficiary = salary.PayrollItem.PersonCanonical;
|
||||
amountCents = salary.GrossSalaryCents;
|
||||
|
||||
break;
|
||||
case 'P': // Parley, aka Conference
|
||||
Parley parley = Parley.FromIdentity(itemId);
|
||||
if (parley.OrganizationId != currentOrganizationId)
|
||||
{
|
||||
throw new InvalidOperationException("Called to attest out-of-org line item");
|
||||
}
|
||||
if (parley.Budget.OwnerPersonId != currentUserId && parley.Budget.OwnerPersonId != Person.NobodyId)
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Called without attestation privileges");
|
||||
}
|
||||
|
||||
attestableItem = parley;
|
||||
attestedTemplate = Resources.Pages.Financial.AttestCosts_ParleyAttested;
|
||||
deattestedTemplate = Resources.Pages.Financial.AttestCosts_ParleyDeattested;
|
||||
beneficiary = parley.Person.Name;
|
||||
amountCents = parley.BudgetCents;
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("Unknown Cost Type in HandleAttestationDeattestation: \"" + identifier + "\"");
|
||||
|
||||
@@ -10,6 +10,7 @@ using Swarmops.Basic.Interfaces;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
@@ -42,6 +43,10 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
_items = new AttestableItems();
|
||||
|
||||
PopulateCashAdvances();
|
||||
PopulateExpenses();
|
||||
PopulateInboundInvoices();
|
||||
PopulateSalaries();
|
||||
PopulateParleys();
|
||||
|
||||
// Format as JSON and return
|
||||
|
||||
@@ -86,7 +91,7 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
|
||||
protected class AttestableItem
|
||||
{
|
||||
public AttestableItem(string identity, string beneficiary, Int64 amountCents, FinancialAccount account, string description, string identityDisplay, IHasIdentity item)
|
||||
public AttestableItem(string identity, string beneficiary, Int64 amountCents, FinancialAccount account, string description, string identityDisplay, bool hasDox, IHasIdentity item)
|
||||
{
|
||||
this.IdentityDisplay = identityDisplay;
|
||||
this.Identity = identity;
|
||||
@@ -94,6 +99,7 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
this.AmountRequestedCents = amountCents;
|
||||
this.Budget = account;
|
||||
this.Description = description;
|
||||
this.HasDox = hasDox;
|
||||
this.Item = item;
|
||||
}
|
||||
|
||||
@@ -105,6 +111,7 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
public string Description { get; private set; }
|
||||
public string IdentityDisplay { get; private set; }
|
||||
public IHasIdentity Item { get; private set; }
|
||||
public bool HasDox { get; private set; }
|
||||
}
|
||||
|
||||
protected class AttestableItems : List<AttestableItem>
|
||||
@@ -141,7 +148,12 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
|
||||
foreach (CashAdvance advance in advances)
|
||||
{
|
||||
_items.Add(new AttestableItem("A" + advance.Identity.ToString(CultureInfo.InvariantCulture), advance.Person.Name, advance.AmountCents, advance.FinancialAccount, advance.Description, "Financial_CashAdvance", advance));
|
||||
if (_attestationRights.ContainsKey(advance.BudgetId) || advance.Budget.OwnerPersonId == Person.NobodyId)
|
||||
{
|
||||
_items.Add(new AttestableItem("A" + advance.Identity.ToString(CultureInfo.InvariantCulture),
|
||||
advance.Person.Name, advance.AmountCents, advance.Budget,
|
||||
advance.Description, "Financial_CashAdvance", false, advance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +161,62 @@ public partial class Pages_v5_Finance_Json_AttestableCosts : System.Web.UI.Page
|
||||
private void PopulateExpenses()
|
||||
{
|
||||
ExpenseClaims expenses = ExpenseClaims.ForOrganization(_currentOrganization).WhereUnattested;
|
||||
|
||||
foreach (var expenseClaim in expenses)
|
||||
{
|
||||
if (_attestationRights.ContainsKey(expenseClaim.BudgetId) || expenseClaim.Budget.OwnerPersonId == Person.NobodyId)
|
||||
{
|
||||
Documents dox = expenseClaim.Documents;
|
||||
bool hasDox = (dox.Count > 0 ? true : false);
|
||||
|
||||
_items.Add(new AttestableItem("E" + expenseClaim.Identity.ToString(CultureInfo.InvariantCulture), expenseClaim.ClaimerCanonical, expenseClaim.AmountCents, expenseClaim.Budget, expenseClaim.Description, "Financial_ExpenseClaim", hasDox, expenseClaim));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PopulateInboundInvoices()
|
||||
{
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(_currentOrganization).WhereUnattested;
|
||||
|
||||
foreach (InboundInvoice invoice in invoices)
|
||||
{
|
||||
Documents dox = invoice.Documents;
|
||||
bool hasDox = (dox.Count > 0 ? true : false);
|
||||
|
||||
if (_attestationRights.ContainsKey(invoice.BudgetId) || invoice.Budget.OwnerPersonId == Person.NobodyId)
|
||||
{
|
||||
_items.Add(new AttestableItem("I" + invoice.Identity.ToString(CultureInfo.InvariantCulture), invoice.Supplier, invoice.AmountCents, invoice.Budget, invoice.InvoiceReference, "Financial_InvoiceInbound", hasDox, invoice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PopulateSalaries()
|
||||
{
|
||||
Salaries salaries = Salaries.ForOrganization(_currentOrganization).WhereUnattested;
|
||||
|
||||
foreach (Salary salary in salaries)
|
||||
{
|
||||
if (_attestationRights.ContainsKey(salary.PayrollItem.BudgetId) || salary.PayrollItem.Budget.OwnerPersonId == Person.NobodyId)
|
||||
{
|
||||
_items.Add(new AttestableItem("S" + salary.Identity.ToString(CultureInfo.InvariantCulture), salary.PayrollItem.PersonCanonical, salary.CostTotalCents, salary.PayrollItem.Budget, string.Format("Salary for {0:yyyy-MMM}", salary.PayoutDate), "Financial_Salary", false, salary));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PopulateParleys()
|
||||
{
|
||||
Parleys parleys = Parleys.ForOrganization(_currentOrganization).WhereUnattested;
|
||||
|
||||
foreach (Parley parley in parleys)
|
||||
{
|
||||
if (_attestationRights.ContainsKey(parley.BudgetId) || parley.Budget.OwnerPersonId == Person.NobodyId)
|
||||
{
|
||||
_items.Add(new AttestableItem("P" + parley.Identity.ToString(CultureInfo.InvariantCulture), parley.Person.Canonical, parley.BudgetCents, parley.ParentBudget, parley.Name, "Financial_Parley", false, parley));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user