Merge branch 'master' of https://github.com/brkcvn/akaunting into code-clean
This commit is contained in:
26
app/Events/Banking/DocumentTransactionCreated.php
Normal file
26
app/Events/Banking/DocumentTransactionCreated.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class DocumentTransactionCreated extends Event
|
||||
{
|
||||
public $document;
|
||||
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct(Document $document, Transaction $transaction)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
25
app/Events/Banking/DocumentTransactionCreating.php
Normal file
25
app/Events/Banking/DocumentTransactionCreating.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class DocumentTransactionCreating extends Event
|
||||
{
|
||||
public $document;
|
||||
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct(Document $document, $request)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
30
app/Events/Banking/DocumentTransactionUpdated.php
Normal file
30
app/Events/Banking/DocumentTransactionUpdated.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class DocumentTransactionUpdated extends Event
|
||||
{
|
||||
public $document;
|
||||
|
||||
public $transaction;
|
||||
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
* @param $transaction
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct(Document $document, Transaction $transaction, $request)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->transaction = $transaction;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
30
app/Events/Banking/DocumentTransactionUpdating.php
Normal file
30
app/Events/Banking/DocumentTransactionUpdating.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class DocumentTransactionUpdating extends Event
|
||||
{
|
||||
public $document;
|
||||
|
||||
public $transaction;
|
||||
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
* @param $transaction
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct(Document $document, Transaction $transaction, $request)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->transaction = $transaction;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
25
app/Events/Banking/TransactionUpdated.php
Normal file
25
app/Events/Banking/TransactionUpdated.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class TransactionUpdated extends Event
|
||||
{
|
||||
public $transaction;
|
||||
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct(Transaction $transaction, $request)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
25
app/Events/Banking/TransactionUpdating.php
Normal file
25
app/Events/Banking/TransactionUpdating.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class TransactionUpdating extends Event
|
||||
{
|
||||
public $transaction;
|
||||
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct(Transaction $transaction, $request)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
@ -16,10 +16,16 @@ class Bills extends Export implements WithColumnFormatting
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$country = null;
|
||||
|
||||
if ($model->contact_country && array_key_exists($model->contact_country, trans('countries'))) {
|
||||
$country = trans('countries.' . $model->contact_country);
|
||||
}
|
||||
|
||||
$model->category_name = $model->category->name;
|
||||
$model->bill_number = $model->document_number;
|
||||
$model->billed_at = $model->issued_at;
|
||||
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
|
||||
$model->contact_country = $country;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
@ -14,7 +14,13 @@ class Vendors extends Export
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
|
||||
$country = null;
|
||||
|
||||
if ($model->country && array_key_exists($model->country, trans('countries'))) {
|
||||
$country = trans('countries.' . $model->country);
|
||||
}
|
||||
|
||||
$model->country = $country;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
@ -14,7 +14,13 @@ class Customers extends Export
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
|
||||
$country = null;
|
||||
|
||||
if ($model->country && array_key_exists($model->country, trans('countries'))) {
|
||||
$country = trans('countries.' . $model->country);
|
||||
}
|
||||
|
||||
$model->country = $country;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
@ -16,10 +16,16 @@ class Invoices extends Export implements WithColumnFormatting
|
||||
|
||||
public function map($model): array
|
||||
{
|
||||
$country = null;
|
||||
|
||||
if ($model->contact_country && array_key_exists($model->contact_country, trans('countries'))) {
|
||||
$country = trans('countries.' . $model->contact_country);
|
||||
}
|
||||
|
||||
$model->category_name = $model->category->name;
|
||||
$model->invoice_number = $model->document_number;
|
||||
$model->invoiced_at = $model->issued_at;
|
||||
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
|
||||
$model->contact_country = $country;
|
||||
|
||||
return parent::map($model);
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ class Company extends FormRequest
|
||||
$rules['api_key'] = 'string|check';
|
||||
}
|
||||
|
||||
if (setting('apps.api_key', false) && (setting('apps.api_key', false) != $this->request->get('api_key'))) {
|
||||
$rules['api_key'] = 'string|check';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Banking\DocumentTransactionCreated;
|
||||
use App\Events\Banking\DocumentTransactionCreating;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Events\Document\PaidAmountCalculated;
|
||||
@ -27,6 +29,8 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
||||
|
||||
public function handle(): Transaction
|
||||
{
|
||||
event(new DocumentTransactionCreating($this->model, $this->request));
|
||||
|
||||
$this->prepareRequest();
|
||||
|
||||
$this->checkAmount();
|
||||
@ -46,6 +50,8 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
||||
$this->createHistory();
|
||||
});
|
||||
|
||||
event(new DocumentTransactionCreated($this->model, $this->transaction));
|
||||
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Banking\DocumentTransactionUpdated;
|
||||
use App\Events\Banking\DocumentTransactionUpdating;
|
||||
use App\Events\Document\PaidAmountCalculated;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Events\Document\PaidAmountCalculated;
|
||||
use App\Interfaces\Job\ShouldUpdate;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Document\Document;
|
||||
@ -26,6 +28,8 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
||||
|
||||
public function handle(): Transaction
|
||||
{
|
||||
event(new DocumentTransactionUpdating($this->model, $this->transaction, $this->request));
|
||||
|
||||
$this->prepareRequest();
|
||||
|
||||
$this->checkAmount();
|
||||
@ -45,6 +49,8 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
||||
$this->createHistory();
|
||||
});
|
||||
|
||||
event(new DocumentTransactionUpdated($this->model, $this->transaction, $this->request));
|
||||
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Banking\TransactionUpdated;
|
||||
use App\Events\Banking\TransactionUpdating;
|
||||
use App\Interfaces\Job\ShouldUpdate;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
@ -12,6 +14,8 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
event(new TransactionUpdating($this->model, $this->request));
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->model->update($this->request->all());
|
||||
|
||||
@ -32,6 +36,8 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
||||
$this->model->updateRecurring($this->request->all());
|
||||
});
|
||||
|
||||
event(new TransactionUpdated($this->model, $this->request));
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
@ -526,8 +526,10 @@ class Company extends Eloquent implements Ownable
|
||||
$location[] = setting('company.state');
|
||||
}
|
||||
|
||||
if (setting('company.country')) {
|
||||
$location[] = trans('countries.' . setting('company.country'));
|
||||
$country = setting('company.country');
|
||||
|
||||
if ($country && in_array($country, trans('countries'))) {
|
||||
$location[] = trans('countries.' . $country);
|
||||
}
|
||||
|
||||
return implode(', ', $location);
|
||||
|
@ -254,7 +254,7 @@ class Contact extends Model
|
||||
$location[] = $this->state;
|
||||
}
|
||||
|
||||
if ($this->country) {
|
||||
if ($this->country && in_array($this->country, trans('countries'))) {
|
||||
$location[] = trans('countries.' . $this->country);
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ class Document extends Model
|
||||
$location[] = $this->contact_state;
|
||||
}
|
||||
|
||||
if ($this->contact_country) {
|
||||
if ($this->contact_country && in_array($this->contact_country, trans('countries'))) {
|
||||
$location[] = trans('countries.' . $this->contact_country);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Country extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (! empty($this->code)) {
|
||||
if (! empty($this->code) && in_array($this->code, trans('countries'))) {
|
||||
$this->country = trans('countries.' . $this->code);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user