diff --git a/VERSION.txt b/VERSION.txt index 9819012c5fef..e4bd2904e214 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.37 \ No newline at end of file +5.5.38 \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 6510aa0ef8d3..2e246e1b514f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -98,7 +98,8 @@ class Kernel extends ConsoleKernel $schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping(); - $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping(); + //not used @deprecate + // $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping(); $schedule->command('ninja:check-data --database=db-ninja-01')->daily('02:00')->withoutOverlapping(); diff --git a/app/Filters/BankIntegrationFilters.php b/app/Filters/BankIntegrationFilters.php new file mode 100644 index 000000000000..09ba40cc0e70 --- /dev/null +++ b/app/Filters/BankIntegrationFilters.php @@ -0,0 +1,133 @@ +=1) + return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); + + return $this->builder; + } + + /** + * Filter based on search text. + * + * @param string query filter + * @return Builder + * @deprecated + */ + public function filter(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where(function ($query) use ($filter) { + $query->where('bank_integrations.bank_account_name', 'like', '%'.$filter.'%'); + }); + + } + + /** + * Filters the list based on the status + * archived, active, deleted. + * + * @param string filter + * @return Builder + */ + public function status(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + $table = 'bank_integrations'; + $filters = explode(',', $filter); + + return $this->builder->where(function ($query) use ($filters, $table) { + $query->whereNull($table.'.id'); + + if (in_array(parent::STATUS_ACTIVE, $filters)) { + $query->orWhereNull($table.'.deleted_at'); + } + + if (in_array(parent::STATUS_ARCHIVED, $filters)) { + $query->orWhere(function ($query) use ($table) { + $query->whereNotNull($table.'.deleted_at'); + + if (! in_array($table, ['users'])) { + $query->where($table.'.is_deleted', '=', 0); + } + }); + } + + if (in_array(parent::STATUS_DELETED, $filters)) { + $query->orWhere($table.'.is_deleted', '=', 1); + } + }); + } + + /** + * Sorts the list based on $sort. + * + * @param string sort formatted as column|asc + * @return Builder + */ + public function sort(string $sort) : Builder + { + $sort_col = explode('|', $sort); + + return $this->builder->orderBy($sort_col[0], $sort_col[1]); + } + + /** + * Returns the base query. + * + * @param int company_id + * @param User $user + * @return Builder + * @deprecated + */ + public function baseQuery(int $company_id, User $user) : Builder + { + + } + + /** + * Filters the query by the users company ID. + * + * @return Illuminate\Database\Query\Builder + */ + public function entityFilter() + { + //return $this->builder->whereCompanyId(auth()->user()->company()->id); + return $this->builder->company(); + } +} diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php new file mode 100644 index 000000000000..f76cc81cfdb7 --- /dev/null +++ b/app/Filters/BankTransactionFilters.php @@ -0,0 +1,133 @@ +=1) + return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); + + return $this->builder; + } + + /** + * Filter based on search text. + * + * @param string query filter + * @return Builder + * @deprecated + */ + public function filter(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where(function ($query) use ($filter) { + $query->where('bank_transactions.description', 'like', '%'.$filter.'%'); + }); + + } + + /** + * Filters the list based on the status + * archived, active, deleted. + * + * @param string filter + * @return Builder + */ + public function status(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + $table = 'bank_transactions'; + $filters = explode(',', $filter); + + return $this->builder->where(function ($query) use ($filters, $table) { + $query->whereNull($table.'.id'); + + if (in_array(parent::STATUS_ACTIVE, $filters)) { + $query->orWhereNull($table.'.deleted_at'); + } + + if (in_array(parent::STATUS_ARCHIVED, $filters)) { + $query->orWhere(function ($query) use ($table) { + $query->whereNotNull($table.'.deleted_at'); + + if (! in_array($table, ['users'])) { + $query->where($table.'.is_deleted', '=', 0); + } + }); + } + + if (in_array(parent::STATUS_DELETED, $filters)) { + $query->orWhere($table.'.is_deleted', '=', 1); + } + }); + } + + /** + * Sorts the list based on $sort. + * + * @param string sort formatted as column|asc + * @return Builder + */ + public function sort(string $sort) : Builder + { + $sort_col = explode('|', $sort); + + return $this->builder->orderBy($sort_col[0], $sort_col[1]); + } + + /** + * Returns the base query. + * + * @param int company_id + * @param User $user + * @return Builder + * @deprecated + */ + public function baseQuery(int $company_id, User $user) : Builder + { + + } + + /** + * Filters the query by the users company ID. + * + * @return Illuminate\Database\Query\Builder + */ + public function entityFilter() + { + //return $this->builder->whereCompanyId(auth()->user()->company()->id); + return $this->builder->company(); + } +} diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index b061adc46acf..750505c24feb 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; use App\Factory\BankIntegrationFactory; +use App\Filters\BankIntegrationFilters; use App\Helpers\Bank\Yodlee\Yodlee; use App\Http\Requests\BankIntegration\AdminBankIntegrationRequest; use App\Http\Requests\BankIntegration\CreateBankIntegrationRequest; @@ -91,10 +92,10 @@ class BankIntegrationController extends BaseController * @param Request $request * @return Response|mixed */ - public function index(Request $request) + public function index(BankIntegrationFilters $filters) { - $bank_integrations = BankIntegration::query()->company(); + $bank_integrations = BankIntegration::filter($filters); return $this->listResponse($bank_integrations); diff --git a/app/Http/Controllers/BankTransactionController.php b/app/Http/Controllers/BankTransactionController.php index 3f63ce04e0e3..13fb7be803dd 100644 --- a/app/Http/Controllers/BankTransactionController.php +++ b/app/Http/Controllers/BankTransactionController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; use App\Factory\BankTransactionFactory; +use App\Filters\BankTransactionFilters; use App\Helpers\Bank\Yodlee\Yodlee; use App\Http\Requests\BankTransaction\AdminBankTransactionRequest; use App\Http\Requests\BankTransaction\CreateBankTransactionRequest; @@ -92,13 +93,13 @@ class BankTransactionController extends BaseController * @OA\JsonContent(ref="#/components/schemas/Error"), * ), * ) - * @param Request $request + * @param BankTransactionFilters $filter * @return Response|mixed */ - public function index(Request $request) + public function index(BankTransactionFilters $filters) { - $bank_transactions = BankTransaction::query()->company(); + $bank_transactions = BankTransaction::filter($filters); return $this->listResponse($bank_transactions); diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index 2f1c439dacbd..ddbb5e5b57c6 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -11,11 +11,13 @@ namespace App\Models; +use App\Models\Filterable; use Illuminate\Database\Eloquent\SoftDeletes; class BankIntegration extends BaseModel { use SoftDeletes; + use Filterable; protected $fillable = [ 'bank_account_name', diff --git a/app/Models/BankTransaction.php b/app/Models/BankTransaction.php index ece2263542df..45ff86ecd2f8 100644 --- a/app/Models/BankTransaction.php +++ b/app/Models/BankTransaction.php @@ -11,6 +11,7 @@ namespace App\Models; +use App\Models\Filterable; use App\Models\Invoice; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; @@ -19,7 +20,8 @@ class BankTransaction extends BaseModel { use SoftDeletes; use MakesHash; - + use Filterable; + const STATUS_UNMATCHED = 1; const STATUS_MATCHED = 2; diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index 7c2378ea2580..9e0709bb7698 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -44,38 +44,6 @@ class QuoteInvitation extends BaseModel return self::class; } - // public function getSignatureDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getSentDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getViewedDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getOpenedDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - public function entityType() { return Quote::class; diff --git a/config/ninja.php b/config/ninja.php index 25d08f0da55a..cada9a6f8c66 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.37', - 'app_tag' => '5.5.37', + 'app_version' => '5.5.38', + 'app_tag' => '5.5.38', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/config/postmark.php b/config/postmark.php index 93e185ade20b..fba48117e01f 100644 --- a/config/postmark.php +++ b/config/postmark.php @@ -24,7 +24,7 @@ return [ */ 'guzzle' => [ - 'timeout' => 10, - 'connect_timeout' => 10, + 'timeout' => 120, + 'connect_timeout' => 120, ], ];