Skip to content

Latest commit

 

History

History
655 lines (571 loc) · 29.4 KB

File metadata and controls

655 lines (571 loc) · 29.4 KB

Accounting.JournalEntries

Overview

Available Operations

  • list - List Journal Entries
  • create - Create Journal Entry
  • get - Get Journal Entry
  • update - Update Journal Entry
  • delete - Delete Journal Entry

list

List Journal Entries

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesAllRequest(
    serviceId: 'salesforce',
    companyId: '12345',
    filter: new Components\JournalEntriesFilter(
        updatedSince: Utils\Utils::parseDateTime('2020-09-30T07:43:32.000Z'),
    ),
    sort: new Components\JournalEntriesSort(
        by: Components\JournalEntriesSortBy::UpdatedAt,
        direction: Components\SortDirection::Desc,
    ),
    passThrough: [
        'search' => 'San Francisco',
    ],
    fields: 'id,updated_at',
);

$responses = $sdk->accounting->journalEntries->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->httpMeta->response->getStatusCode() === 200) {
        // handle response
    }
}

Parameters

Parameter Type Required Description
$request Operations\AccountingJournalEntriesAllRequest ✔️ The request object to use for the request.

Response

?Operations\AccountingJournalEntriesAllResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

create

Create Journal Entry

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesAddRequest(
    serviceId: 'salesforce',
    companyId: '12345',
    journalEntry: new Components\JournalEntryInput(
        title: 'Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry',
        currencyRate: 0.69,
        currency: Components\Currency::Usd,
        companyId: '12345',
        lineItems: [
            new Components\JournalEntryLineItemInput(
                description: 'Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.',
                taxAmount: 27500,
                subTotal: 27500,
                totalAmount: 27500,
                type: Components\JournalEntryLineItemType::Debit,
                taxRate: new Components\LinkedTaxRateInput(
                    id: '123456',
                    rate: 10,
                ),
                trackingCategories: [
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                ],
                ledgerAccount: new Components\LinkedLedgerAccount(
                    id: '123456',
                    nominalCode: 'N091',
                    code: '453',
                ),
                customer: new Components\LinkedCustomerInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    email: 'boring@boring.com',
                ),
                supplier: new Components\LinkedSupplierInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    address: new Components\Address(
                        id: '123',
                        type: Components\Type::Primary,
                        string: '25 Spring Street, Blackburn, VIC 3130',
                        name: 'HQ US',
                        line1: 'Main street',
                        line2: 'apt #',
                        line3: 'Suite #',
                        line4: 'delivery instructions',
                        streetNumber: '25',
                        city: 'San Francisco',
                        state: 'CA',
                        postalCode: '94104',
                        country: 'US',
                        latitude: '40.759211',
                        longitude: '-73.984638',
                        county: 'Santa Clara',
                        contactName: 'Elon Musk',
                        salutation: 'Mr',
                        phoneNumber: '111-111-1111',
                        fax: '122-111-1111',
                        email: 'elon@musk.com',
                        website: 'https://elonmusk.com',
                        notes: 'Address notes or delivery instructions.',
                        rowVersion: '1-12345',
                    ),
                ),
                departmentId: '12345',
                locationId: '12345',
                lineNumber: 1,
            ),
        ],
        status: Components\JournalEntryStatus::Draft,
        memo: 'Thank you for your business and have a great day!',
        postedAt: Utils\Utils::parseDateTime('2020-09-30T07:43:32.000Z'),
        journalSymbol: 'IND',
        taxType: 'sales',
        taxCode: '1234',
        number: 'OIT00546',
        trackingCategories: null,
        accountingPeriod: '01-24',
        rowVersion: '1-12345',
        customFields: [
            new Components\CustomField1(
                id: '2389328923893298',
                name: 'employee_level',
                description: 'Employee Level',
                value: 'Uses Salesforce and Marketo',
            ),
        ],
        passThrough: [
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
        ],
    ),
);

$response = $sdk->accounting->journalEntries->create(
    request: $request
);

if ($response->createJournalEntryResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\AccountingJournalEntriesAddRequest ✔️ The request object to use for the request.

Response

?Operations\AccountingJournalEntriesAddResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

get

Get Journal Entry

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Operations;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesOneRequest(
    id: '<id>',
    serviceId: 'salesforce',
    companyId: '12345',
    fields: 'id,updated_at',
);

$response = $sdk->accounting->journalEntries->get(
    request: $request
);

if ($response->getJournalEntryResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\AccountingJournalEntriesOneRequest ✔️ The request object to use for the request.

Response

?Operations\AccountingJournalEntriesOneResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

update

Update Journal Entry

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesUpdateRequest(
    id: '<id>',
    serviceId: 'salesforce',
    companyId: '12345',
    journalEntry: new Components\JournalEntryInput(
        title: 'Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry',
        currencyRate: 0.69,
        currency: Components\Currency::Usd,
        companyId: '12345',
        lineItems: [
            new Components\JournalEntryLineItemInput(
                description: 'Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.',
                taxAmount: 27500,
                subTotal: 27500,
                totalAmount: 27500,
                type: Components\JournalEntryLineItemType::Debit,
                taxRate: new Components\LinkedTaxRateInput(
                    id: '123456',
                    rate: 10,
                ),
                trackingCategories: [
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                ],
                ledgerAccount: new Components\LinkedLedgerAccount(
                    id: '123456',
                    nominalCode: 'N091',
                    code: '453',
                ),
                customer: new Components\LinkedCustomerInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    email: 'boring@boring.com',
                ),
                supplier: new Components\LinkedSupplierInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    address: new Components\Address(
                        id: '123',
                        type: Components\Type::Primary,
                        string: '25 Spring Street, Blackburn, VIC 3130',
                        name: 'HQ US',
                        line1: 'Main street',
                        line2: 'apt #',
                        line3: 'Suite #',
                        line4: 'delivery instructions',
                        streetNumber: '25',
                        city: 'San Francisco',
                        state: 'CA',
                        postalCode: '94104',
                        country: 'US',
                        latitude: '40.759211',
                        longitude: '-73.984638',
                        county: 'Santa Clara',
                        contactName: 'Elon Musk',
                        salutation: 'Mr',
                        phoneNumber: '111-111-1111',
                        fax: '122-111-1111',
                        email: 'elon@musk.com',
                        website: 'https://elonmusk.com',
                        notes: 'Address notes or delivery instructions.',
                        rowVersion: '1-12345',
                    ),
                ),
                departmentId: '12345',
                locationId: '12345',
                lineNumber: 1,
            ),
        ],
        status: Components\JournalEntryStatus::Draft,
        memo: 'Thank you for your business and have a great day!',
        postedAt: Utils\Utils::parseDateTime('2020-09-30T07:43:32.000Z'),
        journalSymbol: 'IND',
        taxType: 'sales',
        taxCode: '1234',
        number: 'OIT00546',
        trackingCategories: [
            new Components\LinkedTrackingCategory(
                id: '123456',
                name: 'New York',
            ),
            new Components\LinkedTrackingCategory(
                id: '123456',
                name: 'New York',
            ),
        ],
        accountingPeriod: '01-24',
        rowVersion: '1-12345',
        customFields: [
            new Components\CustomField1(
                id: '2389328923893298',
                name: 'employee_level',
                description: 'Employee Level',
                value: 'Uses Salesforce and Marketo',
            ),
        ],
        passThrough: [
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
        ],
    ),
);

$response = $sdk->accounting->journalEntries->update(
    request: $request
);

if ($response->updateJournalEntryResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\AccountingJournalEntriesUpdateRequest ✔️ The request object to use for the request.

Response

?Operations\AccountingJournalEntriesUpdateResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

delete

Delete Journal Entry

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Operations;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesDeleteRequest(
    id: '<id>',
    serviceId: 'salesforce',
    companyId: '12345',
);

$response = $sdk->accounting->journalEntries->delete(
    request: $request
);

if ($response->deleteJournalEntryResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\AccountingJournalEntriesDeleteRequest ✔️ The request object to use for the request.

Response

?Operations\AccountingJournalEntriesDeleteResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*