diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f073896995b9..348be085a873 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -50,7 +50,7 @@ jobs:
sudo rm -rf node_modules
- name: Build project # This would actually build your project, using zip for an example artifact
run: |
- zip -r ./invoiceninja.zip ./
+ zip -r ./invoiceninja.zip .* -x "../*"
- name: Get tag name
id: get_tag_name
diff --git a/VERSION.txt b/VERSION.txt
index bd96b42f4638..ed45e0a6e819 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-5.1.9
\ No newline at end of file
+5.1.10
\ No newline at end of file
diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php
index ffd9e33e0b99..082f30842f34 100644
--- a/app/Console/Commands/CreateSingleAccount.php
+++ b/app/Console/Commands/CreateSingleAccount.php
@@ -17,6 +17,7 @@ use App\Events\Invoice\InvoiceWasCreated;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceItemFactory;
use App\Helpers\Invoice\InvoiceSum;
+use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
@@ -148,6 +149,8 @@ class CreateSingleAccount extends Command
$this->createClient($company, $user);
}
+ CreateCompanyTaskStatuses::dispatchNow($company, $user);
+
for ($x = 0; $x < $this->count; $x++) {
$client = $company->clients->random();
diff --git a/app/Http/Controllers/PostMarkController.php b/app/Http/Controllers/PostMarkController.php
index 74067176b919..cb0ef144c219 100644
--- a/app/Http/Controllers/PostMarkController.php
+++ b/app/Http/Controllers/PostMarkController.php
@@ -11,6 +11,13 @@
namespace App\Http\Controllers;
+use App\Jobs\Util\SystemLogger;
+use App\Libraries\MultiDB;
+use App\Models\CreditInvitation;
+use App\Models\InvoiceInvitation;
+use App\Models\QuoteInvitation;
+use App\Models\RecurringInvoiceInvitation;
+use App\Models\SystemLog;
use Illuminate\Http\Request;
/**
@@ -18,6 +25,7 @@ use Illuminate\Http\Request;
*/
class PostMarkController extends BaseController
{
+ private $invitation;
public function __construct()
{
@@ -64,14 +72,40 @@ class PostMarkController extends BaseController
if($request->header('X-API-SECURITY') && $request->header('X-API-SECURITY') == config('postmark.secret'))
{
+ nlog($request->all());
+
+ MultiDB::findAndSetDbByCompanyKey($request->input('Tag'));
+
+ $this->invitation = $this->discoverInvitation($request->input('MessageID'));
+
+ if($this->invitation){
+ $this->invitation->email_error = $request->input('Details');
+ $this->invitation->save();
+ }
+ else
+ return response()->json(['message' => 'Message not found']);
+
+ switch ($request->input('RecordType'))
+ {
+ case 'Delivery':
+ return $this->processDelivery($request);
+ case 'Bounce':
+ return $this->processBounce($request);
+ case 'SpamComplaint':
+ return $this->processSpamComplaint($request);
+ default:
+ # code...
+ break;
+ }
+
+ return response()->json(['message' => 'Success'], 200);
+
}
+ return response()->json(['message' => 'Unauthorized'], 403);
+
}
-
-
-
-
// {
// "RecordType": "Delivery",
// "ServerID": 23,
@@ -88,7 +122,7 @@ class PostMarkController extends BaseController
// }
private function processDelivery($request)
{
-
+ SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_DELIVERY, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client);
}
// {
@@ -119,7 +153,7 @@ class PostMarkController extends BaseController
private function processBounce($request)
{
-
+ SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client);
}
// {
@@ -149,8 +183,22 @@ class PostMarkController extends BaseController
// }
private function processSpamComplaint($request)
{
-
+ SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client);
}
+ private function discoverInvitation($message_id)
+ {
+ $invitation = false;
+ if($invitation = InvoiceInvitation::whereRaw('BINARY `message_id`= ?', [$message_id])->first())
+ return $invitation;
+ elseif($invitation = QuoteInvitation::whereRaw('BINARY `message_id`= ?', [$message_id])->first())
+ return $invitation;
+ elseif($invitation = RecurringInvoiceInvitation::whereRaw('BINARY `message_id`= ?', [$message_id])->first())
+ return $invitation;
+ elseif($invitation = CreditInvitation::whereRaw('BINARY `message_id`= ?', [$message_id])->first())
+ return $invitation;
+ else
+ return $invitation;
+ }
}
diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php
index bc0cdc725f58..e226751c8078 100644
--- a/app/Http/Controllers/SetupController.php
+++ b/app/Http/Controllers/SetupController.php
@@ -32,6 +32,7 @@ use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\File;
/**
* Class SetupController.
@@ -44,9 +45,12 @@ class SetupController extends Controller
{
$check = SystemHealth::check(false);
- if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) {
+ if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first())
return redirect('/');
- }
+
+ // not sure if we really need this.
+ // if(File::exists(base_path('.env')))
+ // abort(400, '.env file already exists, delete file to start Setup again.');
return view('setup.index', ['check' => $check]);
}
diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php
index d5a3bee52c5d..076b3c346929 100644
--- a/app/Http/Controllers/TaskController.php
+++ b/app/Http/Controllers/TaskController.php
@@ -274,8 +274,13 @@ class TaskController extends BaseController
return $request->disallowUpdate();
}
+ $old_task = json_decode(json_encode($task));
+
$task = $this->task_repo->save($request->all(), $task);
+ if($task->status_order != $old_task->status_order)
+ $this->task_repo->sortStatuses($old_task, $task);
+
event(new TaskWasUpdated($task, $task->company, Ninja::eventVars()));
return $this->itemResponse($task->fresh());
diff --git a/app/Http/Controllers/TwoFactorController.php b/app/Http/Controllers/TwoFactorController.php
index d3c9097bd471..2fddbe371491 100644
--- a/app/Http/Controllers/TwoFactorController.php
+++ b/app/Http/Controllers/TwoFactorController.php
@@ -31,7 +31,7 @@ class TwoFactorController extends BaseController
$secret = $google2fa->generateSecretKey();
$qr_code = $google2fa->getQRCodeGoogleUrl(
- config('ninja.app_name')
+ config('ninja.app_name'),
$user->email,
$secret
);
diff --git a/app/Http/Middleware/PasswordProtection.php b/app/Http/Middleware/PasswordProtection.php
index 6e2920fb79d7..c22c1181df1e 100644
--- a/app/Http/Middleware/PasswordProtection.php
+++ b/app/Http/Middleware/PasswordProtection.php
@@ -11,6 +11,8 @@
namespace App\Http\Middleware;
+use App\Libraries\MultiDB;
+use App\Libraries\OAuth\Providers\Google;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
@@ -34,16 +36,52 @@ class PasswordProtection
'errors' => new stdClass,
];
- if ($request->header('X-API-PASSWORD')) {
+ if($request->header('X-API-OAUTH-PASSWORD')){
+
+ //user is attempting to reauth with OAuth - check the token value
+ //todo expand this to include all OAuth providers
+ $user = false;
+ $google = new Google();
+ $user = $google->getTokenResponse(request()->header('X-API-OAUTH-PASSWORD'));
+
+ if (is_array($user)) {
+
+ $query = [
+ 'oauth_user_id' => $google->harvestSubField($user),
+ 'oauth_provider_id'=> 'google',
+ ];
+
+ /* Cannot allow duplicates! */
+ if ($existing_user = MultiDB::hasUser($query)) {
+ return $next($request);
+ }
+ }
+
+ $error = [
+ 'message' => 'Access denied',
+ 'errors' => new stdClass,
+ ];
+
+ return response()->json($error, 412);
+
+
+ }elseif ($request->header('X-API-PASSWORD')) {
+
+ //user is attempting to reauth with regular password
+ //
if (! Hash::check($request->header('X-API-PASSWORD'), auth()->user()->password)) {
return response()->json($error, 403);
}
+
} elseif (Cache::get(auth()->user()->email.'_logged_in')) {
+
Cache::pull(auth()->user()->email.'_logged_in');
Cache::add(auth()->user()->email.'_logged_in', Str::random(64), now()->addMinutes(30));
return $next($request);
+
} else {
+
$error = [
'message' => 'Access denied',
'errors' => new stdClass,
diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php
index d145fdc8e2a1..882604331bab 100644
--- a/app/Jobs/Account/CreateAccount.php
+++ b/app/Jobs/Account/CreateAccount.php
@@ -23,6 +23,7 @@ use App\Jobs\Mail\NinjaMailerObject;
use App\Jobs\User\CreateUser;
use App\Jobs\Util\VersionCheck;
use App\Mail\Admin\AccountCreatedObject;
+use App\Mail\Admin\VerifyUserObject;
use App\Models\Account;
use App\Notifications\Ninja\NewAccountCreated;
use App\Utils\Ninja;
@@ -95,12 +96,21 @@ class CreateAccount
//todo implement SLACK notifications
//$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
+ // $nmo = new NinjaMailerObject;
+ // $nmo->mailable = new NinjaMailer((new AccountCreatedObject($spaa9f78, $sp035a66))->build());
+ // $nmo->company = $sp035a66;
+ // $nmo->to_user = $spaa9f78;
+ // $nmo->settings = $sp035a66->settings;
+
$nmo = new NinjaMailerObject;
- $nmo->mailable = new NinjaMailer((new AccountCreatedObject($spaa9f78, $sp035a66))->build());
+ $nmo->mailable = new NinjaMailer((new VerifyUserObject($spaa9f78, $sp035a66))->build());
$nmo->company = $sp035a66;
$nmo->to_user = $spaa9f78;
$nmo->settings = $sp035a66->settings;
+ NinjaMailerJob::dispatch($nmo);
+
+
NinjaMailerJob::dispatchNow($nmo);
VersionCheck::dispatchNow();
diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php
index a33eb48ca8eb..9405750032fb 100644
--- a/app/Jobs/Mail/NinjaMailerJob.php
+++ b/app/Jobs/Mail/NinjaMailerJob.php
@@ -72,6 +72,17 @@ class NinjaMailerJob implements ShouldQueue
/* Set the email driver */
$this->setMailDriver();
+ if (strlen($this->nmo->settings->reply_to_email) > 1) {
+
+ $reply_to_name = strlen($this->nmo->settings->reply_to_name) > 1 ? $this->nmo->settings->reply_to_name : $this->nmo->company->present()->name();
+ $this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name);
+
+ }
+
+ if (strlen($this->nmo->settings->bcc_email) > 1)
+ $this->nmo->mailable->bcc($this->nmo->settings->bcc_email, $this->nmo->settings->bcc_email);
+
+
//send email
try {
nlog("trying to send");
diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php
index 62c7ed921763..8bf643e3be8a 100644
--- a/app/Mail/TemplateEmail.php
+++ b/app/Mail/TemplateEmail.php
@@ -53,10 +53,7 @@ class TemplateEmail extends Mailable
$company = $this->client->company;
$this->from(config('mail.from.address'), $this->company->present()->name());
-
- if (strlen($settings->reply_to_email) > 1)
- $this->replyTo($settings->reply_to_email, $settings->reply_to_email);
-
+
if (strlen($settings->bcc_email) > 1)
$this->bcc($settings->bcc_email, $settings->bcc_email);
diff --git a/app/Models/Project.php b/app/Models/Project.php
index 3e69a6a60252..42b84cbbaa29 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -71,11 +71,10 @@ class Project extends BaseModel
{
return $this->belongsTo(User::class)->withTrashed();
}
- // /**
- // * @return \Illuminate\Database\Eloquent\Relations\HasMany
- // */
- // public function tasks()
- // {
- // return $this->hasMany('App\Models\Task');
- // }
+
+ public function tasks()
+ {
+ return $this->hasMany(Task::class);
+ }
+
}
diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php
index 335c530a271a..816846ba255f 100644
--- a/app/Models/SystemLog.php
+++ b/app/Models/SystemLog.php
@@ -47,6 +47,9 @@ class SystemLog extends Model
const EVENT_MAIL_SEND = 30;
const EVENT_MAIL_RETRY_QUEUE = 31; //we use this to queue emails that are spooled and not sent due to the email queue quota being exceeded.
+ const EVENT_MAIL_BOUNCED = 32;
+ const EVENT_MAIL_SPAM_COMPLAINT = 33;
+ const EVENT_MAIL_DELIVERY = 34;
const EVENT_WEBHOOK_RESPONSE = 40;
const EVENT_PDF_RESPONSE = 50;
diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php
index bd5ae90de0e8..778b695763ae 100644
--- a/app/Repositories/TaskRepository.php
+++ b/app/Repositories/TaskRepository.php
@@ -33,6 +33,7 @@ class TaskRepository extends BaseRepository
*/
public function save(array $data, Task $task) : ?Task
{
+
$task->fill($data);
$task->save();
@@ -99,5 +100,36 @@ class TaskRepository extends BaseRepository
$task,
TaskFactory::create(auth()->user()->company()->id, auth()->user()->id)
);
+
+ }
+
+ /**
+ * Sorts the task status order IF the old status has changed between requests
+ *
+ * @param stdCLass $old_task The old task object
+ * @param Task $new_task The new Task model
+ * @return void
+ */
+ public function sortStatuses($old_task, $new_task)
+ {
+
+ if(!$new_task->project()->exists())
+ return;
+
+ $index = $new_task->status_order;
+
+ $tasks = $new_task->project->tasks->reject(function ($task)use($new_task){
+ return $task->id == $new_task->id;
+ });
+
+ $sorted_tasks = $tasks->filter(function($task, $key)use($index){
+ return $key < $index;
+ })->push($new_task)->merge($tasks->filter(function($task, $key)use($index){
+ return $key >= $index;
+ }))->each(function ($item,$key){
+ $item->status_order = $key;
+ $item->save();
+ });
+
}
}
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 49878080f8c2..742a4769576c 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -77,6 +77,7 @@ class AccountTransformer extends EntityTransformer
'debug_enabled' => (bool) config('ninja.debug_enabled'),
'is_docker' => (bool) config('ninja.is_docker'),
'is_scheduler_running' => (bool) $account->is_scheduler_running,
+ 'default_company_id' => (string) $this->encodePrimaryKey($account->default_company_id),
];
}
diff --git a/app/Utils/Traits/MakesInvoiceHtml.php b/app/Utils/Traits/MakesInvoiceHtml.php
index 43d48582755f..d1dfdf5b7de1 100644
--- a/app/Utils/Traits/MakesInvoiceHtml.php
+++ b/app/Utils/Traits/MakesInvoiceHtml.php
@@ -25,56 +25,6 @@ use Throwable;
*/
trait MakesInvoiceHtml
{
- /**
- * Generate the HTML invoice parsing variables
- * and generating the final invoice HTML.
- *
- * @param $labels
- * @param $values
- * @param $section
- * @return string The invoice string in HTML format
- * @deprecated replaced by generateEntityHtml
- *
- */
- // public function generateEntityHtml(Designer $designer, $entity, $contact = null) :string
- // {
- // $entity->load('client');
-
- // $client = $entity->client;
-
- // App::setLocale($client->preferredLocale());
-
- // $values_and_labels = $entity->buildLabelsAndValues($contact);
-
- // $designer->build();
-
- // $data = [];
- // $data['entity'] = $entity;
- // $data['lang'] = $client->preferredLocale();
- // $data['includes'] = $designer->getIncludes();
- // $data['header'] = $designer->getHeader();
- // $data['body'] = $designer->getBody();
- // $data['footer'] = $designer->getFooter();
-
- // $html = view('pdf.stub', $data)->render();
-
- // $html = $this->parseLabelsAndValues($values_and_labels['labels'], $values_and_labels['values'], $html);
-
- // return $html;
- // }
-
- // public function generateEmailEntityHtml($entity, $content, $contact = null) :string
- // {
- // $entity->load('client');
-
- // $client = $entity->client;
-
- // App::setLocale($client->preferredLocale());
-
- // $data = $entity->buildLabelsAndValues($contact);
-
- // return $this->parseLabelsAndValues($data['labels'], $data['values'], $content);
- // }
private function parseLabelsAndValues($labels, $values, $section) :string
{
diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php
index 76fae1e5e15a..c2c1739062f2 100644
--- a/app/Utils/Traits/MakesInvoiceValues.php
+++ b/app/Utils/Traits/MakesInvoiceValues.php
@@ -116,301 +116,6 @@ trait MakesInvoiceValues
return $data;
}
- // public function buildLabelsAndValues($contact)
- // {
- // $data = [];
-
- // $values = $this->makeLabelsAndValues($contact);
-
- // foreach ($values as $key => $value) {
- // $data['values'][$key] = $value['value'];
- // $data['labels'][$key.'_label'] = $value['label'];
- // }
-
- // return $data;
- // }
-
- // private function makeLabelsAndValues($contact = null) :array
- // {
- // if (! $this->client->currency() || ! $this->client) {
- // throw new \Exception(debug_backtrace()[1]['function'], 1);
- // exit;
- // }
-
- // $settings = $this->client->getMergedSettings();
-
- // if (! $contact) {
- // $contact = $this->client->primary_contact()->first();
- // }
-
- // $calc = $this->calc();
- // $invitation = $this->invitations->where('client_contact_id', $contact->id)->first();
-
- // $data = [];
- // $data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];
- // $data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
- // $data['$to'] = ['value' => '', 'label' => ctrans('texts.to')];
- // $data['$total_tax_labels'] = ['value' => $this->totalTaxLabels(), 'label' => ctrans('texts.taxes')];
- // $data['$total_tax_values'] = ['value' => $this->totalTaxValues(), 'label' => ctrans('texts.taxes')];
- // $data['$line_tax_labels'] = ['value' => $this->lineTaxLabels(), 'label' => ctrans('texts.taxes')];
- // $data['$line_tax_values'] = ['value' => $this->lineTaxValues(), 'label' => ctrans('texts.taxes')];
- // $data['$date'] = ['value' => $this->date ?: ' ', 'label' => ctrans('texts.date')];
- // //$data['$invoice_date'] = ['value' => $this->date ?: ' ', 'label' => ctrans('texts.invoice_date')];
- // $data['$invoice.date'] = &$data['$date'];
- // $data['$invoice.due_date'] = ['value' => $this->due_date ?: ' ', 'label' => ctrans('texts.due_date')];
- // $data['$due_date'] = &$data['$invoice.due_date'];
- // $data['$invoice.number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
- // $data['$invoice.po_number'] = ['value' => $this->po_number ?: ' ', 'label' => ctrans('texts.po_number')];
- // $data['$line_taxes'] = ['value' => $this->makeLineTaxes() ?: ' ', 'label' => ctrans('texts.taxes')];
- // $data['$invoice.line_taxes'] = &$data['$line_taxes'];
- // $data['$total_taxes'] = ['value' => $this->makeTotalTaxes() ?: ' ', 'label' => ctrans('texts.taxes')];
- // $data['$invoice.total_taxes'] = &$data['$total_taxes'];
-
- // if ($this instanceof Invoice) {
- // $data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.invoice')];
- // $data['$number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
- // $data['$entity.terms'] = ['value' => $this->terms ?: ' ', 'label' => ctrans('texts.invoice_terms')];
- // $data['$terms'] = &$data['$entity.terms'];
-
- // if($invitation)
- // $data['$view_link'] = ['value' => ''.ctrans('texts.view_invoice').'', 'label' => ctrans('texts.view_invoice')];
- // // $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
- // }
-
- // if ($this instanceof Quote) {
- // $data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.quote')];
- // $data['$number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.quote_number')];
- // $data['$entity.terms'] = ['value' => $this->terms ?: ' ', 'label' => ctrans('texts.quote_terms')];
- // $data['$terms'] = &$data['$entity.terms'];
-
- // if($invitation)
- // $data['$view_link'] = ['value' => ''.ctrans('texts.view_quote').'', 'label' => ctrans('texts.view_quote')];
- // // $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_quote')];
- // }
-
- // if ($this instanceof Credit) {
- // $data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.credit')];
- // $data['$number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.credit_number')];
- // $data['$entity.terms'] = ['value' => $this->terms ?: ' ', 'label' => ctrans('texts.credit_terms')];
- // $data['$terms'] = &$data['$entity.terms'];
-
- // if($invitation)
- // $data['$view_link'] = ['value' => ''.ctrans('texts.view_credit').'', 'label' => ctrans('texts.view_credit')];
- // // $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_credit')];
- // }
-
- // $data['$entity_number'] = &$data['$number'];
-
- // $data['$invoice.discount'] = ['value' => Number::formatMoney($calc->getTotalDiscount(), $this->client) ?: ' ', 'label' => ctrans('texts.discount')];
- // $data['$discount'] = &$data['$invoice.discount'];
- // $data['$subtotal'] = ['value' => Number::formatMoney($calc->getSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
- // $data['$invoice.subtotal'] = &$data['$subtotal'];
- // $data['$invoice.balance_due'] = ['value' => Number::formatMoney($this->balance, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
- // $data['$quote.balance_due'] = &$data['$invoice.balance_due'];
- // $data['$balance_due'] = &$data['$invoice.balance_due'];
- // $data['$invoice.partial_due'] = ['value' => Number::formatMoney($this->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
- // $data['$total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.total')];
- // $data['$amount'] = &$data['$total'];
- // $data['$quote.total'] = &$data['$total'];
- // $data['$invoice.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.invoice_total')];
- // $data['$invoice.amount'] = &$data['$total'];
- // $data['$quote.amount'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.quote_total')];
- // $data['$credit.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_total')];
- // $data['$credit.number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.credit_number')];
- // $data['$credit.total'] = &$data['$credit.total'];
- // $data['$credit.po_number'] = &$data['$invoice.po_number'];
- // $data['$credit.date'] = ['value' => $this->date, 'label' => ctrans('texts.credit_date')];
- // $data['$balance'] = ['value' => Number::formatMoney($calc->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.balance')];
- // $data['$credit.balance'] = &$data['$balance'];
-
- // $data['$invoice.balance'] = &$data['$balance'];
- // $data['$taxes'] = ['value' => Number::formatMoney($calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')];
- // $data['$invoice.taxes'] = &$data['$taxes'];
-
- // $data['$invoice.custom1'] = ['value' => $this->custom_value1 ?: ' ', 'label' => $this->makeCustomField('invoice1')];
- // $data['$invoice.custom2'] = ['value' => $this->custom_value2 ?: ' ', 'label' => $this->makeCustomField('invoice2')];
- // $data['$invoice.custom3'] = ['value' => $this->custom_value3 ?: ' ', 'label' => $this->makeCustomField('invoice3')];
- // $data['$invoice.custom4'] = ['value' => $this->custom_value4 ?: ' ', 'label' => $this->makeCustomField('invoice4')];
- // $data['$invoice.public_notes'] = ['value' => $this->public_notes ?: ' ', 'label' => ctrans('texts.public_notes')];
- // $data['$entity.public_notes'] = &$data['$invoice.public_notes'];
-
- // // $data['$your_invoice'] = ;
- // // $data['$quote'] = ;
- // // $data['$your_quote'] = ;
- // //
- // $data['$quote.date'] = ['value' => $this->date ?: ' ', 'label' => ctrans('texts.quote_date')];
- // $data['$quote.number'] = ['value' => $this->number ?: ' ', 'label' => ctrans('texts.quote_number')];
- // $data['$quote.po_number'] = &$data['$invoice.po_number'];
- // $data['$quote.quote_number'] = &$data['$quote.number'];
- // $data['$quote_no'] = &$data['$quote.number'];
- // $data['$quote.quote_no'] = &$data['$quote.number'];
- // $data['$quote.valid_until'] = ['value' => $this->due_date, 'label' => ctrans('texts.valid_until')];
- // $data['$credit_amount'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_amount')];
- // $data['$credit_balance'] = ['value' => Number::formatMoney($this->balance, $this->client) ?: ' ', 'label' => ctrans('texts.credit_balance')];
-
- // $data['$credit_number'] = &$data['$number'];
- // $data['$credit_no'] = &$data['$number'];
- // $data['$credit.credit_no'] = &$data['$number'];
-
- // // $data['$invoice_issued_to'] = ;
- // // $data['$quote_issued_to'] = ;
- // // $data['$rate'] = ;
- // // $data['$hours'] = ;
- // // $data['$from'] = ;
- // // $data['$to'] = ;
- // // $data['$invoice_to'] = ;
- // // $data['$quote_to'] = ;
- // // $data['$details'] = ;
- // $data['$invoice_no'] = &$data['$number'];
- // $data['$invoice.invoice_no'] = &$data['$number'];
- // $data['$client1'] = ['value' => $this->client->custom_value1 ?: ' ', 'label' => $this->makeCustomField('client1')];
- // $data['$client2'] = ['value' => $this->client->custom_value2 ?: ' ', 'label' => $this->makeCustomField('client2')];
- // $data['$client3'] = ['value' => $this->client->custom_value3 ?: ' ', 'label' => $this->makeCustomField('client3')];
- // $data['$client4'] = ['value' => $this->client->custom_value4 ?: ' ', 'label' => $this->makeCustomField('client4')];
- // $data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')];
- // $data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')];
- // $data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')];
- // $data['$vat_number'] = ['value' => $this->client->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
- // $data['$website'] = ['value' => $this->client->present()->website() ?: ' ', 'label' => ctrans('texts.website')];
- // $data['$phone'] = ['value' => $this->client->present()->phone() ?: ' ', 'label' => ctrans('texts.phone')];
- // $data['$country'] = ['value' => isset($this->client->country->name) ? $this->client->country->name : 'No Country Set', 'label' => ctrans('texts.country')];
- // $data['$email'] = ['value' => isset($contact) ? $contact->email : 'no contact email on record', 'label' => ctrans('texts.email')];
- // $data['$client_name'] = ['value' => $this->present()->clientName() ?: ' ', 'label' => ctrans('texts.client_name')];
- // $data['$client.name'] = &$data['$client_name'];
- // $data['$client.balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
- // $data['$outstanding'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
-
- // $data['$client_balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
-
- // $data['$paid_to_date'] = ['value' => Number::formatMoney($this->client->paid_to_date, $this->client), 'label' => ctrans('texts.paid_to_date')];
-
- // $data['$client.address1'] = &$data['$address1'];
- // $data['$client.address2'] = &$data['$address2'];
- // $data['$client_address'] = ['value' => $this->present()->address() ?: ' ', 'label' => ctrans('texts.address')];
- // $data['$client.address'] = &$data['$client_address'];
- // $data['$client.id_number'] = &$data['$id_number'];
- // $data['$client.vat_number'] = &$data['$vat_number'];
- // $data['$client.website'] = &$data['$website'];
- // $data['$client.phone'] = &$data['$phone'];
- // $data['$city_state_postal'] = ['value' => $this->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')];
- // $data['$client.city_state_postal'] = &$data['$city_state_postal'];
- // $data['$postal_city_state'] = ['value' => $this->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')];
- // $data['$client.postal_city_state'] = &$data['$postal_city_state'];
- // $data['$client.country'] = &$data['$country'];
- // $data['$client.email'] = &$data['$email'];
-
- // $data['$contact.full_name'] = ['value' => $contact->present()->name(), 'label' => ctrans('texts.name')];
- // $data['$contact.email'] = ['value' => $contact->email, 'label' => ctrans('texts.email')];
- // $data['$contact.phone'] = ['value' => $contact->phone, 'label' => ctrans('texts.phone')];
-
- // $data['$contact.name'] = ['value' => isset($contact) ? $contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')];
- // $data['$contact.first_name'] = ['value' => isset($contact) ? $contact->first_name : '', 'label' => ctrans('texts.first_name')];
- // $data['$contact.last_name'] = ['value' => isset($contact) ? $contact->last_name : '', 'label' => ctrans('texts.last_name')];
- // $data['$contact.custom1'] = ['value' => isset($contact) ? $contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')];
- // $data['$contact.custom2'] = ['value' => isset($contact) ? $contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')];
- // $data['$contact.custom3'] = ['value' => isset($contact) ? $contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')];
- // $data['$contact.custom4'] = ['value' => isset($contact) ? $contact->custom_value4 : ' ', 'label' => $this->makeCustomField('contact1')];
-
- // $data['$company.city_state_postal'] = ['value' => $this->company->present()->cityStateZip($settings->city, $settings->state, $settings->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')];
- // $data['$company.postal_city_state'] = ['value' => $this->company->present()->cityStateZip($settings->city, $settings->state, $settings->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')];
- // $data['$company.name'] = ['value' => $this->company->present()->name() ?: ' ', 'label' => ctrans('texts.company_name')];
- // $data['$company.address1'] = ['value' => $settings->address1 ?: ' ', 'label' => ctrans('texts.address1')];
- // $data['$company.address2'] = ['value' => $settings->address2 ?: ' ', 'label' => ctrans('texts.address2')];
- // $data['$company.city'] = ['value' => $settings->city ?: ' ', 'label' => ctrans('texts.city')];
- // $data['$company.state'] = ['value' => $settings->state ?: ' ', 'label' => ctrans('texts.state')];
- // $data['$company.postal_code'] = ['value' => $settings->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')];
- // $data['$company.country'] = ['value' => Country::find($settings->country_id)->first()->name ?: ' ', 'label' => ctrans('texts.country')];
- // $data['$company.phone'] = ['value' => $settings->phone ?: ' ', 'label' => ctrans('texts.phone')];
- // $data['$company.email'] = ['value' => $settings->email ?: ' ', 'label' => ctrans('texts.email')];
- // $data['$company.vat_number'] = ['value' => $settings->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
- // $data['$company.id_number'] = ['value' => $settings->id_number ?: ' ', 'label' => ctrans('texts.id_number')];
- // $data['$company.website'] = ['value' => $settings->website ?: ' ', 'label' => ctrans('texts.website')];
- // $data['$company.address'] = ['value' => $this->company->present()->address($settings) ?: ' ', 'label' => ctrans('texts.address')];
-
- // $logo = $this->company->present()->logo($settings);
-
- // $data['$company.logo'] = ['value' => "
" ?: ' ', 'label' => ctrans('texts.logo')];
- // $data['$company_logo'] = &$data['$company.logo'];
- // $data['$company1'] = ['value' => $settings->custom_value1 ?: ' ', 'label' => $this->makeCustomField('company1')];
- // $data['$company2'] = ['value' => $settings->custom_value2 ?: ' ', 'label' => $this->makeCustomField('company2')];
- // $data['$company3'] = ['value' => $settings->custom_value3 ?: ' ', 'label' => $this->makeCustomField('company3')];
- // $data['$company4'] = ['value' => $settings->custom_value4 ?: ' ', 'label' => $this->makeCustomField('company4')];
-
- // $data['$custom_surcharge1'] = ['value' => $this->custom_surcharge1, 'label' => $this->makeCustomField('custom_surcharge1')];
- // $data['$custom_surcharge2'] = ['value' => $this->custom_surcharge2, 'label' => $this->makeCustomField('custom_surcharge2')];
- // $data['$custom_surcharge3'] = ['value' => $this->custom_surcharge3, 'label' => $this->makeCustomField('custom_surcharge3')];
- // $data['$custom_surcharge4'] = ['value' => $this->custom_surcharge4, 'label' => $this->makeCustomField('custom_surcharge4')];
-
- // $data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')];
- // $data['$product.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
- // $data['$product.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')];
- // $data['$product.notes'] = ['value' => '', 'label' => ctrans('texts.notes')];
- // $data['$product.cost'] = ['value' => '', 'label' => ctrans('texts.cost')];
- // $data['$product.quantity'] = ['value' => '', 'label' => ctrans('texts.quantity')];
- // $data['$product.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$product.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
-
- // $data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')];
- // $data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
- // $data['$task.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')];
- // $data['$task.notes'] = ['value' => '', 'label' => ctrans('texts.notes')];
- // $data['$task.cost'] = ['value' => '', 'label' => ctrans('texts.cost')];
- // $data['$task.quantity'] = ['value' => '', 'label' => ctrans('texts.quantity')];
- // $data['$task.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$task.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$task.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$task.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
- // $data['$task.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
- // //$data['$contact.signature']
-
- // // $data['custom_label1'] = ['value' => '', 'label' => ctrans('texts.')];
- // // $data['custom_label2'] = ['value' => '', 'label' => ctrans('texts.')];
- // // $data['custom_label3'] = ['value' => '', 'label' => ctrans('texts.')];
- // // $data['custom_label4'] = ['value' => '', 'label' => ctrans('texts.')];
- // //$data['$blank'] = ;
- // //$data['$surcharge'] = ;
- // /*
- // $data['$tax_invoice'] =
- // $data['$tax_quote'] =
- // $data['$statement'] = ;
- // $data['$statement_date'] = ;
- // $data['$your_statement'] = ;
- // $data['$statement_issued_to'] = ;
- // $data['$statement_to'] = ;
- // $data['$credit_note'] = ;
- // $data['$credit_date'] = ;
- // $data['$credit_issued_to'] = ;
- // $data['$credit_to'] = ;
- // $data['$your_credit'] = ;
- // $data['$phone'] = ;
-
- // $data['$outstanding'] = ;
- // $data['$invoice_due_date'] = ;
- // $data['$quote_due_date'] = ;
- // $data['$service'] = ;
- // $data['$product_key'] = ;
- // $data['$unit_cost'] = ;
- // $data['$custom_value1'] = ;
- // $data['$custom_value2'] = ;
- // $data['$delivery_note'] = ;
- // $data['$date'] = ;
- // $data['$method'] = ;
- // $data['$payment_date'] = ;
- // $data['$reference'] = ;
- // $data['$amount'] = ;
- // $data['$amount_paid'] =;
- // */
-
- // $arrKeysLength = array_map('strlen', array_keys($data));
- // array_multisort($arrKeysLength, SORT_DESC, $data);
-
- // return $data;
- // }
-
/**
* V2 of building a table header for PDFs.
* @param array $columns The array (or string of column headers)
diff --git a/config/ninja.php b/config/ninja.php
index 74edc1485493..e2e6cf03b951 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''),
- 'app_version' => '5.1.9',
+ 'app_version' => '5.1.10',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),
diff --git a/routes/api.php b/routes/api.php
index 48fdd6c4e244..5ef05ac22167 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -177,6 +177,6 @@ Route::match(['get', 'post'], 'payment_webhook/{company_key}/{company_gateway_id
->middleware(['guest', 'api_db'])
->name('payment_webhook');
-Route::post('postmark_webhook', 'PostMarkController@webhook');
+Route::post('api/v1/postmark_webhook', 'PostMarkController@webhook');
Route::fallback('BaseController@notFound');
diff --git a/tests/Feature/TaskStatusSortOnUpdateTest.php b/tests/Feature/TaskStatusSortOnUpdateTest.php
new file mode 100644
index 000000000000..b5c2732965a8
--- /dev/null
+++ b/tests/Feature/TaskStatusSortOnUpdateTest.php
@@ -0,0 +1,94 @@
+makeTestData();
+
+ $this->withoutMiddleware(
+ ThrottleRequests::class
+ );
+ }
+
+ public function testTasksSort()
+ {
+
+ $project = Project::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'name' => 'Test Project',
+ ]);
+
+ for($x=0; $x<10; $x++)
+ {
+ $task = Task::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'project_id' => $project->id
+ ]);
+
+ $task->status_id = TaskStatus::where('company_id', $this->company->id)->first()->id;
+ $task->save();
+ }
+
+
+ $this->assertTrue($task->project()->exists());
+ $this->assertEquals($task->project->tasks->count(), 10);
+
+ $task->status_order = 1;
+
+ $response = $this->withHeaders([
+ 'X-API-SECRET' => config('ninja.api_secret'),
+ 'X-API-TOKEN' => $this->token,
+ ])->put('/api/v1/tasks/'.$this->encodePrimaryKey($task->id), $task->toArray());
+
+ $response->assertStatus(200);
+
+ $this->assertEquals($task->fresh()->status_order, 1);
+
+
+ $task->status_order = 10;
+
+ $response = $this->withHeaders([
+ 'X-API-SECRET' => config('ninja.api_secret'),
+ 'X-API-TOKEN' => $this->token,
+ ])->put('/api/v1/tasks/'.$this->encodePrimaryKey($task->id), $task->toArray());
+
+ $response->assertStatus(200);
+
+ nlog($task->fresh()->project->tasks->toArray());
+
+ $this->assertEquals($task->fresh()->status_order, 9);
+
+ }
+
+}
diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php
index 1d8952dac4ad..016fd2960794 100644
--- a/tests/MockAccountData.php
+++ b/tests/MockAccountData.php
@@ -20,6 +20,7 @@ use App\Factory\InvoiceInvitationFactory;
use App\Factory\InvoiceItemFactory;
use App\Factory\InvoiceToRecurringInvoiceFactory;
use App\Helpers\Invoice\InvoiceSum;
+use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
@@ -201,6 +202,8 @@ trait MockAccountData
$user_id = $user->id;
$this->user = $user;
+ CreateCompanyTaskStatuses::dispatchNow($this->company, $this->user);
+
$this->cu = CompanyUserFactory::create($user->id, $this->company->id, $this->account->id);
$this->cu->is_owner = true;
$this->cu->is_admin = true;
@@ -286,6 +289,9 @@ trait MockAccountData
'company_id' => $this->company->id,
]);
+ $this->task->status_id = TaskStatus::where('company_id', $this->company->id)->first()->id;
+ $this->task->save();
+
$this->expense_category = ExpenseCategory::factory()->create([
'user_id' => $user_id,
'company_id' => $this->company->id,