Invoice matching is coming together
This commit is contained in:
+55
-1
@@ -511,7 +511,7 @@ namespace Resources.Pages {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Matching Amount, Off In Time.
|
||||
/// Looks up a localized string similar to Matching Amount But On Unexpected Date/Time.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_ExactMatchesFarAway {
|
||||
get {
|
||||
@@ -591,6 +591,15 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Match invoice.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_ModalDialog_ButtonOutboundInvoice {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_ModalDialog_ButtonOutboundInvoice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Match.
|
||||
/// </summary>
|
||||
@@ -645,6 +654,24 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Match this to an open outbound invoice?.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_ModalDialog_RadioOutboundInvoice {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_ModalDialog_RadioOutboundInvoice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Match this to an open outbound invoice in a nonstandard currency (5% forex tolerance)?.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_ModalDialog_RadioOutboundInvoiceForeign {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_ModalDialog_RadioOutboundInvoiceForeign", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Match the transaction difference to an open, unmatched payout?.
|
||||
/// </summary>
|
||||
@@ -672,6 +699,15 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Most Probable Match.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_MostProbableMatch {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_MostProbableMatch", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to (No open payouts).
|
||||
/// </summary>
|
||||
@@ -699,6 +735,15 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Outbound Invoice #{0:N0} for {1}, due {2}: {3}.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_OutboundInvoiceMatch {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_OutboundInvoiceMatch", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Balance & Match Transactions.
|
||||
/// </summary>
|
||||
@@ -735,6 +780,15 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to VAT Report for {1:yyyy-MMM} surplus.
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_VatReportMatch {
|
||||
get {
|
||||
return ResourceManager.GetString("BalanceTransactions_VatReportMatch", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bitcoin Address.
|
||||
/// </summary>
|
||||
|
||||
@@ -681,7 +681,7 @@
|
||||
<comment>Header in selection list. Capitalize as customary for culture.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ExactMatchesFarAway" xml:space="preserve">
|
||||
<value>Matching Amount, Off In Time</value>
|
||||
<value>Matching Amount But On Unexpected Date/Time</value>
|
||||
<comment>Header in selection list. Capitalize as customary for culture.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_FivePercentMatches" xml:space="preserve">
|
||||
@@ -836,4 +836,24 @@
|
||||
<value>Add new transaction</value>
|
||||
<comment>Option in sidebar</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ModalDialog_ButtonOutboundInvoice" xml:space="preserve">
|
||||
<value>Match invoice</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ModalDialog_RadioOutboundInvoice" xml:space="preserve">
|
||||
<value>Match this to an open outbound invoice?</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ModalDialog_RadioOutboundInvoiceForeign" xml:space="preserve">
|
||||
<value>Match this to an open outbound invoice in a nonstandard currency (5% forex tolerance)?</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_MostProbableMatch" xml:space="preserve">
|
||||
<value>Most Probable Match</value>
|
||||
<comment>This is the header of a match where the transaction description somehow matches the invoice reference.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_OutboundInvoiceMatch" xml:space="preserve">
|
||||
<value>Outbound Invoice #{0:N0} for {1}, due {2}: {3}</value>
|
||||
<comment>Argument {0} is the invoice identity, {1} the customer name, {2} the due date and {3} the invoice-currencied amount (which can be different from the org's presentation currency)</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_VatReportMatch" xml:space="preserve">
|
||||
<value>VAT Report for {1:yyyy-MMM} surplus</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -29,6 +29,7 @@
|
||||
$('#buttonExecuteBalance').val(buttonBalanceValue);
|
||||
$('#buttonExecutePayout').val(buttonPayoutValue);
|
||||
$('#buttonExecutePayoutForeign').val(buttonPayoutForeignValue);
|
||||
$('#buttonExecuteOutboundInvoice').val(buttonOutboundInvoiceValue);
|
||||
});
|
||||
|
||||
var transactionId = 0;
|
||||
@@ -148,6 +149,7 @@
|
||||
var buttonBalanceValue = SwarmopsJS.unescape('<asp:Literal ID="LiteralButtonBalance" runat="server" Text="BalanceXYZ" />');
|
||||
var buttonPayoutValue = SwarmopsJS.unescape('<asp:Literal ID="LiteralButtonPayout" runat="server" Text="MatchXYZ" />');
|
||||
var buttonPayoutForeignValue = SwarmopsJS.unescape('<asp:Literal ID="LiteralButtonPayoutForeign" runat="server" Text="MatchXYZ" />');
|
||||
var buttonOutboundInvoiceValue = SwarmopsJS.unescape('<asp:Literal ID="LiteralButtonOutboundInvoice" runat="server" Text="MatchXYZ" />');
|
||||
|
||||
</script>
|
||||
|
||||
@@ -232,14 +234,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="divPositiveDifference">
|
||||
<p><input type="radio" id="RadioPaymentDirect" name="TxOptions" value="PaymentDirect" /><label for="RadioPaymentDirect"> <asp:Label runat="server" ID="LabelRadioPaymentDirect" Text="Match to an open outbound invoice? XYZ" /></label></p>
|
||||
<div id="radioOptionPaymentDirect" class="radioOption">
|
||||
<p><input type="radio" id="RadioOutboundInvoice" name="TxOptions" value="OutboundInvoice" /><label for="RadioOutboundInvoice"> <asp:Label runat="server" ID="LabelRadioOutboundInvoice" Text="Match to an open outbound invoice? XYZ" /></label></p>
|
||||
<div id="radioOptionOutboundInvoice" class="radioOption">
|
||||
<div class="entryFields">
|
||||
<Swarmops5:DropDown ID="DropOpenOutboundInvoices" runat="server" />​<br/>
|
||||
<input type="button" value='#PaymentInvoice#' class="buttonAccentColor" onclick="onMatchOpenOutboundInvoice(); return false;" id="buttonExecutePayoutForeign"/>
|
||||
<input type="button" value='#PaymentInvoice#' class="buttonAccentColor" onclick="onMatchOpenOutboundInvoice(); return false;" id="buttonExecuteOutboundInvoice"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
<asp:Label runat="server" ID="Label2" Text="Match to payout XYZ" />
|
||||
<asp:Label runat="server" ID="LabelDescribeOutboundInvoice" Text="Match to outbound invoice XYZ" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -44,13 +44,16 @@ 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.LabelRadioPayout.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayout;
|
||||
this.LabelRadioPayoutForeign.Text =
|
||||
String.Format(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayoutForeign, 5);
|
||||
this.LabelRadioOutboundInvoice.Text =
|
||||
|
||||
this.LiteralButtonBalance.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonBalance);
|
||||
this.LiteralButtonPayout.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonPayout);
|
||||
this.LiteralButtonPayoutForeign.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonPayout);
|
||||
this.LiteralButtonOutboundInvoice.Text = JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonOutboundInvoice);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,16 +192,24 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
if (invoice.AmountCents > matchAmount * 95 / 100 &&
|
||||
invoice.AmountCents < matchAmount * 105 / 100)
|
||||
{
|
||||
string description = String.Format(Resources.Pages.Ledgers.BalanceTransactions_PayoutMatch, invoice.Identity,
|
||||
invoice.DueDate, invoice.CustomerName, invoice.Organization.Currency.DisplayCode, invoice.AmountCents / 100.0,
|
||||
invoice.DisplayNativeAmount);
|
||||
string description = String.Format(Resources.Pages.Ledgers.BalanceTransactions_OutboundInvoiceMatch, invoice.Identity,
|
||||
invoice.CustomerName, invoice.DueDate, invoice.DisplayNativeAmount);
|
||||
|
||||
if (invoice.HasNativeCurrency)
|
||||
{
|
||||
description += " (" + transaction.Organization.Currency.DisplayCode + " " +
|
||||
(invoice.AmountCents/100.0).ToString("N2") + ")";
|
||||
}
|
||||
|
||||
bool invoiceIdMatch = DescriptionContainsInvoiceReference(invoice.Reference, invoice.TheirReference, transaction.Description);
|
||||
|
||||
|
||||
if (invoice.AmountCents == matchAmount)
|
||||
{
|
||||
listExact.Add(new DropdownOption
|
||||
{
|
||||
id = invoice.Identity.ToString(CultureInfo.InvariantCulture),
|
||||
@group = Resources.Pages.Ledgers.BalanceTransactions_ExactMatches,
|
||||
@group = invoiceIdMatch? Resources.Pages.Ledgers.BalanceTransactions_MostProbableMatch : Resources.Pages.Ledgers.BalanceTransactions_ExactMatches,
|
||||
text = description
|
||||
});
|
||||
}
|
||||
@@ -207,7 +218,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
listTolerant.Add(new DropdownOption
|
||||
{
|
||||
id = invoice.Identity.ToString(CultureInfo.InvariantCulture),
|
||||
@group = Resources.Pages.Ledgers.BalanceTransactions_FivePercentMatches,
|
||||
@group = invoiceIdMatch ? Resources.Pages.Ledgers.BalanceTransactions_MostProbableMatch : Resources.Pages.Ledgers.BalanceTransactions_FivePercentMatches,
|
||||
text = description
|
||||
});
|
||||
}
|
||||
@@ -220,6 +231,33 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool DescriptionContainsInvoiceReference(string ourReference, string theirReference, string description)
|
||||
{
|
||||
// Remove some noise
|
||||
|
||||
ourReference = ourReference.Replace("-", "").Replace(".", "").Replace("/", "");
|
||||
theirReference = theirReference.Replace("-", "").Replace(".", "").Replace("/", "");
|
||||
description = description.Replace("-", "").Replace(".", "").Replace("/", "");
|
||||
|
||||
// For every word in the description, check if it's the invoice reference. If so, return true
|
||||
|
||||
string[] descriptionWords = description.Split(' ');
|
||||
|
||||
foreach (string descriptionWord in descriptionWords)
|
||||
{
|
||||
if (descriptionWord == ourReference)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (descriptionWord == theirReference)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static void BalanceTransactionManually(int transactionId, int accountId)
|
||||
{
|
||||
|
||||
+13
-4
@@ -39,6 +39,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal LiteralButtonPayoutForeign;
|
||||
|
||||
/// <summary>
|
||||
/// LiteralButtonOutboundInvoice 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.Literal LiteralButtonOutboundInvoice;
|
||||
|
||||
/// <summary>
|
||||
/// LabelHeaderUnbalancedTransactions control.
|
||||
/// </summary>
|
||||
@@ -211,13 +220,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
protected global::System.Web.UI.WebControls.Label LabelDescribePayoutForeign;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRadioPaymentDirect control.
|
||||
/// LabelRadioOutboundInvoice 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 LabelRadioPaymentDirect;
|
||||
protected global::System.Web.UI.WebControls.Label LabelRadioOutboundInvoice;
|
||||
|
||||
/// <summary>
|
||||
/// DropOpenOutboundInvoices control.
|
||||
@@ -229,13 +238,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
protected global::Swarmops.Frontend.Controls.Base.DropDown DropOpenOutboundInvoices;
|
||||
|
||||
/// <summary>
|
||||
/// Label2 control.
|
||||
/// LabelDescribeOutboundInvoice 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 Label2;
|
||||
protected global::System.Web.UI.WebControls.Label LabelDescribeOutboundInvoice;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRadioExistingPayment control.
|
||||
|
||||
Reference in New Issue
Block a user