diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index b9a1a53467af..334d9e048a96 100644 --- a/app/Factory/CompanyFactory.php +++ b/app/Factory/CompanyFactory.php @@ -19,19 +19,21 @@ class CompanyFactory { use MakesHash; - public static function create(int $account_id) :Company + /** + * @param int $account_id + * @return Company + */ + public function create(int $account_id) :Company { - $company = new Company; -// $company->name = ''; + // $company->name = ''; $company->account_id = $account_id; $company->company_key = $this->createHash(); $company->settings = CompanySettings::defaults(); $company->db = config('database.default'); $company->custom_fields = (object) ['custom1' => '1', 'custom2' => '2', 'custom3'=>'3']; $company->domain = ''; - + return $company; - } -} \ No newline at end of file +} diff --git a/app/Http/Requests/Product/CreateProductRequest.php b/app/Http/Requests/Product/CreateProductRequest.php index a1080dbad078..455701769461 100644 --- a/app/Http/Requests/Product/CreateProductRequest.php +++ b/app/Http/Requests/Product/CreateProductRequest.php @@ -31,7 +31,7 @@ class CreateProductRequest extends Request { return [ 'product_key' => 'required', - ] + ]; } -} \ No newline at end of file +} diff --git a/app/Jobs/Client/StoreClient.php b/app/Jobs/Client/StoreClient.php index 9e5771e0ed8f..d47165a248d8 100644 --- a/app/Jobs/Client/StoreClient.php +++ b/app/Jobs/Client/StoreClient.php @@ -30,7 +30,8 @@ class StoreClient /** * Create a new job instance. * - * @return void + * @param array $data + * @param Client $client */ public function __construct(array $data, Client $client) @@ -43,10 +44,12 @@ class StoreClient /** * Execute the job. * - * @return void + * @param ClientRepository $client_repo + * @param ClientContactRepository $client_contact_repo + * @return Client|null */ - public function handle(ClientRepository $client_repo, ClientContactRepository $client_contact_repo) : ?Client - + public function handle(ClientRepository $client_repo, ClientContactRepository $client_contact_repo) : ?Client { + $client = $client_repo->save($this->data, $this->client); $contacts = $client_contact_repo->save($data['contacts']), $client); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 9c491703b705..2c9056efbb56 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -41,7 +41,7 @@ class Invoice extends BaseModel use MakesDates; use PresentableTrait; use MakesInvoiceValues; - + protected $presenter = 'App\Models\Presenters\InvoicePresenter'; protected $hidden = [ @@ -109,7 +109,7 @@ class Invoice extends BaseModel const STATUS_UNPAID = -2; const STATUS_REVERSED = -3; - + public function getStatusAttribute() { @@ -125,7 +125,7 @@ class Invoice extends BaseModel return $this->status_id; } - + public function company() { return $this->belongsTo(Company::class); @@ -140,7 +140,7 @@ class Invoice extends BaseModel { return $this->belongsTo(User::class ,'assigned_user_id', 'id')->withTrashed(); } - + public function invitations() { return $this->hasMany(InvoiceInvitation::class); @@ -171,9 +171,9 @@ class Invoice extends BaseModel /* ---------------- */ /** - * If True, prevents an invoice from being + * If True, prevents an invoice from being * modified once it has been marked as sent - * + * * @return boolean isLocked */ public function isLocked() : bool @@ -181,30 +181,30 @@ class Invoice extends BaseModel return $this->client->getSetting('lock_sent_invoices'); } - /** - * Determines if invoice overdue. - * - * @param float $balance The balance - * @param date. $due_date The due date - * - * @return boolean True if overdue, False otherwise. - */ - public static function isOverdue($balance, $due_date) - { - if (! $this->formatValue($balance,2) > 0 || ! $due_date) { - return false; - } - - // it isn't considered overdue until the end of the day - return strtotime($this->createClientDate(date(), $this->client->timezone()->name)) > (strtotime($due_date) + (60 * 60 * 24)); - } +// /** +// * Determines if invoice overdue. +// * +// * @param float $balance The balance +// * @param date. $due_date The due date +// * +// * @return boolean True if overdue, False otherwise. +// */ +// public static function isOverdue($balance, $due_date) +// { +// if (! $this->formatValue($balance,2) > 0 || ! $due_date) { +// return false; +// } +// +// // it isn't considered overdue until the end of the day +// return strtotime($this->createClientDate(date(), $this->client->timezone()->name)) > (strtotime($due_date) + (60 * 60 * 24)); +// } public function markViewed() :void { $this->last_viewed = Carbon::now()->format('Y-m-d H:i'); $this->save(); } - + public function isPayable() : bool { @@ -243,10 +243,10 @@ class Invoice extends BaseModel break; case Invoice::STATUS_UNPAID: return '