mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 03:44:34 -04:00
fixes for conflicts
This commit is contained in:
commit
2f4e4278d7
@ -615,7 +615,7 @@ class PaymentController extends BaseController
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'email_receipt':
|
case 'email_receipt':
|
||||||
$this->payment->service()->sendEmail();
|
$payment->service()->sendEmail();
|
||||||
|
|
||||||
if (! $bulk) {
|
if (! $bulk) {
|
||||||
return $this->itemResponse($payment);
|
return $this->itemResponse($payment);
|
||||||
|
@ -22,6 +22,6 @@ class ShowSchedulerRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->can('view', $this->scheduler);
|
return auth()->user()->can('view', $this->task_scheduler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class UpdateSchedulerRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->isAdmin();
|
return auth()->user()->isAdmin() && $this->task_scheduler->company_id == auth()->user()->company()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
|
@ -49,7 +49,7 @@ class EmailPayment implements ShouldQueue
|
|||||||
* @param $contact
|
* @param $contact
|
||||||
* @param $company
|
* @param $company
|
||||||
*/
|
*/
|
||||||
public function __construct(Payment $payment, Company $company, ClientContact $contact)
|
public function __construct(Payment $payment, Company $company, ?ClientContact $contact)
|
||||||
{
|
{
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
$this->contact = $contact;
|
$this->contact = $contact;
|
||||||
@ -60,7 +60,6 @@ class EmailPayment implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
@ -73,6 +72,10 @@ class EmailPayment implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
$this->payment->load('invoices');
|
$this->payment->load('invoices');
|
||||||
|
|
||||||
|
if(!$this->contact)
|
||||||
|
$this->contact = $this->payment->client->contacts()->first();
|
||||||
|
|
||||||
$this->contact->load('client');
|
$this->contact->load('client');
|
||||||
|
|
||||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||||
@ -90,7 +93,7 @@ class EmailPayment implements ShouldQueue
|
|||||||
$nmo->company = $this->company;
|
$nmo->company = $this->company;
|
||||||
$nmo->entity = $this->payment;
|
$nmo->entity = $this->payment;
|
||||||
|
|
||||||
NinjaMailerJob::dispatch($nmo);
|
(new NinjaMailerJob($nmo))->handle();
|
||||||
|
|
||||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class EmailRefundPayment implements ShouldQueue
|
|||||||
$nmo->company = $this->company;
|
$nmo->company = $this->company;
|
||||||
$nmo->entity = $this->payment;
|
$nmo->entity = $this->payment;
|
||||||
|
|
||||||
NinjaMailerJob::dispatch($nmo);
|
(new NinjaMailerJob($nmo))->handle();
|
||||||
|
|
||||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
}
|
}
|
||||||
|
@ -389,6 +389,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
private function buildViewButton(string $link, string $text): string
|
private function buildViewButton(string $link, string $text): string
|
||||||
{
|
{
|
||||||
return '
|
return '
|
||||||
|
<div>
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
||||||
<tr>
|
<tr>
|
||||||
@ -409,9 +410,10 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
</div>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<table border="0" cellspacing="0" cellpadding="0" align="center">
|
<table border="0" cellspacing="0" cellpadding="0" align="center">
|
||||||
<tr style="border: 0 !important; ">
|
<tr style="border: 0 !important; ">
|
||||||
|
@ -114,7 +114,7 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
$exchange_rate = new CurrencyApi();
|
$exchange_rate = new CurrencyApi();
|
||||||
|
|
||||||
$payment->exchange_rate = $exchange_rate->exchangeRate($client_currency, $company_currency, Carbon::parse($payment->date));
|
$payment->exchange_rate = $exchange_rate->exchangeRate($client_currency, $company_currency, Carbon::parse($payment->date));
|
||||||
//$payment->exchange_currency_id = $client_currency; // 23/06/2021
|
|
||||||
$payment->exchange_currency_id = $company_currency;
|
$payment->exchange_currency_id = $company_currency;
|
||||||
|
|
||||||
$payment->saveQuietly();
|
$payment->saveQuietly();
|
||||||
|
@ -103,7 +103,6 @@ class InvoiceService
|
|||||||
* @param Payment $payment The Payment
|
* @param Payment $payment The Payment
|
||||||
* @param float $payment_amount The Payment amount
|
* @param float $payment_amount The Payment amount
|
||||||
* @return InvoiceService Parent class object
|
* @return InvoiceService Parent class object
|
||||||
* @deprecated 24-11-2022 - cannot find any references to this method anywhere
|
|
||||||
*/
|
*/
|
||||||
public function applyPayment(Payment $payment, float $payment_amount)
|
public function applyPayment(Payment $payment, float $payment_amount)
|
||||||
{
|
{
|
||||||
|
@ -20,16 +20,8 @@ use App\Utils\Ninja;
|
|||||||
|
|
||||||
class MarkSent extends AbstractService
|
class MarkSent extends AbstractService
|
||||||
{
|
{
|
||||||
public $client;
|
public function __construct(public Client $client, public Invoice $invoice)
|
||||||
|
{}
|
||||||
public $invoice;
|
|
||||||
|
|
||||||
public function __construct(Client $client, Invoice $invoice)
|
|
||||||
{
|
|
||||||
$this->client = $client;
|
|
||||||
|
|
||||||
$this->invoice = $invoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run($fire_webhook = false)
|
public function run($fire_webhook = false)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(rand(30, 300)));
|
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(3, 13));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(rand(30, 300)));
|
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(3, 13));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(rand(30, 300)));
|
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(3, 13));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -11,20 +11,15 @@
|
|||||||
|
|
||||||
namespace App\Services\Payment;
|
namespace App\Services\Payment;
|
||||||
|
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\ClientContact;
|
||||||
use App\Jobs\Payment\EmailPayment;
|
use App\Jobs\Payment\EmailPayment;
|
||||||
|
|
||||||
class SendEmail
|
class SendEmail
|
||||||
{
|
{
|
||||||
public $payment;
|
|
||||||
|
|
||||||
public $contact;
|
public function __construct(public Payment $payment, public ?ClientContact $contact)
|
||||||
|
{}
|
||||||
public function __construct($payment, $contact)
|
|
||||||
{
|
|
||||||
$this->payment = $payment;
|
|
||||||
|
|
||||||
$this->contact = $contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the correct template to send.
|
* Builds the correct template to send.
|
||||||
@ -34,18 +29,16 @@ class SendEmail
|
|||||||
{
|
{
|
||||||
$this->payment->load('company', 'client.contacts', 'invoices');
|
$this->payment->load('company', 'client.contacts', 'invoices');
|
||||||
|
|
||||||
$contact = $this->payment->client->contacts()->first();
|
if(!$this->contact)
|
||||||
|
$this->contact = $this->payment->client->contacts()->first();
|
||||||
|
|
||||||
// if ($contact?->email)
|
// $this->payment->invoices->sortByDesc('id')->first(function ($invoice) {
|
||||||
// EmailPayment::dispatch($this->payment, $this->payment->company, $contact)->delay(now()->addSeconds(2));
|
// $invoice->invitations->each(function ($invitation) {
|
||||||
|
// if (!$invitation->contact->trashed() && $invitation->contact->email) {
|
||||||
|
EmailPayment::dispatch($this->payment, $this->payment->company, $this->contact);
|
||||||
$this->payment->invoices->sortByDesc('id')->first(function ($invoice) {
|
// }
|
||||||
$invoice->invitations->each(function ($invitation) {
|
// });
|
||||||
if (!$invitation->contact->trashed() && $invitation->contact->email) {
|
// });
|
||||||
EmailPayment::dispatch($this->payment, $this->payment->company, $invitation->contact)->delay(now()->addSeconds(2));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -985,6 +985,7 @@ html {
|
|||||||
private function buildViewButton(string $link, string $text): string
|
private function buildViewButton(string $link, string $text): string
|
||||||
{
|
{
|
||||||
return '
|
return '
|
||||||
|
<div>
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
||||||
<tr>
|
<tr>
|
||||||
@ -1005,6 +1006,7 @@ html {
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
</div>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,7 @@ trait Uploadable
|
|||||||
{
|
{
|
||||||
public function removeLogo($company)
|
public function removeLogo($company)
|
||||||
{
|
{
|
||||||
//if (Storage::disk(config('filesystems.default'))->exists($company->settings->company_logo)) {
|
(new UnlinkFile(config('filesystems.default'), $company?->settings?->company_logo))->handle();
|
||||||
(new UnlinkFile(config('filesystems.default'), $company->settings->company_logo))->handle();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadLogo($file, $company, $entity)
|
public function uploadLogo($file, $company, $entity)
|
||||||
|
@ -808,6 +808,7 @@ html {
|
|||||||
private function buildViewButton(string $link, string $text): string
|
private function buildViewButton(string $link, string $text): string
|
||||||
{
|
{
|
||||||
return '
|
return '
|
||||||
|
<div>
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
||||||
<tr>
|
<tr>
|
||||||
@ -828,10 +829,10 @@ html {
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
</div>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<table border="0" cellspacing="0" cellpadding="0" align="center">
|
<table border="0" cellspacing="0" cellpadding="0" align="center">
|
||||||
<tr style="border: 0 !important; ">
|
<tr style="border: 0 !important; ">
|
||||||
|
@ -230,8 +230,13 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testStorePaymentWithClientId()
|
public function testStorePaymentWithClientId()
|
||||||
{
|
{
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -289,8 +294,14 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testStorePaymentWithNoInvoiecs()
|
public function testStorePaymentWithNoInvoiecs()
|
||||||
{
|
{
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -336,16 +347,15 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
|
||||||
|
|
||||||
ClientContact::factory()->create([
|
ClientContact::factory()->create([
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' =>$this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'is_primary' => true,
|
'is_primary' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
@ -626,8 +636,14 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -686,8 +702,14 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -739,8 +761,13 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -799,8 +826,14 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -898,8 +931,13 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -944,59 +982,18 @@ class PaymentTest extends TestCase
|
|||||||
$this->assertEquals($payment->amount, 20);
|
$this->assertEquals($payment->amount, 20);
|
||||||
$this->assertEquals($payment->applied, 10);
|
$this->assertEquals($payment->applied, 10);
|
||||||
|
|
||||||
// $invoice = null;
|
|
||||||
// $invoice = InvoiceFactory::create($this->company->id, $this->user->id);//stub the company and user_id
|
|
||||||
// $invoice->client_id = $client->id;
|
|
||||||
|
|
||||||
// $invoice->line_items = $this->buildLineItems();
|
|
||||||
// $invoice->uses_inclusive_taxes = false;
|
|
||||||
|
|
||||||
// $invoice->save();
|
|
||||||
|
|
||||||
// $invoice_calc = new InvoiceSum($invoice);
|
|
||||||
// $invoice_calc->build();
|
|
||||||
|
|
||||||
// $invoice = $invoice_calc->getInvoice();
|
|
||||||
// $invoice->save();
|
|
||||||
// $invoice->service()->markSent()->createInvitations()->save();
|
|
||||||
|
|
||||||
// $data = [
|
|
||||||
// 'amount' => 20.0,
|
|
||||||
// 'client_id' => $this->encodePrimaryKey($client->id),
|
|
||||||
// 'invoices' => [
|
|
||||||
// [
|
|
||||||
// 'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
|
||||||
// 'amount' => 10,
|
|
||||||
// ]
|
|
||||||
// ],
|
|
||||||
// 'date' => '2019/12/12',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// $response = false;
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// $response = $this->withHeaders([
|
|
||||||
// 'X-API-SECRET' => config('ninja.api_secret'),
|
|
||||||
// 'X-API-TOKEN' => $this->token,
|
|
||||||
// ])->put('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data);
|
|
||||||
// } catch (ValidationException $e) {
|
|
||||||
// $message = json_decode($e->validator->getMessageBag(), 1);
|
|
||||||
// \Log::error(print_r($e->validator->getMessageBag(), 1));
|
|
||||||
|
|
||||||
// $this->assertTrue(array_key_exists('invoices', $message));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
|
|
||||||
// $arr = $response->json();
|
|
||||||
|
|
||||||
// $this->assertEquals(20, $arr['data']['applied']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStorePaymentWithNoAmountField()
|
public function testStorePaymentWithNoAmountField()
|
||||||
{
|
{
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -1055,8 +1052,13 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testStorePaymentWithZeroAmountField()
|
public function testStorePaymentWithZeroAmountField()
|
||||||
{
|
{
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -1109,11 +1111,22 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentForInvoicesFromDifferentClients()
|
public function testPaymentForInvoicesFromDifferentClients()
|
||||||
{
|
{
|
||||||
$client1 = ClientFactory::create($this->company->id, $this->user->id);
|
$client1 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client1->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client1->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$client2 = ClientFactory::create($this->company->id, $this->user->id);
|
|
||||||
$client2->save();
|
$client2 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client2->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice1 = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice1 = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice1->client_id = $client1->id;
|
$invoice1->client_id = $client1->id;
|
||||||
@ -1175,8 +1188,13 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentWithSameInvoiceMultipleTimes()
|
public function testPaymentWithSameInvoiceMultipleTimes()
|
||||||
{
|
{
|
||||||
$client1 = ClientFactory::create($this->company->id, $this->user->id);
|
$client1 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client1->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client1->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice1 = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice1 = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice1->client_id = $client1->id;
|
$invoice1->client_id = $client1->id;
|
||||||
@ -1227,8 +1245,13 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testStorePaymentWithCredits()
|
public function testStorePaymentWithCredits()
|
||||||
{
|
{
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -1310,7 +1333,14 @@ class PaymentTest extends TestCase
|
|||||||
$settings = ClientSettings::defaults();
|
$settings = ClientSettings::defaults();
|
||||||
$settings->currency_id = '2';
|
$settings->currency_id = '2';
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$client->settings = $settings;
|
$client->settings = $settings;
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
@ -1374,8 +1404,14 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
@ -1453,8 +1489,14 @@ class PaymentTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]);
|
||||||
$client->save();
|
ClientContact::factory()->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'is_primary' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
@ -54,6 +54,22 @@ class SchedulerTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function testSchedulerGet2()
|
||||||
|
{
|
||||||
|
|
||||||
|
$scheduler = SchedulerFactory::create($this->company->id, $this->user->id);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/task_schedulers/'.$this->encodePrimaryKey($scheduler->id));
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testCustomDateRanges()
|
public function testCustomDateRanges()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
@ -619,21 +635,6 @@ class SchedulerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public function testSchedulerPut()
|
|
||||||
// {
|
|
||||||
// $data = [
|
|
||||||
// 'description' => $this->faker->firstName(),
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// $response = $this->withHeaders([
|
|
||||||
// 'X-API-SECRET' => config('ninja.api_secret'),
|
|
||||||
// 'X-API-TOKEN' => $this->token,
|
|
||||||
// ])->put('/api/v1/task_schedulers/'.$this->encodePrimaryKey($this->task->id), $data);
|
|
||||||
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public function testSchedulerCantBeCreatedWithWrongData()
|
// public function testSchedulerCantBeCreatedWithWrongData()
|
||||||
// {
|
// {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user