Added Due By to Payouts

This commit is contained in:
Rick Falkvinge
2019-03-01 10:39:17 +01:00
parent 3ac5ebbfb9
commit ec6465a842
7 changed files with 152 additions and 26 deletions
+18
View File
@@ -1122,6 +1122,15 @@ namespace Resources {
}
}
/// <summary>
/// Looks up a localized string similar to {0:MMMM} {0:d}.
/// </summary>
internal static string Global_DateFormatLongDateMonth {
get {
return ResourceManager.GetString("Global_DateFormatLongDateMonth", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to MMMM d, yyyy.
/// </summary>
@@ -1131,6 +1140,15 @@ namespace Resources {
}
}
/// <summary>
/// Looks up a localized string similar to {0:MMM} {0:dd}.
/// </summary>
internal static string Global_DateFormatShortDateMonth {
get {
return ResourceManager.GetString("Global_DateFormatShortDateMonth", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to MM/DD/YYYY.
/// </summary>
+8
View File
@@ -1092,4 +1092,12 @@
<value>This line item can be automatically scanned by an app.</value>
<comment>This is when Swarmops can display an expense-to-be-paid in a format, that a mobile banking app can read directly, such as a QR code or other machine-readable format.</comment>
</data>
<data name="Global_DateFormatLongDateMonth" xml:space="preserve">
<value>{0:MMMM} {0:d}</value>
<comment>Format used for just date and month (no year). The formats are MMMM for month name, dd for zero-padded two-digit date, and d for date without padding. This is included as different languages use different ways to write month and date, for example, German would write "23. Dezember" (note the dot), a format which would be "{0:d}. {0:MMMM}".</comment>
</data>
<data name="Global_DateFormatShortDateMonth" xml:space="preserve">
<value>{0:MMM} {0:dd}</value>
<comment>Format used for just date and month (no year). The formats are MMM for three-letter month name, dd for zero-padded two-digit date, and d for date without padding. This is included as different languages write month and date in different orders and with different separators. Do keep the month NAME though, rather than using the month number, even if that's common in the target language.</comment>
</data>
</root>
+9
View File
@@ -1473,6 +1473,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Payment is late.
/// </summary>
internal static string PayOutMoney_PaymentLate {
get {
return ResourceManager.GetString("PayOutMoney_PaymentLate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cannot undo payout #{0}: it has already settled or closed..
/// </summary>
@@ -763,4 +763,8 @@
<value>Transfer Method</value>
<comment>As in "money transfer method"; this can be a domestic bank transfer, mailing a check, et cetera.</comment>
</data>
<data name="PayOutMoney_PaymentLate" xml:space="preserve">
<value>Payment is late</value>
<comment>"Late" in this context means "after its due date".</comment>
</data>
</root>
+42 -20
View File
@@ -80,6 +80,7 @@
$('#idModalInputCurrencyAmount').val(loadingBreadcrumb);
$('#idModalReference').val(loadingBreadcrumb);
$('#idModalTransferMethod').val(loadingBreadcrumb);
$('#idModalDueDate').text(loadingBreadcrumb);
// Show or hide the correct count of extra data fields
@@ -118,6 +119,8 @@
$('#idModalReference').val($(this).attr("data-reference")); // load reference from JSON data
$('#idModalTransferMethod').val(result.TransferMethod);
$('#idModalDueDate').text(result.DueBy + ')');
var customFieldCount = parseInt($(this).attr("data-fieldcount"));
for (var index = 0; index < customFieldCount; index++) {
@@ -354,30 +357,49 @@
<Swarmops5:ModalDialog ID="ModalConfirmPayment" runat="server" >
<DialogCode>
<h2><asp:Label ID="LabelModalHeader" runat="server" Text="Execute this payout manually now XYZ"/></h2>
<div class="data-entry-fields modal wide"><input type="text" id="idModalInputRecipient" readonly="readonly" value="Recipient"/>&#8203;<br/>
<input type="text" id="idModalInputCurrencyAmount" readonly="readonly" class="align-for-numbers" value="Amount"/>&#8203;<br/>
<input type="text" id="idModalReference" readonly="readonly" value="Reference"/>&#8203;<br/>
<input type="text" id="idModalTransferMethod" readonly="readonly" value="Transfer Method"/>&#8203;<br/>
<span id="idModalSpanExtraField0"><input type="text" id="idModalExtraField0" readonly="readonly" value="Extra Field 0"/>&#8203;<br/></span>
<span id="idModalSpanExtraField1"><input type="text" id="idModalExtraField1" readonly="readonly" value="Extra Field 1"/>&#8203;<br/></span>
<span id="idModalSpanExtraField2"><input type="text" id="idModalExtraField2" readonly="readonly" value="Extra Field 2"/>&#8203;<br/></span>
<span id="idModalSpanExtraField3"><input type="text" id="idModalExtraField3" readonly="readonly" value="Extra Field 3"/>&#8203;<br/></span>
<span id="idModalSpanExtraField4"><input type="text" id="idModalExtraField4" readonly="readonly" value="Extra Field 4"/>&#8203;<br/></span>
<Swarmops5:AjaxToggleSlider ID="ToggleModalMachineReadable" runat="server" Label="Show in machine-readable format XYZ" Cookie="MachineReadable" AjaxCallbackUrl="" OnChange="modalToggleMachineReadable"/>
<h2><asp:Label ID="LabelModalHeader" runat="server" Text="Execute this payout manually now XYZ"/> (<asp:Label runat="server" ID="LabelModalHeaderDue"/> <span id="idModalDueDate"></span></h2>
<div class="data-entry-fields modal wide">
<input type="text" id="idModalInputRecipient" readonly="readonly" value="Recipient"/>&#8203;<br/>
<span class="modal-input-regular">
<input type="text" id="idModalInputCurrencyAmount" readonly="readonly" class="align-for-numbers" value="Amount"/>&#8203;<br/>
<input type="text" id="idModalReference" readonly="readonly" value="Reference"/>&#8203;<br/>
<input type="text" id="idModalTransferMethod" readonly="readonly" value="Transfer Method"/>&#8203;<br/>
</span>
<span class="modal-input-automated ocr-font">
<input type="text" id="idModalAutomationField1" readonly="readonly" class="ocr-font" value="Field1"/>&#8203;<br/>
<input type="text" id="idModalAutomationField2" readonly="readonly" class="ocr-font" value="Field2"/>&#8203;<br/>
<input type="text" id="idModalAutomationField3" readonly="readonly" class="ocr-font" value="Field3"/>&#8203;<br/>
</span>
<div class="modal-extra-data-fields">
<span id="idModalSpanExtraField0"><input type="text" id="idModalExtraField0" readonly="readonly" value="Extra Field 0"/>&#8203;<br/></span>
<span id="idModalSpanExtraField1"><input type="text" id="idModalExtraField1" readonly="readonly" value="Extra Field 1"/>&#8203;<br/></span>
<span id="idModalSpanExtraField2"><input type="text" id="idModalExtraField2" readonly="readonly" value="Extra Field 2"/>&#8203;<br/></span>
<span id="idModalSpanExtraField3"><input type="text" id="idModalExtraField3" readonly="readonly" value="Extra Field 3"/>&#8203;<br/></span>
<span id="idModalSpanExtraField4"><input type="text" id="idModalExtraField4" readonly="readonly" value="Extra Field 4"/>&#8203;<br/></span>
</div>
<span class="modal-automation-toggle"><Swarmops5:AjaxToggleSlider ID="ToggleModalMachineReadable" runat="server" Label="Show in machine-readable format XYZ" Cookie="MachineReadable" AjaxCallbackUrl="" OnChange="modalToggleMachineReadable"/></span>
<input type="button" id="idModalButtonConfirm" value="Confirm XYZ" class="button-accent-color suppress-input-focus action-icon-button icon-yes" onclick="onConfirmModal();"/>
</div>
<div class="data-entry-labels">
<asp:Label ID="LabelModalRecipient" runat="server" Text="Recipient XYZ"/><br/>
<asp:Label ID="LabelModalCurrencyAmount" runat="server" Text="Currency and Amount XYZ"/><br/>
<asp:Label ID="LabelModalReference" runat="server" Text="Reference XYZ"/><br/>
<asp:Label ID="LabelModalTransferMethod" runat="server" Text="Transfer Method XYZ"/><br/>
<span id="idModalSpanExtraLabel0">Label 0<br/></span>
<span id="idModalSpanExtraLabel1">Label 1<br/></span>
<span id="idModalSpanExtraLabel2">Label 2<br/></span>
<span id="idModalSpanExtraLabel3">Label 3<br/></span>
<span id="idModalSpanExtraLabel4">Label 4<br/></span>
<span id="idModalSpanEnableOcrLabel"><asp:Label runat="server" ID="LabelModalOcr1" Text="Are you scanning this payment XYZ?"/></span>
<span class="modal-input-regular">
<asp:Label ID="LabelModalCurrencyAmount" runat="server" Text="Currency and Amount XYZ"/><br/>
<asp:Label ID="LabelModalReference" runat="server" Text="Reference XYZ"/><br/>
<asp:Label ID="LabelModalTransferMethod" runat="server" Text="Transfer Method XYZ"/><br/>
</span>
<span class="modal-input-automated">
<asp:Label runat="server" ID="LabelModalAutomation1" />
<asp:Label runat="server" ID="LabelModalAutomation2" />
<asp:Label runat="server" ID="LabelModalAutomation3" />
</span>
<div class="modal-extra-data-fields">
<span id="idModalSpanExtraLabel0">Label 0<br/></span>
<span id="idModalSpanExtraLabel1">Label 1<br/></span>
<span id="idModalSpanExtraLabel2">Label 2<br/></span>
<span id="idModalSpanExtraLabel3">Label 3<br/></span>
<span id="idModalSpanExtraLabel4">Label 4<br/></span>
</div>
<span class="modal-automation-toggle"><span id="idModalSpanEnableOcrLabel"><asp:Label runat="server" ID="LabelModalOcr1" Text="Are you scanning this payment XYZ?"/></span></span>
</div>
</DialogCode>
</Swarmops5:ModalDialog>
+35 -6
View File
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Resources;
using System.Security;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using Swarmops.Common;
using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
@@ -54,6 +56,7 @@ namespace Swarmops.Frontend.Pages.Financial
this.LabelModalHeader.Text = Resources.Pages.Financial.PayOutMoney_Modal_Header;
this.LabelModalCurrencyAmount.Text = Resources.Pages.Financial.PayOutMoney_Modal_CurrencyAmount;
this.LabelModalTransferMethod.Text = Resources.Pages.Financial.PayOutMoney_Modal_TransferMethod;
this.LabelModalHeaderDue.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_DueDate;
this.LabelSidebarOptions.Text = Resources.Global.Sidebar_Options;
this.LabelOptionsShowOcr.Text = Resources.Pages.Financial.PayoutMoney_OptionShowOcr;
@@ -141,6 +144,8 @@ namespace Swarmops.Frontend.Pages.Financial
// with one exception -- we need to determine the amount by adding all the objects
// together, if applicable
DateTime paymentDueBy = Constants.DateTimeLow;
switch (Char.ToUpperInvariant(payoutComponents[0][0]))
{
case 'C': // expense claim
@@ -156,14 +161,14 @@ namespace Swarmops.Frontend.Pages.Financial
new Money(GetSumCentsTotal(prototypeId), authData.CurrentOrganization.Currency));
break;
case 'S': // salary
info =
PaymentTransferInfo.FromObject(
Salary.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1))));
Salary salary = Salary.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1)));
info = PaymentTransferInfo.FromObject(salary);
paymentDueBy = salary.PayoutDate;
break;
case 'I': // inbound invoice
info =
PaymentTransferInfo.FromObject(
InboundInvoice.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1))));
InboundInvoice invoice = InboundInvoice.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1)));
info = PaymentTransferInfo.FromObject(invoice);
paymentDueBy = invoice.DueDate;
break;
default:
throw new NotImplementedException("Unrecognized payment type");
@@ -179,6 +184,29 @@ namespace Swarmops.Frontend.Pages.Financial
TransferMethod = info.LocalizedPaymentMethodName
};
if (paymentDueBy < Constants.DateTimeLowThreshold)
{
result.DueBy = Resources.Global.Global_ASAP;
}
else
{
DateTime nowUtc = DateTime.UtcNow;
if (paymentDueBy.Year != nowUtc.Year || paymentDueBy < nowUtc.AddMonths(-3))
{
result.DueBy = paymentDueBy.ToString(Resources.Global.Global_DateFormatLongSansWeekday);
}
else
{
result.DueBy = paymentDueBy.ToString(Resources.Global.Global_DateFormatLongDateMonth);
}
if (paymentDueBy < nowUtc.AddDays(-1))
{
result.DueBy += " - " + Resources.Pages.Financial.PayOutMoney_PaymentLate;
}
}
List<string> listTransferMethodLabels = new List<string>();
List<string> listTransferMethodData = new List<string>();
@@ -231,6 +259,7 @@ namespace Swarmops.Frontend.Pages.Financial
{
public string Recipient { get; set; }
public string CurrencyAmount { get; set; }
public string DueBy { get; set; }
public string Reference { get; set; }
public string TransferMethod { get; set; }
public string[] TransferMethodLabels { get; set; }
+36
View File
@@ -84,6 +84,15 @@ namespace Swarmops.Frontend.Pages.Financial {
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelModalHeader;
/// <summary>
/// LabelModalHeaderDue 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 LabelModalHeaderDue;
/// <summary>
/// ToggleModalMachineReadable control.
/// </summary>
@@ -129,6 +138,33 @@ namespace Swarmops.Frontend.Pages.Financial {
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelModalTransferMethod;
/// <summary>
/// LabelModalAutomation1 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 LabelModalAutomation1;
/// <summary>
/// LabelModalAutomation2 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 LabelModalAutomation2;
/// <summary>
/// LabelModalAutomation3 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 LabelModalAutomation3;
/// <summary>
/// LabelModalOcr1 control.
/// </summary>