diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs
index d75b9cac..06e184aa 100644
--- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs
+++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs
@@ -618,6 +618,15 @@ namespace Resources.Pages {
}
}
+ ///
+ /// Looks up a localized string similar to Match the transaction to this outbound invoice:.
+ ///
+ internal static string BalanceTransactions_ModalDialog_DescribeOutboundInvoice {
+ get {
+ return ResourceManager.GetString("BalanceTransactions_ModalDialog_DescribeOutboundInvoice", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The transaction matches this payout:.
///
diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx
index a5dc810b..c7145f07 100644
--- a/Site/App_GlobalResources/Pages.Ledgers.resx
+++ b/Site/App_GlobalResources/Pages.Ledgers.resx
@@ -839,6 +839,9 @@
Match invoice
+
+ Match the transaction to this outbound invoice:
+
Match this to an open outbound invoice?
diff --git a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx
index fd749d01..32a7f704 100644
--- a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx
+++ b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx
@@ -146,6 +146,21 @@
}
}
+ function onMatchOpenOutboundInvoice() {
+ var invoiceId = <%=this.DropOpenOutboundInvoices.ClientID%>_val();
+
+ if (invoiceId > 0) {
+ <%= this.DialogTx.ClientID %>_close();
+ SwarmopsJS.ajaxCall(
+ "/Pages/v5/Ledgers/BalanceTransactions.aspx/MatchTransactionOpenOutboundInvoice",
+ { transactionId: transactionId, invoiceId: invoiceId },
+ function () {
+ $('#gridTransactions').datagrid('reload');
+ });
+
+ }
+ }
+
var buttonBalanceValue = SwarmopsJS.unescape('');
var buttonPayoutValue = SwarmopsJS.unescape('');
var buttonPayoutForeignValue = SwarmopsJS.unescape('');
diff --git a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
index 304cfc4b..f959702d 100644
--- a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
+++ b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
@@ -44,11 +44,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.LabelDescribePayout.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribePayout;
this.LabelDescribePayoutForeign.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribePayoutForeign;
- this.LabelDescribeOutboundInvoice.Text =
+ this.LabelDescribeOutboundInvoice.Text =
+ Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribeOutboundInvoice;
this.LabelRadioPayout.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayout;
this.LabelRadioPayoutForeign.Text =
String.Format(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayoutForeign, 5);
this.LabelRadioOutboundInvoice.Text =
+ Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioOutboundInvoice;
this.LiteralButtonBalance.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonBalance);
this.LiteralButtonPayout.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonPayout);
@@ -288,7 +290,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
[WebMethod]
- public static void MatchTransactionOpenPayout (int transactionId, int payoutId)
+ public static void MatchTransactionOpenPayout(int transactionId, int payoutId)
{
if (transactionId == 0 || payoutId == 0)
{
@@ -305,7 +307,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
}
FinancialTransaction transaction = FinancialTransaction.FromIdentity(transactionId);
- Payout payout = Payout.FromIdentity (payoutId);
+ Payout payout = Payout.FromIdentity(payoutId);
if (transaction.OrganizationId != authData.CurrentOrganization.Identity || payout.OrganizationId != authData.CurrentOrganization.Identity)
{
throw new UnauthorizedAccessException();
@@ -316,7 +318,55 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
throw new InvalidOperationException();
}
- payout.BindToTransactionAndClose (transaction, authData.CurrentUser);
+ payout.BindToTransactionAndClose(transaction, authData.CurrentUser);
+
+ }
+
+
+
+ [WebMethod]
+ public static void MatchTransactionOpenOutboundInvoice(int transactionId, int invoiceId)
+ {
+ if (transactionId == 0 || invoiceId == 0)
+ {
+ return;
+ }
+
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+
+ if (
+ !authData.Authority.HasAccess(new Access(authData.CurrentOrganization,
+ AccessAspect.BookkeepingDetails)))
+ {
+ throw new UnauthorizedAccessException();
+ }
+
+ FinancialTransaction transaction = FinancialTransaction.FromIdentity(transactionId);
+ OutboundInvoice outboundInvoice = OutboundInvoice.FromIdentity(invoiceId);
+ if (transaction.OrganizationId != authData.CurrentOrganization.Identity || outboundInvoice.OrganizationId != authData.CurrentOrganization.Identity)
+ {
+ throw new UnauthorizedAccessException();
+ }
+
+ if (transaction.Rows.AmountCentsTotal != outboundInvoice.AmountCents)
+ {
+ throw new InvalidOperationException();
+ }
+
+ // Close invoice
+
+ Payment payment = Payment.CreateSingle(authData.CurrentOrganization, transaction.DateTime,
+ authData.CurrentOrganization.Currency, outboundInvoice.AmountCents, outboundInvoice,
+ authData.CurrentUser);
+
+ // TODO: Notify?
+
+ // TODO: Log?
+
+ // Close transaction
+
+ transaction.AddRow(authData.CurrentOrganization.FinancialAccounts.AssetsOutboundInvoices,
+ -outboundInvoice.AmountCents, authData.CurrentUser);
}