-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Complete automatic foreign balance translation
- Loading branch information
Showing
34 changed files
with
3,920 additions
and
1,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
database/migrations/2021_06_04_155845_create_closing_rates_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateClosingRatesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create(config('ifrs.table_prefix') . 'closing_rates', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
|
||
// relationships | ||
$table->unsignedBigInteger('entity_id'); | ||
$table->unsignedBigInteger('reporting_period_id'); | ||
$table->unsignedBigInteger('exchange_rate_id'); | ||
|
||
// constraints | ||
$table->foreign('entity_id')->references('id')->on(config('ifrs.table_prefix') . 'entities'); | ||
$table->foreign('reporting_period_id')->references('id')->on(config('ifrs.table_prefix') . 'reporting_periods'); | ||
$table->foreign('exchange_rate_id')->references('id')->on(config('ifrs.table_prefix') . 'exchange_rates'); | ||
|
||
// *permanent* deletion | ||
$table->dateTime('destroyed_at')->nullable(); | ||
|
||
//soft deletion | ||
$table->softDeletes(); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists(config('ifrs.table_prefix') .'closing_rates'); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
database/migrations/2021_06_11_202626_add_closing_rate_column.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class AddClosingRateColumn extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table(config('ifrs.table_prefix') . 'reporting_periods', | ||
function (Blueprint $table) { | ||
$table->dateTime('closing_date', 0)->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table(config('ifrs.table_prefix') . 'reporting_periods', function (Blueprint $table) { | ||
if (config('database.default') == 'sqlite') { | ||
DB::statement('PRAGMA foreign_keys = OFF;'); // sqlite needs to drop the entire table to remove a column, which fails because the table is already referenced | ||
} | ||
$table->dropColumn('closing_date'); | ||
}); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
database/migrations/2021_06_12_211003_create_closing_transactions_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateClosingTransactionsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create(config('ifrs.table_prefix') . 'closing_transactions', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
|
||
// relationships | ||
$table->unsignedBigInteger('entity_id'); | ||
$table->unsignedBigInteger('reporting_period_id'); | ||
$table->unsignedBigInteger('transaction_id'); | ||
$table->unsignedBigInteger('currency_id'); | ||
|
||
// constraints | ||
$table->foreign('entity_id')->references('id')->on(config('ifrs.table_prefix') . 'entities'); | ||
$table->foreign('reporting_period_id')->references('id')->on(config('ifrs.table_prefix') . 'reporting_periods'); | ||
$table->foreign('transaction_id')->references('id')->on(config('ifrs.table_prefix') . 'transactions'); | ||
$table->foreign('currency_id')->references('id')->on(config('ifrs.table_prefix') . 'currencies'); | ||
|
||
// *permanent* deletion | ||
$table->dateTime('destroyed_at')->nullable(); | ||
|
||
//soft deletion | ||
$table->softDeletes(); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists(config('ifrs.table_prefix') .'closing_transactions'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
<?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> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<server name="APP_ENV" value="testing"/> | ||
<server name="DB_CONNECTION" value="sqlite"/> | ||
<server name="DB_DATABASE" value=":memory:"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Eloquent IFRS Accounting | ||
* | ||
* @author Edward Mungai | ||
* @copyright Edward Mungai, 2021, Germany | ||
* @license MIT | ||
*/ | ||
|
||
namespace IFRS\Exceptions; | ||
|
||
class DuplicateClosingRate extends IFRSException | ||
{ | ||
/** | ||
* Duplicate Closing Rate Exception | ||
* | ||
* @param string $currencyCode | ||
* @param int $year | ||
* @param string $message | ||
* @param int $code | ||
*/ | ||
public function __construct(string $currencyCode, int $year, string $message = null, int $code = null) | ||
{ | ||
$error = "A Closing Rate already exists for " . $currencyCode . " for " . $year; | ||
|
||
parent::__construct($error . $message, $code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Eloquent IFRS Accounting | ||
* | ||
* @author Edward Mungai | ||
* @copyright Edward Mungai, 2021, Germany | ||
* @license MIT | ||
*/ | ||
|
||
namespace IFRS\Exceptions; | ||
|
||
use IFRS\Models\ReportingPeriod; | ||
|
||
class InvalidPeriodStatus extends IFRSException | ||
{ | ||
/** | ||
* Invalid Period Status Exception | ||
* | ||
* @param string $message | ||
* @param int $code | ||
*/ | ||
public function __construct(string $message = null, int $code = null) | ||
{ | ||
$error = "Reporting Period must have " . config('ifrs')['reporting_period_status'][ReportingPeriod::ADJUSTING] . " status to translate foreign balances"; | ||
|
||
parent::__construct($error . $message, $code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/** | ||
* Eloquent IFRS Accounting | ||
* | ||
* @author Edward Mungai | ||
* @copyright Edward Mungai, 2021, Germany | ||
* @license MIT | ||
*/ | ||
|
||
namespace IFRS\Exceptions; | ||
|
||
class MissingClosingRate extends IFRSException | ||
{ | ||
/** | ||
* Missing Closing Rate Exception | ||
* | ||
* @param $currencyCode | ||
* @param string $message | ||
* @param int $code | ||
*/ | ||
public function __construct(string $currencyCode, string $message = null, int $code = null) | ||
{ | ||
$error = "Closing Rate for " . $currencyCode . " is missing "; | ||
|
||
parent::__construct($error . $message, $code); | ||
} | ||
} |
Oops, something went wrong.