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

Type, Primary key and inconsistency fixes #77

Merged
merged 9 commits into from
Oct 24, 2016
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ See for example: [example/example.php](example/example.php)

## TODO
- Switch administration (now uses default)
- Current entities do not contain all available properties. Feel free to submit a PR with added or extended entities if you require them.
- Current entities do not contain all available properties. Feel free to submit a PR with added or extended entities if you require them. Use the ```userscript.js``` in greasemonkey or tampermonkey to generate entities consistently and completely.


2 changes: 2 additions & 0 deletions src/Picqer/Financials/Exact/Division.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Division extends Model

use Query\Findable;

protected $primaryKey = 'Code';

protected $fillable = [
'Code',
'BlockingStatus',
Expand Down
9 changes: 8 additions & 1 deletion src/Picqer/Financials/Exact/Query/Findable.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ public function findWithSelect($id, $select = '')
public function findId($code, $key='Code'){
if ( $this->isFillable($key) ) {
$format = $this->url == 'crm/Accounts' ? '%18s' : '%s';
$filter = sprintf("$key eq '$format'", $code);
if (preg_match('/^[\w]{8}-([\w]{4}-){3}[\w]{12}$/', $code)) {
$format = "guid'$format'";
}
elseif (is_string($code)) {
$format = "'$format'";
}

$filter = sprintf("$key eq $format", $code);
$request = array('$filter' => $filter, '$top' => 1, '$orderby' => $this->primaryKey);
if( $records = $this->connection()->get($this->url, $request) ){
return $records[0][$this->primaryKey];
Expand Down
26 changes: 26 additions & 0 deletions src/Picqer/Financials/Exact/ReceivableList.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class ReceivableList
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=ReadFinancialReceivablesList
*
* @property Int64 $HID Human readable ID, Primary key
* @property String $AccountCode Code of the Account
* @property Guid $AccountId Reference to the account
* @property String $AccountName Name of Account
* @property Double $Amount Amount
* @property Double $AmountInTransit Amount in transit
* @property String $CurrencyCode Code of Currency
* @property String $Description Description
* @property DateTime $DueDate Date the invoice should be paid
* @property Int32 $EntryNumber Entry number
* @property Guid $Id Obsolete
* @property DateTime $InvoiceDate Invoice date
* @property Int32 $InvoiceNumber Invoice number
* @property String $JournalCode Code of Journal
* @property String $JournalDescription Description of Journal
* @property String $YourRef Your reference
*/
class ReceivableList extends Model
{

use Query\Findable;

protected $primaryKey = 'HID';

protected $fillable = [
'AccountCode',
'AccountId',
Expand All @@ -15,6 +40,7 @@ class ReceivableList extends Model
'Description',
'DueDate',
'EntryNumber',
'HID',
'Id',
'InvoiceDate',
'InvoiceNumber',
Expand Down
106 changes: 106 additions & 0 deletions src/Picqer/Financials/Exact/Subscription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class Subscription
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=subscriptionSubscriptions
*
* @property Guid $EntryID ID of the entry, Primary key
* @property Boolean $BlockEntry Indicates if subscription is blocked for time cost entry
* @property DateTime $CancellationDate Date of cancellation
* @property Guid $Classification Reference to Classification
* @property String $ClassificationCode Code of Classification
* @property String $ClassificationDescription Description of Classification
* @property DateTime $Created Creation date
* @property Guid $Creator User ID of creator
* @property String $CreatorFullName Name of creator
* @property String $Currency Currency code
* @property String $CustomerPONumber Purchase order number of customer
* @property String $Description Description of Classification
* @property Int32 $Division Division code
* @property DateTime $EndDate End date
* @property DateTime $InvoicedTo Invoice date
* @property Guid $InvoiceTo Reference to invoice account
* @property Guid $InvoiceToContactPerson Reference to contact person of invoice account
* @property String $InvoiceToContactPersonFullName Name of contact person of invoice account
* @property String $InvoiceToName Name of invoice account
* @property DateTime $InvoicingStartDate Invoicing start date
* @property DateTime $Modified Last modified date
* @property Guid $Modifier User ID of modifier
* @property String $ModifierFullName Name of modifier
* @property String $Notes Remarks
* @property String $Number Purchase order number of customer
* @property Guid $OrderedBy Reference to order account
* @property Guid $OrderedByContactPerson Reference of contact person of order account
* @property String $OrderedByContactPersonFullName Name of contact person of order account
* @property String $OrderedByName Name of order account
* @property String $PaymentCondition Payment condition
* @property String $PaymentConditionDescription Description of PaymentCondition
* @property Boolean $Printed Indicates if subscription is printed
* @property Guid $ReasonCancelled Reference to reason cancelled
* @property String $ReasonCancelledCode Code of ReasonCancelled
* @property String $ReasonCancelledDescription Description of ReasonCancelled
* @property DateTime $StartDate Invoicing start date
* @property SubscriptionLines $SubscriptionLines Collection of subscription lines
* @property SubscriptionRestrictionEmployees $SubscriptionRestrictionEmployees Collection of restriction employees
* @property SubscriptionRestrictionItems $SubscriptionRestrictionItems Collection of restriction items
* @property Guid $SubscriptionType Reference to subscription type
* @property String $SubscriptionTypeCode Code of SubscriptionType
* @property String $SubscriptionTypeDescription Description of SubscriptionType
*/
class Subscription extends Model
{

use Query\Findable;
use Persistance\Storable;

protected $primaryKey = 'EntryID';

protected $fillable = [
'BlockEntry',
'CancellationDate',
'Classification',
'ClassificationCode',
'ClassificationDescription',
'Created',
'Creator',
'CreatorFullName',
'Currency',
'CustomerPONumber',
'Description',
'Division',
'EndDate',
'EntryID',
'InvoicedTo',
'InvoiceTo',
'InvoiceToContactPerson',
'InvoiceToContactPersonFullName',
'InvoiceToName',
'InvoicingStartDate',
'Modified',
'Modifier',
'ModifierFullName',
'Notes',
'Number',
'OrderedBy',
'OrderedByContactPerson',
'OrderedByContactPersonFullName',
'OrderedByName',
'PaymentCondition',
'PaymentConditionDescription',
'Printed',
'ReasonCancelled',
'ReasonCancelledCode',
'ReasonCancelledDescription',
'StartDate',
'SubscriptionLines',
'SubscriptionRestrictionEmployees',
'SubscriptionRestrictionItems',
'SubscriptionType',
'SubscriptionTypeCode',
'SubscriptionTypeDescription',
];

protected $url = 'subscription/Subscriptions';
}
71 changes: 71 additions & 0 deletions src/Picqer/Financials/Exact/SubscriptionLine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class SubscriptionLine
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SubscriptionSubscriptionLines
*
* @property Guid $ID Primary key
* @property Double $AmountDC Amount in the default currency of the company
* @property Double $AmountFC Amount in the currency of the transaction
* @property String $Costcenter Cost center
* @property String $Costunit Cost unit
* @property String $Description Description
* @property Double $Discount Discount percentage
* @property Int32 $Division Division code
* @property Guid $EntryID Entry ID
* @property DateTime $FromDate From date
* @property Guid $Item Reference to Item
* @property String $ItemDescription Description of Item
* @property Int32 $LineNumber Line number
* @property Int16 $LineType Reference to LineType
* @property String $LineTypeDescription Description of LineType
* @property Double $NetPrice Net price in the currency of the transaction
* @property String $Notes Remarks
* @property Double $Quantity Quantity
* @property DateTime $ToDate To date
* @property String $UnitCode Unit code
* @property String $UnitDescription Description of Unit
* @property Double $UnitPrice Unit price in the currency of the transaction (price * unit factor)
* @property Double $VATAmountFC Vat Amount in the currency of the transaction
* @property String $VATCode VATCode
* @property String $VATCodeDescription Description of VATCode
*/
class SubscriptionLine extends Model
{

use Query\Findable;
use Persistance\Storable;

protected $fillable = [
'ID',
'AmountDC',
'AmountFC',
'Costcenter',
'Costunit',
'Description',
'Discount',
'Division',
'EntryID',
'FromDate',
'Item',
'ItemDescription',
'LineNumber',
'LineType',
'LineTypeDescription',
'NetPrice',
'Notes',
'Quantity',
'ToDate',
'UnitCode',
'UnitDescription',
'UnitPrice',
'VATAmountFC',
'VATCode',
'VATCodeDescription',
];

protected $url = 'subscription/SubscriptionLines';

}
63 changes: 2 additions & 61 deletions src/Picqer/Financials/Exact/SubscriptionLines.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,6 @@
<?php namespace Picqer\Financials\Exact;

use DateTime;
use Picqer\Financials\Exact\Model;
use Picqer\Financials\Exact\Persistance\Storable;
use Picqer\Financials\Exact\Query\Findable;

/**
* Class Subscriptions
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=subscriptionSubscriptions
*
* @property Guid $ID Primary Key
* @property Double $AmountDC Amount in the default currency of the company
* @property Double $AmountFC Amount in the currency of the transaction
* @property String $Costcenter Cost Center
* @property String $Costunit Cost Unit
* @property String $Description Description
* @property String $Discount Discount
* @property Guid $EntryID Entry ID
* @property DateTime $FromDate From date
* @property Guid $Item Reference to Item
* @property Int $LineNumber Line number
* @property Int $LineType Line Type
* @property Double $NetPrice Net Price in the currency of the transaction
* @property String $Notes Remarks
* @property Double $Quantity Quantity
* @property DateTime $ToDate To date
* @property String $UnitCode Unit code
* @property Double $UnitPrice Unit price in the currency of the transaction (price * unit factor)
* @property Double $VATAmountFC Vat Amount in the currency of the transaction
* @property String $VATCode VATCode
* Added deprecated SubscriptionLines class for backward compatibility
*/
class SubscriptionLines extends Model
{

use Findable;
use Storable;

protected $fillable = [
'ID',
'AmountDC',
'AmountFC',
'Costcenter',
'Costunit',
'Description',
'Discount',
'EntryID',
'FromDate',
'Item',
'LineNumber',
'LineType',
'NetPrice',
'Notes',
'Quantity',
'ToDate',
'UnitCode',
'UnitPrice',
'VATAmountFc',
'VATCode'
];

protected $url = 'subscription/SubscriptionLines';
}
class_alias(__NAMESPACE__ . '\SubscriptionLine', __NAMESPACE__ . '\SubscriptionLines');
41 changes: 41 additions & 0 deletions src/Picqer/Financials/Exact/SubscriptionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class SubscriptionType
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SubscriptionSubscriptionTypes
*
* @property Guid $ID Primary key
* @property String $Code Code
* @property DateTime $Created Creation date
* @property Guid $Creator User ID of the creator
* @property String $CreatorFullName Name of the creator
* @property String $Description Description
* @property Int32 $Division Division code
* @property DateTime $Modified Last modified date
* @property Guid $Modifier User ID of the last modifier
* @property String $ModifierFullName Name of the last modifier
*/
class SubscriptionType extends Model
{

use Query\Findable;
use Persistance\Storable;

protected $fillable = [
'ID',
'Code',
'Created',
'Creator',
'CreatorFullName',
'Description',
'Division',
'Modified',
'Modifier',
'ModifierFullName',
];

protected $url = 'subscription/SubscriptionTypes';

}