Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2020 Sage Intacct, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

using Intacct.SDK.Functions.AccountsReceivable;
using Intacct.SDK.Tests.Xml;
using System;
using Xunit;

namespace Intacct.SDK.Tests.Functions.AccountsReceivable
{
public class ArPaymentCreate2Test : XmlObjectTestHelper
{
[Fact]
public void GetXmlTest()
{
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
<create>
<arpymt>
<paymentmethod>Printed Check</paymentmethod>
<customerid>C0020</customerid>
<docnumber>1000</docnumber>
<description>Test Memo</description>
<receiptdate>06/30/2021</receiptdate>
<amounttopay />
<trx_amounttopay>1922.12</trx_amounttopay>
<prbatch>123</prbatch>
<whenpaid>07/01/2021</whenpaid>
<overpaymentamount />
<overpaymentlocationid>1020</overpaymentlocationid>
<overpaymentdepartmentid>900</overpaymentdepartmentid>
</arpymt>
</create>
</function>";

ArPaymentCreate2 record = new ArPaymentCreate2("unittest")
{
CustomerId = "C0020",
TransactionPaymentAmount = 1922.12M,
SummaryRecordNo = 123,
ReceivedDate = new DateTime(2021, 06, 30),
PaymentMethod = "Printed Check",
ReferenceNumber = "1000",
Description = "Test Memo",
OverpaymentDepartmentId = "900",
OverpaymentLocationId = "1020",
WhenPaidDate = new DateTime(2021, 07, 01)
};

this.CompareXml(expected, record);
}
}
}
6 changes: 3 additions & 3 deletions Intacct.SDK.Tests/Intacct.SDK.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net4.6.1;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net5.0;net4.6.1;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
23 changes: 12 additions & 11 deletions Intacct.SDK.Tests/Xml/XmlObjectTestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Copyright 2020 Sage Intacct, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. You may obtain a copy
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

using Intacct.SDK.Xml;
using System.IO;
using System.Text;
using System.Xml;
using Intacct.SDK.Xml;
using Xunit;

namespace Intacct.SDK.Tests.Xml
Expand All @@ -34,14 +34,15 @@ public void CompareXml(string expected, IXmlObject apiFunction)
};

IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

apiFunction.WriteXml(ref xml);

xml.Flush();
stream.Position = 0;
StreamReader reader = new StreamReader(stream);

Assert.Equal(expected, reader.ReadToEnd());

var foo = reader.ReadToEnd();
Assert.Equal(expected, foo);
}
}
}
123 changes: 123 additions & 0 deletions Intacct.SDK/Functions/AccountsReceivable/AbstractArPayment2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright 2020 Sage Intacct, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

using System;
using System.Collections.Generic;

namespace Intacct.SDK.Functions.AccountsReceivable
{
public abstract class AbstractArPayment2 : AbstractFunction
{
/// <summary>
/// ARPYMTDETAILS
/// </summary>
public List<ArPaymentItem2> ApplyToTransactions = new List<ArPaymentItem2>();

/// <summary>
/// FINANCIALENTITY
/// </summary>
public string BankAccountId;

/// <summary>
/// BASECURR
/// </summary>
public string BaseCurrency;

/// <summary>
/// AMOUNTOPAY
/// </summary>
public decimal? BasePaymentAmount;

public string BillToPayName;
public string CustomerId;
public string Description;

/// <summary>
/// EXCH_RATE_TYPE_ID
/// </summary>
public string ExchangeRateType;

/// <summary>
/// EXCHANGE_RATE
/// </summary>
public decimal? ExchangeRateValue;

/// <summary>
/// OVERPAYMENTAMOUNT
/// </summary>
public decimal? OverpaymentAmount;

public string OverpaymentDepartmentId;
public string OverpaymentLocationId;

/// <summary>
/// PAYMENTDATE
/// </summary>
public DateTime? PaymentDate;

public string PaymentMethod;

/// <summary>
/// RECEIPTDATE
/// </summary>
public DateTime? ReceivedDate;

/// <summary>
/// DOCNUMBER
/// </summary>
public string ReferenceNumber;

/// <summary>
/// PRBATCH
/// </summary>
public int? SummaryRecordNo;

/// <summary>
/// CURRENCY
/// </summary>
public string TransactionCurrency;

/// <summary>
/// TRX_AMOUNTTOPAY
/// </summary>
public decimal? TransactionPaymentAmount;

/// <summary>
/// UNDEPOSITEDACCOUNTNO
/// </summary>
public string UndepositedFundsGlAccountNo;

/// <summary>
/// WHENPAID
/// </summary>
public DateTime? WhenPaidDate;

#region Unmappable AbstractArPayment Fields

/// public string CreditCardType;

// public DateTime? ExchangeRateDate;

// public string AuthorizationCode;

// public int? RecordNo;

#endregion Unmappable AbstractArPayment Fields

protected AbstractArPayment2(string controlId = null) : base(controlId)
{
}
}
}
130 changes: 130 additions & 0 deletions Intacct.SDK/Functions/AccountsReceivable/ArPaymentCreate2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright 2020 Sage Intacct, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

using Intacct.SDK.Xml;

namespace Intacct.SDK.Functions.AccountsReceivable
{
/// <summary>
/// This class creates a payment using the non-legacy version of the API.
/// </summary>
public class ArPaymentCreate2 : AbstractArPayment2
{
public ArPaymentCreate2(string controlId = null) : base(controlId)
{
}

public override void WriteXml(ref IaXmlWriter xml)
{
xml.WriteStartElement("function");
xml.WriteAttribute("controlid", ControlId, true);

xml.WriteStartElement("create");

xml.WriteStartElement("arpymt");

if (!string.IsNullOrWhiteSpace(UndepositedFundsGlAccountNo))
{
xml.WriteElement("undepositedaccountno", BankAccountId); // undepfundsacct
}
else
{
xml.WriteElement("financialentity", BankAccountId); // bankaccountid
}

xml.WriteElement("paymentmethod", PaymentMethod, true);
xml.WriteElement("customerid", CustomerId, true);
xml.WriteElement("docnumber", ReferenceNumber); // "refid"
xml.WriteElement("description", Description);

//if (ExchangeRateDate.HasValue)
//{
// xml.WriteStartElement("exchratedate");
// xml.WriteDateSplitElements2(ExchangeRateDate.Value);
// xml.WriteEndElement(); //exchratedate
//}

if (!string.IsNullOrWhiteSpace(ExchangeRateType))
{
xml.WriteElement("exch_rate_type_id", ExchangeRateType); // "exchratetype"
}
else if (ExchangeRateValue.HasValue)
{
xml.WriteElement("exchange_rate", ExchangeRateValue); // "exchrate"
}
else if (!string.IsNullOrWhiteSpace(BaseCurrency) || !string.IsNullOrWhiteSpace(TransactionCurrency))
{
xml.WriteElement("exchratetype", ExchangeRateType, true);
}

xml.WriteStartElement("receiptdate"); // "datereceived"
xml.WriteDateMMddyyyy(ReceivedDate.Value); // Required element
xml.WriteEndElement(); //receiptdate

if (PaymentDate.HasValue)
{
xml.WriteStartElement("paymentdate");
xml.WriteDateMMddyyyy(PaymentDate.Value);
xml.WriteEndElement(); //paymentdate
}

xml.WriteElement("amounttopay", BasePaymentAmount, true); // "translatedamount"
xml.WriteElement("trx_amounttopay", TransactionPaymentAmount, true); // paymentamount

xml.WriteElement("prbatch", SummaryRecordNo); // batchkey

if (WhenPaidDate.HasValue)
{
xml.WriteStartElement("whenpaid");
xml.WriteDateMMddyyyy(WhenPaidDate.Value);
xml.WriteEndElement(); //paymentdate
}

xml.WriteElement("currency", TransactionCurrency);
xml.WriteElement("basecurr", BaseCurrency);

xml.WriteElement("undepositedaccountno", UndepositedFundsGlAccountNo);

xml.WriteElement("overpaymentamount", OverpaymentAmount, true);
xml.WriteElement("overpaymentlocationid", OverpaymentLocationId); // "overpaylocid"
xml.WriteElement("overpaymentdepartmentid", OverpaymentDepartmentId); // "overpaydeptid"

xml.WriteElement("billtopayname", BillToPayName);

//xml.WriteElement("cctype", CreditCardType);
//xml.WriteElement("authcode", AuthorizationCode);

if (ApplyToTransactions.Count > 0)
{
xml.WriteStartElement("arpymtdetails"); // "arpaymentitem"

foreach (ArPaymentItem2 applyToTransaction in ApplyToTransactions)
{
applyToTransaction.WriteXml(ref xml);
}

xml.WriteEndElement(); // arpymtdetails
}

// TODO online payment methods

xml.WriteEndElement(); //create

xml.WriteEndElement(); //arpymt

xml.WriteEndElement(); //function
}
}
}
Loading