Added OCR availability column

This commit is contained in:
Rick Falkvinge
2019-02-28 11:07:10 +01:00
parent 42ba94c1dc
commit 171aa91eb6
4 changed files with 40 additions and 8 deletions
+28 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Text;
@@ -9,6 +10,7 @@ using Swarmops.Common.Interfaces;
using Swarmops.Logic.Swarm;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Resources;
using Swarmops.Logic.Support;
namespace Swarmops.Logic.Financial
{
@@ -27,6 +29,8 @@ namespace Swarmops.Logic.Financial
public string CurrencyAmount { get; set; }
public PaymentTargetType TargetType { get; set; }
public string LocalizedPaymentMethodName { get; set; }
public bool OcrAvailable { get; set; } // defaults to false which is fine
public string[] OcrData { get; set; }
public Dictionary<string,string> LocalizedPaymentInformation { get; set; }
public static PaymentTransferInfo FromObject(IHasIdentity financialObject, Money amountToPay = null)
@@ -93,7 +97,30 @@ namespace Swarmops.Logic.Financial
result.TargetType = PaymentTargetType.DomesticBankGiro; // for now
result.LocalizedPaymentInformation[
Logic_Financial_PaymentTransferInfo.PaymentTargetField_GiroNumber] =
invoice.PayToAccount.Substring(5);
invoice.PayToAccount.Substring(5);
// Check for SEBG OCR availability
if (invoice.InvoiceReference.Length > 2 && Formatting.CheckLuhnChecksum(invoice.InvoiceReference) &&
Formatting.CheckLuhnChecksum(invoice.PayToAccount))
{
result.OcrAvailable = true;
result.OcrData = new string[3];
result.OcrData[0] = invoice.InvoiceReference + " #";
result.OcrData[1] = string.Format("{0} {1:00} &nbsp; {2} &gt;", // three spaces between the cents and the checksum
invoice.AmountCents / 100, invoice.AmountCents % 100,
Formatting.GetLuhnChecksum(invoice.AmountCents.ToString(CultureInfo.InvariantCulture)));
result.OcrData[2] = Formatting.CleanNumber(invoice.PayToAccount);
}
}
else
{
// Assume domestic giro in lack of other information
result.TargetType = PaymentTargetType.DomesticBankGiro;
result.LocalizedPaymentInformation[
Logic_Financial_PaymentTransferInfo.PaymentTargetField_GiroNumber] =
invoice.PayToAccount; // the whole string, as opposed to case above
}
result.LocalizedPaymentMethodName =
@@ -68,8 +68,9 @@ namespace Swarmops.Frontend.Pages.Financial
"\"recipient\":\"{2}\"," +
"\"transferInfo\":\"{3}\"," +
"\"amount\":\"{6}\"," +
"\"ocrAvailable\":\"{4}\"," +
"\"action\":\"" +
"<img id='IconApproval{7}' class='IconApproval{7} LocalIconApproval LocalPrototype action-icon' baseid='{7}' protoid='{0}' data-fieldcount='{8}' data-reference='{5}' />" +
"<img id='IconApproval{7}' class='IconApproval{7} LocalIconApproval LocalPrototype action-icon' baseid='{7}' protoid='{0}' data-ocr='{9}' data-fieldcount='{8}' data-reference='{5}' />" +
"<img id='IconApproved{7}' class='LocalIconApproved LocalPrototype status-icon' baseid='{7}' />" +
"<img id='IconWait{7}' class='LocalIconWait LocalPrototype status-icon' baseid='{7}' />" +
"<img id='IconUndo{7}' class='LocalIconUndo LocalPrototype action-icon' baseid='{7}' />" +
@@ -82,11 +83,12 @@ namespace Swarmops.Frontend.Pages.Financial
: payout.ExpectedTransactionDate.ToShortDateString()),
JsonSanitize (TryLocalize (payout.Recipient)),
transferInfo.Currency.Code + ", " + JsonSanitize (transferInfo.LocalizedPaymentMethodName),
JsonSanitize (payout.Account),
transferInfo.OcrAvailable? "<img class='LocalIconOcr status-icon' />": string.Empty,
JsonSanitize (TryLocalize (payout.Reference)),
payout.HasNativeAmount? payout.NativeAmountString : (payout.AmountCents/100.0).ToString("N2"),
payout.ProtoIdentity.Replace ("|", ""),
transferInfo.LocalizedPaymentInformation.Count);
transferInfo.LocalizedPaymentInformation.Count,
transferInfo.OcrAvailable? "yes": "no");
result.Append ("},");
}
+6 -4
View File
@@ -23,7 +23,8 @@
'/Images/Icons/iconshock-red-cross-circled-128x96px.png',
'/Images/Icons/iconshock-balloon-undo-128x96px.png',
'/Images/Icons/iconshock-balloon-yes-128x96px.png',
'/Images/Icons/iconshock-balloon-no-128x96px-disabled.png'
'/Images/Icons/iconshock-balloon-no-128x96px-disabled.png',
'/Images/Icons/iconshock-barcode-128x96px.png'
]);
$(document).ready(function () {
@@ -60,13 +61,13 @@
if (gridsLoaded == 2) { // onLoadSuccess is triggered _twice_ per grid for some arcane reason
$('#divOcrView').hide();
$(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px.png");
$(".LocalIconApproved").attr("src", "/Images/Icons/iconshock-green-tick-128x96px.png").css("opacity", 0.5);
$(".LocalIconDenied").attr("src", "/Images/Icons/iconshock-red-cross-circled-128x96px.png");
$(".LocalIconWait").attr("src", "/Images/Abstract/ajaxloader-48x36px.gif").hide();
$(".LocalIconUndo").attr("src", "/Images/Icons/iconshock-balloon-undo-128x96px.png");
$(".LocalIconOcr").attr("src", "/Images/Icons/iconshock-barcode-128x96px.png");
$(".LocalIconApproved.LocalPrototype, .LocalIconUndo.LocalPrototype, .LocalIconDenied.LocalPrototype, .LocalIconApproval.LocalPaid, .LocalIconDenial.LocalPaid, .LocalIconDenied.LocalPaid").hide();
$(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-balloon-no-128x96px-disabled.png");
$(".LocalIconApproval, .LocalIconUndo, .LocalIconDenial").css("cursor", "pointer");
@@ -342,8 +343,9 @@
<tr>
<th data-options="field:'due',width:70"><asp:Label ID="LabelGridHeaderDue" runat="server" Text="XYZ Due"/></th>
<th data-options="field:'recipient',width:160,sortable:true"><asp:Label ID="LabelGridHeaderRecipient" runat="server" Text="XYZ Beneficiary" /></th>
<th data-options="field:'transferInfo',width:200"><asp:Label ID="LabelGridHeaderCurrencyMethod" runat="server" Text="XYZ Bank" /></th>
<th data-options="field:'transferInfo',width:150"><asp:Label ID="LabelGridHeaderCurrencyMethod" runat="server" Text="XYZ Bank" /></th>
<th data-options="field:'amount',width:85,align:'right'"><asp:Label ID="LabelGridHeaderAmount" runat="server" Text="XYZ Amount" /></th>
<th data-options="field:'ocrAvailable',width:40"><img src="/Images/Icons/iconshock-barcode-128x96px.png" class="status-icon"/></th>
<th data-options="field:'action',width:68,align:'center'"><asp:Label ID="LabelGridHeaderPay" runat="server" Text="XYZPaid" /></th>
</tr>
</thead>
+1
View File
@@ -1587,6 +1587,7 @@
<Content Include="Images\Flags\tr-64px.png" />
<Content Include="Images\Icons\expensify-icon-official.png" />
<Content Include="Images\Icons\iconshock-balloon-invoice-128x96px.png" />
<Content Include="Images\Icons\iconshock-barcode-128x96px.png" />
<Content Include="Images\Icons\iconshock-download-240px.png" />
<Content Include="Images\Icons\iconshock-download-96px.png" />
<Content Include="Images\Icons\iconshock-download-hot-240px.png" />