mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #4229 from turbo124/v5-develop
Fix for fillable fields
This commit is contained in:
commit
580cab1415
@ -37,7 +37,7 @@ class StoreProjectRequest extends Request
|
|||||||
$rules['name'] = 'required';
|
$rules['name'] = 'required';
|
||||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||||
|
|
||||||
return $rules;
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
|
@ -31,7 +31,9 @@ class UpdateProjectRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [];
|
$rules = [];
|
||||||
|
|
||||||
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
|
@ -53,11 +53,11 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
* @param $user
|
* @param $user
|
||||||
* @param $company
|
* @param $company
|
||||||
*/
|
*/
|
||||||
public function __construct($payment, $user, $company)
|
public function __construct($payment, $company)
|
||||||
{
|
{
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
|
||||||
$this->user = $user;
|
$this->user = $payment->user;
|
||||||
|
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver();
|
$this->setMailDriver();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
$mail_obj = (new EntityPaidObject($this->payment))->build();
|
$mail_obj = (new EntityPaidObject($this->payment))->build();
|
||||||
$mail_obj->from = [$this->payment->user->email, $this->payment->user->present()->name()];
|
$mail_obj->from = [$this->payment->user->email, $this->payment->user->present()->name()];
|
||||||
|
|
||||||
@ -89,9 +91,16 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
Mail::to($this->user->email)
|
Mail::to($this->user->email)
|
||||||
->send(new EntityNotificationMailer($mail_obj));
|
->send(new EntityNotificationMailer($mail_obj));
|
||||||
|
|
||||||
//catch errors
|
} catch (Swift_TransportException $e) {
|
||||||
if (count(Mail::failures()) > 0) {
|
$this->failed($e->getMessage());
|
||||||
return $this->logMailError(Mail::failures(), $this->payment->client);
|
//$this->entityEmailFailed($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count(Mail::failures()) > 0) {
|
||||||
|
$this->logMailError(Mail::failures(), $this->entity->client);
|
||||||
|
} else {
|
||||||
|
// $this->entityEmailSucceeded();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,8 @@ class PaymentNotification implements ShouldQueue
|
|||||||
if (($key = array_search('mail', $methods)) !== false) {
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
//Fire mail notification here!!!
|
EntityPaidMailer::dispatch($payment, $payment->company);
|
||||||
//This allows us better control of how we
|
|
||||||
//handle the mailer
|
|
||||||
|
|
||||||
EntityPaidMailer::dispatch($payment, $user, $payment->company);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification = new NewPaymentNotification($payment, $payment->company);
|
$notification = new NewPaymentNotification($payment, $payment->company);
|
||||||
@ -84,7 +81,6 @@ class PaymentNotification implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Google Analytics Track Revenue*/
|
/*Google Analytics Track Revenue*/
|
||||||
|
|
||||||
if (isset($payment->company->google_analytics_key)) {
|
if (isset($payment->company->google_analytics_key)) {
|
||||||
$this->trackRevenue($event);
|
$this->trackRevenue($event);
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ class Company extends BaseModel
|
|||||||
protected $presenter = CompanyPresenter::class;
|
protected $presenter = CompanyPresenter::class;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'invoice_expense_documents',
|
||||||
|
'invoice_task_documents',
|
||||||
'show_tasks_table',
|
'show_tasks_table',
|
||||||
'mark_expenses_invoiceable',
|
'mark_expenses_invoiceable',
|
||||||
'mark_expenses_paid',
|
'mark_expenses_paid',
|
||||||
|
@ -37,6 +37,7 @@ class Project extends BaseModel
|
|||||||
'custom_value2',
|
'custom_value2',
|
||||||
'custom_value3',
|
'custom_value3',
|
||||||
'custom_value4',
|
'custom_value4',
|
||||||
|
'assigned_user_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getEntityType()
|
public function getEntityType()
|
||||||
|
@ -15,6 +15,7 @@ use App\Models\Filterable;
|
|||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class Task extends BaseModel
|
class Task extends BaseModel
|
||||||
{
|
{
|
||||||
@ -37,6 +38,7 @@ class Task extends BaseModel
|
|||||||
'status_id',
|
'status_id',
|
||||||
'status_sort_order',
|
'status_sort_order',
|
||||||
'invoice_documents',
|
'invoice_documents',
|
||||||
|
'rate',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $touches = [];
|
protected $touches = [];
|
||||||
@ -80,4 +82,69 @@ class Task extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Project::class);
|
return $this->belongsTo(Project::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function calcStartTime()
|
||||||
|
{
|
||||||
|
$parts = json_decode($this->time_log) ?: [];
|
||||||
|
|
||||||
|
if (count($parts)) {
|
||||||
|
return Carbon::createFromTimeStamp($parts[0][0]);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastStartTime()
|
||||||
|
{
|
||||||
|
$parts = json_decode($this->time_log) ?: [];
|
||||||
|
|
||||||
|
if (count($parts)) {
|
||||||
|
$index = count($parts) - 1;
|
||||||
|
|
||||||
|
return $parts[$index][0];
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calcDuration($start_time_cutoff = 0, $end_time_cutoff = 0)
|
||||||
|
{
|
||||||
|
$duration = 0;
|
||||||
|
$parts = json_decode($this->time_log) ?: [];
|
||||||
|
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
$start_time = $part[0];
|
||||||
|
if (count($part) == 1 || ! $part[1]) {
|
||||||
|
$end_time = time();
|
||||||
|
} else {
|
||||||
|
$end_time = $part[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($start_time_cutoff) {
|
||||||
|
$start_time = max($start_time, $start_time_cutoff);
|
||||||
|
}
|
||||||
|
if ($end_time_cutoff) {
|
||||||
|
$end_time = min($end_time, $end_time_cutoff);
|
||||||
|
}
|
||||||
|
|
||||||
|
$duration += max($end_time - $start_time, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class Vendor extends BaseModel
|
|||||||
'assigned_user_id',
|
'assigned_user_id',
|
||||||
'id_number',
|
'id_number',
|
||||||
'vat_number',
|
'vat_number',
|
||||||
'work_phone',
|
'phone',
|
||||||
'address1',
|
'address1',
|
||||||
'address2',
|
'address2',
|
||||||
'city',
|
'city',
|
||||||
|
@ -50,6 +50,11 @@ class TaskRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
|
|
||||||
$task->fill($data);
|
$task->fill($data);
|
||||||
|
|
||||||
|
if(!$task->start_time)
|
||||||
|
$task->start_time = $task->calcStartTime();
|
||||||
|
|
||||||
|
$task->duration = $task->calcDuration();
|
||||||
$task->save();
|
$task->save();
|
||||||
|
|
||||||
if (array_key_exists('documents', $data)) {
|
if (array_key_exists('documents', $data)) {
|
||||||
|
@ -113,6 +113,9 @@ class InvoiceService
|
|||||||
{
|
{
|
||||||
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment))->run();
|
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment))->run();
|
||||||
|
|
||||||
|
if((int)$this->invoice->balance == 0)
|
||||||
|
$this->invoice->next_send_date = null;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
'invoice_task_timelog' => (bool) $company->invoice_task_timelog,
|
'invoice_task_timelog' => (bool) $company->invoice_task_timelog,
|
||||||
'auto_start_tasks' => (bool) $company->auto_start_tasks,
|
'auto_start_tasks' => (bool) $company->auto_start_tasks,
|
||||||
'invoice_task_documents' => (bool) $company->invoice_task_documents,
|
'invoice_task_documents' => (bool) $company->invoice_task_documents,
|
||||||
|
'show_tasks_table' => (bool) $company->show_tasks_table,
|
||||||
'use_credits_payment' => 'always', //todo remove
|
'use_credits_payment' => 'always', //todo remove
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ class ExpenseTransformer extends EntityTransformer
|
|||||||
'public_notes' => (string) $expense->public_notes ?: '',
|
'public_notes' => (string) $expense->public_notes ?: '',
|
||||||
'transaction_reference' => (string) $expense->transaction_reference ?: '',
|
'transaction_reference' => (string) $expense->transaction_reference ?: '',
|
||||||
'transaction_id' => (string) $expense->transaction_id ?: '',
|
'transaction_id' => (string) $expense->transaction_id ?: '',
|
||||||
//'date' => $expense->date ?: '',
|
'date' => $expense->date ?: '',
|
||||||
'expense_date' => $expense->date ?: '',
|
//'expense_date' => $expense->date ?: '',
|
||||||
'number' => (string)$expense->number ?: '',
|
'number' => (string)$expense->number ?: '',
|
||||||
'payment_date' => $expense->payment_date ?: '',
|
'payment_date' => $expense->payment_date ?: '',
|
||||||
'custom_value1' => $expense->custom_value1 ?: '',
|
'custom_value1' => $expense->custom_value1 ?: '',
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class VendorsPhoneColumn extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('vendors', function ($t){
|
||||||
|
$t->renameColumn('work_phone', 'phone');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user