From 151b2ba20176ad3ed9823eaa83b33f3bf918e37e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 3 Apr 2015 20:16:02 +0200 Subject: [PATCH] Rebudgeting works --- Site5/Pages/v5/Financial/AttestCosts.aspx | 1 + Site5/Pages/v5/Financial/AttestCosts.aspx.cs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx b/Site5/Pages/v5/Financial/AttestCosts.aspx index a918bb55..6a31ff48 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx @@ -296,6 +296,7 @@ function onRebudgetRecord() { var newAccountId = <%=this.DropBudgetsRebudget.ClientID%>_val(); + alert(newAccountId); if (newAccountId == 0) { alertify.error(decodeURIComponent('')); return; diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs index c37dcc58..04669999 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs @@ -118,7 +118,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial char recordType = recordId[0]; int itemId = Int32.Parse (recordId.Substring (1)); - FinancialAccount newAccount = FinancialAccount.FromIdentity(itemId); + FinancialAccount newAccount = FinancialAccount.FromIdentity(newAccountId); switch (recordType) { @@ -133,14 +133,24 @@ namespace Swarmops.Frontend.Pages.v5.Financial claim.SetBudget (newAccount, authData.CurrentUser); break; case 'A': // Cash advance - CashAdvance advance = CashAdvance.FromIdentity (itemId); + CashAdvance advance = CashAdvance.FromIdentity(itemId); if (advance.Budget.OrganizationId != authData.CurrentOrganization.Identity || advance.Budget.OwnerPersonId != authData.CurrentUser.Identity || newAccount.OrganizationId != authData.CurrentOrganization.Identity) { throw new UnauthorizedAccessException(); } - advance.Budget = newAccount; // no accounting changes + advance.Budget = newAccount; // no accounting changes, so just change + break; + case 'I': // Cash advance + InboundInvoice invoice = InboundInvoice.FromIdentity (itemId); + if (invoice.Budget.OrganizationId != authData.CurrentOrganization.Identity || + invoice.Budget.OwnerPersonId != authData.CurrentUser.Identity || + newAccount.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new UnauthorizedAccessException(); + } + invoice.SetBudget (newAccount, authData.CurrentUser); break; default: throw new NotImplementedException("Unknown record type");