diff --git a/Common/Enums/PaymentTargetField.cs b/Common/Enums/PaymentTargetField.cs index f351130c..052ffa83 100644 --- a/Common/Enums/PaymentTargetField.cs +++ b/Common/Enums/PaymentTargetField.cs @@ -14,10 +14,11 @@ namespace Swarmops.Common.Enums BicSwift, GiroNumber, GiroService, - ClearingNumber, + ClearingCode, AccountNumber, - BankAccountHolderName, + AccountHolderName, BankName, + BankAddress, CashAccount, CryptoAddress } diff --git a/Common/Enums/PaymentTargetType.cs b/Common/Enums/PaymentTargetType.cs index 98db961e..f1ae04e4 100644 --- a/Common/Enums/PaymentTargetType.cs +++ b/Common/Enums/PaymentTargetType.cs @@ -10,8 +10,17 @@ namespace Swarmops.Common.Enums { Unknown = 0, BitcoinCashAccount, + /// + /// Different countries will require different data to execute a domestic transfer. + /// DomesticBankTransfer, + /// + /// The "Giro" is a special meta-account in some countries that map to an underlying (changeable) account. + /// DomesticBankGiro, + /// + /// The + /// InternationalBankTransfer } } diff --git a/Logic/Financial/PaymentTransferMethodInfo.cs b/Logic/Financial/PaymentTransferMethodInfo.cs new file mode 100644 index 00000000..3f81c5de --- /dev/null +++ b/Logic/Financial/PaymentTransferMethodInfo.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Resources; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Common.Enums; +using Swarmops.Common.Interfaces; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Logic.Financial +{ + public class PaymentTransferMethodInfo + { + public Currency Currency { get; set; } + public PaymentTargetType TargetType { get; set; } + public string LocalizedPaymentMethodName { get; set; } + Dictionary LocalizedPaymentInformation { get; set; } + + public static PaymentTransferMethodInfo FromObject(IHasIdentity financialObject) + { + if (financialObject is ExpenseClaim) + { + return FromObject((financialObject as ExpenseClaim).Claimer); + } + + if (financialObject is CashAdvance) + { + return FromObject((financialObject as CashAdvance).Person); + } + + if (financialObject is Salary) + { + return FromObject((financialObject as Salary).PayrollItem.Person); + } + + if (financialObject is Person) + { + Person person = financialObject as Person; + + // For now, assume the bank - clearing - account triplet + // TODO: Implement payment targets on teh Person object + + PaymentTransferMethodInfo result = new PaymentTransferMethodInfo(); + result.TargetType = PaymentTargetType.DomesticBankTransfer; + } + } + + } +} diff --git a/Logic/Financial/Payout.cs b/Logic/Financial/Payout.cs index affc1455..fa31fe3b 100644 --- a/Logic/Financial/Payout.cs +++ b/Logic/Financial/Payout.cs @@ -25,25 +25,6 @@ namespace Swarmops.Logic.Financial LoadDependencies(); } - public static void Create() - { - // is this even needed? - - throw new NotImplementedException(); - } - - public static Payout Create(Payout payout) - { - throw new NotImplementedException(); // Seems not to be needed - - // This is quite unique in PW4 -- this is the only class which is pre-constructed and - // can take an instance of its own kind as parameter in creation - - // TODO: Create in database - - // return payout; - } - public static Payout FromDependency(IHasIdentity dependency, FinancialDependencyType dependencyType = FinancialDependencyType.Unknown) { int payoutId = 0; @@ -225,7 +206,7 @@ namespace Swarmops.Logic.Financial } - public new string Reference + public new string Reference { set { diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs index 80c4cde1..80db1d43 100644 --- a/Logic/Financial/Payouts.cs +++ b/Logic/Financial/Payouts.cs @@ -176,6 +176,9 @@ namespace Swarmops.Logic.Financial Formatting.GenerateRangeString (claimIds); } + // Finally, add the payout to the result list if and only if the resulting debt less cash advances + // is greater than zero. (Cash advances paid may exceed existing expense claims.) + if (newAmountCents > 0) { payoutList.Add (payout); diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index baddf9c9..f6c8ac52 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -143,6 +143,7 @@ + @@ -162,6 +163,11 @@ True Logic.Financial.FinancialTransactionTagSetTypesStock.resx + + True + True + Logic.Financial.PaymentTransferMethodInfo.resx + True True @@ -693,6 +699,10 @@ + + ResXFileCodeGenerator + Logic.Financial.PaymentTransferMethodInfo.Designer.cs + diff --git a/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.Designer.cs b/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.Designer.cs new file mode 100644 index 00000000..7cbeec51 --- /dev/null +++ b/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.Designer.cs @@ -0,0 +1,207 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Logic_Financial_PaymentTransferMethodInfo { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Logic_Financial_PaymentTransferMethodInfo() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Financial.PaymentTransferMethodInfo", typeof(Logic_Financial_PaymentTransferMethodInfo).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Account Holder Name. + /// + internal static string PaymentTargetField_AccountHolderName { + get { + return ResourceManager.GetString("PaymentTargetField_AccountHolderName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Account Number. + /// + internal static string PaymentTargetField_AccountNumber { + get { + return ResourceManager.GetString("PaymentTargetField_AccountNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bank Address. + /// + internal static string PaymentTargetField_BankAddress { + get { + return ResourceManager.GetString("PaymentTargetField_BankAddress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bank Name. + /// + internal static string PaymentTargetField_BankName { + get { + return ResourceManager.GetString("PaymentTargetField_BankName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to BBAN. + /// + internal static string PaymentTargetField_Bban { + get { + return ResourceManager.GetString("PaymentTargetField_Bban", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to BIC/Swift Code. + /// + internal static string PaymentTargetField_BicSwift { + get { + return ResourceManager.GetString("PaymentTargetField_BicSwift", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bitcoin Cash Account. + /// + internal static string PaymentTargetField_CashAccount { + get { + return ResourceManager.GetString("PaymentTargetField_CashAccount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clearing Code. + /// + internal static string PaymentTargetField_ClearingCode { + get { + return ResourceManager.GetString("PaymentTargetField_ClearingCode", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cryptocurrency Address. + /// + internal static string PaymentTargetField_CryptoAddress { + get { + return ResourceManager.GetString("PaymentTargetField_CryptoAddress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Giro Number. + /// + internal static string PaymentTargetField_GiroNumber { + get { + return ResourceManager.GetString("PaymentTargetField_GiroNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Giro Service. + /// + internal static string PaymentTargetField_GiroService { + get { + return ResourceManager.GetString("PaymentTargetField_GiroService", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to IBAN. + /// + internal static string PaymentTargetField_Iban { + get { + return ResourceManager.GetString("PaymentTargetField_Iban", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bitcoin Cash Account. + /// + internal static string PaymentTargetType_BitcoinCashAccount { + get { + return ResourceManager.GetString("PaymentTargetType_BitcoinCashAccount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Domestic Giro. + /// + internal static string PaymentTargetType_DomesticBankGiro { + get { + return ResourceManager.GetString("PaymentTargetType_DomesticBankGiro", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Domestic Bank Transfer. + /// + internal static string PaymentTargetType_DomesticBankTransfer { + get { + return ResourceManager.GetString("PaymentTargetType_DomesticBankTransfer", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to International Bank Transfer. + /// + internal static string PaymentTargetType_InternationalBankTransfer { + get { + return ResourceManager.GetString("PaymentTargetType_InternationalBankTransfer", resourceCulture); + } + } + } +} diff --git a/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.resx b/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.resx new file mode 100644 index 00000000..af50e8af --- /dev/null +++ b/Logic/Resources/Logic.Financial.PaymentTransferMethodInfo.resx @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Account Holder Name + This is the name of the person that a (bank) account is assigned to + + + Account Number + + + Bank Address + + + Bank Name + + + BBAN + A Basic Bank Account Number (BBAN), a part of the IBAN code + + + BIC/Swift Code + This code uniquely identifies a bank (the Bank Identifier Code, BIC). + + + Bitcoin Cash Account + This is a special way of denoting a Bitcoin Cash address; search for "CashAccount" or look at cashaccount.info + + + Clearing Code + This is sometimes necessary for domestic bank transfers + + + Cryptocurrency Address + + + Giro Number + This is like an account number, but abstracted one level. + + + Giro Service + + + IBAN + The International Bank Account Number (IBAN) + + + Bitcoin Cash Account + This is a special way of denoting a Bitcoin Cash address; search for "CashAccount" or look at cashaccount.info + + + Domestic Giro + Some countries have meta-accounts called "giro" accounts, that map to bank accounts. + + + Domestic Bank Transfer + + + International Bank Transfer + + \ No newline at end of file diff --git a/Logic/Resources/SourceResourceFiles.txt b/Logic/Resources/SourceResourceFiles.txt index 7da54270..057b69bf 100644 --- a/Logic/Resources/SourceResourceFiles.txt +++ b/Logic/Resources/SourceResourceFiles.txt @@ -4,6 +4,7 @@ Logic.Communications.Transmission.NotificationPayload.resx Logic.Financial.FinancialAccount.resx Logic.Financial.FinancialTransactionTagSetTypesStock.resx Logic.Financial.Payout.resx +Logic.Financial.PaymentTransferMethodInfo.resx Logic.Financial.VatReport.resx Logic.Structure.Country.resx Logic.Structure.Geography.resx diff --git a/Site/Pages/v5/Financial/PayOutMoney.aspx b/Site/Pages/v5/Financial/PayOutMoney.aspx index 352a3588..267bc9eb 100644 --- a/Site/Pages/v5/Financial/PayOutMoney.aspx +++ b/Site/Pages/v5/Financial/PayOutMoney.aspx @@ -21,7 +21,9 @@ '/Images/Icons/iconshock-green-tick-128x96px.png', '/Images/Icons/iconshock-red-cross-128x96px.png', '/Images/Icons/iconshock-red-cross-circled-128x96px.png', - '/Images/Icons/iconshock-balloon-undo-128x96px.png' + '/Images/Icons/iconshock-balloon-undo-128x96px.png', + '/Images/Icons/iconshock-balloon-yes-128x96px.png', + '/Images/Icons/iconshock-balloon-no-128x96px-disabled.png' ]); $(document).ready(function () { @@ -71,8 +73,45 @@ $(".LocalIconApproval").click(function () { + // TODO: Check UX-level concurrency lock + + $('#idModalInputRecipient').val(loadingBreadcrumb); + $('#idModalInputCurrencyAmount').val(loadingBreadcrumb); + $('#idModalReference').val(loadingBreadcrumb); + $('#idModalTransferMethod').val(loadingBreadcrumb); + + // TODO: The two fields below will initially be hidden, and + // TODO: replaced with dynamically unfolding fields + + $('#idModalClearing').val(loadingBreadcrumb); + $('#idModalAccountNumber').val(loadingBreadcrumb); + <%=this.ModalConfirmPayment.ClientID%>_open(); + + var prototypeId = $(this).attr("protoid"); + + SwarmopsJS.proxiedAjaxCall( + "/Pages/v5/Financial/PayOutMoney.aspx/ConfirmPayout", + { protoIdentity: prototypeId }, + this, + function(result) { + if (result.Success) { + modalPrototypeId = $(this).attr("protoid"); + + $('#idModalInputRecipient').val(loadingBreadcrumb); + $('#idModalInputCurrencyAmount').val(loadingBreadcrumb); + $('#idModalReference').val(loadingBreadcrumb); + $('#idModalTransferMethod').val(loadingBreadcrumb); + $('#idModalClearing').val(loadingBreadcrumb); + $('#idModalAccountNumber').val(loadingBreadcrumb); + + } else { + // TODO: Handle server-level concurrency lock + } + } + ); + /* var itemId = $(this).attr("baseid"); var prototypeId = $(this).attr("protoid"); @@ -225,6 +264,12 @@ }); var gridsLoaded = 0; + var loadingBreadcrumb = "[...]"; + var modalPrototypeId = ""; + + // Localization + + $('#idModalButtonConfirm').value(SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_ConfirmPaid%>')); @@ -289,16 +334,16 @@

- ​
- ​
- ​
- ​
- ​
- ​
- + ​
+ ​
+ ​
+ ​
+ ​
+ ​
+