More work on Payment Targets
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
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;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Resources;
|
||||
|
||||
namespace Swarmops.Logic.Financial
|
||||
{
|
||||
public class PaymentTransferInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the currency to be used for the transfer. Note that the amount will be converted into this currency!
|
||||
/// </summary>
|
||||
public Currency Currency { get; set; }
|
||||
/// <summary>
|
||||
/// The Country field is needed whenever a transfer is marked as "domestic"
|
||||
/// </summary>
|
||||
public Country Country { get; set; }
|
||||
public string CurrencyAmount { get; set; }
|
||||
public PaymentTargetType TargetType { get; set; }
|
||||
public string LocalizedPaymentMethodName { get; set; }
|
||||
public Dictionary<string,string> LocalizedPaymentInformation { get; set; }
|
||||
|
||||
public static PaymentTransferInfo FromObject(IHasIdentity financialObject, Money amountToPay = null)
|
||||
{
|
||||
if (financialObject is ExpenseClaim)
|
||||
{
|
||||
ExpenseClaim claim = financialObject as ExpenseClaim;
|
||||
|
||||
return FromObject(claim.Claimer, new Money(claim.AmountCents, claim.Organization.Currency));
|
||||
}
|
||||
|
||||
if (financialObject is CashAdvance)
|
||||
{
|
||||
CashAdvance advance = financialObject as CashAdvance;
|
||||
|
||||
return FromObject(advance.Person, new Money(advance.AmountCents, advance.Organization.Currency));
|
||||
}
|
||||
|
||||
if (financialObject is Salary)
|
||||
{
|
||||
Salary salary = financialObject as Salary;
|
||||
return FromObject(salary.PayrollItem.Person, new Money(salary.NetSalaryCents, salary.PayrollItem.Organization.Currency));
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
PaymentTransferInfo result = new PaymentTransferInfo();
|
||||
result.TargetType = PaymentTargetType.DomesticBankTransfer;
|
||||
|
||||
// We must know the amount at this point
|
||||
|
||||
if (amountToPay == null)
|
||||
{
|
||||
throw new ArgumentNullException("amountToPay", @"Cannot determine payment transfer information without knowing origin currency");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(person.BankName) || string.IsNullOrEmpty(person.BankClearing) ||
|
||||
string.IsNullOrEmpty(person.BankAccount))
|
||||
{
|
||||
throw new NotImplementedException("Cannot provide payment transfer information for Person #" + person.Identity.ToString());
|
||||
}
|
||||
|
||||
result.TargetType = PaymentTargetType.DomesticBankTransfer;
|
||||
result.Country = person.Country;
|
||||
result.Currency = amountToPay.Currency; // TODO: The currency will need to come from the payment method instead
|
||||
|
||||
result.CurrencyAmount = result.Currency.Code + " " + (amountToPay.ToCurrency(result.Currency).Cents / 100.0).ToString("N2");
|
||||
|
||||
result.LocalizedPaymentMethodName =
|
||||
Logic_Financial_PaymentTransferInfo.ResourceManager.GetString("PaymentTargetType_" +
|
||||
result.TargetType.ToString());
|
||||
|
||||
result.LocalizedPaymentInformation = new Dictionary<string, string>();
|
||||
result.LocalizedPaymentInformation[
|
||||
Logic_Financial_PaymentTransferInfo.PaymentTargetField_ClearingCode] =
|
||||
person.BankName + " " + person.BankClearing;
|
||||
result.LocalizedPaymentInformation[
|
||||
Logic_Financial_PaymentTransferInfo.PaymentTargetField_AccountNumber] = person.BankAccount;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
throw new NotImplementedException("Unknown payment information");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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<string,string> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -143,7 +143,7 @@
|
||||
<Compile Include="Financial\HotBitcoinAddressUnspent.cs" />
|
||||
<Compile Include="Financial\HotBitcoinAddressUnspents.cs" />
|
||||
<Compile Include="Financial\IPayable.cs" />
|
||||
<Compile Include="Financial\PaymentTransferMethodInfo.cs" />
|
||||
<Compile Include="Financial\PaymentTransferInfo.cs" />
|
||||
<Compile Include="Financial\VatReport.cs" />
|
||||
<Compile Include="Financial\VatReportItem.cs" />
|
||||
<Compile Include="Financial\VatReportItems.cs" />
|
||||
@@ -163,10 +163,10 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Logic.Financial.FinancialTransactionTagSetTypesStock.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Logic.Financial.PaymentTransferMethodInfo.Designer.cs">
|
||||
<Compile Include="Resources\Logic.Financial.PaymentTransferInfo.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Logic.Financial.PaymentTransferMethodInfo.resx</DependentUpon>
|
||||
<DependentUpon>Logic.Financial.PaymentTransferInfo.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Logic.Financial.Payout.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -699,9 +699,9 @@
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.FinancialTransactionTagSetTypesStock.tr-TR.resx" />
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.FinancialTransactionTagSetTypesStock.yo-NG.resx" />
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.FinancialTransactionTagSetTypesStock.zh-CN.resx" />
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.PaymentTransferMethodInfo.resx">
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.PaymentTransferInfo.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Logic.Financial.PaymentTransferMethodInfo.Designer.cs</LastGenOutput>
|
||||
<LastGenOutput>Logic.Financial.PaymentTransferInfo.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.Payout.af-ZA.resx" />
|
||||
<EmbeddedResource Include="Resources\Logic.Financial.Payout.ar-SA.resx" />
|
||||
|
||||
+3
-3
@@ -22,14 +22,14 @@ namespace Swarmops.Logic.Resources {
|
||||
[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 {
|
||||
internal class Logic_Financial_PaymentTransferInfo {
|
||||
|
||||
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() {
|
||||
internal Logic_Financial_PaymentTransferInfo() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,7 +39,7 @@ namespace Swarmops.Logic.Resources {
|
||||
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);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Financial.PaymentTransferInfo", typeof(Logic_Financial_PaymentTransferInfo).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -4,7 +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.PaymentTransferInfo.resx
|
||||
Logic.Financial.VatReport.resx
|
||||
Logic.Structure.Country.resx
|
||||
Logic.Structure.Geography.resx
|
||||
|
||||
Reference in New Issue
Block a user