Lots of work on unique HBAs, OInvs

This commit is contained in:
Rick Falkvinge
2017-11-29 17:51:14 +01:00
parent a8c560ae85
commit e130ae0cbb
8 changed files with 776 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
ALTER TABLE `OutboundInvoices`
ADD COLUMN `OrganizationSequenceId` INT(11) NOT NULL DEFAULT 0 AFTER `OrganizationId`,
ADD INDEX `Index_SequenceId` (`OrganizationSequenceId` ASC)
#
DROP PROCEDURE IF EXISTS `SetOutboundInvoiceOrganizationSequenceId`
#
DROP PROCEDURE IF EXISTS `CreateOutboundInvoice`
#
CREATE PROCEDURE `CreateOutboundInvoice`(
organizationId INTEGER,
createdDateTime DATETIME,
createdByPersonId INTEGER,
dueDate DATETIME,
budgetId INTEGER,
customerName VARCHAR(128),
invoiceAddressPaper VARCHAR(256),
invoiceAddressMail VARCHAR(128),
currencyId INTEGER,
reference VARCHAR(64),
domestic TINYINT(1),
securityCode VARCHAR(16),
theirReference VARCHAR(64)
)
BEGIN
DECLARE newIdentity INTEGER;
DECLARE sequenceNumber INTEGER;
INSERT INTO OutboundInvoices
(CustomerName,InvoiceAddressPaper,InvoiceAddressMail,CurrencyId,
BudgetId,OrganizationId,CreatedDateTime,CreatedByPersonId,
DueDate,ReminderCount,Reference,Open,Domestic,Sent,SecurityCode,TheirReference)
VALUES
(customerName,invoiceAddressPaper,invoiceAddressMail,currencyId,
budgetId,organizationId,createdDateTime,createdByPersonId,
dueDate,0,reference,1,domestic,0,securityCode,theirReference);
SELECT LAST_INSERT_ID() INTO newIdentity;
SELECT COUNT(*) FROM OutboundInvoices WHERE
OutboundInvoices.OrganizationId = organizationId AND
OutboundInvoices.InboundInvoiceId <= newIdentity INTO sequenceNumber;
UPDATE OutboundInvoices
SET OutboundInvoices.OrganizationSequenceId = sequenceNumber
WHERE OutboundInvoices.OutboundInvoiceId = newIdentity;
SELECT newIdentity AS Identity;
END
#
CREATE PROCEDURE `SetOutboundInvoiceOrganizationSequenceId`(
IN outboundInvoiceId INTEGER
)
BEGIN
DECLARE organizationId INTEGER;
DECLARE sequenceNumber INTEGER;
SELECT OutboundInvoices.OrganizationId
FROM OutboundInvoices
WHERE OutboundInvoices.OutboundInvoiceId = outboundInvoiceId
INTO organizationId;
SELECT COUNT(*)
FROM OutboundInvoices
WHERE OutboundInvoices.OrganizationId=organizationId
AND OutboundInvoices.OutboundInvoiceId <= outboundInvoiceId
INTO sequenceNumber;
UPDATE OutboundInvoices SET OrganizationSequenceId = sequenceNumber
WHERE OutboundInvoices.OutboundInvoiceId = outboundInvoiceId;
SELECT sequenceNumber AS OrganizationSequenceId;
END
+98
View File
@@ -0,0 +1,98 @@
ALTER TABLE `HotBitcoinAddresses`
ADD COLUMN `UniqueDerive` INT NOT NULL DEFAULT -1 AFTER `DerivationPath`,
ADD INDEX `Ix_Path` (`DerivationPath` ASC),
ADD INDEX `Ix_Unique` (`UniqueDerive` ASC)
#
DROP PROCEDURE IF EXISTS `SetHotBitcoinAddressAddress`
#
DROP PROCEDURE IF EXISTS `SetHotBitcoinAddress`
#
DROP PROCEDURE IF EXISTS `SetHotBitcoinAddressFallbackAddress`
#
DROP PROCEDURE IF EXISTS `CreateHotBitcoinAddress`
#
CREATE PROCEDURE `CreateHotBitcoinAddress`(
IN organizationId INT,
IN bitcoinChainId INT,
IN derivationPath VARCHAR(256)
)
BEGIN
DECLARE newIdentity INTEGER;
DECLARE sequenceNumber INTEGER;
INSERT INTO HotBitcoinAddresses
(OrganizationId,BitcoinChainId,DerivationPath,UniqueDerive,AddressString,AddressStringFallback,BalanceSatoshis,ThroughputSatoshis)
VALUES
(organizationId,bitcoinChainId,derivationPath,-1,'--TBD--','',0,0);
SELECT LAST_INSERT_ID() INTO newIdentity;
SELECT COUNT(*) FROM HotBitcoinAddresses WHERE
HotBitcoinAddresses.DerivationPath = derivationPath AND
HotBitcoinAddresses.OrganizationId = organizationId AND
HotBitcoinAddresses.HotBitcoinAddressId <= newIdentity INTO sequenceNumber;
UPDATE HotBitcoinAddresses
SET HotBitcoinAddresses.UniqueDerive = sequenceNumber
WHERE HotBitcoinAddreses.HotBitcoinAddressId = newIdentity;
SELECT newIdentity AS Identity;
END
#
CREATE PROCEDURE `SetHotBitcoinAddressAddress`(
IN hotBitcoinAddressId INT,
IN addressString BIGINT
)
BEGIN
UPDATE HotBitcoinAddresses
SET HotBitcoinAddresses.AddressString=addressString
WHERE HotBitcoinAddresses.HotBitcoinAddressId=hotBitcoinAddressId;
SELECT ROW_COUNT() AS RowsUpdated;
END
#
CREATE PROCEDURE `SetHotBitcoinAddressFallbackAddress`(
IN hotBitcoinAddressId INT,
IN addressStringFallback BIGINT
)
BEGIN
UPDATE HotBitcoinAddresses
SET HotBitcoinAddresses.AddressStringFallback=addressStringFallback
WHERE HotBitcoinAddresses.HotBitcoinAddressId=hotBitcoinAddressId;
SELECT ROW_COUNT() AS RowsUpdated;
END
@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" Inherits="Pages_v5_Finance_Json_ListInvoicesOutbound" Codebehind="Json-ListInvoicesOutbound.aspx.cs" %>
@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Swarmops.Common.Enums;
using Swarmops.Common.Interfaces;
using Swarmops.Frontend;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
public partial class Pages_v5_Finance_Json_ListInvoicesOutbound : DataV5Base
{
private OutboundInvoices _invoices;
protected void Page_Load (object sender, EventArgs e)
{
// Get invoices and attestation rights
this._invoices = OutboundInvoices.ForOrganization(this.CurrentOrganization, true);
_invoices.Sort(SortInvoicesByCreatedDateReverse);
// Format as JSON and return
Response.ContentType = "application/json";
string json = FormatAsJson();
Response.Output.WriteLine (json);
Response.End();
}
private static int SortInvoicesByCreatedDateReverse(OutboundInvoice a, OutboundInvoice b)
{
return DateTime.Compare(b.CreatedDateTime, a.CreatedDateTime);
}
private string FormatAsJson()
{
// Fields: item, dueDate, sender, budget, amount, progress, docs, action
StringBuilder result = new StringBuilder (16384);
string hasDoxString =
"<img src='/Images/Icons/iconshock-search-256px.png' onmouseover=\\\"this.src='/Images/Icons/iconshock-search-hot-256px.png';\\\" onmouseout=\\\"this.src='/Images/Icons/iconshock-search-256px.png';\\\" baseid='{6}' class='LocalViewDox' style='cursor:pointer' height='20' width='20' />";
result.Append ("{\"rows\":[");
DateTime dueDateFormatBreakDate = DateTime.Today.AddDays(-240);
foreach (OutboundInvoice invoice in _invoices)
{
result.Append("{");
result.AppendFormat(
"\"item\":\"{0}\",\"dueDate\":\"{1}\",\"sender\":\"{2}\",\"budget\":\"{3}\",\"amount\":\"{4}\",\"progress\":\"{5}\"," +
"\"dox\":\"" + (invoice.Documents.Count > 0 ? hasDoxString : "&nbsp;") + "\"," +
"\"actions\":\"<span style='position:relative;left:-2px'>" +
//"<img id=\\\"IconApproval{5}\\\" class=\\\"LocalIconApproval LocalNew LocalFundsInsufficient\\\" accountid=\\\"{6}\\\" amount=\\\"{4}\\\" baseid=\\\"{5}\\\" height=\\\"18\\\" width=\\\"24\\\" />" +
//"<img id=\\\"IconApproved{5}\\\" class=\\\"LocalIconApproved LocalNew\\\" baseid=\\\"{5}\\\" height=\\\"18\\\" width=\\\"24\\\" />" +
//"<img id=\\\"IconDenial{5}\\\" class=\\\"LocalIconDenial LocalNew\\\" baseid=\\\"{5}\\\" height=\\\"18\\\" width=\\\"24\\\" />" +
//"<img id=\\\"IconDenied{5}\\\" class=\\\"LocalIconDenied LocalNew\\\" baseid=\\\"{5}\\\" height=\\\"18\\\" width=\\\"24\\\" />" +
//"<img id=\\\"IconUndo{5}\\\" class=\\\"LocalIconUndo LocalNew\\\" baseid=\\\"{5}\\\" height=\\\"18\\\" width=\\\"24\\\" />" +
"</span>\"",
"#" + invoice.Identity.ToString("N0"),
JsonSanitize(invoice.DueDate.ToString(invoice.DueDate < dueDateFormatBreakDate ? "yyyy-MMM" : "MMM-dd")),
"Supplier",
JsonSanitize(invoice.Budget.Name),
JsonSanitize((invoice.AmountCents/100.0).ToString("N2")),
GetProgressTicks(invoice),
invoice.Identity); // Item #6 is only present in hasDoxString above
result.Append("},");
}
if (_invoices.Count > 1)
{
result.Remove(result.Length - 1, 1); // remove last comma
}
result.Append ("]}");
return result.ToString();
}
private string _emptyTick = "<img src='/Images/Icons/iconshock-empty-tick-128x96px.png' height='12' width='16'>";
private string _greenTick = "<img src='/Images/Icons/iconshock-green-tick-128x96px.png' height='12' width='16'>";
private string _redCross = "<img src='/Images/Icons/iconshock-red-cross-128x96px.png' height='12' width='16'>";
private string _filler = "<img src='/Images/Icons/transparency-16px.png' height='12' width='16'>";
private string GetProgressTicks(OutboundInvoice invoice)
{
StringBuilder ticks = new StringBuilder(512);
// The first tick is whether the invoice was even received yet, in anticipation of Purchase Orders
// For now, it is always filled
ticks.Append(_greenTick);
// For the time being, the other three are either all filled or all empty
if (invoice.Open)
{
ticks.Append(_emptyTick + _emptyTick + _emptyTick);
}
else
{
ticks.Append(_greenTick + _greenTick + _greenTick);
}
return ticks.ToString();
}
}
@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class Pages_v5_Finance_Json_ListInvoicesOutbound {
}
@@ -0,0 +1,128 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.v5.Financial.ListInvoicesOutbound" Codebehind="ListInvoicesOutbound.aspx.cs" %>
<%@ Register src="~/Controls/v5/Base/ModalDialog.ascx" tagname="ModalDialog" tagprefix="Swarmops5" %>
<%@ Register src="~/Controls/v5/Financial/ComboBudgets.ascx" tagname="ComboBudgets" tagprefix="Swarmops5" %>
<%@ Register src="~/Controls/v5/Financial/CurrencyTextBox.ascx" tagname="CurrencyTextBox" tagprefix="Swarmops5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript" src="/Scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="/Scripts/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="/Scripts/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
function preload(arrayOfImages) {
$(arrayOfImages).each(function () {
(new Image()).src = this;
});
}
preload([
'/Images/Abstract/ajaxloader-medium.gif',
'/Images/Abstract/ajaxloader-48x36px.gif',
'/Images/Icons/iconshock-balloon-yes-128x96px-hot.png',
'/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png',
'/Images/Icons/iconshock-balloon-yes-128x96px-hot-disabled.png',
'/Images/Icons/iconshock-balloon-yes-128x96px-gold.png',
'/Images/Icons/iconshock-balloon-yes-128x96px-hot-gold.png',
'/Images/Icons/iconshock-balloon-no-128x96px-hot.png',
'/Images/Icons/iconshock-green-tick-128x96px.png',
'/Images/Icons/iconshock-red-cross-128x96px.png',
'/Images/Icons/iconshock-red-cross-circled-128x96px.png',
'/Images/Icons/iconshock-balloon-undo-128x96px.png',
'/Images/Icons/iconshock-balloon-undo-128x96px-hot.png'
]);
/* -- commented out -- do we need attestation logic for this page?
loadUninitializedBudgets(); // no need to wait for doc.ready to load operating params
SwarmopsJS.ajaxCall("/Pages/v5/Financial/AttestCosts.aspx/GetRemainingBudgets", {}, function(data) {
data.forEach(function(accountData, dummy1, dummy2) {
budgetRemainingLookup[accountData.AccountId] = accountData.Remaining;
});
if (budgetRemainingLookup.rowsLoaded == true) {
setAttestability();
}
budgetRemainingLookup.budgetsLoaded = true;
});*/
// Doc.ready:
$(document).ready(function() {
// we're still in document.ready
$('input:radio[name="ModalOptions"]').change(function () {
var pickedButtonName = $(this).val();
$('div.radioOption').slideUp();
$('div#radioOption' + pickedButtonName).slideDown();
});
});
var recordId = '';
var accountId = 0;
var budgetRemainingLookup = {};
var budgetUninitializedLookup = {};
var uninitializedPopupDisplayed = false;
</script>
<style type="text/css">
.datagrid-row-selected,.datagrid-row-over{
background:transparent;
}
.rowPrevious {
color: #AAA;
}
div.radioOption {
margin-top: -20px;
padding-bottom: 10px;
padding-left: 12px;
margin-right: 10px;
}
body.ltr div.radioOption {
padding-left: initial;
margin-right: initial;
padding-right: 12px;
margin-left: 10px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2><asp:Label runat="server" ID="LabelListInboundInvoicesHeader" Text="XYZ List Inbound Invoices" /></h2>
<table id="TableInboundInvoices" class="easyui-datagrid" style="width:680px;height:400px"
data-options="rownumbers:false,singleSelect:false,fit:false,fitWidth:true,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-ListInvoicesOutbound.aspx'"
idField="itemId">
<thead>
<tr>
<th data-options="field:'item',width:60"><asp:Label ID="LabelGridHeaderItem" runat="server" Text="XYZ Item"/></th>
<th data-options="field:'dueDate',width:60"><asp:Label ID="LabelGridHeaderDueDate" runat="server" Text="XYZ DueDate" /></th>
<th data-options="field:'sender',width:140,sortable:true"><asp:Label ID="LabelGridHeaderBeneficiary" runat="server" Text="XYZ Beneficiary" /></th>
<th data-options="field:'budget',width:140,sortable:true"><asp:Label ID="LabelGridHeaderBudget" runat="server" Text="XYZ Budget" /></th>
<th data-options="field:'amount',width:100,align:'right',sortable:true,order:'asc'"><asp:Label ID="LabelGridHeaderRequested" runat="server" Text="XYZ Requested" /></th>
<th data-options="field:'progress',width:76,align:'center'"><asp:Label ID="LabelGridHeaderProgress" runat="server" Text="XYZ Progress" /></th>
<th data-options="field:'dox',width:40,align:'center'"><asp:Label ID="LabelGridHeaderDocs" runat="server" Text="Doxyz" /></th>
<th data-options="field:'actions',width:53,align:'center'"><asp:Label ID="LabelGridHeaderActions" runat="server" Text="XYZAction" /></th>
</tr>
</thead>
</table>
<div style="display:none">
<!-- a href links for FancyBox to trigger on -->
<asp:Repeater runat="server" ID="RepeaterLightboxItems">
<ItemTemplate>
<a href="/Pages/v5/Support/StreamUpload.aspx?DocId=<%# Eval("DocId") %>&hq=1" title="<%# Eval("Title") %>" class="FancyBox_Gallery" rel="<%# Eval("BaseId") %>">&nbsp;</a>
</ItemTemplate>
</asp:Repeater>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -0,0 +1,228 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Threading;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using Resources;
using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Frontend.Pages.v5.Financial
{
public partial class ListInvoicesOutbound : PageV5Base
{
private List<RepeatedDocument> _documentList;
protected void Page_Load (object sender, EventArgs e)
{
if (!CurrentOrganization.IsEconomyEnabled)
{
Response.Redirect ("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
return;
}
PageIcon = "iconshock-stamped-paper";
PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Participant, AccessType.Read); // No specific access aspect for owning a budget (yet?)
if (!Page.IsPostBack)
{
Localize();
}
// this.TextDenyReason.Style [HtmlTextWriterStyle.FontSize] = "60% !important";
this._documentList = new List<RepeatedDocument>();
PopulateOutboundInvoices();
RegisterControl(EasyUIControl.DataGrid);
this.RepeaterLightboxItems.DataSource = this._documentList;
this.RepeaterLightboxItems.DataBind();
}
static private Dictionary<int, bool> GetAttestationRights()
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
// Right now, this function is quite primitive. At some point in the future, it needs to take into
// account that a budget may have several attesters. Right now, it just loops over all accounts and
// checks the owner.
Dictionary<int, bool> result = new Dictionary<int, bool>();
FinancialAccounts accounts = FinancialAccounts.ForOrganization(authData.CurrentOrganization);
foreach (FinancialAccount account in accounts)
{
if (account.OwnerPersonId == authData.CurrentUser.Identity ||
(account.OwnerPersonId == 0 && authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Administration))))
{
if (account.AccountType == FinancialAccountType.Cost)
{
result[account.Identity] = true;
}
}
}
return result;
}
[WebMethod]
public static int[] GetUninitializedBudgets()
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
// This function finds the exceptional accounts that aren't initialized, to let a sysadmin approve expenses to them.
List<int> result = new List<int>();
FinancialAccounts accounts = FinancialAccounts.ForOrganization(authData.CurrentOrganization);
foreach (FinancialAccount account in accounts)
{
if (account.AccountType == FinancialAccountType.Cost)
{
if (account.OwnerPersonId == 0 &&
authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
AccessAspect.Administration)))
{
result.Add (account.Identity);
}
}
}
return result.ToArray();
}
private void Localize()
{
PageTitle = Resources.Pages.Financial.ListInboundInvoices_Title;
InfoBoxLiteral = Resources.Pages.Financial.ListInboundInvoices_Info;
this.LabelListInboundInvoicesHeader.Text = Resources.Pages.Financial.ListInboundInvoices_Header;
this.LabelGridHeaderItem.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Item;
this.LabelGridHeaderDueDate.Text = Resources.Global.Financial_DueDate;
this.LabelGridHeaderBeneficiary.Text = Resources.Pages.Financial.ListInboundInvoices_Header_Sender;
this.LabelGridHeaderBudget.Text = Resources.Global.Financial_Budget;
this.LabelGridHeaderRequested.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Requested;
this.LabelGridHeaderProgress.Text = Resources.Global.Global_Progress;
this.LabelGridHeaderDocs.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Docs;
this.LabelGridHeaderActions.Text = Resources.Global.Global_Action;
/* this.LiteralErrorInsufficientBudget.Text = JavascriptEscape (Resources.Pages.Financial.AttestCosts_OutOfBudget);
this.LiteralWarnUnintializedBudget.Text =
JavascriptEscape (Resources.Pages.Financial.AttestCosts_Warn_UninitializedBudget);*/
/*
this.LabelDescribeDeny.Text = Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionDeny;
this.LabelDescribeCorrect.Text = String.Format (Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionAmount, CurrentOrganization.Currency.DisplayCode);
this.LabelDescribeRebudget.Text = Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionRebudget;
this.LabelRadioCorrect.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionAmount;
this.LabelRadioDeny.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionDeny;
this.LabelRadioRebudget.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionRebudget;*/
/* this.LabelModalDenyHeader.Text = Resources.Pages.Financial.AttestCosts_Modal_Header;
this.LabelWhatProblem.Text = Resources.Pages.Financial.AttestCosts_Modal_WhatIsProblem;
this.LiteralPleaseSelectBudget.Text = JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_PleaseSelectBudget);
this.LiteralCannotRebudgetSalary.Text =
JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_CantRebudgetSalary);
this.LiteralConfirmOverdraftNo.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmNo);
this.LiteralConfirmOverdraftYes.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmYes);
this.LiteralConfirmOverdraft.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirm);*/
}
static protected IPayable PayableFromRecordId (string recordId)
{
char recordType = recordId[0];
int itemId = Int32.Parse(recordId.Substring(1));
switch (recordType)
{
case 'E': // Expense claim
return ExpenseClaim.FromIdentity (itemId);
case 'A': // Cash advance
return CashAdvance.FromIdentity(itemId);
case 'I': // Inbound invoice
return InboundInvoice.FromIdentity (itemId);
default:
throw new NotImplementedException("Unknown record type");
}
}
[WebMethod]
public static void RebudgetItem (string recordId, int newAccountId)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
IPayable payable = PayableFromRecordId (recordId);
FinancialAccount newAccount = FinancialAccount.FromIdentity(newAccountId);
if (payable.Budget.OrganizationId != authData.CurrentOrganization.Identity ||
payable.Budget.OwnerPersonId != authData.CurrentUser.Identity ||
newAccount.OrganizationId != authData.CurrentOrganization.Identity)
{
throw new UnauthorizedAccessException();
}
payable.SetBudget (newAccount, authData.CurrentUser);
}
private void PopulateOutboundInvoices()
{
OutboundInvoices invoices = OutboundInvoices.ForOrganization(CurrentOrganization, true);
foreach (OutboundInvoice invoice in invoices)
{
Documents dox = invoice.Documents;
bool hasDox = (dox.Count > 0 ? true : false);
AddDocuments(invoice.Documents, "O" + invoice.Identity.ToString(CultureInfo.InvariantCulture),
String.Format(Global.Financial_OutboundInvoiceSpecificationWithCustomer + " - ",
invoice.OrganizationSequenceId, invoice.CustomerName) + Global.Global_ImageSpecification);
}
}
private void AddDocuments(Documents docs, string baseId, string titleBase)
{
int countTotal = docs.Count;
int count = 0;
foreach (Document document in docs)
{
RepeatedDocument newDoc = new RepeatedDocument
{
DocId = document.Identity,
BaseId = baseId,
Title = String.Format(titleBase, ++count, countTotal)
};
this._documentList.Add(newDoc);
}
}
public class RepeatedDocument
{
public int DocId { get; set; }
public string BaseId { get; set; }
public string Title { get; set; }
}
}
}
@@ -0,0 +1,105 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Frontend.Pages.v5.Financial {
public partial class ListInvoicesOutbound {
/// <summary>
/// LabelListInboundInvoicesHeader control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelListInboundInvoicesHeader;
/// <summary>
/// LabelGridHeaderItem control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderItem;
/// <summary>
/// LabelGridHeaderDueDate control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderDueDate;
/// <summary>
/// LabelGridHeaderBeneficiary control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderBeneficiary;
/// <summary>
/// LabelGridHeaderBudget control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderBudget;
/// <summary>
/// LabelGridHeaderRequested control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderRequested;
/// <summary>
/// LabelGridHeaderProgress control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderProgress;
/// <summary>
/// LabelGridHeaderDocs control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderDocs;
/// <summary>
/// LabelGridHeaderActions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderActions;
/// <summary>
/// RepeaterLightboxItems control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater RepeaterLightboxItems;
}
}