diff --git a/Logic/Financial/PaymentTransferInfo.cs b/Logic/Financial/PaymentTransferInfo.cs index 21256d28..18ed4f49 100644 --- a/Logic/Financial/PaymentTransferInfo.cs +++ b/Logic/Financial/PaymentTransferInfo.cs @@ -22,6 +22,7 @@ namespace Swarmops.Logic.Financial /// The Country field is needed whenever a transfer is marked as "domestic" /// public Country Country { get; set; } + public string Recipient { get; set; } public string CurrencyAmount { get; set; } public PaymentTargetType TargetType { get; set; } public string LocalizedPaymentMethodName { get; set; } @@ -33,14 +34,28 @@ namespace Swarmops.Logic.Financial { ExpenseClaim claim = financialObject as ExpenseClaim; - return FromObject(claim.Claimer, new Money(claim.AmountCents, claim.Organization.Currency)); + if (amountToPay == null) + { + return FromObject(claim.Claimer, new Money(claim.AmountCents, claim.Organization.Currency)); + } + else + { + return FromObject(claim.Claimer, amountToPay); + } } if (financialObject is CashAdvance) { CashAdvance advance = financialObject as CashAdvance; - return FromObject(advance.Person, new Money(advance.AmountCents, advance.Organization.Currency)); + if (amountToPay == null) + { + return FromObject(advance.Person, new Money(advance.AmountCents, advance.Organization.Currency)); + } + else + { + return FromObject(advance.Person, amountToPay); + } } if (financialObject is Salary) diff --git a/Site/Pages/v5/Financial/PayOutMoney.aspx b/Site/Pages/v5/Financial/PayOutMoney.aspx index 267bc9eb..9209ba10 100644 --- a/Site/Pages/v5/Financial/PayOutMoney.aspx +++ b/Site/Pages/v5/Financial/PayOutMoney.aspx @@ -340,6 +340,7 @@ ​
​
​
+
@@ -349,6 +350,7 @@
Clearing
Account Number
+ Are you scanning this payment XYZ?  
Foobar high chaparral diff --git a/Site/Pages/v5/Financial/PayOutMoney.aspx.cs b/Site/Pages/v5/Financial/PayOutMoney.aspx.cs index 6cba0ccb..ff9588e0 100644 --- a/Site/Pages/v5/Financial/PayOutMoney.aspx.cs +++ b/Site/Pages/v5/Financial/PayOutMoney.aspx.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Security; using System.Web; using System.Web.Services; +using System.Web.UI; using Swarmops.Common.Enums; using Swarmops.Logic.Financial; using Swarmops.Logic.Security; @@ -114,12 +115,104 @@ namespace Swarmops.Frontend.Pages.Financial }; } + [WebMethod] + public static PaymentTransferInfoResult GetPayoutTransferInfo(string prototypeId) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + // TODO: Authentication check + + string[] payoutComponents = prototypeId.Split('|'); + + if (payoutComponents.Length < 1) + { + throw new InvalidOperationException("Prototype ID can't be empty"); + } + + PaymentTransferInfo info = new PaymentTransferInfo(); + + // Some payouts are composites of multiple objects, but all these will share the same + // payout data, so we can safely use just the first object to determine payment + // target information + // + // with one exception -- we need to determine the amount by adding all the objects + // together, if applicable + + switch (Char.ToUpperInvariant(payoutComponents[0][0])) + { + case 'E': // expense claim + info = + PaymentTransferInfo.FromObject( + ExpenseClaim.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1))), + new Money(GetSumCentsTotal(prototypeId), authData.CurrentOrganization.Currency)); + break; + case 'A': // cash advance (payout or payback, same logic either way) + info = + PaymentTransferInfo.FromObject( + CashAdvance.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1))), + new Money(GetSumCentsTotal(prototypeId), authData.CurrentOrganization.Currency)); + break; + case 'S': // salary + info = + PaymentTransferInfo.FromObject( + Salary.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1)))); + break; + case 'I': // inbound invoice + info = + PaymentTransferInfo.FromObject( + InboundInvoice.FromIdentity(Int32.Parse(payoutComponents[0].Substring(1)))); + break; + default: + throw new NotImplementedException("Unrecognized payment type"); + } + + PaymentTransferInfoResult result = new PaymentTransferInfoResult + { + Success = true, + CurrencyAmount = info.CurrencyAmount, + DisplayMessage = string.Empty, + Recipient = info.Recipient, + Reference = info.Reference, + TransferMethod = info.LocalizedPaymentMethodName, + }; + + // TODO: Continue with adding localized fields + } + + + static private Int64 GetSumCentsTotal(string prototypeId) + { + string[] payoutComponents = prototypeId.Split('|'); + + Int64 amountCentsTotal = 0; + + foreach (string payoutComponent in payoutComponents) + { + switch (payoutComponent[0]) + { + case 'E': + amountCentsTotal += ExpenseClaim.FromIdentity(Int32.Parse(payoutComponent.Substring(1))).AmountCents; + break; + case 'A': // Advance pay-OUT + amountCentsTotal += CashAdvance.FromIdentity(Int32.Parse(payoutComponent.Substring(1))).AmountCents; + break; + case 'a': // Advance pay-BACK + amountCentsTotal -= CashAdvance.FromIdentity(Int32.Parse(payoutComponent.Substring(1))).AmountCents; + break; + default: + throw new NotImplementedException(); + } + } + + return amountCentsTotal; + } + public class ConfirmPayoutResult: AjaxCallResult { public int AssignedId; }; - public class PayoutInformationResult : AjaxCallResult + public class PaymentTransferInfoResult : AjaxCallResult { public string Recipient { get; set; } public string CurrencyAmount { get; set; } diff --git a/Site/Pages/v5/Financial/PayOutMoney.aspx.designer.cs b/Site/Pages/v5/Financial/PayOutMoney.aspx.designer.cs index 25b4a2fb..f5ac6208 100644 --- a/Site/Pages/v5/Financial/PayOutMoney.aspx.designer.cs +++ b/Site/Pages/v5/Financial/PayOutMoney.aspx.designer.cs @@ -138,6 +138,15 @@ namespace Swarmops.Frontend.Pages.Financial { /// protected global::System.Web.UI.WebControls.Label LabelPayoutModalHeader; + /// + /// MasterEditPerson2FAProvisioning control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Base.AjaxToggleSlider MasterEditPerson2FAProvisioning; + /// /// LabelModalRecipient control. ///