Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add general ledger accounts(glas) support #790

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 52 additions & 0 deletions Tests/Recurly/GeneralLedgerAccountList_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

class Recurly_GeneralLedgerAccountListTest extends Recurly_TestCase
{
public function testGetGeneralLedgerAccountListAll() {
$this->client->addResponse(
'GET',
'/general_ledger_accounts',
'general_ledger_accounts/list-200.xml'
);

$general_ledger_accounts = Recurly_GeneralLedgerAccountList::get(null, $this->client);
$this->assertInstanceOf('Recurly_GeneralLedgerAccountList', $general_ledger_accounts);

$general_ledger_account = $general_ledger_accounts->current();
$this->assertInstanceOf('Recurly_GeneralLedgerAccount', $general_ledger_account);

$this->assertEquals(iterator_count($general_ledger_accounts), 13);
}

public function testGetGeneralLedgerAccountListFilteredByRevenue() {
$this->client->addResponse(
'GET',
'/general_ledger_accounts?account_type=revenue',
'general_ledger_accounts/list-200-revenue.xml'
);

$general_ledger_accounts = Recurly_GeneralLedgerAccountList::getByAccountType('revenue', $this->client);
$this->assertInstanceOf('Recurly_GeneralLedgerAccountList', $general_ledger_accounts);

$general_ledger_account = $general_ledger_accounts->current();
$this->assertInstanceOf('Recurly_GeneralLedgerAccount', $general_ledger_account);

$this->assertEquals(iterator_count($general_ledger_accounts), 4);
}

public function testGetGeneralLedgerAccountListFilteredByLiability() {
$this->client->addResponse(
'GET',
'/general_ledger_accounts?account_type=liability',
'general_ledger_accounts/list-200-liability.xml'
);

$general_ledger_accounts = Recurly_GeneralLedgerAccountList::getByAccountType('liability', $this->client);
$this->assertInstanceOf('Recurly_GeneralLedgerAccountList', $general_ledger_accounts);

$general_ledger_account = $general_ledger_accounts->current();
$this->assertInstanceOf('Recurly_GeneralLedgerAccount', $general_ledger_account);

$this->assertEquals(iterator_count($general_ledger_accounts), 9);
}
}
67 changes: 67 additions & 0 deletions Tests/Recurly/GeneralLedgerAccount_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

class Recurly_GeneralLedgerAccountTest extends Recurly_TestCase
{
function defaultResponses() {
return array(
array('GET', '/general_ledger_accounts/u90r5deeaxix', 'general_ledger_accounts/show-200.xml'),
);
}

public function testGetGeneralLedgerAccount() {
$gla = Recurly_GeneralLedgerAccount::get('u90r5deeaxix', $this->client);

$this->assertInstanceOf('Recurly_GeneralLedgerAccount', $gla);
$this->assertEquals('code1', $gla->code);
$this->assertEquals('revenue', $gla->account_type);
$this->assertEquals('string', $gla->description);
$this->assertEquals('u90r5deeaxix', $gla->id);
}

public function testCreate() {
$this->client->addResponse('POST', '/general_ledger_accounts', 'general_ledger_accounts/create-201.xml');

$gla = new Recurly_GeneralLedgerAccount(null, $this->client);
$gla->code = 'little_llama';
$gla->account_type = 'revenue';
$gla->description = 'A description about llamas';

$gla->create();

$this->assertInstanceOf('Recurly_GeneralLedgerAccount', $gla);
}

public function testCreateXml() {
$gla = new Recurly_GeneralLedgerAccount();
$gla->code = 'little_llama';
$gla->account_type = 'revenue';
$gla->description = 'A description about llamas';

$this->assertXmlStringEqualsXmlString(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<general_ledger_account>
<code>little_llama</code>
<account_type>revenue</account_type>
<description>A description about llamas</description>
</general_ledger_account>",
$gla->xml()
);
}

public function testUpdateXml() {
$gla = Recurly_GeneralLedgerAccount::get('u90r5deeaxix', $this->client);
$gla->code = 'little_llama';
$gla->account_type = 'revenue';
$gla->description = 'A new description about llamas';

$this->assertXmlStringEqualsXmlString(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<general_ledger_account>
<code>little_llama</code>
<account_type>revenue</account_type>
<description>A new description about llamas</description>
</general_ledger_account>",
$gla->xml()
);
}
}
12 changes: 12 additions & 0 deletions Tests/fixtures/general_ledger_accounts/create-201.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
<id>u90r5deeaxix</id>
<code>code1</code>
<account_type>revenue</account_type>
<description>string</description>
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
</general_ledger_account>
78 changes: 78 additions & 0 deletions Tests/fixtures/general_ledger_accounts/list-200-liability.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_accounts type="array">
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/ty4utwr0mrgz">
<id>ty4utwr0mrgz</id>
<code>90-557-279-6957</code>
<account_type>liability</account_type>
<description>optimize rich content</description>
<created_at type="datetime">2023-11-22T16:36:34Z</created_at>
<updated_at type="datetime">2023-11-22T16:36:34Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twyyzw8vcm36">
<id>twyyzw8vcm36</id>
<code>45-571-736-1179</code>
<account_type>liability</account_type>
<description>incentivize sexy functionalities</description>
<created_at type="datetime">2023-11-16T19:45:05Z</created_at>
<updated_at type="datetime">2023-11-16T19:45:05Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twywtf01wkgb">
<id>twywtf01wkgb</id>
<code>70-818-669-8644</code>
<account_type>liability</account_type>
<description>generate transparent metrics</description>
<created_at type="datetime">2023-11-16T19:32:52Z</created_at>
<updated_at type="datetime">2023-11-16T19:32:52Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twywqfr48v9l">
<id>twywqfr48v9l</id>
<code>7-271-680-5012</code>
<account_type>liability</account_type>
<description>My main liability account</description>
<created_at type="datetime">2023-11-16T19:32:24Z</created_at>
<updated_at type="datetime">2023-11-16T19:32:24Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twyvjlhbnej2">
<id>twyvjlhbnej2</id>
<code>1234</code>
<account_type>liability</account_type>
<description>My main liability account</description>
<created_at type="datetime">2023-11-16T19:25:44Z</created_at>
<updated_at type="datetime">2023-11-16T19:25:44Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkzlcm2pde8">
<id>trkzlcm2pde8</id>
<code>validategla</code>
<account_type>liability</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:22:49Z</created_at>
<updated_at type="datetime">2023-10-20T15:22:49Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkzinjccchm">
<id>trkzinjccchm</id>
<code>j</code>
<account_type>liability</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:22:24Z</created_at>
<updated_at type="datetime">2023-10-20T15:22:24Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/tep8f2u4qq51">
<id>tep8f2u4qq51</id>
<code>get dat monayyy</code>
<account_type>liability</account_type>
<description>i can has money</description>
<created_at type="datetime">2023-08-16T15:45:40Z</created_at>
<updated_at type="datetime">2023-08-16T15:45:40Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/tejv6lw4eovy">
<id>tejv6lw4eovy</id>
<code>demo_liability</code>
<account_type>liability</account_type>
<description>i be descriptin'</description>
<created_at type="datetime">2023-08-15T21:42:35Z</created_at>
<updated_at type="datetime">2023-09-13T15:38:04Z</updated_at>
</general_ledger_account>
</general_ledger_accounts>
38 changes: 38 additions & 0 deletions Tests/fixtures/general_ledger_accounts/list-200-revenue.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_accounts type="array">
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
<id>u90r5deeaxix</id>
<code>string</code>
<account_type>revenue</account_type>
<description>string</description>
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trl0h3br1dl7">
<id>trl0h3br1dl7</id>
<code>100</code>
<account_type>revenue</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:27:46Z</created_at>
<updated_at type="datetime">2023-10-20T15:27:46Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkz0atorlk3">
<id>trkz0atorlk3</id>
<code>NEW code</code>
<account_type>revenue</account_type>
<description>NEW description</description>
<created_at type="datetime">2023-10-20T15:19:32Z</created_at>
<updated_at type="datetime">2023-10-20T15:29:30Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/thproqnpcuwp">
<id>thproqnpcuwp</id>
<code>303</code>
<account_type>revenue</account_type>
<description></description>
<created_at type="datetime">2023-08-31T20:46:04Z</created_at>
<updated_at type="datetime">2023-08-31T20:46:04Z</updated_at>
</general_ledger_account>
</general_ledger_accounts>
110 changes: 110 additions & 0 deletions Tests/fixtures/general_ledger_accounts/list-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_accounts type="array">
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
<id>u90r5deeaxix</id>
<code>string</code>
<account_type>revenue</account_type>
<description>string</description>
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/ty4utwr0mrgz">
<id>ty4utwr0mrgz</id>
<code>90-557-279-6957</code>
<account_type>liability</account_type>
<description>optimize rich content</description>
<created_at type="datetime">2023-11-22T16:36:34Z</created_at>
<updated_at type="datetime">2023-11-22T16:36:34Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twyyzw8vcm36">
<id>twyyzw8vcm36</id>
<code>45-571-736-1179</code>
<account_type>liability</account_type>
<description>incentivize sexy functionalities</description>
<created_at type="datetime">2023-11-16T19:45:05Z</created_at>
<updated_at type="datetime">2023-11-16T19:45:05Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twywtf01wkgb">
<id>twywtf01wkgb</id>
<code>70-818-669-8644</code>
<account_type>liability</account_type>
<description>generate transparent metrics</description>
<created_at type="datetime">2023-11-16T19:32:52Z</created_at>
<updated_at type="datetime">2023-11-16T19:32:52Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twywqfr48v9l">
<id>twywqfr48v9l</id>
<code>7-271-680-5012</code>
<account_type>liability</account_type>
<description>My main liability account</description>
<created_at type="datetime">2023-11-16T19:32:24Z</created_at>
<updated_at type="datetime">2023-11-16T19:32:24Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/twyvjlhbnej2">
<id>twyvjlhbnej2</id>
<code>1234</code>
<account_type>liability</account_type>
<description>My main liability account</description>
<created_at type="datetime">2023-11-16T19:25:44Z</created_at>
<updated_at type="datetime">2023-11-16T19:25:44Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trl0h3br1dl7">
<id>trl0h3br1dl7</id>
<code>100</code>
<account_type>revenue</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:27:46Z</created_at>
<updated_at type="datetime">2023-10-20T15:27:46Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkzlcm2pde8">
<id>trkzlcm2pde8</id>
<code>validategla</code>
<account_type>liability</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:22:49Z</created_at>
<updated_at type="datetime">2023-10-20T15:22:49Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkzinjccchm">
<id>trkzinjccchm</id>
<code>j</code>
<account_type>liability</account_type>
<description>HOWDY</description>
<created_at type="datetime">2023-10-20T15:22:24Z</created_at>
<updated_at type="datetime">2023-10-20T15:22:24Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/trkz0atorlk3">
<id>trkz0atorlk3</id>
<code>NEW code</code>
<account_type>revenue</account_type>
<description>NEW description</description>
<created_at type="datetime">2023-10-20T15:19:32Z</created_at>
<updated_at type="datetime">2023-10-20T15:29:30Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/thproqnpcuwp">
<id>thproqnpcuwp</id>
<code>303</code>
<account_type>revenue</account_type>
<description></description>
<created_at type="datetime">2023-08-31T20:46:04Z</created_at>
<updated_at type="datetime">2023-08-31T20:46:04Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/tep8f2u4qq51">
<id>tep8f2u4qq51</id>
<code>get dat monayyy</code>
<account_type>liability</account_type>
<description>i can has money</description>
<created_at type="datetime">2023-08-16T15:45:40Z</created_at>
<updated_at type="datetime">2023-08-16T15:45:40Z</updated_at>
</general_ledger_account>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/tejv6lw4eovy">
<id>tejv6lw4eovy</id>
<code>demo_liability</code>
<account_type>liability</account_type>
<description>i be descriptin'</description>
<created_at type="datetime">2023-08-15T21:42:35Z</created_at>
<updated_at type="datetime">2023-09-13T15:38:04Z</updated_at>
</general_ledger_account>
</general_ledger_accounts>
12 changes: 12 additions & 0 deletions Tests/fixtures/general_ledger_accounts/show-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
<id>u90r5deeaxix</id>
<code>code1</code>
<account_type>revenue</account_type>
<description>string</description>
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
</general_ledger_account>
2 changes: 2 additions & 0 deletions lib/recurly.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
require_once(__DIR__ . '/recurly/external_payment_phase_list.php');
require_once(__DIR__ . '/recurly/external_subscription.php');
require_once(__DIR__ . '/recurly/external_subscription_list.php');
require_once(__DIR__ . '/recurly/general_ledger_account.php');
require_once(__DIR__ . '/recurly/general_ledger_account_list.php');
require_once(__DIR__ . '/recurly/invoice.php');
require_once(__DIR__ . '/recurly/invoice_collection.php');
require_once(__DIR__ . '/recurly/invoice_list.php');
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Recurly_Client
const PATH_EXTERNAL_INVOICES = 'external_invoices';
const PATH_EXTERNAL_ACCOUNTS = 'external_accounts';
const PATH_BUSINESS_ENTITIES = 'business_entities';
const PATH_GENERAL_LEDGER_ACCOUNTS = 'general_ledger_accounts';

/**
* Create a new Recurly Client
Expand Down
Loading
Loading