mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop
This commit is contained in:
commit
53725d4b9b
@ -111,8 +111,9 @@ class CompanyUserController extends BaseController
|
||||
*/
|
||||
public function update(UpdateCompanyUserRequest $request, User $user)
|
||||
{
|
||||
|
||||
$company = auth()->user()->company();
|
||||
/** @var \App\Models\User $auth_user */
|
||||
$auth_user = auth()->user();
|
||||
$company = $auth_user->company();
|
||||
|
||||
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
|
||||
|
||||
@ -122,7 +123,7 @@ class CompanyUserController extends BaseController
|
||||
return;
|
||||
}
|
||||
|
||||
if (auth()->user()->isAdmin()) {
|
||||
if ($auth_user->isAdmin()) {
|
||||
$company_user->fill($request->input('company_user'));
|
||||
} else {
|
||||
$company_user->settings = $request->input('company_user')['settings'];
|
||||
@ -136,8 +137,11 @@ class CompanyUserController extends BaseController
|
||||
|
||||
public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user)
|
||||
{
|
||||
/** @var \App\Models\User $auth_user */
|
||||
$auth_user = auth()->user();
|
||||
$company = $auth_user->company();
|
||||
|
||||
$company = auth()->user()->company();
|
||||
$company = $auth_user->company();
|
||||
|
||||
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
|
||||
|
||||
|
@ -592,11 +592,8 @@ class CreditController extends BaseController
|
||||
}
|
||||
break;
|
||||
case 'download':
|
||||
// $file = $credit->pdf_file_path();
|
||||
$file = $credit->service()->getCreditPdf($credit->invitations->first());
|
||||
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
|
@ -74,7 +74,7 @@ class OneTimeTokenController extends BaseController
|
||||
'user_id' => $user->id,
|
||||
'company_key'=> $user->company()->company_key,
|
||||
'context' => $request->input('context'),
|
||||
'is_react' => $request->has('react') && $request->query('react') == 'true' ? true : false,
|
||||
'is_react' => $request->request()->hasHeader('X-REACT') ? true : false,
|
||||
];
|
||||
|
||||
Cache::put($hash, $data, 3600);
|
||||
|
@ -15,11 +15,9 @@ use App\DataMapper\FeesAndLimits;
|
||||
use App\Factory\CompanyGatewayFactory;
|
||||
use App\Http\Requests\StripeConnect\InitializeStripeConnectRequest;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\GatewayType;
|
||||
use App\PaymentDrivers\Stripe\Jobs\StripeWebhook;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
|
||||
class StripeConnectController extends BaseController
|
||||
@ -124,12 +122,27 @@ class StripeConnectController extends BaseController
|
||||
$company_gateway->setConfig($payload);
|
||||
$company_gateway->save();
|
||||
|
||||
try{
|
||||
$stripe = $company_gateway->driver()->init();
|
||||
$a = \Stripe\Account::retrieve($response->stripe_user_id, $stripe->stripe_connect_auth);
|
||||
|
||||
if($a->business_name ?? false) {
|
||||
$company_gateway->label = substr("Stripe - {$a->business_name}", 0, 250);
|
||||
$company_gateway->save();
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
nlog("could not harvest stripe company name");
|
||||
}
|
||||
|
||||
// nlog("Stripe Connect Redirect URI = {$redirect_uri}");
|
||||
|
||||
// StripeWebhook::dispatch($company->company_key, $company_gateway->id);
|
||||
// if(isset($request->getTokenContent()['is_react']) && $request->getTokenContent()['is_react']) {
|
||||
if(isset($request->getTokenContent()['is_react']) && $request->getTokenContent()['is_react']) {
|
||||
$redirect_uri = 'https://app.invoicing.co/#/settings/online_payments';
|
||||
// } else {
|
||||
// $redirect_uri = 'https://invoicing.co/stripe/completed';
|
||||
// }
|
||||
} else {
|
||||
$redirect_uri = 'https://invoicing.co/stripe/completed';
|
||||
}
|
||||
|
||||
//response here
|
||||
return view('auth.connect.completed', ['url' => $redirect_uri]);
|
||||
|
@ -959,11 +959,17 @@ class SubscriptionService
|
||||
'date' => now()->format('Y-m-d'),
|
||||
];
|
||||
|
||||
return $invoice_repo->save($data, $invoice)
|
||||
$invoice_repo->save($data, $invoice)
|
||||
->service()
|
||||
->markSent()
|
||||
->fillDefaults()
|
||||
->save();
|
||||
|
||||
if($invoice->fresh()->balance == 0){
|
||||
$invoice->service()->markPaid()->save();
|
||||
}
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits;
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Parsedown;
|
||||
|
||||
/**
|
||||
* Class PaymentEmailBuilder.
|
||||
*/
|
||||
trait PaymentEmailBuilder
|
||||
{
|
||||
/**
|
||||
* Builds the correct template to send.
|
||||
* @param null $reminder_template The template name ie reminder1
|
||||
* @param null $contact
|
||||
* @return array
|
||||
*/
|
||||
public function getEmailData($reminder_template = null, $contact = null) :array
|
||||
{
|
||||
//client
|
||||
//$client = $this->client;
|
||||
|
||||
//Need to determine which email template we are producing
|
||||
return $this->generateTemplateData($reminder_template, $contact);
|
||||
}
|
||||
|
||||
private function generateTemplateData(string $reminder_template, $contact) :array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$client = $this->client;
|
||||
|
||||
$body_template = $client->getSetting('email_template_'.$reminder_template);
|
||||
|
||||
/* Use default translations if a custom message has not been set*/
|
||||
if (iconv_strlen($body_template) == 0) {
|
||||
$body_template = trans('texts.payment_message', ['amount'=>$this->present()->amount(), 'account'=>$this->company->present()->name()], null, $this->client->locale());
|
||||
}
|
||||
|
||||
$subject_template = $client->getSetting('payment_subject');
|
||||
|
||||
if (iconv_strlen($subject_template) == 0) {
|
||||
$subject_template = trans('texts.invoice_subject', ['number'=>$this->present()->invoice_number(), 'account'=>$this->company->present()->name()], null, $this->client->locale());
|
||||
}
|
||||
|
||||
$data['body'] = $this->parseTemplate($body_template, false, $contact);
|
||||
$data['subject'] = $this->parseTemplate($subject_template, true, $contact);
|
||||
|
||||
if ($client->getSetting('pdf_email_attachment') !== false) {
|
||||
$data['files'][] = $this->pdf_file_path();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function parseTemplate(string $template_data, bool $is_markdown, $contact) :string
|
||||
{
|
||||
//$invoice_variables = $this->makeValues($contact);
|
||||
|
||||
//process variables
|
||||
//$data = str_replace(array_keys($invoice_variables), array_values($invoice_variables), $template_data);
|
||||
|
||||
$data = strtr($template_data, $invoice_variables);
|
||||
|
||||
//process markdown
|
||||
if ($is_markdown) {
|
||||
//$data = Parsedown::instance()->line($data);
|
||||
|
||||
$converter = new CommonMarkConverter([
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
$data = $converter->convert($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits;
|
||||
|
||||
use App\Models\Quote;
|
||||
use Illuminate\Support\Carbon;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Parsedown;
|
||||
|
||||
/**
|
||||
* Class QuoteEmailBuilder.
|
||||
*/
|
||||
trait QuoteEmailBuilder
|
||||
{
|
||||
/**
|
||||
* Builds the correct template to send.
|
||||
* @param null $reminder_template The template name ie reminder1
|
||||
* @param null $contact
|
||||
* @return array
|
||||
*/
|
||||
public function getEmailData($reminder_template = null, $contact = null) :array
|
||||
{
|
||||
if (! $reminder_template) {
|
||||
$reminder_template = 'quote';
|
||||
|
||||
//$reminder_template = $this->calculateTemplate('quote');
|
||||
}
|
||||
|
||||
//Need to determine which email template we are producing
|
||||
return $this->generateTemplateData($reminder_template, $contact);
|
||||
}
|
||||
|
||||
private function generateTemplateData(string $reminder_template, $contact) :array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$client = $this->client;
|
||||
|
||||
$body_template = $client->getSetting('email_template_'.$reminder_template);
|
||||
|
||||
/* Use default translations if a custom message has not been set*/
|
||||
if (iconv_strlen($body_template) == 0) {
|
||||
$body_template = trans('texts.quote_message', ['amount'=>$this->present()->amount(), 'account'=>$this->company->present()->name()], null, $this->client->locale());
|
||||
}
|
||||
|
||||
$subject_template = $client->getSetting('email_subject_'.$reminder_template);
|
||||
|
||||
if (iconv_strlen($subject_template) == 0) {
|
||||
if ($reminder_template == 'quote') {
|
||||
$subject_template = trans('texts.quote_subject', ['number'=>$this->present()->invoice_number(), 'account'=>$this->company->present()->name()], null, $this->client->locale());
|
||||
} else {
|
||||
$subject_template = trans('texts.reminder_subject', ['number'=>$this->present()->invoice_number(), 'account'=>$this->company->present()->name()], null, $this->client->locale());
|
||||
}
|
||||
}
|
||||
|
||||
$data['body'] = $this->parseTemplate($body_template, true, $contact);
|
||||
$data['subject'] = $this->parseTemplate($subject_template, false, $contact);
|
||||
|
||||
if ($client->getSetting('pdf_email_attachment') !== false) {
|
||||
$data['files'][] = $this->pdf_file_path();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function parseTemplate(string $template_data, bool $is_markdown, $contact) :string
|
||||
{
|
||||
// $quote_variables = $this->makeValues($contact);
|
||||
|
||||
//process variables
|
||||
// $data = str_replace(array_keys($quote_variables), array_values($quote_variables), $template_data);
|
||||
$data = strtr($template_data, $quote_variables);
|
||||
|
||||
//process markdown
|
||||
if ($is_markdown) {
|
||||
//$data = Parsedown::instance()->line($data);
|
||||
|
||||
$converter = new CommonMarkConverter([
|
||||
'html_input' => 'allow',
|
||||
'allow_unsafe_links' => true,
|
||||
]);
|
||||
|
||||
$data = $converter->convert($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function calculateTemplate() :string
|
||||
{
|
||||
//if invoice is currently a draft, or being marked as sent, this will be the initial email
|
||||
$client = $this->client;
|
||||
|
||||
//if the invoice
|
||||
if ($this->status_id == Quote::STATUS_DRAFT || Carbon::parse($this->due_date) > now()) {
|
||||
return 'quote';
|
||||
} elseif ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow($client->getSetting('schedule_reminder1'), $client->getSetting('num_days_reminder1'))) {
|
||||
return 'template1';
|
||||
} elseif ($client->getSetting('enable_reminder2') !== false && $this->inReminderWindow($client->getSetting('schedule_reminder2'), $client->getSetting('num_days_reminder2'))) {
|
||||
return 'template2';
|
||||
} elseif ($client->getSetting('enable_reminder3') !== false && $this->inReminderWindow($client->getSetting('schedule_reminder3'), $client->getSetting('num_days_reminder3'))) {
|
||||
return 'template3';
|
||||
} else {
|
||||
return 'quote';
|
||||
}
|
||||
|
||||
//also implement endless reminders here
|
||||
}
|
||||
|
||||
private function inReminderWindow($schedule_reminder, $num_days_reminder)
|
||||
{
|
||||
switch ($schedule_reminder) {
|
||||
case 'after_invoice_date':
|
||||
return Carbon::parse($this->date)->addDays($num_days_reminder)->startOfDay()->eq(Carbon::now()->startOfDay());
|
||||
break;
|
||||
case 'before_due_date':
|
||||
return Carbon::parse($this->due_date)->subDays($num_days_reminder)->startOfDay()->eq(Carbon::now()->startOfDay());
|
||||
break;
|
||||
case 'after_due_date':
|
||||
return Carbon::parse($this->due_date)->addDays($num_days_reminder)->startOfDay()->eq(Carbon::now()->startOfDay());
|
||||
break;
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@
|
||||
"microsoft/microsoft-graph": "^1.69",
|
||||
"mollie/mollie-api-php": "^2.36",
|
||||
"nelexa/zip": "^4.0",
|
||||
"nwidart/laravel-modules": "8.3",
|
||||
"nwidart/laravel-modules": "^10.0",
|
||||
"omnipay/paypal": "^3.0",
|
||||
"payfast/payfast-php-sdk": "^1.1",
|
||||
"pragmarx/google2fa": "^8.0",
|
||||
|
56
composer.lock
generated
56
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7c3f126aafc640beb01f58c7047f6e23",
|
||||
"content-hash": "fe4e98a48b87b1d62a7c93b6f56c57cc",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adrienrn/php-mimetyper",
|
||||
@ -2586,16 +2586,16 @@
|
||||
},
|
||||
{
|
||||
"name": "google/apiclient-services",
|
||||
"version": "v0.313.0",
|
||||
"version": "v0.314.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/googleapis/google-api-php-client-services.git",
|
||||
"reference": "e41289c4488563af75bd291972f0fa00949e084a"
|
||||
"reference": "fe2f7513dc5a4a6cf82715fd0edf7589423d6535"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/e41289c4488563af75bd291972f0fa00949e084a",
|
||||
"reference": "e41289c4488563af75bd291972f0fa00949e084a",
|
||||
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/fe2f7513dc5a4a6cf82715fd0edf7589423d6535",
|
||||
"reference": "fe2f7513dc5a4a6cf82715fd0edf7589423d6535",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2624,9 +2624,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
|
||||
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.313.0"
|
||||
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.314.0"
|
||||
},
|
||||
"time": "2023-08-25T01:10:13+00:00"
|
||||
"time": "2023-09-03T01:04:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "google/auth",
|
||||
@ -6800,30 +6800,30 @@
|
||||
},
|
||||
{
|
||||
"name": "nwidart/laravel-modules",
|
||||
"version": "v8.3.0",
|
||||
"version": "v10.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nWidart/laravel-modules.git",
|
||||
"reference": "ee06dc0ac019cc392bd66a1c3e6cec0412fcc52d"
|
||||
"reference": "35e514f13cb8ae8dce093e9794785fea27319d81"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/ee06dc0ac019cc392bd66a1c3e6cec0412fcc52d",
|
||||
"reference": "ee06dc0ac019cc392bd66a1c3e6cec0412fcc52d",
|
||||
"url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/35e514f13cb8ae8dce093e9794785fea27319d81",
|
||||
"reference": "35e514f13cb8ae8dce093e9794785fea27319d81",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">=7.3"
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"laravel/framework": "^8.0",
|
||||
"mockery/mockery": "~1.0",
|
||||
"orchestra/testbench": "^6.2",
|
||||
"phpstan/phpstan": "^0.12.14",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"spatie/phpunit-snapshot-assertions": "^2.1.0|^4.2"
|
||||
"friendsofphp/php-cs-fixer": "^3.6",
|
||||
"laravel/framework": "^10.0",
|
||||
"mockery/mockery": "^1.5",
|
||||
"orchestra/testbench": "^8.0",
|
||||
"phpstan/phpstan": "^1.4",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"spatie/phpunit-snapshot-assertions": "^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -6836,7 +6836,7 @@
|
||||
}
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "8.0-dev"
|
||||
"dev-master": "10.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -6869,7 +6869,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nWidart/laravel-modules/issues",
|
||||
"source": "https://github.com/nWidart/laravel-modules/tree/v8.3.0"
|
||||
"source": "https://github.com/nWidart/laravel-modules/tree/v10.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -6877,7 +6877,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-02-10T20:30:19+00:00"
|
||||
"time": "2023-02-16T11:08:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7",
|
||||
@ -15068,16 +15068,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.25.0",
|
||||
"version": "v3.25.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "9025b7d2b6e1d90a63d0ac0905018ce5d03ec88d"
|
||||
"reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/9025b7d2b6e1d90a63d0ac0905018ce5d03ec88d",
|
||||
"reference": "9025b7d2b6e1d90a63d0ac0905018ce5d03ec88d",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8e21d69801de6b5ecb0dbe0bcdf967b335b1260b",
|
||||
"reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -15151,7 +15151,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.25.0"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.25.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -15159,7 +15159,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-08-31T21:27:18+00:00"
|
||||
"time": "2023-09-04T01:22:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "hamcrest/hamcrest-php",
|
||||
|
Loading…
x
Reference in New Issue
Block a user