Skip to content

Commit 91e9b2c

Browse files
author
sunny
committed
adds vertex_transaction_type to adjustment and invoice models
1 parent fbb047d commit 91e9b2c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

Library/Adjustment.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public List<CustomField> CustomFields
9393
}
9494
private List<CustomField> _customFields;
9595

96+
/// <summary>
97+
/// Optional vertex transaction type for tax purposes.
98+
/// </summary>
99+
public string VertexTransactionType { get; set; }
100+
96101
private const string UrlPrefix = "/accounts/";
97102
private const string UrlPostfix = "/adjustments/";
98103

@@ -405,6 +410,8 @@ internal void WriteXml(XmlTextWriter xmlWriter, bool embedded = false)
405410

406411
if (TaxCode != null)
407412
xmlWriter.WriteElementString("tax_code", TaxCode);
413+
if (VertexTransactionType != null)
414+
xmlWriter.WriteElementString("vertex_transaction_type", VertexTransactionType);
408415
if (StartDate != DateTime.MinValue)
409416
xmlWriter.WriteElementString("start_date", StartDate.ToString("s"));
410417
if (EndDate.HasValue)

Library/Invoice.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public Address Address
140140
public string TermsAndConditions { get; set; }
141141
public string VatReverseChargeNotes { get; set; }
142142
public string GatewayCode { get; set; }
143+
public string VertexTransactionType { get; set; }
143144
public DateTime? AttemptNextCollectionAt { get; set; }
144145
public string RecoveryReason { get; set; }
145146
public string AllLineItemsLink { get; set; }
@@ -793,6 +794,9 @@ internal override void WriteXml(XmlTextWriter xmlWriter)
793794
xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes);
794795
xmlWriter.WriteElementString("po_number", PoNumber);
795796

797+
if (VertexTransactionType != null)
798+
xmlWriter.WriteElementString("vertex_transaction_type", VertexTransactionType);
799+
796800
if (CollectionMethod == Collection.Manual)
797801
{
798802
xmlWriter.WriteElementString("collection_method", "manual");
@@ -825,6 +829,8 @@ internal void WriteUpdateXml(XmlTextWriter xmlWriter)
825829
xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes);
826830
if (GatewayCode != null)
827831
xmlWriter.WriteElementString("gateway_code", GatewayCode);
832+
if (VertexTransactionType != null)
833+
xmlWriter.WriteElementString("vertex_transaction_type", VertexTransactionType);
828834
if (PoNumber != null)
829835
xmlWriter.WriteElementString("po_number", PoNumber);
830836

Test/AdjustmentTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,23 @@ public void CheckForRevRecDataOut()
281281
xml.Should().Contain("<revenue_gl_account_id>sxo2b1hpjrye</revenue_gl_account_id>");
282282
xml.Should().Contain("<performance_obligation_id>7pu</performance_obligation_id>");
283283
}
284+
285+
[RecurlyFact(TestEnvironment.Type.Unit)]
286+
public void AdjustmentWithVertexTransactionType()
287+
{
288+
var adjustment = new Adjustment
289+
{
290+
VertexTransactionType = "lease"
291+
};
292+
293+
// Verify the request serializes vertex_transaction_type correctly
294+
var xmlOutput = new System.Text.StringBuilder();
295+
using (var xmlWriter = new XmlTextWriter(new System.IO.StringWriter(xmlOutput)))
296+
{
297+
adjustment.WriteXml(xmlWriter);
298+
}
299+
var xml = xmlOutput.ToString();
300+
Assert.Contains("<vertex_transaction_type>lease</vertex_transaction_type>", xml);
301+
}
284302
}
285303
}

Test/InvoiceTest.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Linq;
3+
using System.Xml;
34
using FluentAssertions;
5+
using Recurly.Test.Fixtures;
46
using Xunit;
57

68
namespace Recurly.Test
@@ -587,5 +589,41 @@ public void CreateInvoiceWithEOMNetTerms()
587589
Assert.Equal(response.NetTerms, 45);
588590
Assert.Equal(response.NetTermsType, NetTermsType.EOM);
589591
}
592+
593+
[RecurlyFact(TestEnvironment.Type.Unit)]
594+
public void InvoiceWithVertexTransactionType()
595+
{
596+
var invoice = new Invoice
597+
{
598+
VertexTransactionType = "lease"
599+
};
600+
601+
// Verify the request serializes vertex_transaction_type correctly
602+
var xmlOutput = new System.Text.StringBuilder();
603+
using (var xmlWriter = new XmlTextWriter(new System.IO.StringWriter(xmlOutput)))
604+
{
605+
invoice.WriteXml(xmlWriter);
606+
}
607+
var xml = xmlOutput.ToString();
608+
Assert.Contains("<vertex_transaction_type>lease</vertex_transaction_type>", xml);
609+
}
610+
611+
[RecurlyFact(TestEnvironment.Type.Unit)]
612+
public void InvoiceWithVertexTransactionTypeUpdate()
613+
{
614+
var invoice = new Invoice
615+
{
616+
VertexTransactionType = "rental"
617+
};
618+
619+
// Verify the update request serializes vertex_transaction_type correctly
620+
var xmlOutput = new System.Text.StringBuilder();
621+
using (var xmlWriter = new XmlTextWriter(new System.IO.StringWriter(xmlOutput)))
622+
{
623+
invoice.WriteUpdateXml(xmlWriter);
624+
}
625+
var xml = xmlOutput.ToString();
626+
Assert.Contains("<vertex_transaction_type>rental</vertex_transaction_type>", xml);
627+
}
590628
}
591629
}

0 commit comments

Comments
 (0)