Skip to content

Commit

Permalink
Merge branch 'master' into reports-start-date-hours-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmungai authored Apr 2, 2021
2 parents 914a479 + 6bc7b09 commit 69cc2d8
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 62 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The motivation for this package can be found in detail on my blog post [here](ht

## Installation

Use composer to Install the package into your laravel or lumen application. Eloquent IFRS requires PHP version 7.2 and Eloquent version 6 and above.
Use composer to Install the package into your laravel or lumen application. Eloquent IFRS requires PHP version 7.2 and Eloquent version 7 and above.

#### For production

Expand Down Expand Up @@ -329,7 +329,7 @@ use IFRS\Models\ReportingPeriod;

$period = ReportingPeriod::create([
'period_count' => 1,
'year' => 2020,
'year' => 2021,
]);

```
Expand All @@ -339,8 +339,8 @@ The Income Statement (Profit and Loss):
use IFRS\Reports\IncomeStatement;

$incomeStatement = new IncomeStatement(
"2020-01-01", // Report start date
"2020-12-31", // Report end date
"2021-01-01", // Report start date
"2021-12-31", // Report end date
)->getSections();// Fetch balances from the ledger and store them internally

/**
Expand All @@ -351,7 +351,7 @@ dd($incomeStatement->toString());

Example Company
Income Statement
For the Period: Jan 01 2020 to Dec 31 2020
For the Period: Jan 01 2021 to Dec 31 2021

Operating Revenues
Operating Revenue 200 (100 cash sales + 100 credit sales)
Expand Down Expand Up @@ -383,7 +383,7 @@ The Balance Sheet:
use IFRS\Reports\BalanceSheet;

$balanceSheet = new BalanceSheet(
"2020-12-31" // Report end date
"2021-12-31" // Report end date
)->getSections();

/**
Expand All @@ -394,7 +394,7 @@ dd($balanceSheet->toString());

Example Company
Balance Sheet
As at: Dec 31 2020
As at: Dec 31 2021

Assets
Non Current Asset 120 (asset purchase)
Expand Down Expand Up @@ -467,7 +467,7 @@ I am acutely aware that as a professionally trained Accountant I may have used s
## Roadmap

- [x] Add Cashflow Statement
- [ ] Laravel 8 Compatibility
- [x] Laravel 8 Compatibility
- [ ] Add Multicurrency support

## License
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
],
"minimum-stability" : "dev",
"require" : {
"php" : "^7.2.5",
"illuminate/database" : "^6.0|^7.30.4",
"illuminate/auth" : "^6.0|^7.30.4",
"calebporzio/parental" : "^0.10.0",
"doctrine/dbal": "^2.5"
"php" : "^7.3.0",
"illuminate/database" : "^7.0|^8.0",
"illuminate/auth" : "^7.0|^8.0",
"calebporzio/parental" : "^0.11.0",
"doctrine/dbal": "^2.10.1"
},
"require-dev" : {
"facade/ignition" : "^1.4",
"facade/ignition" : "^2.3.6",
"friendsofphp/php-cs-fixer" : "^2.16",
"fzaninotto/faker" : "^1.4",
"mockery/mockery" : "^1.0",
"nunomaduro/collision" : "^3.0",
"nunomaduro/collision" : "^5.0",
"nunomaduro/larastan" : "^0.5.0",
"phpmd/phpmd" : "^2.8",
"phpunit/phpunit" : "^8.0",
"phpunit/phpunit" : "9.4.3",
"squizlabs/php_codesniffer" : "*",
"orchestra/testbench" : "^3.0|^4.0"
"orchestra/testbench" : "^5.0|^6.0"
},
"autoload" : {
"psr-4" : {
Expand Down
11 changes: 8 additions & 3 deletions config/ifrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@
|
| Eloquent model for the users. This assumes you already have a working
| user model. If not, create one and reference it here. During initial
| migration, columns are added to the table name. Your users model should
| also use the IFRSUser trait to provide access to the entity scope
| migration, columns are added to the table. Your users model should
| also use the IFRSUser trait to provide access to the entity scope.
| Make sure to place your model under the right eloquent version key
| otherwise the migrations may not work
|
*/
'user_model' => App\User::class,
'user_model' => [
7 => App\User::class,
8 => App\Models\User::class,
],

/*
|--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Schema;

class IfrsCreateOrUpdateUsersTable extends Migration
Expand Down Expand Up @@ -81,7 +82,7 @@ function (Blueprint $table) {

private function getTableName()
{
$userModel = config('ifrs.user_model');
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval(App::version())] : config('ifrs.user_model');
return (new $userModel())->getTable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function (Blueprint $table) {
$table->boolean('multi_currency')->default(false);
$table->boolean('mid_year_balances')->default(false);
$table->integer('year_start')->default(1);
$table->string('locale', 20)->default(config('ifrs.locales')[0]);

// *permanent* deletion
$table->dateTime('destroyed_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function (Blueprint $table) {
$table->unsignedBigInteger('user_id');

// constraints
$userModel = config('ifrs.user_model');
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval(App::version())] : config('ifrs.user_model');
$table->foreign('entity_id')->references('id')->on(config('ifrs.table_prefix').'entities');
$table->foreign('user_id')->references('id')->on((new $userModel())->getTable());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function (Blueprint $table) {

// constraints
$table->foreign('entity_id')->references('id')->on(config('ifrs.table_prefix').'entities');
$table->foreign('category_id')->references('id')->on(config('ifrs.table_prefix').'categories');
$table->foreign('category_id')->references('id')->on(config('ifrs.table_prefix').'categories') ;
$table->foreign('currency_id')->references('id')->on(config('ifrs.table_prefix').'currencies');

// attributes
Expand Down
36 changes: 0 additions & 36 deletions database/migrations/2021_03_04_194118_add_entity_locale.php

This file was deleted.

30 changes: 30 additions & 0 deletions phpunit.xml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
4 changes: 2 additions & 2 deletions tests/Unit/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use IFRS\Exceptions\HangingTransactions;
use IFRS\Exceptions\InvalidCategoryType;
use IFRS\Exceptions\MissingAccountType;
use IFRS\Models\Entity;
use IFRS\Transactions\JournalEntry;

class AccountTest extends TestCase
Expand Down Expand Up @@ -216,8 +217,7 @@ public function testAccountCodes()
$account = new Account([
'name' => $this->faker->name,
'account_type' => Account::OPERATING_REVENUE,
'category_id' => null,
'entity_id' => 2
'entity_id' => factory(Entity::class)->create()->id
]);
$account->save();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/JournalEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testJournalEntryFind()
'category_id' => null
]);
$transaction = new JournalEntry([
"account_id" => $account,
"account_id" => $account->id,
"transaction_date" => Carbon::now(),
"narration" => $this->faker->word,
]);
Expand Down

0 comments on commit 69cc2d8

Please sign in to comment.