mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for tasks
This commit is contained in:
parent
c1c8b6c14e
commit
8cf55010c6
@ -51,6 +51,10 @@ class StoreTaskRequest extends Request
|
||||
|
||||
$input = $this->decodePrimaryKeys($this->all());
|
||||
|
||||
if (array_key_exists('status_id', $input) && is_string($input['status_id'])) {
|
||||
$input['status_id'] = $this->decodePrimaryKey($input['status_id']);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Mail\Engine;
|
||||
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Number;
|
||||
|
||||
class QuoteEmailEngine extends BaseEmailEngine
|
||||
|
@ -98,9 +98,9 @@ class Task extends BaseModel
|
||||
$parts = json_decode($this->time_log) ?: [];
|
||||
|
||||
if (count($parts)) {
|
||||
return Carbon::createFromTimeStamp($parts[0][0]);
|
||||
return Carbon::createFromTimeStamp($parts[0][0])->timestamp;
|
||||
} else {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,49 @@ class TaskRepository extends BaseRepository
|
||||
{
|
||||
|
||||
$task->fill($data);
|
||||
$task->save();
|
||||
|
||||
if(!$task->start_time)
|
||||
$task->start_time = $task->calcStartTime();
|
||||
$task->start_time = $task->start_time ?: $task->calcStartTime();
|
||||
$task->number = empty($task->number) ? $this->getNextTaskNumber($task) : $task->number;
|
||||
|
||||
if (isset($data['description'])) {
|
||||
$task->description = trim($data['description']);
|
||||
}
|
||||
|
||||
if (isset($data['status_sort_order'])) {
|
||||
$task->status_sort_order = $data['status_sort_order'];
|
||||
}
|
||||
|
||||
if (isset($data['time_log'])) {
|
||||
$time_log = json_decode($data['time_log']);
|
||||
} elseif ($task->time_log) {
|
||||
$time_log = json_decode($task->time_log);
|
||||
} else {
|
||||
$time_log = [];
|
||||
}
|
||||
|
||||
array_multisort($time_log);
|
||||
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] == 'start') {
|
||||
$task->is_running = true;
|
||||
$time_log[] = [strtotime('now'), false];
|
||||
} elseif ($data['action'] == 'resume') {
|
||||
$task->is_running = true;
|
||||
$time_log[] = [strtotime('now'), false];
|
||||
} elseif ($data['action'] == 'stop' && $task->is_running) {
|
||||
$time_log[count($time_log) - 1][1] = time();
|
||||
$task->is_running = false;
|
||||
} elseif ($data['action'] == 'offline'){
|
||||
$task->is_running = $data['is_running'] ? 1 : 0;
|
||||
}
|
||||
} elseif (isset($data['is_running'])) {
|
||||
$task->is_running = $data['is_running'] ? 1 : 0;
|
||||
}
|
||||
|
||||
$task->time_log = json_encode($time_log);
|
||||
$task->duration = $task->calcDuration();
|
||||
|
||||
$task->save();
|
||||
|
||||
if (array_key_exists('documents', $data)) {
|
||||
|
@ -106,12 +106,12 @@ class AuthorizeTest extends TestCase
|
||||
$controller = new GetCustomerProfileIdsController($request);
|
||||
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
|
||||
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
|
||||
info("GetCustomerProfileId's SUCCESS: "."\n");
|
||||
info(print_r($response->getIds(), 1));
|
||||
// info("GetCustomerProfileId's SUCCESS: "."\n");
|
||||
// info(print_r($response->getIds(), 1));
|
||||
} else {
|
||||
info("GetCustomerProfileId's ERROR : Invalid response\n");
|
||||
// info("GetCustomerProfileId's ERROR : Invalid response\n");
|
||||
$errorMessages = $response->getMessages()->getMessage();
|
||||
info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
// info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
}
|
||||
|
||||
$this->assertNotNull($response);
|
||||
@ -179,14 +179,14 @@ class AuthorizeTest extends TestCase
|
||||
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
|
||||
info('Succesfully created customer profile : '.$response->getCustomerProfileId()."\n");
|
||||
$paymentProfiles = $response->getCustomerPaymentProfileIdList();
|
||||
info(print_r($paymentProfiles, 1));
|
||||
// info(print_r($paymentProfiles, 1));
|
||||
} else {
|
||||
info("ERROR : Invalid response\n");
|
||||
$errorMessages = $response->getMessages()->getMessage();
|
||||
info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
// info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
}
|
||||
|
||||
info('the new customer profile id = '.$response->getCustomerProfileId());
|
||||
// info('the new customer profile id = '.$response->getCustomerProfileId());
|
||||
|
||||
$this->assertNotNull($response);
|
||||
}
|
||||
@ -208,8 +208,8 @@ class AuthorizeTest extends TestCase
|
||||
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
|
||||
|
||||
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
|
||||
info('got profile');
|
||||
info(print_r($response->getProfile(), 1));
|
||||
// info('got profile');
|
||||
// info(print_r($response->getProfile(), 1));
|
||||
} else {
|
||||
info("ERROR : Invalid response\n");
|
||||
}
|
||||
@ -276,11 +276,11 @@ class AuthorizeTest extends TestCase
|
||||
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
|
||||
|
||||
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
|
||||
info('Create Customer Payment Profile SUCCESS: '.$response->getCustomerPaymentProfileId()."\n");
|
||||
// info('Create Customer Payment Profile SUCCESS: '.$response->getCustomerPaymentProfileId()."\n");
|
||||
} else {
|
||||
info("Create Customer Payment Profile: ERROR Invalid response\n");
|
||||
// info("Create Customer Payment Profile: ERROR Invalid response\n");
|
||||
$errorMessages = $response->getMessages()->getMessage();
|
||||
info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
// info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText()."\n");
|
||||
}
|
||||
|
||||
$this->assertNotNull($response);
|
||||
@ -354,26 +354,5 @@ class AuthorizeTest extends TestCase
|
||||
|
||||
$this->assertNotNull($tresponse);
|
||||
|
||||
/* Testing refunds - need to research more as payments are in a pending state so cannot be 'refunded'*/
|
||||
|
||||
// info("transaction reference = " . $tresponse->getTransId());
|
||||
|
||||
// $payment = PaymentFactory::create($this->company->id, $this->user->id);
|
||||
// $payment->amount = 400;
|
||||
// $payment->client_id = $this->client->id;
|
||||
// $payment->date = now();
|
||||
// $payment->transaction_reference = $tresponse->getTransId();
|
||||
// $payment->company_gateway_id = 1;
|
||||
|
||||
// $payment->save();
|
||||
|
||||
// $company_gateway = CompanyGateway::where('gateway_key', '3b6621f970ab18887c4f6dca78d3f8bb')->first();
|
||||
|
||||
// $authorize_payment_driver = new AuthorizePaymentDriver($company_gateway, $this->client);
|
||||
// $response = $authorize_payment_driver->refund($payment, 350);
|
||||
|
||||
// info(print_r($response,1));
|
||||
|
||||
// $this->assertTrue(is_array($response));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user