Merge pull request #4315 from turbo124/v5-stable

V5.0.25
This commit is contained in:
David Bomba 2020-11-17 21:35:13 +11:00 committed by GitHub
commit dd2bd828a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
91 changed files with 127675 additions and 123875 deletions

View File

@ -1 +1 @@
5.0.24 5.0.25

View File

@ -321,9 +321,9 @@ class CheckData extends Command
Client::withTrashed()->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) { Client::withTrashed()->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
$total_invoice_payments = 0; $total_invoice_payments = 0;
foreach ($client->invoices as $invoice) { foreach ($client->invoices->where('is_deleted', false) as $invoice) {
$total_amount = $invoice->payments->sum('pivot.amount'); $total_amount = $invoice->payments->whereNull('deleted_at')->sum('pivot.amount');
$total_refund = $invoice->payments->sum('pivot.refunded'); $total_refund = $invoice->payments->whereNull('deleted_at')->sum('pivot.refunded');
$total_invoice_payments += ($total_amount - $total_refund); $total_invoice_payments += ($total_amount - $total_refund);
} }
@ -356,7 +356,7 @@ class CheckData extends Command
$wrong_paid_to_dates = 0; $wrong_paid_to_dates = 0;
Client::cursor()->each(function ($client) use ($wrong_balances) { Client::cursor()->each(function ($client) use ($wrong_balances) {
$client->invoices->where('is_deleted', false)->each(function ($invoice) use ($wrong_balances, $client) { $client->invoices->where('is_deleted', false)->whereIn('status_id', '!=', Invoice::STATUS_DRAFT)->each(function ($invoice) use ($wrong_balances, $client) {
$total_amount = $invoice->payments->sum('pivot.amount'); $total_amount = $invoice->payments->sum('pivot.amount');
$total_refund = $invoice->payments->sum('pivot.refunded'); $total_refund = $invoice->payments->sum('pivot.refunded');
$total_credit = $invoice->credits->sum('amount'); $total_credit = $invoice->credits->sum('amount');

View File

@ -88,14 +88,16 @@ class ImportMigrations extends Command
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
]); ]);
CompanyToken::unguard();
$company_token = CompanyToken::create([ $company_token = CompanyToken::create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
'account_id' => $account->id, 'account_id' => $account->id,
'name' => 'test token', 'name' => 'First token',
'token' => Str::random(64), 'token' => Str::random(64),
]); ]);
$user->companies()->attach($company->id, [ $user->companies()->attach($company->id, [
'account_id' => $account->id, 'account_id' => $account->id,
'is_owner' => 1, 'is_owner' => 1,

View File

@ -66,7 +66,7 @@ class SendRemindersCron extends Command
->cursor(); ->cursor();
$invoices->each(function ($invoice){ $invoices->each(function ($invoice){
WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice); WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company);
}); });
} }
@ -79,7 +79,7 @@ class SendRemindersCron extends Command
->cursor(); ->cursor();
$quotes->each(function ($quote){ $quotes->each(function ($quote){
WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote); WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company);
}); });
} }
} }

View File

@ -58,9 +58,9 @@ class CompanySettings extends BaseSettings
public $send_reminders = false; //@TODO public $send_reminders = false; //@TODO
public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending
public $custom_message_unpaid_invoice = ''; //@ben to implement public $custom_message_unpaid_invoice = '';
public $custom_message_paid_invoice = ''; //@ben to implement public $custom_message_paid_invoice = '';
public $custom_message_unapproved_quote = ''; //@ben to implement public $custom_message_unapproved_quote = '';
public $auto_archive_quote = false; //@implemented public $auto_archive_quote = false; //@implemented
public $auto_convert_quote = true; //@implemented public $auto_convert_quote = true; //@implemented
public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send? public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send?
@ -175,7 +175,7 @@ class CompanySettings extends BaseSettings
public $email_template_reminder3 = ''; //@implemented public $email_template_reminder3 = ''; //@implemented
public $email_template_reminder_endless = ''; //@implemented public $email_template_reminder_endless = ''; //@implemented
public $email_signature = ''; //@implemented public $email_signature = ''; //@implemented
public $enable_email_markup = true; //@TODO public $enable_email_markup = true; //@TODO -
public $email_subject_custom1 = ''; //@TODO public $email_subject_custom1 = ''; //@TODO
public $email_subject_custom2 = ''; //@TODO public $email_subject_custom2 = ''; //@TODO
@ -185,35 +185,35 @@ class CompanySettings extends BaseSettings
public $email_template_custom2 = ''; //@TODO public $email_template_custom2 = ''; //@TODO
public $email_template_custom3 = ''; //@TODO public $email_template_custom3 = ''; //@TODO
public $enable_reminder1 = false; //@partially implmemented public $enable_reminder1 = false; //@implmemented
public $enable_reminder2 = false; //@partially implmemented public $enable_reminder2 = false; //@implmemented
public $enable_reminder3 = false; //@partially implmemented public $enable_reminder3 = false; //@implmemented
public $enable_reminder_endless = false; //@partially implmemented public $enable_reminder_endless = false; //@implmemented
public $num_days_reminder1 = 0;//@partially implmemented public $num_days_reminder1 = 0;//@implmemented
public $num_days_reminder2 = 0;//@partially implmemented public $num_days_reminder2 = 0;//@implmemented
public $num_days_reminder3 = 0;//@partially implmemented public $num_days_reminder3 = 0;//@implmemented
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders @TODO
public $late_fee_amount1 = 0; //@TODO public $late_fee_amount1 = 0; //@implemented
public $late_fee_amount2 = 0; //@TODO public $late_fee_amount2 = 0; //@implemented
public $late_fee_amount3 = 0; //@TODO public $late_fee_amount3 = 0; //@implemented
public $late_fee_percent1 = 0; //@TODO public $late_fee_percent1 = 0; //@implemented
public $late_fee_percent2 = 0; //@TODO public $late_fee_percent2 = 0; //@implemented
public $late_fee_percent3 = 0; //@TODO public $late_fee_percent3 = 0; //@implemented
public $endless_reminder_frequency_id = '0'; //@implemented public $endless_reminder_frequency_id = '0'; //@implemented
public $late_fee_endless_amount = 0; //@TODO public $late_fee_endless_amount = 0; //@implemented
public $late_fee_endless_percent = 0; //@TODO public $late_fee_endless_percent = 0; //@implemented
public $client_online_payment_notification = true; //@todo implement in notifications public $client_online_payment_notification = true; //@todo implement in notifications check this bool prior to sending payment notification to client
public $client_manual_payment_notification = true; //@todo implement in notifications public $client_manual_payment_notification = true; //@todo implement in notifications check this bool prior to sending manual payment notification to client
/* Company Meta data that we can use to build sub companies*/ /* Company Meta data that we can use to build sub companies*/
@ -232,26 +232,26 @@ class CompanySettings extends BaseSettings
public $id_number = ''; //@implemented public $id_number = ''; //@implemented
public $page_size = 'A4'; //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 public $page_size = 'A4'; //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
public $font_size = 9; public $font_size = 9; //@implemented
public $primary_font = 'Roboto'; public $primary_font = 'Roboto';
public $secondary_font = 'Roboto'; public $secondary_font = 'Roboto';
public $primary_color = '#4caf50'; public $primary_color = '#4caf50';
public $secondary_color = '#2196f3'; public $secondary_color = '#2196f3';
public $hide_paid_to_date = false; //@TODO where? public $hide_paid_to_date = false; //@TODO where?
public $embed_documents = false; //@TODO public $embed_documents = false; //@TODO where?
public $all_pages_header = false; //@implemented public $all_pages_header = false; //@implemented
public $all_pages_footer = false; //@implemented public $all_pages_footer = false; //@implemented
public $pdf_variables = ''; //@implemented public $pdf_variables = ''; //@implemented
public $portal_custom_head = ''; //@TODO public $portal_custom_head = ''; //@TODO @BEN
public $portal_custom_css = ''; //@TODO public $portal_custom_css = ''; //@TODO @BEN
public $portal_custom_footer = ''; //@TODO public $portal_custom_footer = ''; //@TODO @BEN
public $portal_custom_js = ''; //@TODO public $portal_custom_js = ''; //@TODO @BEN
public $client_can_register = false; //@implemented public $client_can_register = false; //@implemented
public $client_portal_terms = ''; //@TODO public $client_portal_terms = ''; //@TODO @BEN
public $client_portal_privacy_policy = ''; //@TODO public $client_portal_privacy_policy = ''; //@TODO @BEN
public $client_portal_enable_uploads = false; //@implemented public $client_portal_enable_uploads = false; //@implemented
public $client_portal_allow_under_payment = false; //@implemented public $client_portal_allow_under_payment = false; //@implemented
public $client_portal_under_payment_minimum = 0; //@implemented public $client_portal_under_payment_minimum = 0; //@implemented
@ -511,6 +511,7 @@ class CompanySettings extends BaseSettings
/** /**
* Provides class defaults on init. * Provides class defaults on init.
*
* @return stdClass * @return stdClass
*/ */
public static function defaults(): stdClass public static function defaults(): stdClass
@ -543,6 +544,7 @@ class CompanySettings extends BaseSettings
* set new properties to the object prior to being returned. * set new properties to the object prior to being returned.
* *
* @param $settings * @param $settings
*
* @return stdClass * @return stdClass
*/ */
public static function setProperties($settings): stdClass public static function setProperties($settings): stdClass
@ -551,14 +553,19 @@ class CompanySettings extends BaseSettings
foreach ($company_settings as $key => $value) { foreach ($company_settings as $key => $value) {
if (! property_exists($settings, $key)) { if (! property_exists($settings, $key)) {
$settings->{ $key} = self::castAttribute($key, $company_settings->{ $key}); $settings->{$key} = self::castAttribute($key, $company_settings->{$key});
} }
} }
return $settings; return $settings;
} }
public static function notificationDefaults() /**
* Stubs the notification defaults
*
* @return stdClass
*/
public static function notificationDefaults() :stdClass
{ {
$notification = new stdClass; $notification = new stdClass;
$notification->email = ['all_notifications']; $notification->email = ['all_notifications'];
@ -566,12 +573,16 @@ class CompanySettings extends BaseSettings
return $notification; return $notification;
} }
private static function getEntityVariableDefaults() /**
* Defines entity variables for PDF generation
*
* @return stdClass The stdClass of PDF variables
*/
private static function getEntityVariableDefaults() :stdClass
{ {
$variables = [ $variables = [
'client_details' => [ 'client_details' => [
'$client.name', '$client.name',
'$client.id_number',
'$client.vat_number', '$client.vat_number',
'$client.address1', '$client.address1',
'$client.address2', '$client.address2',
@ -618,19 +629,17 @@ class CompanySettings extends BaseSettings
], ],
'product_columns' => [ 'product_columns' => [
'$product.product_key', '$product.product_key',
'$product.notes', '$product.description',
'$product.cost', '$product.unit_cost',
'$product.quantity', '$product.quantity',
'$product.discount',
'$product.tax', '$product.tax',
'$product.line_total', '$product.line_total',
], ],
'task_columns' =>[ 'task_columns' =>[
'$task.product_key', '$task.product_key',
'$task.notes', '$task.description',
'$task.rate', '$task.rate',
'$task.hours', '$task.hours',
'$task.discount',
'$task.tax', '$task.tax',
'$task.line_total', '$task.line_total',
], ],

View File

@ -11,8 +11,15 @@
namespace App\Events\Payment; namespace App\Events\Payment;
use App\Models\Client;
use App\Models\Company; use App\Models\Company;
use App\Models\Payment; use App\Models\Payment;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
@ -20,7 +27,7 @@ use Illuminate\Queue\SerializesModels;
*/ */
class PaymentWasEmailed class PaymentWasEmailed
{ {
use SerializesModels; use Dispatchable, InteractsWithSockets, SerializesModels;
/** /**
* @var Payment * @var Payment

View File

@ -11,15 +11,23 @@
namespace App\Events\Payment; namespace App\Events\Payment;
use App\Models\Client;
use App\Models\Company;
use App\Models\Payment; use App\Models\Payment;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class InvoiceWasEmailedAndFailed. * Class PaymentWasEmailedAndFailed.
*/ */
class PaymentWasEmailedAndFailed class PaymentWasEmailedAndFailed
{ {
use SerializesModels; use Dispatchable, InteractsWithSockets, SerializesModels;
/** /**
* @var Payment * @var Payment
@ -39,7 +47,7 @@ class PaymentWasEmailedAndFailed
* @param array $errors * @param array $errors
* @param array $event_vars * @param array $event_vars
*/ */
public function __construct(Payment $payment, $company, array $errors, array $event_vars) public function __construct(Payment $payment, Company $company, array $errors, array $event_vars)
{ {
$this->payment = $payment; $this->payment = $payment;

View File

@ -46,7 +46,7 @@ class Handler extends ExceptionHandler
*/ */
protected $dontReport = [ protected $dontReport = [
PDOException::class, PDOException::class,
Swift_TransportException::class, //Swift_TransportException::class,
MaxAttemptsExceededException::class, MaxAttemptsExceededException::class,
CommandNotFoundException::class, CommandNotFoundException::class,
]; ];

View File

@ -207,14 +207,17 @@ class InvoiceSum
private function setCalculatedAttributes() private function setCalculatedAttributes()
{ {
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */ /* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
if ($this->invoice->amount != $this->invoice->balance) {
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date; if($this->invoice->status_id != Invoice::STATUS_DRAFT)
} else { {
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); if ($this->invoice->amount != $this->invoice->balance) {
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
} else {
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
}
} }
/* Set new calculated total */ /* Set new calculated total */
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); $this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);

View File

@ -168,11 +168,13 @@ class LoginController extends BaseController
$user = $this->guard()->user(); $user = $this->guard()->user();
$user->setCompany($user->company_user->account->default_company); $user->setCompany($user->account->default_company);
$ct = CompanyUser::whereUserId($user->id); $cu = CompanyUser::query()
->where('user_id', auth()->user()->id);
return $this->listResponse($cu);
return $this->listResponse($ct);
} else { } else {
LightLogs::create(new LoginFailure()) LightLogs::create(new LoginFailure())
->increment() ->increment()
@ -280,9 +282,10 @@ class LoginController extends BaseController
Auth::login($existing_user, true); Auth::login($existing_user, true);
$existing_user->setCompany($existing_user->account->default_company); $existing_user->setCompany($existing_user->account->default_company);
$ct = CompanyUser::whereUserId(auth()->user()->id); $cu = CompanyUser::query()
->where('user_id', auth()->user()->id);
return $this->listResponse($ct); return $this->listResponse($cu);
} }
} }

View File

@ -21,6 +21,7 @@ use App\Utils\Ninja;
use App\Utils\Statics; use App\Utils\Statics;
use App\Utils\Traits\AppSetup; use App\Utils\Traits\AppSetup;
use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request as Input; use Illuminate\Support\Facades\Request as Input;
@ -68,7 +69,7 @@ class BaseController extends Controller
'company.task_statuses', 'company.task_statuses',
'company.expense_categories', 'company.expense_categories',
'company.documents', 'company.documents',
'company.users.company_user', //'company.users.company_user',
'company.clients.contacts.company', 'company.clients.contacts.company',
'company.clients.gateway_tokens', 'company.clients.gateway_tokens',
'company.clients.documents', 'company.clients.documents',
@ -107,7 +108,7 @@ class BaseController extends Controller
'user.company_user', 'user.company_user',
'token', 'token',
'company.activities', 'company.activities',
'company.users.company_user', //'company.users.company_user',
'company.tax_rates', 'company.tax_rates',
'company.groups', 'company.groups',
'company.payment_terms', 'company.payment_terms',
@ -130,7 +131,6 @@ class BaseController extends Controller
$include = implode(',', array_merge($this->forced_includes, $this->getRequestIncludes([]))); $include = implode(',', array_merge($this->forced_includes, $this->getRequestIncludes([])));
} elseif (request()->input('include') !== null) { } elseif (request()->input('include') !== null) {
$include = array_merge($this->forced_includes, explode(',', request()->input('include'))); $include = array_merge($this->forced_includes, explode(',', request()->input('include')));
$include = implode(',', $include); $include = implode(',', $include);
} elseif (count($this->forced_includes) >= 1) { } elseif (count($this->forced_includes) >= 1) {
$include = implode(',', $this->forced_includes); $include = implode(',', $this->forced_includes);
@ -218,7 +218,7 @@ class BaseController extends Controller
$query->whereNotNull('updated_at'); $query->whereNotNull('updated_at');
}, },
'company.credits'=> function ($query) use ($updated_at) { 'company.credits'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents',); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
}, },
'company.designs'=> function ($query) use ($updated_at) { 'company.designs'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('company'); $query->where('updated_at', '>=', $updated_at)->with('company');
@ -227,7 +227,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
}, },
'company.expenses'=> function ($query) use ($updated_at) { 'company.expenses'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('documents' ); $query->where('updated_at', '>=', $updated_at)->with('documents');
}, },
'company.groups' => function ($query) use ($updated_at) { 'company.groups' => function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
@ -236,7 +236,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents'); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
}, },
'company.payments'=> function ($query) use ($updated_at) { 'company.payments'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('paymentables','documents', ); $query->where('updated_at', '>=', $updated_at)->with('paymentables','documents');
}, },
'company.payment_terms'=> function ($query) use ($updated_at) { 'company.payment_terms'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
@ -248,7 +248,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at)->with('documents' ); $query->where('updated_at', '>=', $updated_at)->with('documents' );
}, },
'company.quotes'=> function ($query) use ($updated_at) { 'company.quotes'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents',); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
}, },
'company.recurring_invoices'=> function ($query) use ($updated_at) { 'company.recurring_invoices'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents'); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
@ -260,7 +260,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
}, },
'company.vendors'=> function ($query) use ($updated_at) { 'company.vendors'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('contacts','documents' ); $query->where('updated_at', '>=', $updated_at)->with('contacts','documents');
}, },
'company.expense_categories'=> function ($query) use ($updated_at) { 'company.expense_categories'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
@ -271,8 +271,8 @@ class BaseController extends Controller
] ]
); );
if (is_a($query, "Illuminate\Database\Eloquent\Builder")) { if ($query instanceof Builder) {
$limit = Input::get('per_page', 20); $limit = request()->input('per_page', 20);
$paginator = $query->paginate($limit); $paginator = $query->paginate($limit);
$query = $paginator->getCollection(); $query = $paginator->getCollection();
@ -289,7 +289,7 @@ class BaseController extends Controller
{ {
$this->buildManager(); $this->buildManager();
$transformer = new $this->entity_transformer(Input::get('serializer')); $transformer = new $this->entity_transformer(request()->input('serializer'));
$includes = $transformer->getDefaultIncludes(); $includes = $transformer->getDefaultIncludes();
@ -297,40 +297,27 @@ class BaseController extends Controller
$query->with($includes); $query->with($includes);
if (auth()->user() && ! auth()->user()->hasPermission('view_'.lcfirst(class_basename($this->entity_type)))) { if (auth()->user() && ! auth()->user()->hasPermission('view_'.lcfirst(class_basename($this->entity_type))))
$query->where('user_id', '=', auth()->user()->id); $query->where('user_id', '=', auth()->user()->id);
}
if (request()->has('updated_at') && request()->input('updated_at') > 0) { if (request()->has('updated_at') && request()->input('updated_at') > 0)
$updated_at = intval(request()->input('updated_at')); $query->where('updated_at', '>=', date('Y-m-d H:i:s', intval(request()->input('updated_at'))));
$query->where('updated_at', '>=', date('Y-m-d H:i:s', $updated_at));
}
$data = $this->createCollection($query, $transformer, $this->entity_type); if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON)
$this->entity_type = null;
return $this->response($data);
}
protected function createCollection($query, $transformer, $entity_type)
{
$this->buildManager();
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
$entity_type = null;
}
if (is_a($query, "Illuminate\Database\Eloquent\Builder")) {
$limit = Input::get('per_page', 20);
if ($query instanceof Builder) {
$limit = request()->input('per_page', 20);
$paginator = $query->paginate($limit); $paginator = $query->paginate($limit);
$query = $paginator->getCollection(); $query = $paginator->getCollection();
$resource = new Collection($query, $transformer, $entity_type); $resource = new Collection($query, $transformer, $this->entity_type);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
} else { } else {
$resource = new Collection($query, $transformer, $entity_type); $resource = new Collection($query, $transformer, $this->entity_type);
} }
return $this->manager->createData($resource)->toArray(); return $this->response($this->manager->createData($resource)->toArray());
} }
protected function response($response) protected function response($response)
@ -368,26 +355,17 @@ class BaseController extends Controller
{ {
$this->buildManager(); $this->buildManager();
$transformer = new $this->entity_transformer(Input::get('serializer')); $transformer = new $this->entity_transformer(request()->input('serializer'));
$data = $this->createItem($item, $transformer, $this->entity_type); if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON)
$this->entity_type = null;
$resource = new Item($item, $transformer, $this->entity_type);
if (auth()->user() && request()->include_static) { if (auth()->user() && request()->include_static)
$data['static'] = Statics::company(auth()->user()->getCompany()->getLocale()); $data['static'] = Statics::company(auth()->user()->getCompany()->getLocale());
}
return $this->response($data); return $this->response($this->manager->createData($resource)->toArray());
}
protected function createItem($data, $transformer, $entity_type)
{
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
$entity_type = null;
}
$resource = new Item($data, $transformer, $entity_type);
return $this->manager->createData($resource)->toArray();
} }
public static function getApiHeaders($count = 0) public static function getApiHeaders($count = 0)
@ -429,7 +407,7 @@ class BaseController extends Controller
public function flutterRoute() public function flutterRoute()
{ {
// if ((bool) $this->checkAppSetup() !== false && Schema::hasTable('accounts') && $account = Account::first()) {
if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) { if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) {
if (config('ninja.require_https') && ! request()->isSecure()) { if (config('ninja.require_https') && ! request()->isSecure()) {
return redirect()->secure(request()->getRequestUri()); return redirect()->secure(request()->getRequestUri());
@ -443,7 +421,7 @@ class BaseController extends Controller
$data['report_errors'] = true; $data['report_errors'] = true;
} }
$data['hash'] = md5(public_path('main.dart.js')); // $data['hash'] = md5_file(public_path('main.dart.js'));
$this->buildCache(); $this->buildCache();

View File

@ -729,6 +729,7 @@ class InvoiceController extends BaseController
$invoice->service()->touchReminder($this->reminder_template)->save(); $invoice->service()->touchReminder($this->reminder_template)->save();
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) { $invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
info("firing email");
EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template); EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template);
}); });

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Invoice Ninja (https://invoiceninja.com). * Invoice Ninja (https://invoiceninja.com).
* *
@ -198,204 +199,124 @@ class MigrationController extends BaseController
* @param Company $company * @param Company $company
* @return \Illuminate\Http\JsonResponse|void * @return \Illuminate\Http\JsonResponse|void
*/ */
public function startMigration(Request $request, Company $company) public function startMigration(Request $request)
{ {
$user = auth()->user(); $companies = json_decode($request->companies);
if (app()->environment() === 'local') { if (app()->environment() === 'local') {
info([ info($request->all());
'Company key' => $company->company_key,
'Request key' => $request->company_key,
]);
} }
$existing_company = Company::where('company_key', $request->company_key)->first(); foreach ($companies as $company) {
$is_valid = $request->file($company->company_key)->isValid();
$checks = [ if (!$is_valid) {
'same_keys' => $request->company_key == $company->company_key, // We might want to send user something's wrong with migration or nope?
'existing_company' => (bool) $existing_company,
'with_force' => (bool) ($request->has('force') && ! empty($request->force)),
];
// If same company keys, and force provided. continue;
if ($checks['same_keys'] && $checks['with_force']) {
info('Migrating: Same company keys, with force.');
if ($company) {
$this->purgeCompany($company);
} }
$account = auth()->user()->account; $user = auth()->user();
$company = (new ImportMigrations())->getCompany($account);
$company->is_disabled = true;
$company->save();
$account->default_company_id = $company->id; // Look for possible existing company (based on company keys).
$account->save(); $existing_company = Company::where('company_key', $request->company_key)->first();
$company_token = new CompanyToken(); $checks = [
$company_token->user_id = $user->id; 'existing_company' => (bool) $existing_company,
$company_token->company_id = $company->id; 'force' => property_exists($company, 'force') ? (bool) $company->force : false,
$company_token->account_id = $account->id; ];
$company_token->name = $request->token_name ?? Str::random(12);
$company_token->token = $request->token ?? Str::random(64);
$company_token->is_system = true;
$company_token->save();
$user->companies()->attach($company->id, [ // If there's existing company and ** no ** force is provided - skip migration.
'account_id' => $account->id, if ($checks['existing_company'] == true && $checks['force'] == false) {
'is_owner' => 1, info('Migrating: Existing company without force. (CASE_01)');
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
}
// If keys are same and no force has been provided. MailRouter::dispatch(new ExistingMigration(), $company, $user);
if ($checks['same_keys'] && ! $checks['with_force']) {
info('Migrating: Same company keys, no force provided.');
MailRouter::dispatch(new ExistingMigration(), $company, $user); return response()->json([
'_id' => Str::uuid(),
return response()->json([ 'method' => config('queue.default'),
'_id' => Str::uuid(), 'started_at' => now(),
'method' => config('queue.default'), ], 200);
'started_at' => now(),
], 200);
}
// If keys ain't same, but existing company without force.
if (! $checks['same_keys'] && $checks['existing_company'] && ! $checks['with_force']) {
info('Migrating: Different keys, existing company with the key without the force option.');
MailRouter::dispatch(new ExistingMigration(), $company, $user);
return response()->json([
'_id' => Str::uuid(),
'method' => config('queue.default'),
'started_at' => now(),
], 200);
}
// If keys ain't same, but existing company with force.
if (! $checks['same_keys'] && $checks['existing_company'] && $checks['with_force']) {
info('Migrating: Different keys, existing company with force option.');
if ($company) {
$this->purgeCompany($company);
} }
$account = auth()->user()->account; // If there's existing company and force ** is provided ** - purge the company and migrate again.
$company = (new ImportMigrations())->getCompany($account); if ($checks['existing_company'] == true && $checks['force'] == true) {
$company->is_disabled = true;
$company->save();
$account->default_company_id = $company->id;
$account->save();
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
$company_token->name = $request->token_name ?? Str::random(12);
$company_token->token = $request->token ?? Str::random(64);
$company_token->is_system = true;
$company_token->save();
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
}
// If keys ain't same, but with force.
if (! $checks['same_keys'] && $checks['with_force']) {
info('Migrating: Different keys with force.');
if ($existing_company) {
$this->purgeCompany($existing_company); $this->purgeCompany($existing_company);
$account = auth()->user()->account;
$fresh_company = (new ImportMigrations())->getCompany($account);
$fresh_company->is_disabled = true;
$fresh_company->save();
$account->default_company_id = $fresh_company->id;
$account->save();
$fresh_company_token = new CompanyToken();
$fresh_company_token->user_id = $user->id;
$fresh_company_token->company_id = $fresh_company->id;
$fresh_company_token->account_id = $account->id;
$fresh_company_token->name = $request->token_name ?? Str::random(12);
$fresh_company_token->token = $request->token ?? Str::random(64);
$fresh_company_token->is_system = true;
$fresh_company_token->save();
$user->companies()->attach($fresh_company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
} }
$account = auth()->user()->account; // If there's no existing company migrate just normally.
$company = (new ImportMigrations())->getCompany($account); if ($checks['existing_company'] == false) {
$account = auth()->user()->account;
$company->is_disabled = true; $fresh_company = (new ImportMigrations())->getCompany($account);
$company->save();
$account->default_company_id = $company->id;
$account->save();
$company_token = new CompanyToken(); $fresh_company->is_disabled = true;
$company_token->user_id = $user->id; $fresh_company->save();
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
$company_token->name = $request->token_name ?? Str::random(12);
$company_token->token = $request->token ?? Str::random(64);
$company_token->is_system = true;
$company_token->save(); $fresh_company_token = new CompanyToken();
$fresh_company_token->user_id = $user->id;
$fresh_company_token->company_id = $fresh_company->id;
$fresh_company_token->account_id = $account->id;
$fresh_company_token->name = $request->token_name ?? Str::random(12);
$fresh_company_token->token = $request->token ?? Str::random(64);
$fresh_company_token->is_system = true;
$user->companies()->attach($company->id, [ $fresh_company_token->save();
'account_id' => $account->id,
'is_owner' => 1, $user->companies()->attach($fresh_company->id, [
'is_admin' => 1, 'account_id' => $account->id,
'is_locked' => 0, 'is_owner' => 1,
'notifications' => CompanySettings::notificationDefaults(), 'is_admin' => 1,
'permissions' => '', 'is_locked' => 0,
'settings' => null, 'notifications' => CompanySettings::notificationDefaults(),
]); 'permissions' => '',
'settings' => null,
]);
}
$migration_file = $request->file($company->company_key)
->storeAs(
'migrations',
$request->file($company->company_key)->getClientOriginalName()
);
if (app()->environment() == 'testing') {
return;
}
try {
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(60));
} catch (\Exception $e) {
info($e->getMessage());
}
} }
// If keys ain't same, fresh migrate.
if (! $checks['same_keys'] && ! $checks['with_force']) {
info('Migrating: Vanilla, fresh migrate.');
$account = auth()->user()->account;
$company = (new ImportMigrations())->getCompany($account);
$company->is_disabled = true;
$company->save();
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
$company_token->name = $request->token_name ?? Str::random(12);
$company_token->token = $request->token ?? Str::random(64);
$company_token->is_system = true;
$company_token->save();
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
}
$migration_file = $request->file('migration')
->storeAs('migrations', $request->file('migration')->getClientOriginalName());
if (app()->environment() == 'testing') {
return;
}
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $company)->delay(now()->addSeconds(60));
return response()->json([ return response()->json([
'_id' => Str::uuid(), '_id' => Str::uuid(),
'method' => config('queue.default'), 'method' => config('queue.default'),

View File

@ -438,11 +438,13 @@ class PaymentController extends BaseController
*/ */
public function destroy(DestroyPaymentRequest $request, Payment $payment) public function destroy(DestroyPaymentRequest $request, Payment $payment)
{ {
$payment->service()->reversePayment(); // $payment->service()->deletePayment();
$payment->is_deleted = true; // $payment->is_deleted = true;
$payment->save(); // $payment->save();
$payment->delete(); // $payment->delete();
$this->payment_repo->delete($payment);
return $this->itemResponse($payment); return $this->itemResponse($payment);
} }

View File

@ -58,7 +58,7 @@ class TokenAuth
}); });
//user who once existed, but has been soft deleted //user who once existed, but has been soft deleted
if ($user->company_user->is_locked) { if ($company_token->company_user->is_locked) {
$error = [ $error = [
'message' => 'User access locked', 'message' => 'User access locked',
'errors' => new stdClass, 'errors' => new stdClass,

View File

@ -39,7 +39,8 @@ class StoreExpenseRequest extends Request
{ {
$rules = []; $rules = [];
$rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id; $rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id);
// $rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
$rules['contacts.*.email'] = 'nullable|distinct'; $rules['contacts.*.email'] = 'nullable|distinct';
//$rules['number'] = new UniqueExpenseNumberRule($this->all()); //$rules['number'] = new UniqueExpenseNumberRule($this->all());
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id; $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;

View File

@ -42,9 +42,8 @@ class UpdateExpenseRequest extends Request
//$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; //$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id;
$rules['contacts.*.email'] = 'nullable|distinct'; $rules['contacts.*.email'] = 'nullable|distinct';
if ($this->input('number')) { if(isset($this->number))
$rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.$this->expense->company_id; $rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }

View File

@ -69,7 +69,9 @@ class StoreInvoiceRequest extends Request
$input = $this->decodePrimaryKeys($input); $input = $this->decodePrimaryKeys($input);
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
$input['amount'] = 0;
$input['balance'] = 0;
$this->replace($input); $this->replace($input);
} }
} }

View File

@ -33,9 +33,8 @@ class UpdateProjectRequest extends Request
{ {
$rules = []; $rules = [];
if ($this->input('number')) { if(isset($this->number))
$rules['number'] = 'unique:projects,number,'.$this->id.',id,company_id,'.$this->project->company_id; $rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }
@ -44,6 +43,9 @@ class UpdateProjectRequest extends Request
{ {
$input = $this->decodePrimaryKeys($this->all()); $input = $this->decodePrimaryKeys($this->all());
if(isset($input['client_id']))
unset($input['client_id']);
$this->replace($input); $this->replace($input);
} }
} }

View File

@ -18,6 +18,7 @@ use App\Jobs\Company\CreateCompanyPaymentTerms;
use App\Jobs\Company\CreateCompanyTaskStatuses; use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Jobs\Company\CreateCompanyToken; use App\Jobs\Company\CreateCompanyToken;
use App\Jobs\User\CreateUser; use App\Jobs\User\CreateUser;
use App\Jobs\Util\VersionCheck;
use App\Models\Account; use App\Models\Account;
use App\Models\User; use App\Models\User;
use App\Notifications\Ninja\NewAccountCreated; use App\Notifications\Ninja\NewAccountCreated;
@ -93,6 +94,8 @@ class CreateAccount
$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja(); $sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
VersionCheck::dispatchNow();
LightLogs::create(new AnalyticsAccountCreated()) LightLogs::create(new AnalyticsAccountCreated())
->increment() ->increment()
->batch(); ->batch();

View File

@ -116,13 +116,13 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
$this->invitation->contact->client $this->invitation->contact->client
) )
); );
} catch (Swift_TransportException $e) { } catch (\Exception $e) {
$this->failed($e);
$this->entityEmailFailed($e->getMessage()); $this->entityEmailFailed($e->getMessage());
$this->logMailError($e->getMessage(), $this->entity->client);
} }
if (count(Mail::failures()) > 0) { if (count(Mail::failures()) == 0) {
$this->logMailError(Mail::failures(), $this->entity->client);
} else {
$this->entityEmailSucceeded(); $this->entityEmailSucceeded();
} }
@ -130,19 +130,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
$this->entity->service()->markSent()->save(); $this->entity->service()->markSent()->save();
} }
public function failed($exception = null)
{
info('the job failed');
$job_failure = new EmailInvoiceFailure();
$job_failure->string_metric5 = $this->entity_string;
$job_failure->string_metric6 = $exception->getMessage();
LightLogs::create($job_failure)
->batch();
}
private function resolveEntityString() :string private function resolveEntityString() :string
{ {
if($this->invitation instanceof InvoiceInvitation) if($this->invitation instanceof InvoiceInvitation)

View File

@ -94,9 +94,15 @@ class ZipInvoices extends BaseMailerJob implements ShouldQueue
$this->setMailDriver(); $this->setMailDriver();
Mail::to($this->email) try {
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company)); Mail::to($this->email)
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
}
catch (\Exception $e) {
$this->failed($e);
}
UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1)); UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1));
} }
} }

View File

@ -12,8 +12,10 @@
namespace App\Jobs\Mail; namespace App\Jobs\Mail;
use App\DataMapper\Analytics\EmailFailure; use App\DataMapper\Analytics\EmailFailure;
use App\Jobs\Util\SystemLogger;
use App\Libraries\Google\Google; use App\Libraries\Google\Google;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\SystemLog;
use App\Models\User; use App\Models\User;
use App\Providers\MailServiceProvider; use App\Providers\MailServiceProvider;
use App\Utils\Ninja; use App\Utils\Ninja;
@ -75,7 +77,7 @@ class BaseMailerJob implements ShouldQueue
} }
public function logMailError($errors, $recipient_object) public function logMailError($errors, $recipient_object)
{info(print_r($errors,1)); {
SystemLogger::dispatch( SystemLogger::dispatch(
$errors, $errors,
SystemLog::CATEGORY_MAIL, SystemLog::CATEGORY_MAIL,

View File

@ -90,15 +90,9 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
Mail::to($this->user->email) Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
} catch (Swift_TransportException $e) { } catch (\Exception $e) {
$this->failed($e->getMessage()); $this->failed($e);
//$this->entityEmailFailed($e->getMessage()); $this->logMailError($e->getMessage(), $this->payment->client);
}
if (count(Mail::failures()) > 0) {
$this->logMailError(Mail::failures(), $this->payment->client);
} else {
// $this->entityEmailSucceeded();
} }
} }

View File

@ -88,13 +88,15 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build(); $mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()]; $mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
//send email try {
Mail::to($this->user->email) Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
}catch(\Exception $e) {
$this->failed($e);
$this->logMailError($e->getMessage(), $this->entity->client);
//catch errors
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures(), $this->entity->client);
} }
} }
} }

View File

@ -89,12 +89,15 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()]; $mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
//send email //send email
Mail::to($this->user->email) try{
->send(new EntityNotificationMailer($mail_obj)); Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj));
}
catch (\Exception $e) {
$this->failed($e);
$this->logMailError($e->getMessage(), $this->entity->client);
//catch errors
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures(), $this->invoice->client);
} }
} }
} }

View File

@ -22,7 +22,6 @@ use App\Models\Company;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\Models\User; use App\Models\User;
use App\Providers\MailServiceProvider; use App\Providers\MailServiceProvider;
use Dacastro4\LaravelGmail\Services\Message\Mail;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
@ -77,12 +76,16 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
$this->setMailDriver(); $this->setMailDriver();
//send email //send email
Mail::to($this->to_user->email) try {
->send($this->mailable); Mail::to($this->to_user->email)
->send($this->mailable);
//catch errors
if (count(Mail::failures()) > 0) {
$this->logMailError(Mail::failures(), $this->to_user);
} }
catch (\Exception $e) {
$this->failed($e);
$this->logMailError($e->getMessage(), $this->to_user);
}
} }
} }

View File

@ -100,13 +100,17 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
$mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()]; $mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()];
//send email //send email
Mail::to($company_user->user->email) try {
->send(new EntityNotificationMailer($mail_obj)); Mail::to($company_user->user->email)
->send(new EntityNotificationMailer($mail_obj));
//catch errors
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures(), $this->client);
} }
catch(\Exception $e) {
$this->failed($e);
$this->logMailError($e->getMessage(), $this->client);
}
} }
}); });
} }

View File

@ -1,4 +1,13 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Jobs\Payment; namespace App\Jobs\Payment;
@ -64,6 +73,7 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
if($this->company->is_disabled) if($this->company->is_disabled)
return true; return true;
@ -76,13 +86,18 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build(); $email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
Mail::to($this->contact->email, $this->contact->present()->name()) try{
->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
if (count(Mail::failures()) > 0) { $mail = Mail::to($this->contact->email, $this->contact->present()->name());
event(new PaymentWasEmailedAndFailed($this->payment, Mail::failures(), Ninja::eventVars())); $mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
}catch(\Exception $e) {
info("mailing failed with message " . $e->getMessage());
event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars()));
$this->failed($e);
return $this->logMailError($e->getMessage(), $this->payment->client);
return $this->logMailError(Mail::failures());
} }
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars())); event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars()));
@ -90,17 +105,5 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
} }
} }
public function failed($exception = null)
{
info('the job failed');
$job_failure = new EmailInvoiceFailure();
$job_failure->string_metric5 = 'payment';
$job_failure->string_metric6 = $exception->getMessage();
LightLogs::create($job_failure)
->batch();
}
} }

View File

@ -56,8 +56,6 @@ class SendRecurring implements ShouldQueue
*/ */
public function handle() : void public function handle() : void
{ {
info(" in the handle ");
// Generate Standard Invoice // Generate Standard Invoice
$invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client); $invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client);
@ -99,8 +97,9 @@ class SendRecurring implements ShouldQueue
$this->recurring_invoice->save(); $this->recurring_invoice->save();
if ($invoice->invitations->count() > 0) //this is duplicated!!
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); // if ($invoice->invitations->count() > 0)
// event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
} }

View File

@ -72,16 +72,21 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
$mail_obj->data = $this->getData(); $mail_obj->data = $this->getData();
//Send email via a Mailable class //Send email via a Mailable class
//
try {
Mail::to($this->old_email) Mail::to($this->old_email)
->send(new UserNotificationMailer($mail_obj)); ->send(new UserNotificationMailer($mail_obj));
Mail::to($this->new_email) Mail::to($this->new_email)
->send(new UserNotificationMailer($mail_obj)); ->send(new UserNotificationMailer($mail_obj));
//Catch errors and report.
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures(), $this->company);
} }
catch (\Exception $e) {
$this->failed($e);
$this->logMailError($e->getMessage(), $this->company->owner());
}
} }
private function getData() private function getData()

View File

@ -1191,6 +1191,8 @@ class Import implements ShouldQueue
if (! $user) { if (! $user) {
$user = UserFactory::create($this->company->account->id); $user = UserFactory::create($this->company->account->id);
} }
info("getting user id = {$user->id} - {$user->email}");
return $user; return $user;
} }

View File

@ -51,11 +51,11 @@ class StartMigration implements ShouldQueue
* @param User $user * @param User $user
* @param Company $company * @param Company $company
*/ */
public $tries = 1; public $tries = 0;
public $timeout = 86400; public $timeout = 86400;
public $backoff = 86430; //public $backoff = 86430;
public function __construct($filepath, User $user, Company $company) public function __construct($filepath, User $user, Company $company)
{ {
@ -108,7 +108,6 @@ class StartMigration implements ShouldQueue
$data = json_decode(file_get_contents($file), 1); $data = json_decode(file_get_contents($file), 1);
Import::dispatchNow($data, $this->company, $this->user); Import::dispatchNow($data, $this->company, $this->user);
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) { } catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage())); Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));

View File

@ -21,6 +21,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use App\Libraries\MultiDB;
class WebhookHandler implements ShouldQueue class WebhookHandler implements ShouldQueue
{ {
@ -30,16 +31,18 @@ class WebhookHandler implements ShouldQueue
private $event_id; private $event_id;
private $company;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param $event_id * @param $event_id
* @param $entity * @param $entity
*/ */
public function __construct($event_id, $entity) public function __construct($event_id, $entity, $company)
{ {
$this->event_id = $event_id; $this->event_id = $event_id;
$this->entity = $entity; $this->entity = $entity;
$this->company = $company;
} }
/** /**
@ -49,6 +52,9 @@ class WebhookHandler implements ShouldQueue
*/ */
public function handle() :bool public function handle() :bool
{//todo set multidb here {//todo set multidb here
MultiDB::setDb($this->company->db);
if (! $this->entity->company || $this->entity->company->is_disabled) { if (! $this->entity->company || $this->entity->company->is_disabled) {
return true; return true;
} }

View File

@ -57,15 +57,6 @@ class PaymentCreatedActivity implements ShouldQueue
$fields->company_id = $payment->company_id; $fields->company_id = $payment->company_id;
$fields->activity_type_id = Activity::CREATE_PAYMENT; $fields->activity_type_id = Activity::CREATE_PAYMENT;
/*todo tests fail for this for some reason?*/
// foreach ($invoices as $invoice) { //todo we may need to add additional logic if in the future we apply payments to other entity Types, not just invoices
// $fields->invoice_id = $invoice->id;
// InvoiceWorkflowSettings::dispatchNow($invoice);
// $this->activity_repo->save($fields, $invoice, $event->event_vars);
// }
if (count($invoices) == 0) { if (count($invoices) == 0) {
$this->activity_repo->save($fields, $payment, $event->event_vars); $this->activity_repo->save($fields, $payment, $event->event_vars);
} }

View File

@ -60,12 +60,9 @@ class InvoiceEmailedNotification implements ShouldQueue
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
unset($methods[$key]); unset($methods[$key]);
//Fire mail notification here!!!
//This allows us better control of how we
//handle the mailer
EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company); EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company);
$first_notification_sent = false; $first_notification_sent = false;
} }
$notification->method = $methods; $notification->method = $methods;

View File

@ -0,0 +1,57 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Payment;
use App\Jobs\Mail\EntityPaidMailer;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Models\Invoice;
use App\Models\Payment;
use App\Notifications\Admin\NewPaymentNotification;
use App\Repositories\ActivityRepository;
use App\Utils\Ninja;
use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Notification;
class PaymentEmailFailureActivity implements ShouldQueue
{
use UserNotifies;
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
}
/**
* Handle the event.
*
* @param object $event
* @return bool
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$payment = $event->payment;
info("i failed emailing {$payment->number}");
// info(print_r($event->errors,1));
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Payment;
use App\Jobs\Mail\EntityPaidMailer;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Models\Invoice;
use App\Models\Payment;
use App\Notifications\Admin\NewPaymentNotification;
use App\Repositories\ActivityRepository;
use App\Utils\Ninja;
use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Notification;
class PaymentEmailedActivity implements ShouldQueue
{
use UserNotifies;
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
}
/**
* Handle the event.
*
* @param object $event
* @return bool
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$payment = $event->payment;
info("i succeeded in emailing payment {$payment->number}");
}
}

View File

@ -54,8 +54,15 @@ class TemplateEmail extends Mailable
$company = $this->client->company; $company = $this->client->company;
$message = $this->from($this->user->email, $this->user->present()->name())//todo this needs to be fixed to handle the hosted version $this->from($this->user->email, $this->user->present()->name());
->subject($this->build_email->getSubject())
if(strlen($settings->reply_to_email) > 1)
$this->replyTo($settings->reply_to_email, $settings->reply_to_email);
if(strlen($settings->bcc_email) > 1)
$this->bcc($settings->bcc_email, $settings->bcc_email);
$this->subject($this->build_email->getSubject())
->text('email.template.plain', [ ->text('email.template.plain', [
'body' => $this->build_email->getBody(), 'body' => $this->build_email->getBody(),
'footer' => $this->build_email->getFooter(), 'footer' => $this->build_email->getFooter(),
@ -78,10 +85,10 @@ class TemplateEmail extends Mailable
//conditionally attach files //conditionally attach files
if ($settings->pdf_email_attachment !== false && ! empty($this->build_email->getAttachments())) { if ($settings->pdf_email_attachment !== false && ! empty($this->build_email->getAttachments())) {
foreach ($this->build_email->getAttachments() as $file) { foreach ($this->build_email->getAttachments() as $file) {
$message->attach($file); $this->attach($file);
} }
} }
return $message; return $this;
} }
} }

View File

@ -41,7 +41,7 @@ class CompanyGateway extends BaseModel
'require_billing_address', 'require_billing_address',
'require_shipping_address', 'require_shipping_address',
'require_client_name', 'require_client_name',
'require_zip', 'require_postal_code',
'require_client_phone', 'require_client_phone',
'require_contact_name', 'require_contact_name',
'update_details', 'update_details',
@ -287,7 +287,11 @@ class CompanyGateway extends BaseModel
} }
if ($fees_and_limits->fee_percent) { if ($fees_and_limits->fee_percent) {
$fee += round(($amount * $fees_and_limits->fee_percent / 100),2); if ($fees_and_limits->adjust_fee_percent) {
$fee += round(($amount / (1 - $fees_and_limits->fee_percent / 100) - $amount),2);
} else {
$fee += round(($amount * $fees_and_limits->fee_percent / 100),2);
}
info("fee after adding fee percent = {$fee}"); info("fee after adding fee percent = {$fee}");
} }

View File

@ -51,6 +51,7 @@ class CompanyToken extends BaseModel
public function company_user() public function company_user()
{ {
return $this->hasOne(CompanyUser::class, 'user_id', 'user_id') return $this->hasOne(CompanyUser::class, 'user_id', 'user_id')
->where('company_id', $this->company_id) ->where('company_id', $this->company_id)
->where('user_id', $this->user_id); ->where('user_id', $this->user_id);

View File

@ -12,9 +12,12 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Database\Eloquent\SoftDeletes;
class Paymentable extends Pivot class Paymentable extends Pivot
{ {
use SoftDeletes;
protected $table = 'paymentables'; protected $table = 'paymentables';
//protected $dateFormat = 'Y-m-d H:i:s.u'; //protected $dateFormat = 'Y-m-d H:i:s.u';

View File

@ -166,10 +166,16 @@ class User extends Authenticatable implements MustVerifyEmail
*/ */
public function getCompany() public function getCompany()
{ {
if ($this->company) { if ($this->company) {
return $this->company; return $this->company;
} }
if(request()->header('X-API-TOKEN')){
$company_token = CompanyToken::whereRaw('BINARY `token`= ?', [request()->header('X-API-TOKEN')])->first();
return $company_token->company;
}
return Company::find(config('ninja.company_id')); return Company::find(config('ninja.company_id'));
} }
@ -201,21 +207,17 @@ class User extends Authenticatable implements MustVerifyEmail
$this->id = auth()->user()->id; $this->id = auth()->user()->id;
} }
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id') if(request()->header('X-API-TOKEN')){
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
->where('company_tokens.token', request()->header('X-API-TOKEN'))
->withTrashed();
}
else {
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
->where('company_user.user_id', $this->id) ->where('company_user.user_id', $this->id)
->withTrashed(); ->withTrashed();
}
// if(request()->header('X-API-TOKEN')){
// return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
// ->where('company_tokens.token', request()->header('X-API-TOKEN'))
// ->withTrashed();
// }
// else {
// return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
// ->where('company_user.user_id', $this->id)
// ->withTrashed();
// }
} }
/** /**

View File

@ -25,7 +25,7 @@ class ClientObserver
*/ */
public function created(Client $client) public function created(Client $client)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_CLIENT, $client); WebhookHandler::dispatch(Webhook::EVENT_CREATE_CLIENT, $client, $client->company);
} }
/** /**
@ -36,7 +36,7 @@ class ClientObserver
*/ */
public function updated(Client $client) public function updated(Client $client)
{ {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_CLIENT, $client); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_CLIENT, $client, $client->company);
} }
/** /**
@ -47,7 +47,7 @@ class ClientObserver
*/ */
public function deleted(Client $client) public function deleted(Client $client)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_CLIENT, $client); WebhookHandler::dispatch(Webhook::EVENT_DELETE_CLIENT, $client, $client->company);
} }
/** /**

View File

@ -25,7 +25,7 @@ class ExpenseObserver
*/ */
public function created(Expense $expense) public function created(Expense $expense)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_EXPENSE, $expense); WebhookHandler::dispatch(Webhook::EVENT_CREATE_EXPENSE, $expense, $expense->company);
} }
/** /**
@ -36,7 +36,7 @@ class ExpenseObserver
*/ */
public function updated(Expense $expense) public function updated(Expense $expense)
{ {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_EXPENSE, $expense); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_EXPENSE, $expense, $expense->company);
} }
/** /**
@ -47,7 +47,7 @@ class ExpenseObserver
*/ */
public function deleted(Expense $expense) public function deleted(Expense $expense)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_EXPENSE, $expense); WebhookHandler::dispatch(Webhook::EVENT_DELETE_EXPENSE, $expense, $expense->company);
} }
/** /**

View File

@ -26,7 +26,7 @@ class InvoiceObserver
*/ */
public function created(Invoice $invoice) public function created(Invoice $invoice)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice); WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice, $invoice->company);
} }
/** /**
@ -37,7 +37,7 @@ class InvoiceObserver
*/ */
public function updated(Invoice $invoice) public function updated(Invoice $invoice)
{ {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company);
} }
/** /**
@ -48,7 +48,7 @@ class InvoiceObserver
*/ */
public function deleted(Invoice $invoice) public function deleted(Invoice $invoice)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice); WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice, $invoice->company);
} }
/** /**

View File

@ -26,7 +26,7 @@ class PaymentObserver
*/ */
public function created(Payment $payment) public function created(Payment $payment)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_PAYMENT, $payment); WebhookHandler::dispatch(Webhook::EVENT_CREATE_PAYMENT, $payment, $payment->company);
} }
/** /**
@ -47,7 +47,7 @@ class PaymentObserver
*/ */
public function deleted(Payment $payment) public function deleted(Payment $payment)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_PAYMENT, $payment); WebhookHandler::dispatch(Webhook::EVENT_DELETE_PAYMENT, $payment, $payment->company);
} }
/** /**

View File

@ -25,7 +25,7 @@ class QuoteObserver
*/ */
public function created(Quote $quote) public function created(Quote $quote)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_QUOTE, $quote); WebhookHandler::dispatch(Webhook::EVENT_CREATE_QUOTE, $quote, $quote->company);
} }
/** /**
@ -36,7 +36,7 @@ class QuoteObserver
*/ */
public function updated(Quote $quote) public function updated(Quote $quote)
{ {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote, $quote->company);
} }
/** /**
@ -47,7 +47,7 @@ class QuoteObserver
*/ */
public function deleted(Quote $quote) public function deleted(Quote $quote)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_QUOTE, $quote); WebhookHandler::dispatch(Webhook::EVENT_DELETE_QUOTE, $quote, $quote->company);
} }
/** /**

View File

@ -25,7 +25,7 @@ class TaskObserver
*/ */
public function created(Task $task) public function created(Task $task)
{ {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_TASK, $task); WebhookHandler::dispatch(Webhook::EVENT_CREATE_TASK, $task, $task->company);
} }
/** /**
@ -36,7 +36,7 @@ class TaskObserver
*/ */
public function updated(Task $task) public function updated(Task $task)
{ {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_TASK, $task); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_TASK, $task, $task->company);
} }
/** /**
@ -47,7 +47,7 @@ class TaskObserver
*/ */
public function deleted(Task $task) public function deleted(Task $task)
{ {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_TASK, $task); WebhookHandler::dispatch(Webhook::EVENT_DELETE_TASK, $task, $task->company);
} }
/** /**

View File

@ -17,6 +17,7 @@ use App\Models\GatewayType;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentHash; use App\Models\PaymentHash;
use App\Models\SystemLog;
use App\PaymentDrivers\Authorize\AuthorizeCreditCard; use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
use App\PaymentDrivers\Authorize\AuthorizePaymentMethod; use App\PaymentDrivers\Authorize\AuthorizePaymentMethod;
use App\PaymentDrivers\Authorize\ChargePaymentProfile; use App\PaymentDrivers\Authorize\ChargePaymentProfile;
@ -43,6 +44,8 @@ class AuthorizePaymentDriver extends BaseDriver
GatewayType::CREDIT_CARD => AuthorizeCreditCard::class, GatewayType::CREDIT_CARD => AuthorizeCreditCard::class,
]; ];
const SYSTEM_LOG_TYPE = SystemLog::TYPE_AUTHORIZE;
public function setPaymentMethod($payment_method_id) public function setPaymentMethod($payment_method_id)
{ {
$class = self::$methods[$payment_method_id]; $class = self::$methods[$payment_method_id];

View File

@ -1,5 +1,4 @@
<?php <?php
/** /**
* Invoice Ninja (https://invoiceninja.com). * Invoice Ninja (https://invoiceninja.com).
* *
@ -308,11 +307,13 @@ class BaseDriver extends AbstractPaymentDriver
$error = $e->getBody(); $error = $e->getBody();
} }
$amount = optional($this->payment_hash->data)->value ?? optional($this->payment_hash->data)->amount;
PaymentFailureMailer::dispatch( PaymentFailureMailer::dispatch(
$gateway->client, $gateway->client,
$error, $error,
$gateway->client->company, $gateway->client->company,
$this->payment_hash->data->value $amount
); );
SystemLogger::dispatch( SystemLogger::dispatch(

View File

@ -84,6 +84,8 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
]; ];
} }
const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL;
/** /**
* Processes the payment with this gateway. * Processes the payment with this gateway.
* *

View File

@ -120,14 +120,6 @@ class CreditCard
{ {
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
if ($this->stripe->payment_hash->data->store_card) {
$customer = $this->stripe->findOrCreateCustomer();
$this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer);
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
}
$data = [ $data = [
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method, 'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)), 'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)),
@ -135,6 +127,20 @@ class CreditCard
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id, 'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
]; ];
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
$this->stripe->payment_hash->save();
if ($this->stripe->payment_hash->data->store_card) {
$customer = new \stdClass;
$customer->id = $this->stripe->payment_hash->data->customer;
$this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer);
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
}
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
SystemLogger::dispatch( SystemLogger::dispatch(

View File

@ -68,6 +68,8 @@ class StripePaymentDriver extends BaseDriver
GatewayType::SEPA => 1, // TODO GatewayType::SEPA => 1, // TODO
]; ];
const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE;
/** /**
* Initializes the Stripe API. * Initializes the Stripe API.
* @return void * @return void

View File

@ -51,6 +51,8 @@ use App\Events\Misc\InvitationWasViewed;
use App\Events\Payment\PaymentWasArchived; use App\Events\Payment\PaymentWasArchived;
use App\Events\Payment\PaymentWasCreated; use App\Events\Payment\PaymentWasCreated;
use App\Events\Payment\PaymentWasDeleted; use App\Events\Payment\PaymentWasDeleted;
use App\Events\Payment\PaymentWasEmailed;
use App\Events\Payment\PaymentWasEmailedAndFailed;
use App\Events\Payment\PaymentWasRefunded; use App\Events\Payment\PaymentWasRefunded;
use App\Events\Payment\PaymentWasRestored; use App\Events\Payment\PaymentWasRestored;
use App\Events\Payment\PaymentWasUpdated; use App\Events\Payment\PaymentWasUpdated;
@ -129,6 +131,8 @@ use App\Listeners\Invoice\InvoiceViewedActivity;
use App\Listeners\Invoice\UpdateInvoiceActivity; use App\Listeners\Invoice\UpdateInvoiceActivity;
use App\Listeners\Invoice\UpdateInvoiceInvitations; use App\Listeners\Invoice\UpdateInvoiceInvitations;
use App\Listeners\Misc\InvitationViewedListener; use App\Listeners\Misc\InvitationViewedListener;
use App\Listeners\Payment\PaymentEmailFailureActivity;
use App\Listeners\Payment\PaymentEmailedActivity;
use App\Listeners\Payment\PaymentNotification; use App\Listeners\Payment\PaymentNotification;
use App\Listeners\Payment\PaymentRestoredActivity; use App\Listeners\Payment\PaymentRestoredActivity;
use App\Listeners\Quote\QuoteApprovedActivity; use App\Listeners\Quote\QuoteApprovedActivity;
@ -310,6 +314,12 @@ class EventServiceProvider extends ServiceProvider
InvitationWasViewed::class => [ InvitationWasViewed::class => [
InvitationViewedListener::class, InvitationViewedListener::class,
], ],
PaymentWasEmailed::class => [
PaymentEmailedActivity::class,
],
PaymentWasEmailedAndFailed::class => [
PaymentEmailFailureActivity::class,
],
CompanyDocumentsDeleted::class => [ CompanyDocumentsDeleted::class => [
DeleteCompanyDocuments::class, DeleteCompanyDocuments::class,
], ],

View File

@ -158,6 +158,7 @@ class BaseRepository
*/ */
protected function alternativeSave($data, $model) protected function alternativeSave($data, $model)
{ {
$class = new ReflectionClass($model); $class = new ReflectionClass($model);
if (array_key_exists('client_id', $data)) { if (array_key_exists('client_id', $data)) {

View File

@ -138,10 +138,6 @@ class InvoiceMigrationRepository extends BaseRepository
$model = $model->service()->applyNumber()->save(); $model = $model->service()->applyNumber()->save();
if ($model->company->update_products !== false) {
UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company);
}
if ($class->name == Invoice::class || $class->name == RecurringInvoice::class) { if ($class->name == Invoice::class || $class->name == RecurringInvoice::class) {
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
@ -152,6 +148,11 @@ class InvoiceMigrationRepository extends BaseRepository
if (! $model->design_id) { if (! $model->design_id) {
$model->design_id = $this->decodePrimaryKey($client->getSetting('invoice_design_id')); $model->design_id = $this->decodePrimaryKey($client->getSetting('invoice_design_id'));
} }
if ($model->company->update_products !== false) {
UpdateOrCreateProduct::dispatchNow($model->line_items, $model, $model->company);
}
} }
if ($class->name == Credit::class) { if ($class->name == Credit::class) {

View File

@ -75,7 +75,8 @@ class MarkPaid extends AbstractService
->applyNumber() ->applyNumber()
->save(); ->save();
EmailPayment::dispatch($payment, $payment->company, $payment->client->primary_contact()->first()); if($this->invoice->client->getSetting('client_manual_payment_notification'))
EmailPayment::dispatch($payment, $payment->company, $payment->client->primary_contact()->first());
/* Update Invoice balance */ /* Update Invoice balance */
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));

View File

@ -46,6 +46,7 @@ class MarkSent extends AbstractService
->setStatus(Invoice::STATUS_SENT) ->setStatus(Invoice::STATUS_SENT)
->applyNumber() ->applyNumber()
->setDueDate() ->setDueDate()
->updateBalance($this->invoice->amount)
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->client->service()->updateBalance($this->invoice->balance)->save();

View File

@ -40,6 +40,7 @@ class DeletePayment
->updateCreditables() //return the credits first ->updateCreditables() //return the credits first
->adjustInvoices() ->adjustInvoices()
->updateClient() ->updateClient()
->deletePaymentables()
->save(); ->save();
} }
@ -51,6 +52,13 @@ class DeletePayment
//set applied amount to 0 //set applied amount to 0
private function deletePaymentables()
{
$this->payment->paymentables()->update(['deleted_at' => now()]);
return $this;
}
private function updateClient() private function updateClient()
{ {
$this->payment->client->service()->updatePaidToDate(-1 * $this->payment->amount)->save(); $this->payment->client->service()->updatePaidToDate(-1 * $this->payment->amount)->save();
@ -66,7 +74,7 @@ class DeletePayment
$paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount)->save(); $paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount)->save();
$paymentable_invoice->client->service()->updateBalance($paymentable_invoice->pivot->amount)->save(); $paymentable_invoice->client->service()->updateBalance($paymentable_invoice->pivot->amount)->save();
if (floatval($paymentable_invoice->balance) == 0) { if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save(); $paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
} else { } else {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save(); $paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();

View File

@ -140,7 +140,7 @@ trait PdfMakerUtilities
// .. in case string doesn't contain any HTML, we'll just return // .. in case string doesn't contain any HTML, we'll just return
// raw $content. // raw $content.
$_child = $this->document->createElement($child['element'], isset($child['content']) ? $child['content'] : ''); $_child = $this->document->createElement($child['element'], isset($child['content']) ? htmlspecialchars($child['content']) : '');
} }
$element->appendChild($_child); $element->appendChild($_child);

View File

@ -53,6 +53,7 @@ class CompanyGatewayTransformer extends EntityTransformer
'require_shipping_address' => (bool) $company_gateway->require_shipping_address, 'require_shipping_address' => (bool) $company_gateway->require_shipping_address,
'require_client_name' => (bool) $company_gateway->require_client_name, 'require_client_name' => (bool) $company_gateway->require_client_name,
'require_zip' => (bool) $company_gateway->require_zip, 'require_zip' => (bool) $company_gateway->require_zip,
'require_postal_code' => (bool) $company_gateway->require_postal_code,
'require_client_phone' => (bool) $company_gateway->require_client_phone, 'require_client_phone' => (bool) $company_gateway->require_client_phone,
'require_contact_name' => (bool) $company_gateway->require_contact_name, 'require_contact_name' => (bool) $company_gateway->require_contact_name,
'require_contact_email' => (bool) $company_gateway->require_contact_email, 'require_contact_email' => (bool) $company_gateway->require_contact_email,

View File

@ -27,10 +27,7 @@ class CompanyUserTransformer extends EntityTransformer
* @var array * @var array
*/ */
protected $defaultIncludes = [ protected $defaultIncludes = [
// 'account',
// 'company',
'user', 'user',
// 'token'
]; ];
/** /**
@ -76,6 +73,7 @@ class CompanyUserTransformer extends EntityTransformer
public function includeUser(CompanyUser $company_user) public function includeUser(CompanyUser $company_user)
{ {
$transformer = new UserTransformer($this->serializer); $transformer = new UserTransformer($this->serializer);
$company_user->user->company_id = $company_user->company_id;
return $this->includeItem($company_user->user, $transformer, User::class); return $this->includeItem($company_user->user, $transformer, User::class);
} }

View File

@ -46,6 +46,7 @@ class PaymentableTransformer extends EntityTransformer
'refunded' => (float) $paymentable->refunded, 'refunded' => (float) $paymentable->refunded,
'created_at' => (int) $paymentable->created_at, 'created_at' => (int) $paymentable->created_at,
'updated_at' => (int) $paymentable->updated_at, 'updated_at' => (int) $paymentable->updated_at,
'archived_at' => (int) $paymentable->deleted_at,
]; ];
} }
} }

View File

@ -95,10 +95,16 @@ class UserTransformer extends EntityTransformer
} }
public function includeCompanyUser(User $user) public function includeCompanyUser(User $user)
{ {
if(!$user->company_id && request()->header('X-API-TOKEN')){
$company_token = CompanyToken::whereRaw('BINARY `token`= ?', [request()->header('X-API-TOKEN')])->first();
$user->company_id = $company_token->company_id;
}
$transformer = new CompanyUserTransformer($this->serializer); $transformer = new CompanyUserTransformer($this->serializer);
$cu = $user->company_users()->whereCompanyId(config('ninja.company_id'))->first(); $cu = $user->company_users()->whereCompanyId($user->company_id)->first();
return $this->includeItem($cu, $transformer, CompanyUser::class); return $this->includeItem($cu, $transformer, CompanyUser::class);
} }

View File

@ -152,7 +152,12 @@ class HtmlEngine
$data['$discount'] = &$data['$invoice.discount']; $data['$discount'] = &$data['$invoice.discount'];
$data['$subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.subtotal')]; $data['$subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.subtotal')];
$data['$invoice.subtotal'] = &$data['$subtotal']; $data['$invoice.subtotal'] = &$data['$subtotal'];
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance_due')];
if($this->entity->partial > 0)
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance_due')];
else
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance_due')];
$data['$quote.balance_due'] = &$data['$balance_due']; $data['$quote.balance_due'] = &$data['$balance_due'];
$data['$invoice.balance_due'] = &$data['$balance_due']; $data['$invoice.balance_due'] = &$data['$balance_due'];
$data['$balance_due'] = &$data['$balance_due']; $data['$balance_due'] = &$data['$balance_due'];
@ -291,19 +296,21 @@ class HtmlEngine
$data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')]; $data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')];
$data['$product.discount'] = ['value' => '', 'label' => ctrans('texts.discount')]; $data['$product.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
$data['$product.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')]; $data['$product.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')];
$data['$product.notes'] = ['value' => '', 'label' => ctrans('texts.notes')]; $data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.cost'] = ['value' => '', 'label' => ctrans('texts.cost')]; $data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$product.quantity'] = ['value' => '', 'label' => ctrans('texts.quantity')]; $data['$product.quantity'] = ['value' => '', 'label' => ctrans('texts.quantity')];
$data['$product.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$product.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.tax'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$product.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')]; $data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')]; $data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')];
$data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')]; $data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
$data['$task.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')]; $data['$task.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')];
$data['$task.notes'] = ['value' => '', 'label' => ctrans('texts.notes')]; $data['$task.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$task.rate'] = ['value' => '', 'label' => ctrans('texts.rate')]; $data['$task.rate'] = ['value' => '', 'label' => ctrans('texts.rate')];
$data['$task.hours'] = ['value' => '', 'label' => ctrans('texts.hours')]; $data['$task.hours'] = ['value' => '', 'label' => ctrans('texts.hours')];
$data['$task.tax'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$task.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];

View File

@ -618,13 +618,16 @@ trait MakesInvoiceValues
$data[$key][$table_type.'.product_key'] = $item->product_key; $data[$key][$table_type.'.product_key'] = $item->product_key;
$data[$key][$table_type.'.notes'] = $item->notes; $data[$key][$table_type.'.notes'] = $item->notes;
$data[$key][$table_type.'.description'] = $item->notes;
$data[$key][$table_type.'.custom_value1'] = $item->custom_value1; $data[$key][$table_type.'.custom_value1'] = $item->custom_value1;
$data[$key][$table_type.'.custom_value2'] = $item->custom_value2; $data[$key][$table_type.'.custom_value2'] = $item->custom_value2;
$data[$key][$table_type.'.custom_value3'] = $item->custom_value3; $data[$key][$table_type.'.custom_value3'] = $item->custom_value3;
$data[$key][$table_type.'.custom_value4'] = $item->custom_value4; $data[$key][$table_type.'.custom_value4'] = $item->custom_value4;
$data[$key][$table_type.'.quantity'] = $item->quantity; $data[$key][$table_type.'.quantity'] = $item->quantity;
$data[$key][$table_type.'.unit_cost'] = Number::formatMoney($item->cost, $this->client);
$data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client); $data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);
$data[$key][$table_type.'.line_total'] = Number::formatMoney($item->line_total, $this->client); $data[$key][$table_type.'.line_total'] = Number::formatMoney($item->line_total, $this->client);
if (isset($item->discount) && $item->discount > 0) { if (isset($item->discount) && $item->discount > 0) {

View File

@ -12,7 +12,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/').'/', 'app_url' => rtrim(env('APP_URL', ''), '/').'/',
'app_domain' => env('APP_DOMAIN', ''), 'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.0.24', 'app_version' => '5.0.25',
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false), 'api_secret' => env('API_SECRET', false),

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CompanyGatewayRenameColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('company_gateways', function(Blueprint $table){
$table->renameColumn('require_zip', 'require_postal_code');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SoftDeletePaymentables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('paymentables', function(Blueprint $table){
$table->softDeletes('deleted_at', 6);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -1489,7 +1489,6 @@ source_map_stack_trace
stream_channel stream_channel
typed_data typed_data
vm_service vm_service
vm_service_client
Copyright 2015, the Dart project authors. All rights reserved. Copyright 2015, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -5135,6 +5134,31 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
contacts_service
MIT License
Copyright (c) 2018 Clovis NICOLAS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
dart dart
@ -5548,6 +5572,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
dart dart
Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
for details. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
dart
Copyright 2009 The Go Authors. All rights reserved. Copyright 2009 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file license that can be found in the LICENSE file
@ -5556,36 +5609,6 @@ dart
Copyright 2012, the Dart project authors. Copyright 2012, the Dart project authors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
dart
wasmer
Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
for details. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
met: met:
@ -5614,6 +5637,7 @@ device_info
device_info_platform_interface device_info_platform_interface
image_picker_platform_interface image_picker_platform_interface
local_auth local_auth
package_info
path_provider_macos path_provider_macos
path_provider_windows path_provider_windows
shared_preferences shared_preferences
@ -5769,6 +5793,29 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
extended_image extended_image
MIT License
Copyright (c) 2019 zmtzawqlp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------------------------------
extended_image_library extended_image_library
MIT License MIT License
@ -6508,6 +6555,211 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
--------------------------------------------------------------------------------
flutter_styled_toast
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
flutter_typeahead flutter_typeahead
@ -7945,7 +8197,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
google_sign_in_platform_interface google_sign_in_platform_interface
package_info
shared_preferences_windows shared_preferences_windows
// Copyright 2017 The Chromium Authors. All rights reserved. // Copyright 2017 The Chromium Authors. All rights reserved.
@ -13004,6 +13255,7 @@ SOFTWARE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
path_provider path_provider
share share
shared_preferences_macos
Copyright 2017, the Flutter project authors. All rights reserved. Copyright 2017, the Flutter project authors. All rights reserved.
@ -13064,34 +13316,59 @@ path_provider_linux
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
path_provider_platform_interface path_provider_platform_interface
shared_preferences_linux shared_preferences_linux
url_launcher_linux
// Copyright 2020 The Chromium Authors. All rights reserved. Copyright 2020 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without modification,
// modification, are permitted provided that the following conditions are are permitted provided that the following conditions are met:
// met:
// * Redistributions of source code must retain the above copyright
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
// copyright notice, this list of conditions and the following disclaimer disclaimer in the documentation and/or other materials provided
// in the documentation and/or other materials provided with the with the distribution.
// distribution. * Neither the name of Google Inc. nor the names of its
// * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived
// contributors may be used to endorse or promote products derived from from this software without specific prior written permission.
// this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------
permission_handler
permission_handler_platform_interface
MIT License
Copyright (c) 2018 Baseflow
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
petitparser petitparser
@ -14196,35 +14473,6 @@ sentry
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
shared_preferences_macos
Copyright 2017, the Flutter project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
skcms skcms
Copyright (c) 2018 Google Inc. All rights reserved. Copyright (c) 2018 Google Inc. All rights reserved.
@ -15966,35 +16214,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
--------------------------------------------------------------------------------
url_launcher_linux
Copyright 2020 The Chromium Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
url_launcher_web url_launcher_web

2
public/css/app.css vendored

File diff suppressed because one or more lines are too long

View File

@ -23,13 +23,13 @@ const RESOURCES = {
"assets/assets/images/payment_types/discover.png": "6c0a386a00307f87db7bea366cca35f5", "assets/assets/images/payment_types/discover.png": "6c0a386a00307f87db7bea366cca35f5",
"assets/assets/images/google-icon.png": "0f118259ce403274f407f5e982e681c3", "assets/assets/images/google-icon.png": "0f118259ce403274f407f5e982e681c3",
"assets/fonts/MaterialIcons-Regular.otf": "1288c9e28052e028aba623321f7826ac", "assets/fonts/MaterialIcons-Regular.otf": "1288c9e28052e028aba623321f7826ac",
"assets/NOTICES": "82a3d6846c60bb6275f9444e0283bb42", "assets/NOTICES": "86034c34fd4330a5f028df4c6dafd6cf",
"assets/FontManifest.json": "cf3c681641169319e61b61bd0277378f", "assets/FontManifest.json": "cf3c681641169319e61b61bd0277378f",
"assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "c1242726c7eac4eb5e843d826f78fb1b", "assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "c1242726c7eac4eb5e843d826f78fb1b",
"assets/AssetManifest.json": "ea09ed4b9b8b6c83d6896248aac7c527", "assets/AssetManifest.json": "ea09ed4b9b8b6c83d6896248aac7c527",
"manifest.json": "77215c1737c7639764e64a192be2f7b8", "manifest.json": "77215c1737c7639764e64a192be2f7b8",
"main.dart.js": "6b055e72fe2198c55035b415de13a3cd", "main.dart.js": "7c5eabcd4c179bc7d4fd0918f27ad7fb",
"version.json": "9e7038290cbbfbc73f5449c9efa930ff", "version.json": "399f70d54a0cf071e6e83bb5382fcdf5",
"/": "23224b5e03519aaa87594403d54412cf", "/": "23224b5e03519aaa87594403d54412cf",
"icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed", "icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed",
"icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35" "icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35"

249727
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"/js/app.js": "/js/app.js?id=a33a5a58bfc6e2174841", "/js/app.js": "/js/app.js?id=a33a5a58bfc6e2174841",
"/css/app.css": "/css/app.css?id=d338d4916fca469819c3", "/css/app.css": "/css/app.css?id=e55ed33a5056c9779c03",
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=cddcd46c630c71737bda", "/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=cddcd46c630c71737bda",

View File

@ -1 +1 @@
{"app_name":"invoiceninja_flutter","version":"5.0.24","build_number":"24"} {"app_name":"invoiceninja_flutter","version":"5.0.26","build_number":"26"}

View File

@ -1,7 +1,7 @@
@component('email.template.master', ['design' => 'dark', 'settings' => $settings, 'whitelabel' => $whitelabel]) @component('email.template.master', ['design' => 'dark', 'settings' => $settings, 'whitelabel' => $whitelabel])
@slot('header') @slot('header')
@component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png']) @component('email.components.header', ['p' => $body, 'logo' => $settings->company_logo ?: 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
@if(isset($title)) @if(isset($title))
{{$title}} {{$title}}

View File

@ -1,7 +1,7 @@
@component('email.template.master', ['design' => 'light', 'settings' => $settings, 'whitelabel' => $whitelabel]) @component('email.template.master', ['design' => 'light', 'settings' => $settings, 'whitelabel' => $whitelabel])
@slot('header') @slot('header')
@component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png']) @component('email.components.header', ['p' => $body, 'logo' => $settings->company_logo ?: 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
@if(isset($title)) @if(isset($title))
{{$title}} {{$title}}

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Invoice Ninja</title> <title>Invoice Ninja</title>
<meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}"> <meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}">
<link rel="manifest" href="manifest.json?v={{ $hash }}"> <link rel="manifest" href="manifest.json?v={{ config('ninja.app_version') }}">
</head> </head>
<body style="background-color:#888888;"> <body style="background-color:#888888;">
@ -88,7 +88,7 @@
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
window.addEventListener('load', function () { window.addEventListener('load', function () {
navigator.serviceWorker.register('/flutter_service_worker.js?v={{ $hash }}'); navigator.serviceWorker.register('/flutter_service_worker.js?v={{ config('ninja.app_version') }}');
}); });
} }
@ -97,7 +97,7 @@
}); });
</script> </script>
<script defer src="main.dart.js?v={{ $hash }}" type="application/javascript"></script> <script defer src="main.dart.js?v={{ config('ninja.app_version') }}" type="application/javascript"></script>
<center style="padding-top: 150px" id="loader"> <center style="padding-top: 150px" id="loader">
<div class="loader"></div> <div class="loader"></div>

View File

@ -1,8 +1,27 @@
<footer class="bg-white px-4 py-5 shadow px-4 sm:px-6 md:px-8 flex justify-center border border-gray-200 justify-between items-center"> <footer class="bg-white px-4 py-5 shadow px-4 sm:px-6 md:px-8 flex justify-center border border-gray-200 justify-between items-center" x-data="{ privacy: false, tos: false }">
<span class="text-sm text-gray-700">{{ ctrans('texts.footer_label', ['year' => date('Y')]) }}</span> <section>
<span class="text-xs md:text-sm text-gray-700">{{ ctrans('texts.footer_label', ['year' => date('Y')]) }}</span>
<div class="flex items-center space-x-2">
<a x-on:click="privacy = true; tos = false" href="#" class="button-link text-sm primary-color flex items-center">{{ __('texts.privacy_policy')}}</a>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minus">
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
<a x-on:click="privacy = false; tos = true" href="#" class="button-link text-sm primary-color flex items-center">{{ __('texts.terms')}}</a>
</div>
</section>
@if(auth()->user()->user && !auth()->user()->user->account->isPaid()) @if(auth()->user()->user && !auth()->user()->user->account->isPaid())
<a href="https://invoiceninja.com" target="_blank"> <a href="https://invoiceninja.com" target="_blank">
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo"> <img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
</a> </a>
@endif @endif
</footer>
@component('portal.ninja2020.components.general.pop-up', ['title' => __('texts.privacy_policy') ,'show_property' => 'privacy'])
{!! $client->getSetting('client_portal_privacy_policy') !!}
@endcomponent
@component('portal.ninja2020.components.general.pop-up', ['title' => __('texts.terms') ,'show_property' => 'tos'])
{!! $client->getSetting('client_portal_terms') !!}
@endcomponent
</footer>

View File

@ -0,0 +1,26 @@
<div class="fixed z-10 inset-0 overflow-y-auto" style="display:none;" x-show="{{ $show_property }}">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen"></span>&#8203;
<div class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6" role="dialog" aria-modal="true" aria-labelledby="modal-headline">
<div class="flex items-center justify-between">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-headline">
{{ $title }}
</h3>
<button @click="{{ $show_property }} = false" class="focus:outline-none" aria-label="Close pop-up">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
<div class="mt-4 text-sm leading-5 text-gray-500">
{!! $slot !!}
</div>
</div>
</div>
</div>

View File

@ -1,9 +1,22 @@
@extends('portal.ninja2020.layout.app') @extends('portal.ninja2020.layout.app')
@section('meta_title', ctrans('texts.credit')) @section('meta_title', ctrans('texts.credit'))
@push('head')
<meta name="pdf-url" content="{{ $credit->pdf_file_path() }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
@endpush
@section('body') @section('body')
<div class="container mx-auto"> <div class="container mx-auto" x-data="{ tab: 'overview' }">
<div class="bg-white shadow overflow-hidden sm:rounded-lg"> <div class="flex mb-4">
<button class="button button-primary text-black mr-4" x-on:click="tab = 'overview'" x-bind:class="{ 'border border-black': tab == 'overview' }">
Overview
</button>
<button class="button button-primary text-black" x-on:click="tab = 'pdf'" x-bind:class="{ 'border border-black': tab == 'pdf' }">
PDF
</button>
</div>
<div class="bg-white shadow overflow-hidden sm:rounded-lg" x-show="tab == 'overview'">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6"> <div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900"> <h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.credit') }} {{ ctrans('texts.credit') }}
@ -49,5 +62,69 @@
</dl> </dl>
</div> </div>
</div> </div>
<div class="flex items-center justify-between" x-show="tab == 'pdf'">
<section class="flex items-center">
<div class="items-center" style="display: none" id="pagination-button-container">
<button class="input-label focus:outline-none hover:text-blue-600 transition ease-in-out duration-300" id="previous-page-button" title="Previous page">
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
</button>
<button class="input-label focus:outline-none hover:text-blue-600 transition ease-in-out duration-300" id="next-page-button" title="Next page">
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
</div>
<span class="text-sm text-gray-700 ml-2">{{ ctrans('texts.page') }}:
<span id="current-page-container"></span>
<span>{{ strtolower(ctrans('texts.of')) }}</span>
<span id="total-page-container"></span>
</span>
</section>
<section class="flex items-center space-x-1">
<div class="flex items-center mr-4 space-x-1">
<span class="text-gray-600 mr-2" id="zoom-level">100%</span>
<a href="#" id="zoom-in">
<svg class="text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600 cursor-pointer" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
<line x1="11" y1="8" x2="11" y2="14"></line>
<line x1="8" y1="11" x2="14" y2="11"></line>
</svg>
</a>
<a href="#" id="zoom-out">
<svg class="text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600 cursor-pointer" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
<line x1="8" y1="11" x2="14" y2="11"></line>
</svg>
</a>
</div>
<div x-data="{ open: false }" @keydown.escape="open = false" @click.away="open = false" class="relative inline-block text-left">
<div>
<button @click="open = !open" class="flex items-center text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600">
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" />
</svg>
</button>
</div>
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
<div class="rounded-md bg-white shadow-xs">
<div class="py-1">
<a target="_blank" href="?mode=fullscreen" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="flex justify-center" x-show="tab == 'pdf'">
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white mt-4 p-4"></canvas>
</div>
</div> </div>
@endsection @endsection
@section('footer')
<script src="{{ asset('js/clients/shared/pdf.js') }}"></script>
@endsection

View File

@ -8,21 +8,9 @@
@section('body') @section('body')
@if($invoice->isPayable() && !empty($client->getSetting('custom_message_unpaid_invoice'))) @if(!$invoice->isPayable() && $client->getSetting('custom_message_paid_invoice'))
@component('portal.ninja2020.components.message') @component('portal.ninja2020.components.message')
{!! CustomMessage::client($client) {{ $client->getSetting('custom_message_paid_invoice') }}
->company($client->company)
->entity($invoice)
->message($client->getSetting('custom_message_unpaid_invoice')) !!}
@endcomponent
@endif
@if(!$invoice->isPayable() && !empty($client->getSetting('custom_message_paid_invoice')))
@component('portal.ninja2020.components.message')
{!! CustomMessage::client($client)
->company($client->company)
->entity($invoice)
->message($client->getSetting('custom_message_paid_invoice')) !!}
@endcomponent @endcomponent
@endif @endif

View File

@ -56,16 +56,20 @@
<link rel="canonical" href="{{ config('ninja.site_url') }}/{{ request()->path() }}"/> <link rel="canonical" href="{{ config('ninja.site_url') }}/{{ request()->path() }}"/>
<style> @if((bool) \App\Utils\Ninja::isSelfHost())
{!! $client->getSetting('portal_custom_css') !!} <style>
</style> {!! $client->getSetting('portal_custom_css') !!}
</style>
@endif
@livewireStyles @livewireStyles
{{-- Feel free to push anything to header using @push('header') --}} {{-- Feel free to push anything to header using @push('header') --}}
@stack('head') @stack('head')
{!! $client->getSetting('portal_custom_head') !!} @if((bool) \App\Utils\Ninja::isSelfHost())
{!! $client->getSetting('portal_custom_head') !!}
@endif
</head> </head>
@include('portal.ninja2020.components.primary-color') @include('portal.ninja2020.components.primary-color')
@ -88,11 +92,14 @@
@yield('footer') @yield('footer')
@stack('footer') @stack('footer')
{!! $client->getSetting('portal_custom_footer') !!} @if((bool) \App\Utils\Ninja::isSelfHost())
{!! $client->getSetting('portal_custom_footer') !!}
@endif
</footer> </footer>
<script> @if((bool) \App\Utils\Ninja::isSelfHost())
{!! $client->getSetting('portal_custom_js') !!} <script>
</script> {!! $client->getSetting('portal_custom_js') !!}
</script>
@endif
</html> </html>

View File

@ -8,12 +8,9 @@
@section('body') @section('body')
@if(!$quote->isApproved() && !empty($client->getSetting('custom_message_unapproved_quote'))) @if(!$quote->isApproved() && $client->getSetting('custom_message_unpaid_invoice'))
@component('portal.ninja2020.components.message') @component('portal.ninja2020.components.message')
{!! CustomMessage::client($client) {{ $client->getSetting('custom_message_unpaid_invoice') }}
->company($client->company)
->entity($quote)
->message($client->getSetting('custom_message_unapproved_quote')) !!}
@endcomponent @endcomponent
@endif @endif

View File

@ -123,7 +123,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::post('companies/purge/{company}', 'MigrationController@purgeCompany')->middleware('password_protected'); Route::post('companies/purge/{company}', 'MigrationController@purgeCompany')->middleware('password_protected');
Route::post('companies/purge_save_settings/{company}', 'MigrationController@purgeCompanySaveSettings')->middleware('password_protected'); Route::post('companies/purge_save_settings/{company}', 'MigrationController@purgeCompanySaveSettings')->middleware('password_protected');
Route::post('migration/start/{company}', 'MigrationController@startMigration'); Route::post('migration/start', 'MigrationController@startMigration');
Route::resource('companies', 'CompanyController'); // name = (companies. index / create / show / update / destroy / edit Route::resource('companies', 'CompanyController'); // name = (companies. index / create / show / update / destroy / edit

View File

@ -78,6 +78,7 @@ class CompanyGatewayResolutionTest extends TestCase
$data[1]['fee_tax_rate2'] = 10; $data[1]['fee_tax_rate2'] = 10;
$data[1]['fee_tax_name3'] = 'GST'; $data[1]['fee_tax_name3'] = 'GST';
$data[1]['fee_tax_rate3'] = 10; $data[1]['fee_tax_rate3'] = 10;
$data[1]['adjust_fee_percent'] = true;
$data[1]['fee_cap'] = 0; $data[1]['fee_cap'] = 0;
$data[2]['min_limit'] = -1; $data[2]['min_limit'] = -1;
@ -90,6 +91,7 @@ class CompanyGatewayResolutionTest extends TestCase
$data[2]['fee_tax_rate2'] = 10; $data[2]['fee_tax_rate2'] = 10;
$data[2]['fee_tax_name3'] = 'GST'; $data[2]['fee_tax_name3'] = 'GST';
$data[2]['fee_tax_rate3'] = 10; $data[2]['fee_tax_rate3'] = 10;
$data[2]['adjust_fee_percent'] = true;
$data[2]['fee_cap'] = 0; $data[2]['fee_cap'] = 0;
//disable ach here //disable ach here

View File

@ -56,6 +56,7 @@ class CompanyGatewayTest extends TestCase
$data[1]['fee_tax_rate2'] = ''; $data[1]['fee_tax_rate2'] = '';
$data[1]['fee_tax_name3'] = ''; $data[1]['fee_tax_name3'] = '';
$data[1]['fee_tax_rate3'] = 0; $data[1]['fee_tax_rate3'] = 0;
$data[1]['adjust_fee_percent'] = true;
$data[1]['fee_cap'] = 0; $data[1]['fee_cap'] = 0;
$cg = new CompanyGateway; $cg = new CompanyGateway;
@ -126,6 +127,7 @@ class CompanyGatewayTest extends TestCase
$data[1]['fee_tax_rate2'] = 0; $data[1]['fee_tax_rate2'] = 0;
$data[1]['fee_tax_name3'] = ''; $data[1]['fee_tax_name3'] = '';
$data[1]['fee_tax_rate3'] = 0; $data[1]['fee_tax_rate3'] = 0;
$data[1]['adjust_fee_percent'] = true;
$data[1]['fee_cap'] = 0; $data[1]['fee_cap'] = 0;
$cg = new CompanyGateway; $cg = new CompanyGateway;
@ -163,6 +165,7 @@ class CompanyGatewayTest extends TestCase
$data[1]['fee_tax_rate2'] = 10; $data[1]['fee_tax_rate2'] = 10;
$data[1]['fee_tax_name3'] = 'GST'; $data[1]['fee_tax_name3'] = 'GST';
$data[1]['fee_tax_rate3'] = 10; $data[1]['fee_tax_rate3'] = 10;
$data[1]['adjust_fee_percent'] = true;
$data[1]['fee_cap'] = 0; $data[1]['fee_cap'] = 0;
$cg = new CompanyGateway; $cg = new CompanyGateway;

View File

@ -23,7 +23,7 @@ use Tests\TestCase;
class GroupSettingTest extends TestCase class GroupSettingTest extends TestCase
{ {
use MakesHash; use MakesHash;
use DatabaseTransactions; //use DatabaseTransactions;
use MockAccountData; use MockAccountData;
public function setUp(): void public function setUp(): void
@ -42,7 +42,7 @@ class GroupSettingTest extends TestCase
public function testAddGroupSettings() public function testAddGroupSettings()
{ {
$settings = new \stdClass; $settings = new \stdClass;
$settings->currency_id = 1; $settings->currency_id = '1';
$data = [ $data = [
'name' => 'testX', 'name' => 'testX',
@ -65,7 +65,7 @@ class GroupSettingTest extends TestCase
public function testArchiveGroupSettings() public function testArchiveGroupSettings()
{ {
$settings = new \stdClass; $settings = new \stdClass;
$settings->currency_id = 1; $settings->currency_id = '1';
$data = [ $data = [
'name' => 'testY', 'name' => 'testY',

View File

@ -114,8 +114,8 @@ class UserTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
$this->assertNotNull($user->company_user); // $this->assertNotNull($user->company_user);
$this->assertEquals($user->company_user->company_id, $this->company->id); // $this->assertEquals($user->company_user->company_id, $this->company->id);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
@ -169,8 +169,8 @@ class UserTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
$this->assertNotNull($new_user->company_user); // $this->assertNotNull($new_user->company_user);
$this->assertEquals($new_user->company_user->company_id, $company2->id); // $this->assertEquals($new_user->company_user->company_id, $company2->id);
/*Create brand new user manually with company_user object and attach to a different company*/ /*Create brand new user manually with company_user object and attach to a different company*/
$data = [ $data = [

View File

@ -10,11 +10,13 @@
*/ */
namespace Tests\Integration; namespace Tests\Integration;
use App\DataMapper\CompanySettings;
use App\Factory\CompanyUserFactory; use App\Factory\CompanyUserFactory;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Account; use App\Models\Account;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\CompanyUser;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase; use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -60,7 +62,7 @@ class MultiDBUserTest extends TestCase
$coco = Company::on('db-ninja-01')->create($company->toArray()); $coco = Company::on('db-ninja-01')->create($company->toArray());
Company::on('db-ninja-02')->create($company2->toArray()); $coco2 = Company::on('db-ninja-02')->create($company2->toArray());
$user = [ $user = [
'account_id' => $account->id, 'account_id' => $account->id,
@ -91,12 +93,30 @@ class MultiDBUserTest extends TestCase
$user = User::on('db-ninja-01')->create($user); $user = User::on('db-ninja-01')->create($user);
$cu = CompanyUserFactory::create($user->id, $coco->id, $account->id); // $cu = CompanyUserFactory::create($user->id, $coco->id, $account->id);
$cu->is_owner = true; // $cu->is_owner = true;
$cu->is_admin = true; // $cu->is_admin = true;
$cu->save(); // $cu->setConnection('db-ninja-01');
// $cu->save();
CompanyUser::on('db-ninja-01')->create([
'company_id' => $coco->id,
'account_id' => $account->id,
'user_id' => $user->id,
'is_owner' => true,
'is_admin' => true,
]);
$user2 = User::on('db-ninja-02')->create($user2);
CompanyUser::on('db-ninja-02')->create([
'company_id' => $coco2->id,
'account_id' => $account2->id,
'user_id' => $user2->id,
'is_owner' => true,
'is_admin' => true,
]);
User::on('db-ninja-02')->create($user2);
$this->token = \Illuminate\Support\Str::random(40); $this->token = \Illuminate\Support\Str::random(40);