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: 2 additions & 0 deletions src/Picqer/Financials/Exact/Division.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Division extends Model
{

use Query\Findable;

protected $primaryKey = 'Code';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just updated Komodo Edit will check its settings.


protected $fillable = [
'Code',
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this indentation?


protected $fillable = [
'AccountCode',
'AccountId',
Expand All @@ -15,6 +40,7 @@ class ReceivableList extends Model
'Description',
'DueDate',
'EntryNumber',
'HID',
'Id',
'InvoiceDate',
'InvoiceNumber',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class Subscriptions
* 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
Expand Down Expand Up @@ -48,11 +49,13 @@
* @property String $SubscriptionTypeCode Code of SubscriptionType
* @property String $SubscriptionTypeDescription Description of SubscriptionType
*/
class Subscriptions extends Model
class Subscription extends Model
{

use Query\Findable;
use Persistance\Storable;

protected $primaryKey = 'EntryID';

protected $fillable = [
'BlockEntry',
Expand All @@ -68,6 +71,7 @@ class Subscriptions extends Model
'Description',
'Division',
'EndDate',
'EntryID',
'InvoicedTo',
'InvoiceTo',
'InvoiceToContactPerson',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Picqer\Financials\Exact\Query\Findable;

/**
* Class Subscriptions
* Class SubscriptionLine
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=subscriptionSubscriptions
Expand All @@ -32,7 +32,7 @@
* @property Double $VATAmountFC Vat Amount in the currency of the transaction
* @property String $VATCode VATCode
*/
class SubscriptionLines extends Model
class SubscriptionLine extends Model
{

use Findable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Picqer\Financials\Exact\Query\Findable;

/**
* Class Subscriptions
* Class SubscriptionType
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=subscriptionSubscriptions
Expand All @@ -22,7 +22,7 @@
* @property Guid $Modifier User ID of the last modifier
* @property String $ModifierFullName Name of the last modifier
*/
class SubscriptionTypes extends Model
class SubscriptionType extends Model
{

use Findable;
Expand Down
56 changes: 56 additions & 0 deletions src/Picqer/Financials/Exact/Transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class Transaction
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=financialtransactionTransactions
*
* @property Guid $EntryID Primary key
* @property Double $ClosingBalanceFC Closing balance in the currency of the transaction
* @property DateTime $Date Creation date
* @property String $Description Description
* @property Int32 $Division Division code
* @property Int32 $EntryNumber Entry number
* @property Int16 $FinancialPeriod Financial period
* @property Int16 $FinancialYear Financial year
* @property String $JournalCode Code of Journal
* @property String $JournalDescription Description of Journal
* @property Double $OpeningBalanceFC Opening balance in the currency of the transaction
* @property String $PaymentConditionCode Code of PaymentCondition
* @property String $PaymentConditionDescription Description of PaymentCondition
* @property Int16 $Status Status: 5 = Rejected, 20 = Open, 50 = Processed
* @property String $StatusDescription Description of Status
* @property TransactionLines $TransactionLines Collection of lines
* @property Int32 $Type The transaction type. 10 = Opening balance, 20 = Sales entry, 21 = Sales credit note, 22 = Return invoice sent, 30 = Purchase entry, 31 = Purchase credit note, 32 = Return invoice received, 40 = Cash flow, 50 = VAT return, 70 = Asset depreciation, 71 = Asset investment, 72 = Asset revaluation, 73 = Asset transfer, 74 = Asset split, 75 = Asset discontinue, 76 = Asset sales, 80 = Revaluation, 82 = Exchange rate difference, 83 = Payment difference, 84 = Deferred revenue, 85 = Tracking number:Revaluation, 86 = Deferred cost, 90 = Other, 120 = Delivery, 121 = Sales return, 130 = Receipt, 131 = Purchase return, 140 = Shop order stock receipt, 141 = Shop order stock reversal, 142 = Issue to parent, 145 = Shop order time entry, 146 = Shop order time entry reversal, 150 = Requirement issue, 151 = Requirement reversal, 152 = Returned from parent, 155 = Subcontract Issue, 156 = Subcontract reversal, 158 = Shop order completed, 162 = Finish assembly, 170 = Payroll, 180 = Stock revaluation, 195 = Stock count, 290 = Correction entry, 310 = Period closing, 320 = Year end reflection, 321 = Year end costing, 322 = Year end profits to gross profit, 323 = Year end costs to gross profit, 324 = Year end tax, 325 = Year end gross profit to net p/l, 326 = Year end net p/l to balance sheet, 327 = Year end closing balance, 328 = Year start opening balance, 3000 = Budget
* @property String $TypeDescription The description of the transaction type
*/
class Transaction extends Model
{
use Query\Findable;
use Persistance\Storable;

protected $primaryKey = 'EntryID';

protected $fillable = [
'ClosingBalanceFC',
'Date',
'Description',
'Division',
'EntryID',
'EntryNumber',
'FinancialPeriod',
'FinancialYear',
'JournalCode',
'JournalDescription',
'OpeningBalanceFC',
'PaymentConditionCode',
'PaymentConditionDescription',
'Status',
'StatusDescription',
'TransactionLines',
'Type',
'TypeDescription'
];
protected $url = 'financialtransaction/Transactions';
}
52 changes: 2 additions & 50 deletions src/Picqer/Financials/Exact/Transactions.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,6 @@
<?php namespace Picqer\Financials\Exact;

/**
* Class Transactions
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=financialtransactionTransactions
*
* @property Double $ClosingBalanceFC Closing balance in the currency of the transaction
* @property DateTime $Date Creation date
* @property String $Description Description
* @property Int32 $Division Division code
* @property Int32 $EntryNumber Entry number
* @property Int16 $FinancialPeriod Financial period
* @property Int16 $FinancialYear Financial year
* @property String $JournalCode Code of Journal
* @property String $JournalDescription Description of Journal
* @property Double $OpeningBalanceFC Opening balance in the currency of the transaction
* @property String $PaymentConditionCode Code of PaymentCondition
* @property String $PaymentConditionDescription Description of PaymentCondition
* @property Int16 $Status Status: 5 = Rejected, 20 = Open, 50 = Processed
* @property String $StatusDescription Description of Status
* @property TransactionLines $TransactionLines Collection of lines
* @property Int32 $Type The transaction type. 10 = Opening balance, 20 = Sales entry, 21 = Sales credit note, 22 = Return invoice sent, 30 = Purchase entry, 31 = Purchase credit note, 32 = Return invoice received, 40 = Cash flow, 50 = VAT return, 70 = Asset depreciation, 71 = Asset investment, 72 = Asset revaluation, 73 = Asset transfer, 74 = Asset split, 75 = Asset discontinue, 76 = Asset sales, 80 = Revaluation, 82 = Exchange rate difference, 83 = Payment difference, 84 = Deferred revenue, 85 = Tracking number:Revaluation, 86 = Deferred cost, 90 = Other, 120 = Delivery, 121 = Sales return, 130 = Receipt, 131 = Purchase return, 140 = Shop order stock receipt, 141 = Shop order stock reversal, 142 = Issue to parent, 145 = Shop order time entry, 146 = Shop order time entry reversal, 150 = Requirement issue, 151 = Requirement reversal, 152 = Returned from parent, 155 = Subcontract Issue, 156 = Subcontract reversal, 158 = Shop order completed, 162 = Finish assembly, 170 = Payroll, 180 = Stock revaluation, 195 = Stock count, 290 = Correction entry, 310 = Period closing, 320 = Year end reflection, 321 = Year end costing, 322 = Year end profits to gross profit, 323 = Year end costs to gross profit, 324 = Year end tax, 325 = Year end gross profit to net p/l, 326 = Year end net p/l to balance sheet, 327 = Year end closing balance, 328 = Year start opening balance, 3000 = Budget
* @property String $TypeDescription The description of the transaction type
* Added deprecated Transactions class for backward compatibility
*/
class Transactions extends Model
{
use Query\Findable;
use Persistance\Storable;

protected $primaryKey = 'EntryID';

protected $fillable = [
'ClosingBalanceFC',
'Date',
'Description',
'Division',
'EntryNumber',
'FinancialPeriod',
'FinancialYear',
'JournalCode',
'JournalDescription',
'OpeningBalanceFC',
'PaymentConditionCode',
'PaymentConditionDescription',
'Status',
'StatusDescription',
'TransactionLines',
'Type',
'TypeDescription'
];
protected $url = 'financialtransaction/Transactions';
}
class_alias(__NAMESPACE__ . '\Transaction', __NAMESPACE__ . '\Transactions');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have created an extra class for backward compatibility here but have not done so for the Subscription* classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Subscriptions and SubscriptionTypes and SubscriptionLines are added recently added I dit not think this nessesary. Do you want me to add aliases for these classes as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are already released, we should. If you can do that, it would be great :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just added them. All issues with this pull request should be resolved unless I introduced something in a5da440 or more likely 87a2e70 that you do not approve off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a use case that does not use the Autoloader so I could add a trigger_error statement with a depreciation warning. This way we can in the future clean up the extra files.