diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php
index 264d6d5eb96b5..a2b8f884690ac 100644
--- a/app/DataMapper/CompanySettings.php
+++ b/app/DataMapper/CompanySettings.php
@@ -109,6 +109,8 @@ class CompanySettings extends BaseSettings
public $reset_counter_date = '';
public $counter_padding = 4;
+ public $auto_bill = 'off'; //off,always,optin,optout
+
public $design = 'views/pdf/design1.blade.php';
public $invoice_terms = '';
@@ -238,6 +240,7 @@ class CompanySettings extends BaseSettings
public $client_portal_enable_uploads = false;
public static $casts = [
+ 'auto_bill' => 'string',
'lock_invoices' => 'string',
'client_portal_terms' => 'string',
'client_portal_privacy_policy' => 'string',
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index ba18615979f74..444bd6fb7aa53 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -37,6 +37,9 @@ class Handler extends ExceptionHandler
*/
protected $dontReport = [
\PDOException::class,
+ \Swift_TransportException::class,
+ \Illuminate\Queue\MaxAttemptsExceededException::class,
+ \Symfony\Component\Console\Exception\CommandNotFoundException::class
];
/**
diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php
index 955e4b3b7adbb..1e1b363c6d254 100644
--- a/app/Http/Controllers/MigrationController.php
+++ b/app/Http/Controllers/MigrationController.php
@@ -147,6 +147,8 @@ class MigrationController extends BaseController
{
$company->clients()->delete();
+ $company->products()->delete();
+
$company->save();
return response()->json(['message' => 'Settings preserved'], 200);
diff --git a/app/Jobs/Quote/EmailQuote.php b/app/Jobs/Quote/EmailQuote.php
index 58a1193e2ffd1..407157a4ad401 100644
--- a/app/Jobs/Quote/EmailQuote.php
+++ b/app/Jobs/Quote/EmailQuote.php
@@ -60,7 +60,7 @@ class EmailQuote implements ShouldQueue
return $this->logMailError(Mail::failures());
}
- $this->quote_invitation->quote->markSent()->save();
+ $this->quote_invitation->quote->service()->markSent()->save();
}
diff --git a/app/Models/Client.php b/app/Models/Client.php
index e68f50a9a9018..ecead74d77f3c 100644
--- a/app/Models/Client.php
+++ b/app/Models/Client.php
@@ -460,7 +460,8 @@ class Client extends BaseModel implements HasLocalePreference
$company_gateways = $this->getSetting('company_gateway_ids');
- if ($company_gateways) {
+ if ($company_gateways || $company_gateways == "0") { //we need to check for "0" here as we disable a payment gateway for a client with the number "0"
+
$transformed_ids = $this->transformKeys(explode(",", $company_gateways));
$gateways = $this->company
->company_gateways
diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php
index 202c2e2b9c7a3..3a086b51b1b0a 100644
--- a/app/Models/CompanyGateway.php
+++ b/app/Models/CompanyGateway.php
@@ -43,6 +43,7 @@ class CompanyGateway extends BaseModel
'custom_value2',
'custom_value3',
'custom_value4',
+ 'token_billing',
];
public static $credit_cards = [
@@ -270,8 +271,9 @@ class CompanyGateway extends BaseModel
info("fee after adding fee tax 3 = {$fee}");
}
- //TODO CALCULATE FEE CAP HERE
-
+ if($fees_and_limits->fee_cap > 0 && ($fee > $fees_and_limits->fee_cap))
+ $fee = $fees_and_limits->fee_cap;
+
return $fee;
}
diff --git a/app/Models/Document.php b/app/Models/Document.php
index ed62e2bc7584e..b0281b95e7ff6 100644
--- a/app/Models/Document.php
+++ b/app/Models/Document.php
@@ -26,6 +26,7 @@ class Document extends BaseModel
*/
protected $fillable = [
'is_default',
+ 'is_public',
];
diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php
index 6f8ced3a6eed4..0585aaf2ee5be 100644
--- a/app/PaymentDrivers/BasePaymentDriver.php
+++ b/app/PaymentDrivers/BasePaymentDriver.php
@@ -268,7 +268,7 @@ class BasePaymentDriver
$payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now();
- return $payment;
+ return $payment->service()->applyNumber()->save();
}
diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php
index 38aa4d0b3d797..ca3668922e72c 100644
--- a/app/PaymentDrivers/Stripe/Charge.php
+++ b/app/PaymentDrivers/Stripe/Charge.php
@@ -160,7 +160,7 @@ class Charge
return false;
$payment_method_type = $response->charges->data[0]->payment_method_details->card->brand;
- info($payment_method_type);
+ //info($payment_method_type);
$data = [
'gateway_type_id' => $cgt->gateway_type_id,
diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php
index 523d9a894df32..f441b6a0075ee 100644
--- a/app/PaymentDrivers/StripePaymentDriver.php
+++ b/app/PaymentDrivers/StripePaymentDriver.php
@@ -393,9 +393,8 @@ class StripePaymentDriver extends BasePaymentDriver
$payment->date = Carbon::now();
$payment->transaction_reference = $data['transaction_reference'];
$payment->amount = $amount;
- $payment->client->getNextPaymentNumber($this->client);
$payment->save();
- return $payment;
+ return $payment->service()->applyNumber()->save();
}
}
diff --git a/app/Repositories/ActivityRepository.php b/app/Repositories/ActivityRepository.php
index 0875bcbb87ff9..d66fdca933774 100644
--- a/app/Repositories/ActivityRepository.php
+++ b/app/Repositories/ActivityRepository.php
@@ -69,6 +69,7 @@ class ActivityRepository extends BaseRepository
if (get_class($entity) == Invoice::class || get_class($entity) == Quote::class || get_class($entity) == Credit::class){
$contact = $entity->client->primary_contact()->first();
$backup->html_backup = $this->generateEntityHtml($entity->getEntityDesigner(), $entity, $contact);
+ $backup->amount = $entity->amount;
}
$backup->activity_id = $activity->id;
diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php
index 92ef24d24802b..9e30c9f212f52 100644
--- a/app/Repositories/PaymentRepository.php
+++ b/app/Repositories/PaymentRepository.php
@@ -71,8 +71,6 @@ class PaymentRepository extends BaseRepository
private function applyPayment(array $data, Payment $payment): ?Payment
{
-info(print_r($data,1));
-
//check currencies here and fill the exchange rate data if necessary
if (!$payment->id) {
$this->processExchangeRates($data, $payment);
@@ -149,10 +147,10 @@ info(print_r($data,1));
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
-/*info("invoice totals = {$invoice_totals}");
-info("credit totals = {$credit_totals}");
-info("applied totals = " . array_sum(array_column($data['invoices'], 'amount')));
-*/
+ /*info("invoice totals = {$invoice_totals}");
+ info("credit totals = {$credit_totals}");
+ info("applied totals = " . array_sum(array_column($data['invoices'], 'amount')));
+ */
//$invoice_totals -= $credit_totals;
////$payment->amount = $invoice_totals; //creates problems when setting amount like this.
diff --git a/app/Services/Quote/SendEmail.php b/app/Services/Quote/SendEmail.php
index 7444131368424..75203fb6bbefc 100644
--- a/app/Services/Quote/SendEmail.php
+++ b/app/Services/Quote/SendEmail.php
@@ -39,7 +39,7 @@ class SendEmail
* @param string $this->reminder_template The template name ie reminder1
* @return array
*/
- public function run(): array
+ public function run()
{
if (!$this->reminder_template) {
$this->reminder_template = $this->quote->calculateTemplate();
@@ -52,5 +52,7 @@ class SendEmail
EmailQuote::dispatchNow($email_builder, $invitation);
}
});
+
+ $this->quote->service()->markSent();
}
}
diff --git a/app/Transformers/CreditTransformer.php b/app/Transformers/CreditTransformer.php
index 988e5f1329a2a..b0bc6f720e58b 100644
--- a/app/Transformers/CreditTransformer.php
+++ b/app/Transformers/CreditTransformer.php
@@ -27,7 +27,6 @@ class CreditTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
- 'history',
];
protected $availableIncludes = [
@@ -136,6 +135,7 @@ class CreditTransformer extends EntityTransformer
'custom_surcharge_tax4' => (bool) $credit->custom_surcharge_tax4,
'line_items' => $credit->line_items ?: (array)[],
'entity_type' => 'credit',
+ 'exchange_rate' => (float)$credit->exchange_rate,
];
}
}
diff --git a/app/Transformers/InvoiceHistoryTransformer.php b/app/Transformers/InvoiceHistoryTransformer.php
index d9f2fa0198048..44d2d3574d919 100644
--- a/app/Transformers/InvoiceHistoryTransformer.php
+++ b/app/Transformers/InvoiceHistoryTransformer.php
@@ -35,6 +35,7 @@ class InvoiceHistoryTransformer extends EntityTransformer
'activity_id' => $this->encodePrimaryKey($backup->activity_id),
'json_backup' => (string) $backup->json_backup ?: '',
'html_backup' => (string) $backup->html_backup ?: '',
+ 'amount' => (float) $backup->amount,
'created_at' => (int)$backup->created_at,
'updated_at' => (int)$backup->updated_at,
];
diff --git a/app/Transformers/InvoiceTransformer.php b/app/Transformers/InvoiceTransformer.php
index eeb7fe76a70c2..c6737e568e6f5 100644
--- a/app/Transformers/InvoiceTransformer.php
+++ b/app/Transformers/InvoiceTransformer.php
@@ -135,6 +135,7 @@ class InvoiceTransformer extends EntityTransformer
'custom_surcharge2' => (float)$invoice->custom_surcharge2,
'custom_surcharge3' => (float)$invoice->custom_surcharge3,
'custom_surcharge4' => (float)$invoice->custom_surcharge4,
+ 'exchange_rate' => (float)$invoice->exchange_rate,
'custom_surcharge_tax1' => (bool) $invoice->custom_surcharge_tax1,
'custom_surcharge_tax2' => (bool) $invoice->custom_surcharge_tax2,
'custom_surcharge_tax3' => (bool) $invoice->custom_surcharge_tax3,
diff --git a/app/Transformers/QuoteTransformer.php b/app/Transformers/QuoteTransformer.php
index b20f6f95bf33c..14e5ba270ca4b 100644
--- a/app/Transformers/QuoteTransformer.php
+++ b/app/Transformers/QuoteTransformer.php
@@ -27,7 +27,6 @@ class QuoteTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
- 'history'
];
protected $availableIncludes = [
@@ -135,7 +134,7 @@ class QuoteTransformer extends EntityTransformer
'custom_surcharge_taxes' => (bool) $quote->custom_surcharge_taxes,
'line_items' => $quote->line_items ?: (array)[],
'entity_type' => 'quote',
-
+ 'exchange_rate' => (float)$quote->exchange_rate,
];
}
}
diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 5db0a98713609..5ed126eee41dd 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -122,7 +122,9 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_invoice').'', 'label' => ctrans('texts.view_invoice')];
+ // $data['$view_link'] = ['value' => ''. ctrans('texts.view_invoice').'', 'label' => ctrans('texts.view_invoice')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
+
}
if ($this->entity_string == 'quote') {
@@ -130,7 +132,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_quote').'', 'label' => ctrans('texts.view_quote')];
+ // $data['$view_link'] = ['value' => ''. ctrans('texts.view_quote').'', 'label' => ctrans('texts.view_quote')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
}
if ($this->entity_string == 'credit') {
@@ -138,7 +141,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_credit').'', 'label' => ctrans('texts.view_credit')];
+ // $data['$view_link'] = ['value' => ''. ctrans('texts.view_credit').'', 'label' => ctrans('texts.view_credit')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];
diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php
index c4cc4e60c1bf2..07aa4d698f034 100644
--- a/app/Utils/SystemHealth.php
+++ b/app/Utils/SystemHealth.php
@@ -82,12 +82,12 @@ class SystemHealth
exec('node -v', $foo, $exitCode);
if ($exitCode === 0) {
- return $foo[0];
+ return empty($foo[0]) ? 'Found node, but no version information' : $foo[0];
}
} catch (\Exception $e) {
- return false;
+ return false;
}
}
@@ -98,12 +98,11 @@ class SystemHealth
exec('npm -v', $foo, $exitCode);
if ($exitCode === 0) {
- return $foo[0];
+ return empty($foo[0]) ? 'Found npm, but no version information' : $foo[0];
}
}catch (\Exception $e) {
-
- return false;
+ return false;
}
}
diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php
index 27e0048f960a4..f0f38c24a7cb6 100644
--- a/app/Utils/Traits/MakesInvoiceValues.php
+++ b/app/Utils/Traits/MakesInvoiceValues.php
@@ -215,7 +215,8 @@ trait MakesInvoiceValues
$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'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_invoice').'', 'label' => ctrans('texts.view_invoice')];
+ //$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) {
@@ -223,7 +224,8 @@ trait MakesInvoiceValues
$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'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_quote').'', 'label' => ctrans('texts.view_quote')];
+ // $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) {
@@ -231,7 +233,8 @@ trait MakesInvoiceValues
$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'];
- $data['$view_link'] = ['value' => ''. ctrans('texts.view_credit').'', 'label' => ctrans('texts.view_credit')];
+ // $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'];
diff --git a/config/ninja.php b/config/ninja.php
index 358d25949ab85..47c255d610315 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -30,6 +30,7 @@ return [
'phantomjs_key' => env('PHANTOMJS_KEY', false),
'phantomjs_secret' => env('PHANTOMJS_SECRET', false),
+ 'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://b36c3ae4f26b45689bc3d4e3774fb303@sentry.invoicing.co/4'),
'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'
// Settings used by invoiceninja.com
diff --git a/config/sentry.php b/config/sentry.php
index e428cbbce5133..2669e086fa370 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -2,8 +2,8 @@
return [
- 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
-
+ //'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
+ 'dsn' => config('ninja.sentry_dsn'),
// capture release as git sha
// 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),
diff --git a/database/factories/QuoteInvitationFactory.php b/database/factories/QuoteInvitationFactory.php
new file mode 100644
index 0000000000000..2cf3b27210e6b
--- /dev/null
+++ b/database/factories/QuoteInvitationFactory.php
@@ -0,0 +1,10 @@
+define(App\Models\QuoteInvitation::class, function (Faker $faker) {
+ return [
+ 'key' => Str::random(40),
+ ];
+});
diff --git a/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php b/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php
index f5d7664aefa7e..7cc0fbb2606d3 100644
--- a/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php
+++ b/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php
@@ -13,9 +13,18 @@ class AddIsPublicToDocumentsTable extends Migration
*/
public function up()
{
+
Schema::table('documents', function (Blueprint $table) {
$table->boolean('is_public')->default(false);
});
+
+ Schema::table('backups', function (Blueprint $table) {
+ $table->decimal('amount', 16, 4);
+ });
+
+ Schema::table('company_gateways', function (Blueprint $table) {
+ $table->enum('token_billing', ['off', 'always','optin','optout'])->default('off');
+ });
}
/**
@@ -25,8 +34,6 @@ class AddIsPublicToDocumentsTable extends Migration
*/
public function down()
{
- Schema::table('documents', function (Blueprint $table) {
- $table->dropColumn('is_public');
- });
+
}
}
diff --git a/tests/Feature/CompanyGatewayApiTest.php b/tests/Feature/CompanyGatewayApiTest.php
index a3e7dc3dbac6a..4441a9f1fba25 100644
--- a/tests/Feature/CompanyGatewayApiTest.php
+++ b/tests/Feature/CompanyGatewayApiTest.php
@@ -26,6 +26,7 @@ use Tests\TestCase;
/**
* @test
+ * @covers App\Models\CompanyGateway
*/
class CompanyGatewayApiTest extends TestCase
{
@@ -352,4 +353,42 @@ class CompanyGatewayApiTest extends TestCase
$this->assertEquals(12, $company_gateway->calcGatewayFee(10));
}
+
+
+ public function testFeesAndLimitsFeePercentAndAmountAndDoubleTaxCalcuationWithFeeCap()
+ {
+ //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}}
+ $fee = new FeesAndLimits;
+ $fee->fee_amount = 10;
+ // $fee->fee_percent = 2;
+ $fee->fee_tax_name1 = 'GST';
+ $fee->fee_tax_rate1 = '10.0';
+ $fee->fee_tax_name2 = 'GST';
+ $fee->fee_tax_rate2 = '10.0';
+ $fee->fee_cap = 1;
+
+ $fee_arr[1] = (array)$fee;
+
+ $data = [
+ 'config' => 'random config',
+ 'gateway_key' => '3b6621f970ab18887c4f6dca78d3f8bb',
+ 'fees_and_limits' => $fee_arr,
+ ];
+
+ /* POST */
+ $response = $this->withHeaders([
+ 'X-API-SECRET' => config('ninja.api_secret'),
+ 'X-API-TOKEN' => $this->token
+ ])->post('/api/v1/company_gateways', $data);
+
+
+ $response->assertStatus(200);
+
+ $arr = $response->json();
+ $id = $this->decodePrimaryKey($arr['data']['id']);
+
+ $company_gateway = CompanyGateway::find($id);
+
+ $this->assertEquals(1, $company_gateway->calcGatewayFee(10));
+ }
}
diff --git a/tests/Integration/MultiDBUserTest.php b/tests/Integration/MultiDBUserTest.php
index 91bf4ac66f26d..29220cdd5c300 100644
--- a/tests/Integration/MultiDBUserTest.php
+++ b/tests/Integration/MultiDBUserTest.php
@@ -204,7 +204,8 @@ class MultiDBUserTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
- ])->post('/api/v1/users?include=company_user', $data);
+ 'X-API-PASSWORD' => 'ALongAndBriliantPassword',
+ ])->post('/api/v1/users?include=company_user', $data);
} catch (ValidationException $e) {
\Log::error('in the validator');
$message = json_decode($e->validator->getMessageBag(), 1);
diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php
index dc9b397d25fe8..d2a9df1219350 100644
--- a/tests/MockAccountData.php
+++ b/tests/MockAccountData.php
@@ -154,7 +154,7 @@ trait MockAccountData
]);
- $contact = factory(\App\Models\ClientContact::class, 1)->create([
+ $contact = factory(\App\Models\ClientContact::class)->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
@@ -162,12 +162,13 @@ trait MockAccountData
'send_email' => true,
]);
- $contact2 = factory(\App\Models\ClientContact::class, 1)->create([
+ $contact2 = factory(\App\Models\ClientContact::class)->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
'send_email' => true
]);
+
// $rels = collect($contact, $contact2);
// $this->client->setRelation('contacts', $rels);
@@ -211,7 +212,24 @@ trait MockAccountData
$this->invoice->save();
- $this->invoice->service()->createInvitations()->markSent();
+ //$this->invoice->service()->createInvitations()->markSent();
+ //$this->invoice->service()->createInvitations();
+
+ factory(\App\Models\InvoiceInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact->id,
+ 'invoice_id' => $this->invoice->id,
+ ]);
+
+ factory(\App\Models\InvoiceInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact2->id,
+ 'invoice_id' => $this->invoice->id,
+ ]);
+
+ $this->invoice->service()->markSent();
$this->quote = factory(\App\Models\Quote::class)->create([
'user_id' => $this->user->id,
@@ -229,8 +247,24 @@ trait MockAccountData
$this->quote = $this->quote_calc->getQuote();
+ $this->quote->status_id = Quote::STATUS_SENT;
$this->quote->number = $this->getNextQuoteNumber($this->client);
- $this->quote->service()->createInvitations()->markSent();
+
+ //$this->quote->service()->createInvitations()->markSent();
+
+ factory(\App\Models\QuoteInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact->id,
+ 'quote_id' => $this->quote->id,
+ ]);
+
+ factory(\App\Models\QuoteInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact2->id,
+ 'quote_id' => $this->quote->id,
+ ]);
$this->quote->setRelation('client', $this->client);
$this->quote->setRelation('company', $this->company);