diff --git a/Logic/Financial/PaymentTransferInfo.cs b/Logic/Financial/PaymentTransferInfo.cs index 56107df2..34b64276 100644 --- a/Logic/Financial/PaymentTransferInfo.cs +++ b/Logic/Financial/PaymentTransferInfo.cs @@ -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(); + + 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; diff --git a/Site/Pages/v5/Financial/Json-PayableCosts.aspx.cs b/Site/Pages/v5/Financial/Json-PayableCosts.aspx.cs index 22540e88..0f735e2e 100644 --- a/Site/Pages/v5/Financial/Json-PayableCosts.aspx.cs +++ b/Site/Pages/v5/Financial/Json-PayableCosts.aspx.cs @@ -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\":\"" + "" + @@ -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 ("},"); } diff --git a/Site/Pages/v5/Financial/PayOutMoney.aspx b/Site/Pages/v5/Financial/PayOutMoney.aspx index aaa5ff8a..5f3d6889 100644 --- a/Site/Pages/v5/Financial/PayOutMoney.aspx +++ b/Site/Pages/v5/Financial/PayOutMoney.aspx @@ -342,7 +342,7 @@ - +