This should add InboundInvoice to PaymentTransferInfo

This commit is contained in:
Rick Falkvinge
2019-02-28 10:20:50 +01:00
parent 41df4d2a47
commit a2373a9550
3 changed files with 59 additions and 6 deletions
+53
View File
@@ -65,6 +65,59 @@ namespace Swarmops.Logic.Financial
return FromObject(salary.PayrollItem.Person, new Money(salary.NetSalaryCents, salary.PayrollItem.Organization.Currency));
}
if (financialObject is InboundInvoice)
{
// TODO: Create Supplier object, read from that instead
InboundInvoice invoice = financialObject as InboundInvoice;
PaymentTransferInfo result = new PaymentTransferInfo();
// For now, do a switch on the pay-to-account string, before the payment targets are implemented
// on invoices and expense claims:
result.LocalizedPaymentInformation = new Dictionary<string, string>();
if (invoice.PayToAccount.StartsWith("IBAN"))
{
result.TargetType = PaymentTargetType.InternationalBankTransfer;
result.LocalizedPaymentInformation[
Logic_Financial_PaymentTransferInfo.PaymentTargetField_Iban] =
invoice.PayToAccount.Substring(5);
// this should have bic too but we don't have that information before payment targets
// are properly implemented
}
else if (invoice.PayToAccount.StartsWith("SEBG"))
{
result.TargetType = PaymentTargetType.DomesticBankGiro; // for now
result.LocalizedPaymentInformation[
Logic_Financial_PaymentTransferInfo.PaymentTargetField_GiroNumber] =
invoice.PayToAccount.Substring(5);
}
result.LocalizedPaymentMethodName =
Logic_Financial_PaymentTransferInfo.ResourceManager.GetString("PaymentTargetType_" +
result.TargetType.ToString());
if (invoice.HasNativeCurrency)
{
result.Currency = invoice.NativeCurrencyAmount.Currency;
result.CurrencyAmount = result.Currency.Code + " " +
(invoice.NativeCurrencyAmount.Cents/100.0).ToString("N2");
}
else
{
result.Currency = invoice.Organization.Currency;
result.CurrencyAmount = result.Currency.Code + " " + (invoice.AmountCents/100.0).ToString("N2");
}
result.Country = null; // TODO: Set to Supplier's PaymentTarget country
result.Recipient = invoice.Supplier;
return result;
}
if (financialObject is Person)
{
Person person = financialObject as Person;
@@ -59,14 +59,14 @@ namespace Swarmops.Frontend.Pages.Financial
continue;
}
PaymentTransferInfo transferInfo = payout.PaymentTransferInfo;
result.Append ("{");
result.AppendFormat (
"\"itemId\":\"{0}\"," +
"\"due\":\"{1}\"," +
"\"recipient\":\"{2}\"," +
"\"bank\":\"{3}\"," +
"\"account\":\"{4}\"," +
"\"reference\":\"{5}\"," +
"\"transferInfo\":\"{3}\"," +
"\"amount\":\"{6}\"," +
"\"action\":\"" +
"<img id='IconApproval{7}' class='IconApproval{7} LocalIconApproval LocalPrototype action-icon' baseid='{7}' protoid='{0}' data-fieldcount='{8}' data-reference='{5}' />" +
@@ -81,12 +81,12 @@ namespace Swarmops.Frontend.Pages.Financial
? Global.Global_ASAP
: payout.ExpectedTransactionDate.ToShortDateString()),
JsonSanitize (TryLocalize (payout.Recipient)),
JsonSanitize (TryLocalize (payout.Bank)),
transferInfo.Currency.Code + ", " + JsonSanitize (transferInfo.LocalizedPaymentMethodName),
JsonSanitize (payout.Account),
JsonSanitize (TryLocalize (payout.Reference)),
payout.HasNativeAmount? payout.NativeAmountString : (payout.AmountCents/100.0).ToString("N2"),
payout.ProtoIdentity.Replace ("|", ""),
payout.PaymentTransferInfo.LocalizedPaymentInformation.Count);
transferInfo.LocalizedPaymentInformation.Count);
result.Append ("},");
}
+1 -1
View File
@@ -342,7 +342,7 @@
<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:'bank',width:200"><asp:Label ID="LabelGridHeaderCurrencyMethod" runat="server" Text="XYZ Bank" /></th>
<th data-options="field:'transferInfo',width:200"><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:'action',width:68,align:'center'"><asp:Label ID="LabelGridHeaderPay" runat="server" Text="XYZPaid" /></th>
</tr>