2022-05-11 07:25:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2022-05-11 07:25:33 +02:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Jobs\Report;
|
|
|
|
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Services\Report\ProfitLoss;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class ProfitAndLoss implements ShouldQueue
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
2022-05-11 07:25:33 +02:00
|
|
|
|
2023-08-02 12:10:42 +02:00
|
|
|
public function __construct(protected Company $company, protected array $payload)
|
2022-05-11 07:25:33 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2024-01-14 05:05:00 +01:00
|
|
|
public function handle(): void
|
2022-05-11 07:25:33 +02:00
|
|
|
{
|
|
|
|
MultiDB::setDb($this->company->db);
|
|
|
|
|
|
|
|
/*
|
|
|
|
payload variables.
|
|
|
|
|
|
|
|
start_date - Y-m-d
|
|
|
|
end_date - Y-m-d
|
2022-06-21 11:57:17 +02:00
|
|
|
date_range -
|
2022-05-11 07:25:33 +02:00
|
|
|
all
|
|
|
|
last7
|
|
|
|
last30
|
|
|
|
this_month
|
|
|
|
last_month
|
|
|
|
this_quarter
|
|
|
|
last_quarter
|
|
|
|
this_year
|
|
|
|
custom
|
|
|
|
income_billed - true = Invoiced || false = Payments
|
|
|
|
expense_billed - true = Expensed || false = Expenses marked as paid
|
|
|
|
include_tax - true tax_included || false - tax_excluded
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
$pl = new ProfitLoss($this->company, $this->payload);
|
|
|
|
|
|
|
|
$pl->build();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function failed($exception = null)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|