1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge pull request #3992 from turbo124/v2

Fixes for company Purging
This commit is contained in:
David Bomba 2020-08-16 21:32:35 +10:00 committed by GitHub
commit 17acab76b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 411 additions and 236 deletions

View File

@ -593,6 +593,19 @@ class CompanySettings extends BaseSettings
'$task.tax',
'$task.line_total',
],
'total_columns' => [
'$total_taxes',
'$line_taxes',
'$subtotal',
'$total',
'$discount',
'$custom_surcharge1',
'$custom_surcharge2',
'$custom_surcharge3',
'$custom_surcharge4',
'$paid_to_date',
'$client.balance'
],
];
return json_decode(json_encode($variables));

View File

@ -40,7 +40,7 @@ class InvoiceWasEmailedAndFailed
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice, Company $company, array $errors, array $event_vars)
public function __construct(Invoice $invoice, Company $company, string $errors, array $event_vars)
{
$this->invoice = $invoice;

View File

@ -20,7 +20,6 @@ class CompanyGatewayFactory
$company_gateway = new CompanyGateway;
$company_gateway->company_id = $company_id;
$company_gateway->user_id = $user_id;
return $company_gateway;
}
}

View File

@ -497,80 +497,5 @@ class CompanyController extends BaseController
return response()->json(['message' => 'success'], 200);
}
/**
*
* Purge Company
*
* @OA\Post(
* path="/api/v1/companies/purge/{company}",
* operationId="postCompanyPurge",
* tags={"companies"},
* summary="Attempts to purge a company record and all its child records",
* description="Attempts to purge a company record and all its child records",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(
* name="company",
* in="path",
* description="The Company Hashed ID",
* example="D2J234DFA",
* required=true,
* @OA\Schema(
* type="string",
* format="string",
* ),
* ),
* @OA\Response(
* response=200,
* description="Returns a refresh object",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/CompanyUser"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
*/
public function purgeCompany(Company $company)
{
$account = $company->account;
$company_id = $company->id;
$company->delete();
/*Set New Company*/
if($account->companies->count() >= 1)
auth()->user()->setCompany($account->companies->first());
/*Update the new default company if necessary*/
if($company_id == $account->default_company_id){
$new_default_company = $account->companies->first();
if($new_default_company){
$account->default_company_id = $new_default_company->id;
$account->save();
}
}
/*Prep response*/
$this->entity_type = CompanyUser::class;
$this->entity_transformer = CompanyUserTransformer::class;
$company_user = $account->company_users->where('user_id', auth()->user()->id);
return $this->refreshResponse($company_user);
}
}

View File

@ -78,8 +78,24 @@ class MigrationController extends BaseController
public function purgeCompany(Company $company)
{
$account = $company->account;
$company_id = $company->id;
$company->delete();
/*Update the new default company if necessary*/
if($company_id == $account->default_company_id && $account->companies->count() >= 1)
{
$new_default_company = $account->companies->first();
if($new_default_company){
$account->default_company_id = $new_default_company->id;
$account->save();
}
}
return response()->json(['message' => 'Company purged'], 200);
}
@ -127,9 +143,10 @@ class MigrationController extends BaseController
* ),
* )
*/
public function purgeCompanySaveSettings(Company $company)
public function purgeCompanySaveSettings(Request $request, Company $company)
{
$company->client->delete();
$company->clients()->delete();
$company->save();
return response()->json(['message' => 'Settings preserved'], 200);

View File

@ -675,7 +675,7 @@ class QuoteController extends BaseController
return $this->listResponse($quote);
break;
case 'email':
$this->quote->service()->sendEmail();
$quote->service()->sendEmail();
return response()->json(['message'=>'email sent'], 200);
break;
case 'mark_sent':

View File

@ -43,7 +43,7 @@ class UpdateCreditRequest extends FormRequest
}
if($this->input('number'))
$rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->invoice->company_id;
$rules['number'] = 'unique:credits,number,' . $this->id . ',id,company_id,' . $this->credit->company_id;
return $rules;
}
@ -83,6 +83,8 @@ class UpdateCreditRequest extends FormRequest
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
$input['id'] = $this->credit->id;
$this->replace($input);
}
}

View File

@ -75,7 +75,7 @@ class UpdateInvoiceRequest extends Request
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
}
if (isset($input['invitations'])) {
foreach ($input['invitations'] as $key => $value) {
if (array_key_exists('id', $input['invitations'][$key]) && is_numeric($input['invitations'][$key]['id'])) {

View File

@ -51,7 +51,7 @@ class UpdateQuoteRequest extends Request
}
if($this->input('number'))
$rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->invoice->company_id;
$rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->quote->company_id;
return $rules;
@ -77,6 +77,8 @@ class UpdateQuoteRequest extends Request
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
}
$input['id'] = $this->quote->id;
$this->replace($input);
}
}

View File

@ -94,12 +94,16 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
}
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures(), $this->invoice->client);
$this->logMailError(Mail::failures(), $this->invoice->client);
}
else{
event(new InvoiceWasEmailed($this->invoice_invitation, $this->company, Ninja::eventVars()));
}
/* Mark invoice sent */
$this->invoice_invitation->invoice->service()->markSent()->save();
}

View File

@ -59,6 +59,9 @@ class EmailQuote implements ShouldQueue
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures());
}
$this->quote_invitation->quote->markSent()->save();
}
private function logMailError($errors)

View File

@ -53,6 +53,7 @@ class UpdateExchangeRates implements ShouldQueue
private function updateCurrencies()
{
info("updating currencies");
if(empty(config('ninja.currency_converter_api_key')))
return;

View File

@ -23,6 +23,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Carbon;
class BaseModel extends Model
{
@ -50,6 +51,15 @@ class BaseModel extends Model
return $this->encodePrimaryKey($this->id);
}
public function dateMutator($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
public function __call($method, $params)
{
$entity = strtolower(class_basename($this));

View File

@ -411,8 +411,7 @@ class Company extends BaseModel
public function resolveRouteBinding($value)
{
return $this
->where('id', $this->decodePrimaryKey($value))->firstOrFail();
return $this->where('id', $this->decodePrimaryKey($value))->firstOrFail();
}
public function domain()
@ -445,4 +444,5 @@ class Company extends BaseModel
}
}
}

View File

@ -71,6 +71,9 @@ class Credit extends BaseModel
];
protected $casts = [
// 'date' => 'date:Y-m-d',
// 'due_date' => 'date:Y-m-d',
// 'partial_due_date' => 'date:Y-m-d',
'line_items' => 'object',
'backup' => 'object',
'updated_at' => 'timestamp',
@ -92,36 +95,30 @@ class Credit extends BaseModel
public function getDateAttribute($value)
{
if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getDueDateAttribute($value)
{
if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getPartialDueDateAttribute($value)
{
if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function assigned_user()
{
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
}
public function history()
{
return $this->hasManyThrough(Backup::class, Activity::class);
}
public function company()
{
return $this->belongsTo(Company::class);

View File

@ -107,6 +107,9 @@ class Invoice extends BaseModel
];
protected $casts = [
// 'date' => 'date:Y-m-d',
// 'due_date' => 'date:Y-m-d',
// 'partial_due_date' => 'date:Y-m-d',
'line_items' => 'object',
'backup' => 'object',
'updated_at' => 'timestamp',
@ -114,20 +117,13 @@ class Invoice extends BaseModel
'deleted_at' => 'timestamp',
];
protected $with = [
// 'company',
// 'client',
];
protected $with = [];
protected $appends = [
'hashed_id',
'status'
];
protected $dates = [
'date',
];
const STATUS_DRAFT = 1;
const STATUS_SENT = 2;
const STATUS_PARTIAL = 3;
@ -145,28 +141,20 @@ class Invoice extends BaseModel
public function getDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getDueDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getPartialDueDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function company()
{
return $this->belongsTo(Company::class);

View File

@ -77,9 +77,9 @@ class Quote extends BaseModel
];
protected $casts = [
'date' => 'date:Y-m-d',
'due_date' => 'date:Y-m-d',
'partial_due_date' => 'date:Y-m-d',
// 'date' => 'date:Y-m-d',
// 'due_date' => 'date:Y-m-d',
// 'partial_due_date' => 'date:Y-m-d',
'line_items' => 'object',
'backup' => 'object',
'updated_at' => 'timestamp',
@ -87,6 +87,8 @@ class Quote extends BaseModel
'deleted_at' => 'timestamp',
];
protected $dates = [];
const STATUS_DRAFT = 1;
const STATUS_SENT = 2;
const STATUS_APPROVED = 3;
@ -100,33 +102,30 @@ class Quote extends BaseModel
public function getDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getDueDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function getPartialDueDateAttribute($value)
{
if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
return $this->dateMutator($value);
}
public function company()
{
return $this->belongsTo(Company::class);
}
public function history()
{
return $this->hasManyThrough(Backup::class, Activity::class);
}
public function user()
{
return $this->belongsTo(User::class)->withTrashed();

View File

@ -27,6 +27,7 @@ class CompanyGatewayTransformer extends EntityTransformer
* @var array
*/
protected $defaultIncludes = [
'gateway'
];
/**

View File

@ -11,11 +11,13 @@
namespace App\Transformers;
use App\Models\Backup;
use App\Models\Credit;
use App\Models\CreditInvitation;
use App\Models\Document;
use App\Transformers\CreditInvitationTransformer;
use App\Transformers\DocumentTransformer;
use App\Transformers\InvoiceHistoryTransformer;
use App\Utils\Traits\MakesHash;
class CreditTransformer extends EntityTransformer
@ -25,15 +27,23 @@ class CreditTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
'history',
];
protected $availableIncludes = [
'invitations',
// 'payments',
'history',
// 'client',
'documents',
];
public function includeHistory(Credit $credit)
{
$transformer = new InvoiceHistoryTransformer($this->serializer);
return $this->includeCollection($credit->history, $transformer, Backup::class);
}
public function includeInvitations(Credit $credit)
{
$transformer = new CreditInvitationTransformer($this->serializer);
@ -90,6 +100,10 @@ class CreditTransformer extends EntityTransformer
'date' => $credit->date ?: '',
'last_sent_date' => $credit->last_sent_date ?: '',
'next_send_date' => $credit->date ?: '',
'reminder1_sent' => $credit->reminder1_sent ?: '',
'reminder2_sent' => $credit->reminder2_sent ?: '',
'reminder3_sent' => $credit->reminder3_sent ?: '',
'reminder_last_sent' => $credit->reminder_last_sent ?: '',
'due_date' => $credit->due_date ?: '',
'terms' => $credit->terms ?: '',
'public_notes' => $credit->public_notes ?: '',

View File

@ -11,7 +11,9 @@
namespace App\Transformers;
use App\Models\Activity;
use App\Models\Backup;
use App\Transformers\ActivityTransformer;
use App\Utils\Traits\MakesHash;
class InvoiceHistoryTransformer extends EntityTransformer
@ -19,9 +21,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
use MakesHash;
protected $defaultIncludes = [
'activity'
];
protected $availableIncludes = [
'activity'
];
public function transform(Backup $backup)
@ -35,4 +39,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
'updated_at' => (int)$backup->updated_at,
];
}
public function includeActivity(Backup $backup)
{
$transformer = new ActivityTransformer($this->serializer);
return $this->includeItem($backup->activity, $transformer, Activity::class);
}
}

View File

@ -105,6 +105,10 @@ class InvoiceTransformer extends EntityTransformer
'date' => $invoice->date ?: '',
'last_sent_date' => $invoice->last_sent_date ?: '',
'next_send_date' => $invoice->date ?: '',
'reminder1_sent' => $invoice->reminder1_sent ?: '',
'reminder2_sent' => $invoice->reminder2_sent ?: '',
'reminder3_sent' => $invoice->reminder3_sent ?: '',
'reminder_last_sent' => $invoice->reminder_last_sent ?: '',
'due_date' => $invoice->due_date ?: '',
'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '',

View File

@ -26,7 +26,7 @@ class PaymentTransformer extends EntityTransformer
protected $serializer;
protected $defaultIncludes = [
// 'invoices'
'paymentables',
'documents',
];

View File

@ -11,10 +11,12 @@
namespace App\Transformers;
use App\Models\Backup;
use App\Models\Document;
use App\Models\Quote;
use App\Models\QuoteInvitation;
use App\Transformers\DocumentTransformer;
use App\Transformers\InvoiceHistoryTransformer;
use App\Transformers\QuoteInvitationTransformer;
use App\Utils\Traits\MakesHash;
@ -25,15 +27,24 @@ class QuoteTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
'history'
];
protected $availableIncludes = [
'invitations',
'documents',
'history'
// 'payments',
// 'client',
];
public function includeHistory(Quote $quote)
{
$transformer = new InvoiceHistoryTransformer($this->serializer);
return $this->includeCollection($quote->history, $transformer, Backup::class);
}
public function includeInvitations(Quote $quote)
{
$transformer = new QuoteInvitationTransformer($this->serializer);
@ -90,6 +101,10 @@ class QuoteTransformer extends EntityTransformer
'date' => $quote->date ?: '',
'last_sent_date' => $quote->last_sent_date ?: '',
'next_send_date' => $quote->date ?: '',
'reminder1_sent' => $quote->reminder1_sent ?: '',
'reminder2_sent' => $quote->reminder2_sent ?: '',
'reminder3_sent' => $quote->reminder3_sent ?: '',
'reminder_last_sent' => $quote->reminder_last_sent ?: '',
'due_date' => $quote->due_date ?: '',
'terms' => $quote->terms ?: '',
'public_notes' => $quote->public_notes ?: '',

265
composer.lock generated
View File

@ -107,16 +107,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.147.14",
"version": "3.149.0",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "2ac5757aee4333c382c222880a51bd56930dafc4"
"reference": "0ab4ac60f94d53d55f2c7374deb75d9a58961970"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2ac5757aee4333c382c222880a51bd56930dafc4",
"reference": "2ac5757aee4333c382c222880a51bd56930dafc4",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0ab4ac60f94d53d55f2c7374deb75d9a58961970",
"reference": "0ab4ac60f94d53d55f2c7374deb75d9a58961970",
"shasum": ""
},
"require": {
@ -188,7 +188,7 @@
"s3",
"sdk"
],
"time": "2020-08-06T18:18:37+00:00"
"time": "2020-08-13T18:10:50+00:00"
},
{
"name": "checkout/checkout-sdk-php",
@ -514,21 +514,21 @@
},
{
"name": "composer/package-versions-deprecated",
"version": "1.10.99",
"version": "1.10.99.1",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "dd51b4443d58b34b6d9344cf4c288e621c9a826f"
"reference": "68c9b502036e820c33445ff4d174327f6bb87486"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/dd51b4443d58b34b6d9344cf4c288e621c9a826f",
"reference": "dd51b4443d58b34b6d9344cf4c288e621c9a826f",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/68c9b502036e820c33445ff4d174327f6bb87486",
"reference": "68c9b502036e820c33445ff4d174327f6bb87486",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1.0 || ^2.0",
"php": "^7"
"php": "^7 || ^8"
},
"replace": {
"ocramius/package-versions": "1.10.99"
@ -579,7 +579,7 @@
"type": "tidelift"
}
],
"time": "2020-07-15T08:39:18+00:00"
"time": "2020-08-13T12:55:41+00:00"
},
{
"name": "composer/semver",
@ -774,6 +774,50 @@
],
"time": "2020-06-04T11:16:35+00:00"
},
{
"name": "cweagans/composer-patches",
"version": "1.6.7",
"source": {
"type": "git",
"url": "https://github.com/cweagans/composer-patches.git",
"reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2e6f72a2ad8d59cd7e2b729f218bf42adb14f590",
"reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0",
"php": ">=5.3.0"
},
"require-dev": {
"composer/composer": "~1.0",
"phpunit/phpunit": "~4.6"
},
"type": "composer-plugin",
"extra": {
"class": "cweagans\\Composer\\Patches"
},
"autoload": {
"psr-4": {
"cweagans\\Composer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Cameron Eagans",
"email": "me@cweagans.net"
}
],
"description": "Provides a way to patch Composer packages.",
"time": "2019-08-29T20:11:49+00:00"
},
{
"name": "czproject/git-php",
"version": "v3.18.1",
@ -1418,16 +1462,16 @@
},
{
"name": "egulias/email-validator",
"version": "2.1.18",
"version": "2.1.19",
"source": {
"type": "git",
"url": "https://github.com/egulias/EmailValidator.git",
"reference": "cfa3d44471c7f5bfb684ac2b0da7114283d78441"
"reference": "840d5603eb84cc81a6a0382adac3293e57c1c64c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/cfa3d44471c7f5bfb684ac2b0da7114283d78441",
"reference": "cfa3d44471c7f5bfb684ac2b0da7114283d78441",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/840d5603eb84cc81a6a0382adac3293e57c1c64c",
"reference": "840d5603eb84cc81a6a0382adac3293e57c1c64c",
"shasum": ""
},
"require": {
@ -1472,7 +1516,7 @@
"validation",
"validator"
],
"time": "2020-06-16T20:11:17+00:00"
"time": "2020-08-08T21:28:19+00:00"
},
{
"name": "fedeisas/laravel-mail-css-inliner",
@ -2892,28 +2936,29 @@
},
{
"name": "league/flysystem",
"version": "1.0.70",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "585824702f534f8d3cf7fab7225e8466cc4b7493"
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/585824702f534f8d3cf7fab7225e8466cc4b7493",
"reference": "585824702f534f8d3cf7fab7225e8466cc4b7493",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/6e96f54d82e71f71c4108da33ee96a7f57083710",
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": ">=5.5.9"
"league/mime-type-detection": "^1.3",
"php": "^7.2.5 || ^8.0"
},
"conflict": {
"league/flysystem-sftp": "<1.0.6"
},
"require-dev": {
"phpspec/phpspec": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"phpunit/phpunit": "^5.7.26"
"phpspec/prophecy": "^1.11.1",
"phpunit/phpunit": "^8.5.8"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
@ -2978,7 +3023,7 @@
"type": "other"
}
],
"time": "2020-07-26T07:20:36+00:00"
"time": "2020-08-12T14:23:41+00:00"
},
{
"name": "league/flysystem-aws-s3-v3",
@ -3199,6 +3244,57 @@
],
"time": "2020-07-07T12:23:45+00:00"
},
{
"name": "league/mime-type-detection",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "fda190b62b962d96a069fcc414d781db66d65b69"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/fda190b62b962d96a069fcc414d781db66d65b69",
"reference": "fda190b62b962d96a069fcc414d781db66d65b69",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": "^7.2 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.36",
"phpunit/phpunit": "^8.5.8"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\MimeTypeDetection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Mime-type detection for Flysystem",
"funding": [
{
"url": "https://github.com/frankdejonge",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/flysystem",
"type": "tidelift"
}
],
"time": "2020-08-09T10:34:01+00:00"
},
{
"name": "league/oauth1-client",
"version": "1.7.0",
@ -3805,16 +3901,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.7.0",
"version": "v4.8.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "21dce06dfbf0365c6a7cc8fdbdc995926c6a9300"
"reference": "8c58eb4cd4f3883f82611abeac2efbc3dbed787e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/21dce06dfbf0365c6a7cc8fdbdc995926c6a9300",
"reference": "21dce06dfbf0365c6a7cc8fdbdc995926c6a9300",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8c58eb4cd4f3883f82611abeac2efbc3dbed787e",
"reference": "8c58eb4cd4f3883f82611abeac2efbc3dbed787e",
"shasum": ""
},
"require": {
@ -3822,8 +3918,8 @@
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "0.0.5",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0"
"ircmaxell/php-yacc": "^0.0.6",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
@ -3831,7 +3927,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.7-dev"
"dev-master": "4.8-dev"
}
},
"autoload": {
@ -3853,7 +3949,7 @@
"parser",
"php"
],
"time": "2020-07-25T13:18:53+00:00"
"time": "2020-08-09T10:23:20+00:00"
},
{
"name": "nwidart/laravel-modules",
@ -4129,16 +4225,16 @@
},
{
"name": "opis/closure",
"version": "3.5.5",
"version": "3.5.6",
"source": {
"type": "git",
"url": "https://github.com/opis/closure.git",
"reference": "dec9fc5ecfca93f45cd6121f8e6f14457dff372c"
"reference": "e8d34df855b0a0549a300cb8cb4db472556e8aa9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/closure/zipball/dec9fc5ecfca93f45cd6121f8e6f14457dff372c",
"reference": "dec9fc5ecfca93f45cd6121f8e6f14457dff372c",
"url": "https://api.github.com/repos/opis/closure/zipball/e8d34df855b0a0549a300cb8cb4db472556e8aa9",
"reference": "e8d34df855b0a0549a300cb8cb4db472556e8aa9",
"shasum": ""
},
"require": {
@ -4186,7 +4282,7 @@
"serialization",
"serialize"
],
"time": "2020-06-17T14:59:55+00:00"
"time": "2020-08-11T08:46:50+00:00"
},
{
"name": "paragonie/random_compat",
@ -4838,19 +4934,20 @@
},
{
"name": "predis/predis",
"version": "v1.1.1",
"version": "v1.1.2",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
"url": "https://github.com/predishq/predis.git",
"reference": "82eb18c6c3860849cb6e2ff34b0c4b39d5daee46"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"url": "https://api.github.com/repos/predishq/predis/zipball/82eb18c6c3860849cb6e2ff34b0c4b39d5daee46",
"reference": "82eb18c6c3860849cb6e2ff34b0c4b39d5daee46",
"shasum": ""
},
"require": {
"cweagans/composer-patches": "^1.6",
"php": ">=5.3.9"
},
"require-dev": {
@ -4861,6 +4958,18 @@
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"type": "library",
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "./tests/phpunit_php7.patch",
"Fix PHP 8 compatibility": "./tests/phpunit_php8.patch"
}
}
},
"autoload": {
"psr-4": {
"Predis\\": "src/"
@ -4884,7 +4993,17 @@
"predis",
"redis"
],
"time": "2016-06-16T16:22:20+00:00"
"funding": [
{
"url": "https://www.paypal.me/tillkruss",
"type": "custom"
},
{
"url": "https://github.com/tillkruss",
"type": "github"
}
],
"time": "2020-08-11T17:28:15+00:00"
},
{
"name": "psr/cache",
@ -5544,16 +5663,16 @@
},
{
"name": "seld/jsonlint",
"version": "1.8.0",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/jsonlint.git",
"reference": "ff2aa5420bfbc296cf6a0bc785fa5b35736de7c1"
"reference": "3d5eb71705adfa34bd34b993400622932b2f62fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/ff2aa5420bfbc296cf6a0bc785fa5b35736de7c1",
"reference": "ff2aa5420bfbc296cf6a0bc785fa5b35736de7c1",
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/3d5eb71705adfa34bd34b993400622932b2f62fd",
"reference": "3d5eb71705adfa34bd34b993400622932b2f62fd",
"shasum": ""
},
"require": {
@ -5599,7 +5718,7 @@
"type": "tidelift"
}
],
"time": "2020-04-30T19:05:18+00:00"
"time": "2020-08-13T09:07:59+00:00"
},
{
"name": "seld/phar-utils",
@ -6111,16 +6230,16 @@
},
{
"name": "stripe/stripe-php",
"version": "v7.46.1",
"version": "v7.47.0",
"source": {
"type": "git",
"url": "https://github.com/stripe/stripe-php.git",
"reference": "fd57205d3e3a1dccab80538654128d5c46a1f5ac"
"reference": "b51656cb398d081fcee53a76f6edb8fd5c1a5306"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/fd57205d3e3a1dccab80538654128d5c46a1f5ac",
"reference": "fd57205d3e3a1dccab80538654128d5c46a1f5ac",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/b51656cb398d081fcee53a76f6edb8fd5c1a5306",
"reference": "b51656cb398d081fcee53a76f6edb8fd5c1a5306",
"shasum": ""
},
"require": {
@ -6164,7 +6283,7 @@
"payment processing",
"stripe"
],
"time": "2020-08-07T22:11:58+00:00"
"time": "2020-08-13T22:35:56+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -8827,29 +8946,30 @@
},
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.3.3",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "57f2219f6d9efe41ed1bc880d86701c52f261bf5"
"reference": "9e785aa5584e8839fd43070202dd7f2e912db51c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/57f2219f6d9efe41ed1bc880d86701c52f261bf5",
"reference": "57f2219f6d9efe41ed1bc880d86701c52f261bf5",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/9e785aa5584e8839fd43070202dd7f2e912db51c",
"reference": "9e785aa5584e8839fd43070202dd7f2e912db51c",
"shasum": ""
},
"require": {
"illuminate/routing": "^5.5|^6|^7",
"illuminate/session": "^5.5|^6|^7",
"illuminate/support": "^5.5|^6|^7",
"maximebf/debugbar": "^1.15.1",
"maximebf/debugbar": "^1.16.3",
"php": ">=7.0",
"symfony/debug": "^3|^4|^5",
"symfony/finder": "^3|^4|^5"
},
"require-dev": {
"laravel/framework": "5.5.x"
"orchestra/testbench": "^3.5|^4.0|^5.0",
"phpunit/phpunit": "^6.0|^7.0|^8.5|^9.0"
},
"type": "library",
"extra": {
@ -8897,7 +9017,7 @@
"type": "github"
}
],
"time": "2020-05-05T10:53:32+00:00"
"time": "2020-08-11T10:30:51+00:00"
},
{
"name": "beyondcode/laravel-dump-server",
@ -9032,16 +9152,16 @@
},
{
"name": "doctrine/annotations",
"version": "1.10.3",
"version": "1.10.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d"
"reference": "bfe91e31984e2ba76df1c1339681770401ec262f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/5db60a4969eba0e0c197a19c077780aadbc43c5d",
"reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/bfe91e31984e2ba76df1c1339681770401ec262f",
"reference": "bfe91e31984e2ba76df1c1339681770401ec262f",
"shasum": ""
},
"require": {
@ -9051,7 +9171,8 @@
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^7.5"
"phpstan/phpstan": "^0.12.20",
"phpunit/phpunit": "^7.5 || ^9.1.5"
},
"type": "library",
"extra": {
@ -9097,7 +9218,7 @@
"docblock",
"parser"
],
"time": "2020-05-25T17:24:27+00:00"
"time": "2020-08-10T19:35:50+00:00"
},
{
"name": "doctrine/instantiator",
@ -9476,16 +9597,16 @@
},
{
"name": "mockery/mockery",
"version": "1.3.2",
"version": "1.3.3",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "9b6f117dd7d36dc3858d8d8ddf9b3d584fcae283"
"reference": "60fa2f67f6e4d3634bb4a45ff3171fa52215800d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/9b6f117dd7d36dc3858d8d8ddf9b3d584fcae283",
"reference": "9b6f117dd7d36dc3858d8d8ddf9b3d584fcae283",
"url": "https://api.github.com/repos/mockery/mockery/zipball/60fa2f67f6e4d3634bb4a45ff3171fa52215800d",
"reference": "60fa2f67f6e4d3634bb4a45ff3171fa52215800d",
"shasum": ""
},
"require": {
@ -9494,7 +9615,7 @@
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0|~9.0"
"phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3"
},
"type": "library",
"extra": {
@ -9537,7 +9658,7 @@
"test double",
"testing"
],
"time": "2020-07-09T08:23:05+00:00"
"time": "2020-08-11T18:10:21+00:00"
},
{
"name": "myclabs/deep-copy",

View File

@ -0,0 +1,17 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Gateway::class, function (Faker $faker) {
return [
'key' => '3b6621f970ab18887c4f6dca78d3f8bb',
'visible' => true,
'sort_order' =>1,
'name' => 'demo',
'provider' => 'test',
'is_offsite' => true,
'is_secure' => true,
'fields' => '',
'default_gateway_type_id' => 1,
];
});

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddReminderSentFieldsToEntityTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('activities', function (Blueprint $table) {
$table->unsignedInteger('quote_id')->nullable();
});
Schema::table('quotes', function (Blueprint $table) {
$table->date('reminder1_sent')->nullable();
$table->date('reminder2_sent')->nullable();
$table->date('reminder3_sent')->nullable();
$table->date('reminder_last_sent')->nullable();
});
Schema::table('invoices', function (Blueprint $table) {
$table->date('reminder1_sent')->nullable();
$table->date('reminder2_sent')->nullable();
$table->date('reminder3_sent')->nullable();
$table->date('reminder_last_sent')->nullable();
});
Schema::table('credits', function (Blueprint $table) {
$table->date('reminder1_sent')->nullable();
$table->date('reminder2_sent')->nullable();
$table->date('reminder3_sent')->nullable();
$table->date('reminder_last_sent')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}

View File

@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
use PaymentLibrariesSeeder;
/**
* @test
@ -48,6 +49,7 @@ class CompanyGatewayApiTest extends TestCase
public function testCompanyGatewayEndPoints()
{
$data = [
'config' => 'random config',
'gateway_key' => '3b6621f970ab18887c4f6dca78d3f8bb',
@ -67,55 +69,31 @@ class CompanyGatewayApiTest extends TestCase
$response->assertStatus(200);
/* GET */
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token
])->get("/api/v1/company_gateways/{$cg_id}");
$response->assertStatus(200);
/* GET CREATE */
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token
])->get('/api/v1/company_gateways/create');
$response->assertStatus(200);
/* PUT */
$data = [
'config' => 'changed',
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token
])->put("/api/v1/company_gateways/".$cg_id, $data);
$response->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token
])->delete("/api/v1/company_gateways/{$cg_id}", $data);
$response->assertStatus(200);
}
public function testCompanyGatewayFeesAndLimitsSuccess()
{
$fee = new FeesAndLimits;
$fee = (array)$fee;
@ -164,6 +142,7 @@ class CompanyGatewayApiTest extends TestCase
public function testCompanyGatewayFeesAndLimitsFails()
{
$fee_and_limit['bank_transfer'] = new FeesAndLimits;
$fee_and_limit['bank_transfer']->adjust_fee_percent = 10;
@ -186,6 +165,7 @@ class CompanyGatewayApiTest extends TestCase
public function testCompanyGatewayArrayBuilder()
{
$arr = [
'min_limit' => 1,
'max_limit' => 2