mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Merge remote-tracking branch 'upstream/v5-develop' into 1314-subscriptions-v3
This commit is contained in:
commit
4cee352009
76
.github/workflows/react_release.yml
vendored
Normal file
76
.github/workflows/react_release.yml
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
name: React Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Upload Release Asset
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
extensions: mysql, mysqlnd, sqlite3, bcmath, gd, curl, zip, openssl, mbstring, xml
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
ref: v5-develop
|
||||
|
||||
- name: Copy .env file
|
||||
run: |
|
||||
cp .env.example .env
|
||||
|
||||
- name: Install composer dependencies
|
||||
run: |
|
||||
composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
|
||||
composer install --no-dev
|
||||
|
||||
- name: Prepare Laravel Application
|
||||
run: |
|
||||
cp .env.example .env
|
||||
php artisan key:generate --force
|
||||
php artisan optimize
|
||||
php artisan storage:link --force
|
||||
sudo php artisan cache:clear
|
||||
sudo find ./vendor/bin/ -type f -exec chmod +x {} \;
|
||||
sudo find ./ -type d -exec chmod 755 {} \;
|
||||
sudo rm -f public/main.*
|
||||
sudo rm -f public/flutter*
|
||||
|
||||
- name: Prepare React FrontEnd
|
||||
run: |
|
||||
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/ui.git
|
||||
cd ui
|
||||
git checkout develop
|
||||
npm i
|
||||
npm run build
|
||||
cp -r dist/* ../public/
|
||||
|
||||
- name: Prepare JS/CSS assets
|
||||
run: |
|
||||
npm i
|
||||
npm run production
|
||||
|
||||
- name: Cleanup Builds
|
||||
run: |
|
||||
sudo rm -rf bootstrap/cache/*
|
||||
sudo rm -rf node_modules
|
||||
sudo rm -rf .git
|
||||
sudo rm .env
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
shopt -s dotglob
|
||||
tar --exclude='public/storage' --exclude='.htaccess' --exclude='invoiceninja.zip' -zcvf /home/runner/work/invoiceninja/react-invoiceninja.tar *
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
files: |
|
||||
/home/runner/work/invoiceninja/react-invoiceninja.tar
|
@ -1 +1 @@
|
||||
5.8.24
|
||||
5.8.27
|
@ -891,7 +891,7 @@ class CheckData extends Command
|
||||
$this->logMessage("Fixing country for # {$client->id}");
|
||||
});
|
||||
|
||||
Client::query()->whereNull("settings->currency_id")->cursor()->each(function ($client){
|
||||
Client::query()->whereNull("settings->currency_id")->cursor()->each(function ($client) {
|
||||
$settings = $client->settings;
|
||||
$settings->currency_id = (string)$client->company->settings->currency_id;
|
||||
$client->settings = $settings;
|
||||
@ -901,7 +901,7 @@ class CheckData extends Command
|
||||
|
||||
});
|
||||
|
||||
Payment::withTrashed()->where('exchange_rate', 0)->cursor()->each(function ($payment){
|
||||
Payment::withTrashed()->where('exchange_rate', 0)->cursor()->each(function ($payment) {
|
||||
$payment->exchange_rate = 1;
|
||||
$payment->saveQuietly();
|
||||
|
||||
@ -917,11 +917,11 @@ class CheckData extends Command
|
||||
$p->currency_id = $p->client->settings->currency_id;
|
||||
$p->saveQuietly();
|
||||
|
||||
|
||||
|
||||
$this->logMessage("Fixing currency for # {$p->id}");
|
||||
|
||||
});
|
||||
|
||||
|
||||
Company::whereNull("subdomain")
|
||||
->cursor()
|
||||
->when(Ninja::isHosted())
|
||||
@ -942,7 +942,7 @@ class CheckData extends Command
|
||||
$i->partial_due_date = null;
|
||||
$i->saveQuietly();
|
||||
|
||||
|
||||
|
||||
$this->logMessage("Fixing partial due date for # {$i->id}");
|
||||
|
||||
});
|
||||
|
@ -52,9 +52,10 @@ class EncryptNinja extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if($this->option('encrypt'))
|
||||
if($this->option('encrypt')) {
|
||||
return $this->encryptFiles();
|
||||
|
||||
}
|
||||
|
||||
if($this->option('decrypt')) {
|
||||
return $this->decryptFiles();
|
||||
}
|
||||
@ -67,7 +68,7 @@ class EncryptNinja extends Command
|
||||
$contents = Storage::disk('base')->get($file);
|
||||
$encrypted = encrypt($contents);
|
||||
Storage::disk('base')->put($file.".enc", $encrypted);
|
||||
Storage::disk('base')->delete($file);
|
||||
// Storage::disk('base')->delete($file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,4 +81,4 @@ class EncryptNinja extends Command
|
||||
Storage::disk('base')->put($file, $decrypted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class OpenApiYaml extends Command
|
||||
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components.yaml'));
|
||||
|
||||
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/examples.yaml'));
|
||||
|
||||
|
||||
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/responses.yaml'));
|
||||
|
||||
$directory = new DirectoryIterator($path . '/components/responses/');
|
||||
|
@ -494,8 +494,11 @@ class CompanySettings extends BaseSettings
|
||||
public $payment_email_all_contacts = false;
|
||||
|
||||
public $show_pdfhtml_on_mobile = true;
|
||||
|
||||
|
||||
public $use_unapplied_payment = 'off'; //always, option, off //@implemented
|
||||
|
||||
public static $casts = [
|
||||
'use_unapplied_payment' => 'string',
|
||||
'show_pdfhtml_on_mobile' => 'bool',
|
||||
'payment_email_all_contacts' => 'bool',
|
||||
'statement_design_id' => 'string',
|
||||
@ -878,7 +881,7 @@ class CompanySettings extends BaseSettings
|
||||
{
|
||||
$notification = new stdClass();
|
||||
$notification->email = [];
|
||||
$notification->email = ['invoice_sent_all'];
|
||||
$notification->email = ['invoice_sent_all','payment_success_all','payment_manual_all'];
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
@ -59391,7 +59391,7 @@ class Domains
|
||||
'wireconnected.com'
|
||||
];
|
||||
|
||||
public static function getDomains()
|
||||
public static function getDomains(): array
|
||||
{
|
||||
return self::$verify_domains;
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ class Handler extends ExceptionHandler
|
||||
if (Ninja::isHosted()) {
|
||||
|
||||
// if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) {
|
||||
// $uri = urldecode(request()->getRequestUri());
|
||||
// event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()?->account?->key, $uri, request()->ip()));
|
||||
// $uri = urldecode(request()->getRequestUri());
|
||||
// event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()?->account?->key, $uri, request()->ip()));
|
||||
// }
|
||||
|
||||
Integration::configureScope(function (Scope $scope): void {
|
||||
|
@ -451,17 +451,19 @@ class BaseExport
|
||||
{
|
||||
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
|
||||
|
||||
if(!is_int($this->input['client_id']))
|
||||
if(!is_int($this->input['client_id'])) {
|
||||
$this->input['client_id'] = $this->decodePrimaryKey($this->input['client_id']);
|
||||
}
|
||||
|
||||
$client = Client::withTrashed()->find($this->input['client_id']);
|
||||
|
||||
if(!$client)
|
||||
if(!$client) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$this->client_description = $client->present()->name;
|
||||
return $query->where('client_id', $this->input['client_id']);
|
||||
|
||||
|
||||
} elseif(isset($this->input['clients']) && count($this->input['clients']) > 0) {
|
||||
|
||||
$this->client_description = 'Multiple Clients';
|
||||
@ -844,64 +846,69 @@ class BaseExport
|
||||
}
|
||||
|
||||
protected function addClientFilter($query, $clients): Builder
|
||||
{
|
||||
if(is_string($clients))
|
||||
$clients = explode(',', $clients);
|
||||
{
|
||||
if(is_string($clients)) {
|
||||
$clients = explode(',', $clients);
|
||||
}
|
||||
|
||||
$transformed_clients = $this->transformKeys($clients);
|
||||
|
||||
nlog($clients);
|
||||
nlog($transformed_clients);
|
||||
|
||||
if(count($transformed_clients) > 0)
|
||||
if(count($transformed_clients) > 0) {
|
||||
$query->whereIn('client_id', $transformed_clients);
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addVendorFilter($query, $vendors): Builder
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
if(is_string($vendors)) {
|
||||
$vendors = explode(',', $vendors);
|
||||
}
|
||||
|
||||
|
||||
$transformed_vendors = $this->transformKeys($vendors);
|
||||
|
||||
if(count($transformed_vendors) > 0)
|
||||
if(count($transformed_vendors) > 0) {
|
||||
$query->whereIn('vendor_id', $transformed_vendors);
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addProjectFilter($query, $projects): Builder
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
if(is_string($projects)) {
|
||||
$projects = explode(',', $projects);
|
||||
}
|
||||
|
||||
$transformed_projects = $this->transformKeys($projects);
|
||||
|
||||
if(count($transformed_projects) > 0)
|
||||
|
||||
if(count($transformed_projects) > 0) {
|
||||
$query->whereIn('project_id', $transformed_projects);
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addCategoryFilter($query, $expense_categories): Builder
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
if(is_string($expense_categories)) {
|
||||
$expense_categories = explode(',', $expense_categories);
|
||||
}
|
||||
|
||||
$transformed_expense_categories = $this->transformKeys($expense_categories);
|
||||
|
||||
|
||||
if(count($transformed_expense_categories) > 0)
|
||||
|
||||
if(count($transformed_expense_categories) > 0) {
|
||||
$query->whereIn('category_id', $transformed_expense_categories);
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -1299,12 +1306,12 @@ class BaseExport
|
||||
public function queueDocuments(Builder $query)
|
||||
{
|
||||
nlog("queue docs pls");
|
||||
if($query->getModel() instanceof Document)
|
||||
if($query->getModel() instanceof Document) {
|
||||
$documents = $query->pluck('id')->toArray();
|
||||
else{
|
||||
} else {
|
||||
$documents = $query->cursor()
|
||||
->map(function ($entity){
|
||||
return $entity->documents()->pluck('id')->toArray();
|
||||
->map(function ($entity) {
|
||||
return $entity->documents()->pluck('id')->toArray();
|
||||
})->flatten()
|
||||
->toArray();
|
||||
}
|
||||
@ -1315,11 +1322,13 @@ class BaseExport
|
||||
|
||||
$user = $this->company->owner();
|
||||
|
||||
if(auth()->user() && auth()->user()->account_id == $this->company->account_id)
|
||||
if(auth()->user() && auth()->user()->account_id == $this->company->account_id) {
|
||||
$user = auth()->user();
|
||||
}
|
||||
|
||||
if($this->input['user_id'] ?? false)
|
||||
if($this->input['user_id'] ?? false) {
|
||||
$user = User::where('id', $this->input['user_id'])->where('account_id', $this->company->account_id)->first();
|
||||
}
|
||||
|
||||
ZipDocuments::dispatch($documents, $this->company, $user);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class CreditExport extends BaseExport
|
||||
->where('is_deleted', 0);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class DocumentExport extends BaseExport
|
||||
$query = Document::query()->where('company_id', $this->company->id);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ use League\Csv\Writer;
|
||||
|
||||
class ExpenseExport extends BaseExport
|
||||
{
|
||||
|
||||
private $expense_transformer;
|
||||
|
||||
private Decorator $decorator;
|
||||
@ -103,7 +102,7 @@ class ExpenseExport extends BaseExport
|
||||
if(isset($this->input['categories'])) {
|
||||
$query = $this->addCategoryFilter($query, $this->input['categories']);
|
||||
}
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
@ -206,23 +205,21 @@ class ExpenseExport extends BaseExport
|
||||
|
||||
if($expense->calculate_tax_by_amount) {
|
||||
$total_tax_amount = round($expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3, $precision);
|
||||
}
|
||||
else {
|
||||
|
||||
if($expense->uses_inclusive_taxes){
|
||||
$total_tax_amount = ($this->calcInclusiveLineTax($expense->tax_rate1 ?? 0, $expense->amount,$precision)) + ($this->calcInclusiveLineTax($expense->tax_rate2 ?? 0, $expense->amount,$precision)) + ($this->calcInclusiveLineTax($expense->tax_rate3 ?? 0, $expense->amount,$precision));
|
||||
} else {
|
||||
|
||||
if($expense->uses_inclusive_taxes) {
|
||||
$total_tax_amount = ($this->calcInclusiveLineTax($expense->tax_rate1 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate2 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate3 ?? 0, $expense->amount, $precision));
|
||||
$entity['expense.net_amount'] = round(($expense->amount - round($total_tax_amount, $precision)), $precision);
|
||||
}
|
||||
else{
|
||||
$total_tax_amount = ($expense->amount * (($expense->tax_rate1 ?? 0)/100)) + ($expense->amount * (($expense->tax_rate2 ?? 0)/100)) + ($expense->amount * (($expense->tax_rate3 ?? 0)/100));
|
||||
} else {
|
||||
$total_tax_amount = ($expense->amount * (($expense->tax_rate1 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate2 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate3 ?? 0) / 100));
|
||||
$entity['expense.net_amount'] = round(($expense->amount + round($total_tax_amount, $precision)), $precision);
|
||||
}
|
||||
}
|
||||
|
||||
$entity['expense.tax_amount'] = round($total_tax_amount, $precision);
|
||||
|
||||
|
||||
return $entity;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function calcInclusiveLineTax($tax_rate, $amount, $precision): float
|
||||
|
@ -76,7 +76,7 @@ class InvoiceItemExport extends BaseExport
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->applyFilters($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class PaymentExport extends BaseExport
|
||||
->where('is_deleted', 0);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class ProductExport extends BaseExport
|
||||
->where('is_deleted', 0);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class PurchaseOrderExport extends BaseExport
|
||||
->where('is_deleted', 0);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class QuoteItemExport extends BaseExport
|
||||
->where('is_deleted', 0);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -49,6 +49,14 @@ class CompanyFactory
|
||||
$company->markdown_enabled = false;
|
||||
$company->tax_data = new TaxModel();
|
||||
$company->first_month_of_year = 1;
|
||||
$company->smtp_encryption = 'tls';
|
||||
$company->smtp_host = '';
|
||||
$company->smtp_local_domain = '';
|
||||
$company->smtp_password = '';
|
||||
$company->smtp_port = '';
|
||||
$company->smtp_username = '';
|
||||
$company->smtp_verify_peer = true;
|
||||
|
||||
return $company;
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +165,7 @@ class ClientFilters extends QueryFilters
|
||||
|
||||
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
|
||||
|
||||
if($sort_col[0] == 'number')
|
||||
{
|
||||
if($sort_col[0] == 'number') {
|
||||
return $this->builder->orderByRaw('ABS(number) ' . $dir);
|
||||
}
|
||||
|
||||
|
@ -318,13 +318,12 @@ class InvoiceFilters extends QueryFilters
|
||||
|
||||
if ($sort_col[0] == 'client_id') {
|
||||
|
||||
return $this->builder->orderBy(\App\Models\Client::select ('name')
|
||||
return $this->builder->orderBy(\App\Models\Client::select('name')
|
||||
->whereColumn('clients.id', 'invoices.client_id'), $dir);
|
||||
|
||||
}
|
||||
|
||||
if($sort_col[0] == 'number')
|
||||
{
|
||||
if($sort_col[0] == 'number') {
|
||||
return $this->builder->orderByRaw('ABS(number) ' . $dir);
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
namespace App\Filters;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* PaymentFilters.
|
||||
@ -163,7 +164,7 @@ class PaymentFilters extends QueryFilters
|
||||
{
|
||||
$sort_col = explode('|', $sort);
|
||||
|
||||
if (!is_array($sort_col) || count($sort_col) != 2) {
|
||||
if (!is_array($sort_col) || count($sort_col) != 2 || !in_array($sort_col, Schema::getColumnListing('payments'))) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class ProjectFilters extends QueryFilters
|
||||
public function sort(string $sort = ''): Builder
|
||||
{
|
||||
$sort_col = explode('|', $sort);
|
||||
|
||||
|
||||
if (!is_array($sort_col) || count($sort_col) != 2) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
namespace App\Helpers\Bank\Nordigen;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Services\Email\Email;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Services\Email\EmailObject;
|
||||
@ -138,11 +139,11 @@ class Nordigen
|
||||
* @param string $dateFrom
|
||||
* @return array
|
||||
*/
|
||||
public function getTransactions(string $accountId, string $dateFrom = null): array
|
||||
public function getTransactions(Company $company, string $accountId, string $dateFrom = null): array
|
||||
{
|
||||
$transactionResponse = $this->client->account($accountId)->getAccountTransactions($dateFrom);
|
||||
|
||||
$it = new TransactionTransformer();
|
||||
$it = new TransactionTransformer($company);
|
||||
return $it->transform($transactionResponse);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,10 @@
|
||||
namespace App\Helpers\Bank\Nordigen\Transformer;
|
||||
|
||||
use App\Helpers\Bank\BankRevenueInterface;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Models\Company;
|
||||
use App\Models\DateFormat;
|
||||
use App\Models\Timezone;
|
||||
use Carbon\Carbon;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Log;
|
||||
@ -66,12 +69,20 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
{
|
||||
use AppSetup;
|
||||
|
||||
private Company $company;
|
||||
|
||||
function __construct(Company $company)
|
||||
{
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
public function transform($transactionResponse)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"]))
|
||||
if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"])) {
|
||||
throw new \Exception('invalid dataset');
|
||||
}
|
||||
|
||||
foreach ($transactionResponse["transactions"]["booked"] as $transaction) {
|
||||
$data[] = $this->transformTransaction($transaction);
|
||||
@ -83,11 +94,11 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
{
|
||||
// depending on institution, the result can be different, so we load the first available unique id
|
||||
$transactionId = '';
|
||||
if (array_key_exists('transactionId', $transaction))
|
||||
if (array_key_exists('transactionId', $transaction)) {
|
||||
$transactionId = $transaction["transactionId"];
|
||||
else if (array_key_exists('internalTransactionId', $transaction))
|
||||
} elseif (array_key_exists('internalTransactionId', $transaction)) {
|
||||
$transactionId = $transaction["internalTransactionId"];
|
||||
else {
|
||||
} else {
|
||||
nlog(`Invalid Input for nordigen transaction transformer: ` . $transaction);
|
||||
throw new \Exception('invalid dataset: missing transactionId - Please report this error to the developer');
|
||||
}
|
||||
@ -96,23 +107,25 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
|
||||
// description could be in varios places
|
||||
$description = '';
|
||||
if (array_key_exists('remittanceInformationStructured', $transaction))
|
||||
if (array_key_exists('remittanceInformationStructured', $transaction)) {
|
||||
$description = $transaction["remittanceInformationStructured"];
|
||||
else if (array_key_exists('remittanceInformationStructuredArray', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationStructuredArray', $transaction)) {
|
||||
$description = implode('\n', $transaction["remittanceInformationStructuredArray"]);
|
||||
else if (array_key_exists('remittanceInformationUnstructured', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationUnstructured', $transaction)) {
|
||||
$description = $transaction["remittanceInformationUnstructured"];
|
||||
else if (array_key_exists('remittanceInformationUnstructuredArray', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationUnstructuredArray', $transaction)) {
|
||||
$description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]);
|
||||
else
|
||||
} else {
|
||||
Log::warning("Missing description for the following transaction: " . json_encode($transaction));
|
||||
}
|
||||
|
||||
// enrich description with currencyExchange informations
|
||||
if (array_key_exists('currencyExchange', $transaction))
|
||||
if (isset($transaction['currencyExchange'])) {
|
||||
foreach ($transaction["currencyExchange"] as $exchangeRate) {
|
||||
$targetAmount = round($amount * (float) $exchangeRate["exchangeRate"], 2);
|
||||
$description .= '\nexchangeRate: ' . $amount . " " . $exchangeRate["sourceCurrency"] . " = " . $targetAmount . " " . $exchangeRate["targetCurrency"] . " (" . $exchangeRate["quotationDate"] . ")";
|
||||
$targetAmount = round($amount * (float) ($exchangeRate["exchangeRate"] ?? 1), 2);
|
||||
$description .= '\n' . ctrans('texts.exchange_rate') . ' : ' . $amount . " " . ($exchangeRate["sourceCurrency"] ?? '?') . " = " . $targetAmount . " " . ($exchangeRate["targetCurrency"] ?? '?') . " (" . (isset($exchangeRate["quotationDate"]) ? $this->formatDate($exchangeRate["quotationDate"]) : '?') . ")";
|
||||
}
|
||||
}
|
||||
|
||||
// participant data
|
||||
$participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ?
|
||||
@ -153,11 +166,32 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
return $item->code == $code;
|
||||
})->first();
|
||||
|
||||
if ($currency)
|
||||
if ($currency) {
|
||||
return $currency->id;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
private function formatDate(string $input)
|
||||
{
|
||||
$timezone = Timezone::find($this->company->settings->timezone_id);
|
||||
$timezone_name = 'US/Eastern';
|
||||
|
||||
if ($timezone) {
|
||||
$timezone_name = $timezone->name;
|
||||
}
|
||||
|
||||
$date_format_default = 'Y-m-d';
|
||||
|
||||
$date_format = DateFormat::find($this->company->settings->date_format_id);
|
||||
|
||||
if ($date_format) {
|
||||
$date_format_default = $date_format->format;
|
||||
}
|
||||
|
||||
return Carbon::createFromFormat("d-m-Y", $input)->setTimezone($timezone_name)->format($date_format_default) ?? $input;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class ActivityController extends BaseController
|
||||
$system = ctrans('texts.system');
|
||||
|
||||
$data = $activities->cursor()->map(function ($activity) {
|
||||
|
||||
|
||||
/** @var \App\Models\Activity $activity */
|
||||
return $activity->activity_string();
|
||||
|
||||
|
@ -112,8 +112,9 @@ class BankTransactionController extends BaseController
|
||||
$this->bank_transaction_repo->convert_matched($bank_transactions);
|
||||
} else {
|
||||
$bank_transactions->each(function ($bank_transaction, $key) use ($action, $user) {
|
||||
if($user->can('edit', $bank_transaction))
|
||||
if($user->can('edit', $bank_transaction)) {
|
||||
$this->bank_transaction_repo->{$action}($bank_transaction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,7 @@ class BaseController extends Controller
|
||||
'company.quotes.invitations.company',
|
||||
'company.quotes.documents',
|
||||
'company.tasks.documents',
|
||||
// 'company.tasks.project',
|
||||
'company.subscriptions',
|
||||
'company.tax_rates',
|
||||
'company.tokens_hashed',
|
||||
@ -458,7 +459,7 @@ class BaseController extends Controller
|
||||
}
|
||||
},
|
||||
'company.tasks' => function ($query) use ($updated_at, $user) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('documents');
|
||||
$query->where('updated_at', '>=', $updated_at)->with('project','documents');
|
||||
|
||||
if (! $user->hasPermission('view_task')) {
|
||||
$query->whereNested(function ($query) use ($user) {
|
||||
@ -796,7 +797,7 @@ class BaseController extends Controller
|
||||
}
|
||||
},
|
||||
'company.tasks' => function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at)->with('documents');
|
||||
$query->where('created_at', '>=', $created_at)->with('project.documents','documents');
|
||||
|
||||
if (! $user->hasPermission('view_task')) {
|
||||
$query->whereNested(function ($query) use ($user) {
|
||||
|
@ -412,19 +412,19 @@ class ClientController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function documents(ClientDocumentsRequest $request, Client $client)
|
||||
public function documents(ClientDocumentsRequest $request, Client $client)
|
||||
{
|
||||
|
||||
|
||||
$this->entity_type = Document::class;
|
||||
|
||||
$this->entity_transformer = DocumentTransformer::class;
|
||||
|
||||
|
||||
$documents = Document::query()
|
||||
->company()
|
||||
->whereHasMorph('documentable', [Invoice::class, Quote::class, Credit::class, Expense::class, Payment::class, Task::class], function ($query) use($client) {
|
||||
->whereHasMorph('documentable', [Invoice::class, Quote::class, Credit::class, Expense::class, Payment::class, Task::class], function ($query) use ($client) {
|
||||
$query->where('client_id', $client->id);
|
||||
})
|
||||
->orWhereHasMorph('documentable', [Client::class], function ($query) use ($client){
|
||||
->orWhereHasMorph('documentable', [Client::class], function ($query) use ($client) {
|
||||
$query->where('id', $client->id);
|
||||
});
|
||||
|
||||
|
@ -353,7 +353,7 @@ class ClientGatewayTokenController extends BaseController
|
||||
*/
|
||||
public function store(StoreClientGatewayTokenRequest $request)
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -73,12 +73,13 @@ class DocumentController extends Controller
|
||||
{
|
||||
|
||||
$hash = Cache::pull($hash);
|
||||
|
||||
if(!$hash)
|
||||
|
||||
if(!$hash) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
MultiDB::setDb($hash['db']);
|
||||
|
||||
|
||||
/** @var \App\Models\Document $document **/
|
||||
$document = Document::where('hash', $hash['doc_hash'])->firstOrFail();
|
||||
|
||||
|
@ -58,4 +58,3 @@ class EmailPreferencesController extends Controller
|
||||
return back()->with('message', ctrans('texts.updated_settings'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class InvoiceController extends Controller
|
||||
}
|
||||
|
||||
$variables = ($invitation && auth()->guard('contact')->user()->client->getSetting('show_accept_invoice_terms')) ? (new HtmlEngine($invitation))->generateLabelsAndValues() : false;
|
||||
|
||||
|
||||
$data = [
|
||||
'invoice' => $invoice,
|
||||
'invitation' => $invitation ?: $invoice->invitations->first(),
|
||||
@ -224,8 +224,9 @@ class InvoiceController extends Controller
|
||||
$settings = auth()->guard('contact')->user()->client->getMergedSettings();
|
||||
$variables = false;
|
||||
|
||||
if(($invitation = $invoices->first()->invitations()->first() ?? false) && $settings->show_accept_invoice_terms)
|
||||
if(($invitation = $invoices->first()->invitations()->first() ?? false) && $settings->show_accept_invoice_terms) {
|
||||
$variables = (new HtmlEngine($invitation))->generateLabelsAndValues();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'settings' => $settings,
|
||||
|
@ -12,24 +12,25 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Utils\HtmlEngine;
|
||||
use Illuminate\View\View;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use App\PaymentDrivers\Stripe\BankTransfer;
|
||||
use App\Services\ClientPortal\InstantPayment;
|
||||
use App\Services\Subscription\SubscriptionService;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
|
||||
/**
|
||||
* Class PaymentController.
|
||||
@ -125,10 +126,16 @@ class PaymentController extends Controller
|
||||
|
||||
// 09-07-2022 catch duplicate responses for invoices that already paid here.
|
||||
if ($invoice && $invoice->status_id == Invoice::STATUS_PAID) {
|
||||
|
||||
$invitation = $invoice->invitations->first();
|
||||
|
||||
$variables = ($invitation && auth()->guard('contact')->user()->client->getSetting('show_accept_invoice_terms')) ? (new HtmlEngine($invitation))->generateLabelsAndValues() : false;
|
||||
|
||||
$data = [
|
||||
'invoice' => $invoice,
|
||||
'key' => false,
|
||||
'invitation' => $invoice->invitations->first()
|
||||
'invitation' => $invitation,
|
||||
'variables' => $variables,
|
||||
];
|
||||
|
||||
if ($request->query('mode') === 'fullscreen') {
|
||||
|
@ -147,7 +147,7 @@ class PaymentMethodController extends Controller
|
||||
$payment_method->is_deleted = true;
|
||||
$payment_method->delete();
|
||||
$payment_method->save();
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -215,7 +215,7 @@ class QuoteController extends Controller
|
||||
->withSuccess('Quote(s) approved successfully.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$variables = false;
|
||||
|
||||
if($invitation = $quotes->first()->invitations()->first() ?? false) {
|
||||
|
@ -149,7 +149,7 @@ class CompanyGatewayController extends BaseController
|
||||
*/
|
||||
public function create(CreateCompanyGatewayRequest $request)
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -64,7 +64,7 @@ class CompanyLedgerController extends BaseController
|
||||
*/
|
||||
public function index(ShowCompanyLedgerRequest $request)
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -121,7 +121,7 @@ class ConnectedAccountController extends BaseController
|
||||
'email_verified_at' => now()
|
||||
];
|
||||
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
@ -169,13 +169,16 @@ class ConnectedAccountController extends BaseController
|
||||
'email_verified_at' => now(),
|
||||
];
|
||||
|
||||
auth()->user()->update($connected_account);
|
||||
auth()->user()->email_verified_at = now();
|
||||
auth()->user()->save();
|
||||
/** @var \App\Models\User $logged_in_user */
|
||||
$logged_in_user = auth()->user();
|
||||
|
||||
$this->setLoginCache(auth()->user());
|
||||
$logged_in_user->update($connected_account);
|
||||
$logged_in_user->email_verified_at = now();
|
||||
$logged_in_user->save();
|
||||
|
||||
return $this->itemResponse(auth()->user());
|
||||
$this->setLoginCache($logged_in_user);
|
||||
|
||||
return $this->itemResponse($logged_in_user);
|
||||
}
|
||||
|
||||
return response()
|
||||
@ -214,20 +217,22 @@ class ConnectedAccountController extends BaseController
|
||||
// 'email_verified_at' =>now(),
|
||||
];
|
||||
|
||||
if (auth()->user()->email != $google->harvestEmail($user)) {
|
||||
/** @var \App\Models\User $logged_in_user */
|
||||
$logged_in_user = auth()->user();
|
||||
|
||||
if ($logged_in_user->email != $google->harvestEmail($user)) {
|
||||
return response()->json(['message' => 'Primary Email differs to OAuth email. Emails must match.'], 400);
|
||||
}
|
||||
|
||||
auth()->user()->update($connected_account);
|
||||
auth()->user()->email_verified_at = now();
|
||||
auth()->user()->oauth_user_token = $token;
|
||||
auth()->user()->oauth_user_refresh_token = $refresh_token;
|
||||
$logged_in_user->update($connected_account);
|
||||
$logged_in_user->email_verified_at = now();
|
||||
$logged_in_user->oauth_user_token = $token;
|
||||
$logged_in_user->oauth_user_refresh_token = $refresh_token;
|
||||
$logged_in_user->save();
|
||||
|
||||
auth()->user()->save();
|
||||
$this->activateGmail($logged_in_user);
|
||||
|
||||
$this->activateGmail(auth()->user());
|
||||
|
||||
return $this->itemResponse(auth()->user());
|
||||
return $this->itemResponse($logged_in_user);
|
||||
}
|
||||
|
||||
return response()
|
||||
|
@ -128,7 +128,7 @@ class ExpenseCategoryController extends BaseController
|
||||
*/
|
||||
public function create(CreateExpenseCategoryRequest $request)
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -21,7 +21,7 @@ class HostedMigrationController extends Controller
|
||||
{
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
|
||||
|
||||
if ($request->header('X-API-HOSTED-SECRET') != config('ninja.ninja_hosted_secret')) {
|
||||
return;
|
||||
}
|
||||
@ -29,19 +29,20 @@ class HostedMigrationController extends Controller
|
||||
MultiDB::findAndSetDbByCompanyKey($request->company_key);
|
||||
$c = Company::where('company_key', $request->company_key)->first();
|
||||
|
||||
if(!$c || $c->is_disabled)
|
||||
if(!$c || $c->is_disabled) {
|
||||
return response()->json(['message' => 'ok'], 200);
|
||||
}
|
||||
|
||||
// if(\App\Models\Invoice::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2))->first())
|
||||
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);
|
||||
|
||||
// if(\App\Models\Client::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2))->first())
|
||||
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);
|
||||
|
||||
// if(\App\Models\Quote::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2)))
|
||||
|
||||
// if(\App\Models\Client::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2))->first())
|
||||
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);
|
||||
|
||||
// if(\App\Models\RecurringInvoice::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2)))
|
||||
// if(\App\Models\Quote::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2)))
|
||||
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);
|
||||
|
||||
// if(\App\Models\RecurringInvoice::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2)))
|
||||
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);
|
||||
|
||||
return response()->json(['message' => 'You have already activated this company on v5!!!!!! This migration may be a BAD idea. Contact us contact@invoiceninja.com to confirm this action.'], 400);
|
||||
|
@ -22,18 +22,22 @@ class MailgunWebhookController extends BaseController
|
||||
{
|
||||
private $invitation;
|
||||
|
||||
public function __construct() {}
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function webhook(Request $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
if (\abs(\time() - $request['signature']['timestamp']) > 15)
|
||||
if (\abs(\time() - $request['signature']['timestamp']) > 15) {
|
||||
return response()->json(['message' => 'Success'], 200);
|
||||
}
|
||||
|
||||
if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature']))
|
||||
if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) {
|
||||
ProcessMailgunWebhook::dispatch($request->all())->delay(10);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Success.'], 200);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ class PaymentController extends BaseController
|
||||
if($action == 'template' && $user->can('view', $payments->first())) {
|
||||
|
||||
$hash_or_response = request()->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||
|
||||
|
||||
TemplateAction::dispatch(
|
||||
$payments->pluck('hashed_id')->toArray(),
|
||||
$request->template_id,
|
||||
|
@ -316,8 +316,8 @@ class PreviewPurchaseOrderController extends BaseController
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
//if phantom js...... inject here..
|
||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||
|
@ -181,7 +181,7 @@ class ProductController extends BaseController
|
||||
*/
|
||||
public function store(StoreProductRequest $request)
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -399,7 +399,7 @@ class QuoteController extends BaseController
|
||||
|
||||
$quote->service()
|
||||
->triggeredActions($request);
|
||||
|
||||
|
||||
event(new QuoteWasUpdated($quote, $quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->itemResponse($quote);
|
||||
|
64
app/Http/Controllers/SmtpController.php
Normal file
64
app/Http/Controllers/SmtpController.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?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\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Smtp\CheckSmtpRequest;
|
||||
use App\Mail\TestMailServer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SmtpController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function check(CheckSmtpRequest $request)
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
$company = $user->company();
|
||||
|
||||
|
||||
|
||||
config([
|
||||
'mail.mailers.smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'host' => $request->input('smtp_host', $company->smtp_host),
|
||||
'port' => $request->input('smtp_port', $company->smtp_port),
|
||||
'username' => $request->input('smtp_username', $company->smtp_username),
|
||||
'password' => $request->input('smtp_password', $company->smtp_password),
|
||||
'encryption' => $request->input('smtp_encryption', $company->smtp_encryption ?? 'tls'),
|
||||
'local_domain' => $request->input('smtp_local_domain', strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null),
|
||||
'verify_peer' => $request->input('verify_peer', $company->smtp_verify_peer ?? true),
|
||||
'timeout' => 5,
|
||||
],
|
||||
]);
|
||||
|
||||
(new \Illuminate\Mail\MailServiceProvider(app()))->register();
|
||||
|
||||
try {
|
||||
Mail::to($user->email, $user->present()->name())->send(new TestMailServer('Email Server Works!', strlen($company->settings->custom_sending_email) > 1 ? $company->settings->custom_sending_email : $user->email));
|
||||
} catch (\Exception $e) {
|
||||
app('mail.manager')->forgetMailers();
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
}
|
||||
|
||||
app('mail.manager')->forgetMailers();
|
||||
|
||||
return response()->json(['message' => 'Ok'], 200);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -86,7 +86,7 @@ class StripeConnectController extends BaseController
|
||||
]);
|
||||
|
||||
nlog($response);
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return view('auth.connect.access_denied');
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class TwoFactorController extends BaseController
|
||||
|
||||
public function disableTwoFactor()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -499,7 +499,7 @@ class VendorController extends BaseController
|
||||
|
||||
$ids = request()->input('ids');
|
||||
$vendors = Vendor::withTrashed()->find($this->transformKeys($ids));
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -67,7 +67,7 @@ class TokenAuth
|
||||
$truth->setUser($company_token->user);
|
||||
$truth->setCompany($company_token->company);
|
||||
$truth->setCompanyToken($company_token);
|
||||
|
||||
$truth->setPremiumHosted($company_token->account->isPremium());
|
||||
/*
|
||||
| This method binds the db to the jobs created using this
|
||||
| session
|
||||
|
@ -49,6 +49,9 @@ class StoreClientRequest extends Request
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -53,6 +53,8 @@ class UpdateClientRequest extends Request
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
} elseif ($this->file('file')) {
|
||||
$rules['file'] = $this->file_validation;
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000';
|
||||
|
@ -27,7 +27,7 @@ class CreatePaymentMethodRequest extends FormRequest
|
||||
->filter(function ($method) use (&$available_methods) {
|
||||
$available_methods[] = $method['gateway_type_id'];
|
||||
});
|
||||
|
||||
|
||||
if (in_array($this->query('method'), $available_methods)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -56,6 +56,15 @@ class StoreCompanyRequest extends Request
|
||||
}
|
||||
}
|
||||
|
||||
$rules['smtp_host'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_port'] = 'sometimes|integer|nullable';
|
||||
$rules['smtp_encryption'] = 'sometimes|string';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_encryption'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
|
||||
// $rules['smtp_verify_peer'] = 'sometimes|in:true,false';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@ -67,11 +76,11 @@ class StoreCompanyRequest extends Request
|
||||
$input['name'] = 'Untitled Company';
|
||||
}
|
||||
|
||||
if (array_key_exists('google_analytics_url', $input)) {
|
||||
if (isset($input['google_analytics_url'])) {
|
||||
$input['google_analytics_key'] = $input['google_analytics_url'];
|
||||
}
|
||||
|
||||
if (array_key_exists('portal_domain', $input)) {
|
||||
if (isset($input['portal_domain'])) {
|
||||
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
||||
}
|
||||
|
||||
@ -79,6 +88,21 @@ class StoreCompanyRequest extends Request
|
||||
$input['subdomain'] = MultiDB::randomSubdomainGenerator();
|
||||
}
|
||||
|
||||
if(isset($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
unset($input['smtp_username']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
unset($input['smtp_password']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_port'])) {
|
||||
$input['smtp_port'] = (int) $input['smtp_port'];
|
||||
}
|
||||
|
||||
if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer']))
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,14 @@ class UpdateCompanyRequest extends Request
|
||||
$rules['matomo_id'] = 'nullable|integer';
|
||||
$rules['e_invoice_certificate_passphrase'] = 'sometimes|nullable';
|
||||
$rules['e_invoice_certificate'] = 'sometimes|nullable|file|mimes:p12,pfx,pem,cer,crt,der,txt,p7b,spc,bin';
|
||||
// $rules['client_registration_fields'] = 'array';
|
||||
|
||||
$rules['smtp_host'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_port'] = 'sometimes|integer|nullable';
|
||||
$rules['smtp_encryption'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
// $rules['smtp_verify_peer'] = 'sometimes|string';
|
||||
|
||||
|
||||
if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
$rules['portal_domain'] = 'bail|nullable|sometimes|url';
|
||||
}
|
||||
@ -74,23 +80,39 @@ class UpdateCompanyRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if (array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1) {
|
||||
if (isset($input['portal_domain']) && strlen($input['portal_domain']) > 1) {
|
||||
$input['portal_domain'] = $this->addScheme($input['portal_domain']);
|
||||
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
||||
}
|
||||
|
||||
if (array_key_exists('settings', $input)) {
|
||||
if (isset($input['settings'])) {
|
||||
$input['settings'] = (array)$this->filterSaveableSettings($input['settings']);
|
||||
}
|
||||
|
||||
if(array_key_exists('subdomain', $input) && $this->company->subdomain == $input['subdomain']) {
|
||||
if(isset($input['subdomain']) && $this->company->subdomain == $input['subdomain']) {
|
||||
unset($input['subdomain']);
|
||||
}
|
||||
|
||||
if(array_key_exists('e_invoice_certificate_passphrase', $input) && empty($input['e_invoice_certificate_passphrase'])) {
|
||||
if(isset($input['e_invoice_certificate_passphrase']) && empty($input['e_invoice_certificate_passphrase'])) {
|
||||
unset($input['e_invoice_certificate_passphrase']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_username']) && strlen(str_replace("*","", $input['smtp_username'])) < 2) {
|
||||
unset($input['smtp_username']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
unset($input['smtp_password']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_port'])) {
|
||||
$input['smtp_port'] = (int)$input['smtp_port'];
|
||||
}
|
||||
|
||||
if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) {
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,8 @@ class StoreCreditRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -52,6 +52,8 @@ class UpdateCreditRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -52,6 +52,7 @@ class StoreExpenseRequest extends Request
|
||||
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.$user->company()->id.',is_deleted,0';
|
||||
$rules['payment_date'] = 'bail|nullable|sometimes|date:Y-m-d';
|
||||
$rules['date'] = 'bail|sometimes|date:Y-m-d';
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
|
@ -29,25 +29,32 @@ class UpdateExpenseRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->user()->can('edit', $this->expense);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('edit', $this->expense);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
$rules = [];
|
||||
|
||||
if (isset($this->number)) {
|
||||
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
|
||||
$rules['number'] = Rule::unique('expenses')->where('company_id', $user->company()->id)->ignore($this->expense->id);
|
||||
}
|
||||
|
||||
if ($this->client_id) {
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.$user->company()->id;
|
||||
}
|
||||
|
||||
$rules['category_id'] = 'bail|sometimes|nullable|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
$rules['transaction_id'] = 'bail|sometimes|nullable|exists:bank_transactions,id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['invoice_id'] = 'bail|sometimes|nullable|exists:invoices,id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['category_id'] = 'bail|sometimes|nullable|exists:expense_categories,id,company_id,'.$user->company()->id.',is_deleted,0';
|
||||
$rules['transaction_id'] = 'bail|sometimes|nullable|exists:bank_transactions,id,company_id,'.$user->company()->id;
|
||||
$rules['invoice_id'] = 'bail|sometimes|nullable|exists:invoices,id,company_id,'.$user->company()->id;
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
|
||||
|
||||
return $this->globalRules($rules);
|
||||
@ -55,6 +62,10 @@ class UpdateExpenseRequest extends Request
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
@ -64,7 +75,7 @@ class UpdateExpenseRequest extends Request
|
||||
}
|
||||
|
||||
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
||||
$input['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
|
||||
$input['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
|
||||
/* Ensure the project is related */
|
||||
|
@ -32,7 +32,7 @@ class StoreExpenseCategoryRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -26,7 +26,7 @@ class UpdateExpenseCategoryRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
@ -35,7 +35,7 @@ class UpdateExpenseCategoryRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -47,6 +47,8 @@ class StoreInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
@ -76,6 +78,7 @@ class StoreInvoiceRequest extends Request
|
||||
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
@ -77,6 +79,7 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,8 @@ class StorePaymentRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -55,6 +55,8 @@ class UpdatePaymentRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -35,6 +35,8 @@ class StoreProductRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -25,7 +25,11 @@ class UpdateProductRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->user()->can('edit', $this->product);
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('edit', $this->product);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
@ -34,6 +38,8 @@ class UpdateProductRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -53,6 +53,8 @@ class StoreProjectRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -49,6 +49,8 @@ class UpdateProjectRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -57,6 +57,8 @@ class StorePurchaseOrderRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -59,6 +59,8 @@ class UpdatePurchaseOrderRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -49,6 +49,8 @@ class StoreQuoteRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
@ -59,11 +61,8 @@ class StoreQuoteRequest extends Request
|
||||
|
||||
$rules['number'] = ['nullable', Rule::unique('quotes')->where('company_id', $user->company()->id)];
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||
|
||||
// $rules['number'] = new UniqueQuoteNumberRule($this->all());
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
|
@ -46,6 +46,8 @@ class UpdateQuoteRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -49,6 +49,8 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -48,6 +48,8 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -198,18 +198,22 @@ class Request extends FormRequest
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($input['public_notes']))
|
||||
$input['public_notes'] = str_replace("</sc","<-", $input['public_notes']);
|
||||
if(isset($input['public_notes'])) {
|
||||
$input['public_notes'] = str_replace("</sc", "<-", $input['public_notes']);
|
||||
}
|
||||
|
||||
if(isset($input['footer']))
|
||||
if(isset($input['footer'])) {
|
||||
$input['footer'] = str_replace("</sc", "<-", $input['footer']);
|
||||
|
||||
if(isset($input['terms']))
|
||||
}
|
||||
|
||||
if(isset($input['terms'])) {
|
||||
$input['terms'] = str_replace("</sc", "<-", $input['terms']);
|
||||
|
||||
if(isset($input['private_notes']))
|
||||
}
|
||||
|
||||
if(isset($input['private_notes'])) {
|
||||
$input['private_notes'] = str_replace("</sc", "<-", $input['private_notes']);
|
||||
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
54
app/Http/Requests/Smtp/CheckSmtpRequest.php
Normal file
54
app/Http/Requests/Smtp/CheckSmtpRequest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?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\Http\Requests\Smtp;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class CheckSmtpRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$input = $this->input();
|
||||
|
||||
if(isset($input['smtp_username']) && $input['smtp_username'] == '********')
|
||||
unset($input['smtp_username']);
|
||||
|
||||
if(isset($input['smtp_password'])&& $input['smtp_password'] == '********')
|
||||
unset($input['smtp_password']);
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
@ -82,6 +82,8 @@ class StoreTaskRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -88,6 +88,8 @@ class UpdateTaskRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -64,6 +64,8 @@ class StoreVendorRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -65,6 +65,8 @@ class UpdateVendorRequest extends Request
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
|
@ -39,11 +39,11 @@ class CanAddUserRule implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Check that we have sufficient quota to allow this to happen
|
||||
/*
|
||||
Check that we have sufficient quota to allow this to happen
|
||||
|
||||
@ 31-01-2024 - changed query to use email instead of user_id
|
||||
|
||||
|
||||
$count = CompanyUser::query()
|
||||
->where('company_user.account_id', $user->account_id)
|
||||
->join('users', 'users.id', '=', 'company_user.user_id')
|
||||
@ -69,7 +69,7 @@ class CanAddUserRule implements Rule
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -88,10 +88,9 @@ class PaymentAppliedValidAmount implements Rule
|
||||
nlog($inv->amount);
|
||||
nlog($invoice['amount']);
|
||||
|
||||
if($inv->status_id == Invoice::STATUS_DRAFT && $inv->amount >= $invoice['amount']){
|
||||
if($inv->status_id == Invoice::STATUS_DRAFT && $inv->amount >= $invoice['amount']) {
|
||||
|
||||
}
|
||||
elseif ($inv->balance < $invoice['amount']) {
|
||||
} elseif ($inv->balance < $invoice['amount']) {
|
||||
$this->message = 'Amount cannot be greater than invoice balance';
|
||||
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ class BaseImport
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $bestDelimiter ?? ',';
|
||||
}
|
||||
|
||||
|
@ -117,10 +117,8 @@ class Wave extends BaseImport implements ImportInterface
|
||||
|
||||
$this->transformer = new InvoiceTransformer($this->company);
|
||||
|
||||
foreach($data as $key => $invoice)
|
||||
{
|
||||
if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number']))
|
||||
{
|
||||
foreach($data as $key => $invoice) {
|
||||
if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number'])) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -315,14 +315,11 @@ class BaseTransformer
|
||||
public function getFloat($data, $field)
|
||||
{
|
||||
if (array_key_exists($field, $data)) {
|
||||
//$number = preg_replace('/[^0-9-.]+/', '', $data[$field]);
|
||||
return Number::parseFloat($data[$field]);
|
||||
} else {
|
||||
//$number = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// return Number::parseFloat($number);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
private function processTransactions()
|
||||
{
|
||||
//Get transaction count object
|
||||
$transactions = $this->nordigen->getTransactions($this->bank_integration->nordigen_account_id, $this->from_date);
|
||||
$transactions = $this->nordigen->getTransactions($this->company, $this->bank_integration->nordigen_account_id, $this->from_date);
|
||||
|
||||
//if no transactions, update the from_date and move on
|
||||
if (count($transactions) == 0) {
|
||||
|
@ -72,13 +72,13 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
$this->file_name = date('Y-m-d') . '_' . str_replace([" ", "/"], ["_",""], $this->company->present()->name() . '_' . $this->company->company_key . '.json');
|
||||
|
||||
$this->writer = new File($this->file_name);
|
||||
$this->writer = new File($this->file_name);
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$this->writer->value('app_version', config('ninja.app_version'));
|
||||
$this->writer->value('storage_url', Storage::url(''));
|
||||
|
||||
$this->writer->value('app_version', config('ninja.app_version'));
|
||||
$this->writer->value('storage_url', Storage::url(''));
|
||||
|
||||
$this->export_data['activities'] = $this->company->all_activities->map(function ($activity) {
|
||||
$activity = $this->transformArrayOfKeys($activity, [
|
||||
'user_id',
|
||||
@ -104,9 +104,9 @@ $this->writer->value('storage_url', Storage::url(''));
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('activities');
|
||||
$x->addItems($this->export_data['activities']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('activities');
|
||||
$x->addItems($this->export_data['activities']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['users'] = $this->company->users()->withTrashed()->cursor()->map(function ($user) {
|
||||
@ -116,9 +116,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('users');
|
||||
$x->addItems($this->export_data['users']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('users');
|
||||
$x->addItems($this->export_data['users']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['client_contacts'] = $this->company->client_contacts->map(function ($client_contact) {
|
||||
@ -140,9 +140,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('client_contacts');
|
||||
$x->addItems($this->export_data['client_contacts']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('client_contacts');
|
||||
$x->addItems($this->export_data['client_contacts']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['client_gateway_tokens'] = $this->company->client_gateway_tokens->map(function ($client_gateway_token) {
|
||||
$client_gateway_token = $this->transformArrayOfKeys($client_gateway_token, ['company_id', 'client_id', 'company_gateway_id']);
|
||||
@ -151,9 +151,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('client_gateway_tokens');
|
||||
$x->addItems($this->export_data['client_gateway_tokens']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('client_gateway_tokens');
|
||||
$x->addItems($this->export_data['client_gateway_tokens']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['clients'] = $this->company->clients()->orderBy('number', 'DESC')->cursor()->map(function ($client) {
|
||||
$client = $this->transformArrayOfKeys($client, ['company_id', 'user_id', 'assigned_user_id', 'group_settings_id']);
|
||||
@ -162,18 +162,18 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('clients');
|
||||
$x->addItems($this->export_data['clients']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('clients');
|
||||
$x->addItems($this->export_data['clients']);
|
||||
$this->export_data = null;
|
||||
|
||||
// $this->export_data['company'] = $this->company->toArray();
|
||||
// $this->export_data['company']['company_key'] = $this->createHash();
|
||||
|
||||
$this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
|
||||
// $x = $this->writer->collection('company');
|
||||
// $x->addItems($this->export_data['company']);
|
||||
// $this->export_data = null;
|
||||
$this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
|
||||
// $x = $this->writer->collection('company');
|
||||
// $x->addItems($this->export_data['company']);
|
||||
// $this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['company_gateways'] = $this->company->company_gateways()->withTrashed()->cursor()->map(function ($company_gateway) {
|
||||
@ -184,11 +184,11 @@ $this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_gateways');
|
||||
$x->addItems($this->export_data['company_gateways']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_gateways');
|
||||
$x->addItems($this->export_data['company_gateways']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->export_data['company_tokens'] = $this->company->tokens->map(function ($token) {
|
||||
@ -198,9 +198,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_tokens');
|
||||
$x->addItems($this->export_data['company_tokens']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_tokens');
|
||||
$x->addItems($this->export_data['company_tokens']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['company_ledger'] = $this->company->ledger->map(function ($ledger) {
|
||||
@ -210,20 +210,20 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_ledger');
|
||||
$x->addItems($this->export_data['company_ledger']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_ledger');
|
||||
$x->addItems($this->export_data['company_ledger']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$this->export_data['company_users'] = $this->company->company_users()->without(['user','account'])->cursor()->map(function ($company_user) {
|
||||
$company_user = $this->transformArrayOfKeys($company_user, ['company_id', 'account_id', 'user_id']);
|
||||
return $company_user;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_users');
|
||||
$x->addItems($this->export_data['company_users']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_users');
|
||||
$x->addItems($this->export_data['company_users']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['credits'] = $this->company->credits()->orderBy('number', 'DESC')->cursor()->map(function ($credit) {
|
||||
@ -233,9 +233,9 @@ $this->export_data = null;
|
||||
return $credit->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('credits');
|
||||
$x->addItems($this->export_data['credits']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('credits');
|
||||
$x->addItems($this->export_data['credits']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['credit_invitations'] = CreditInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($credit) {
|
||||
@ -244,18 +244,18 @@ $this->export_data = null;
|
||||
return $credit->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('credit_invitations');
|
||||
$x->addItems($this->export_data['credit_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('credit_invitations');
|
||||
$x->addItems($this->export_data['credit_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['designs'] = $this->company->user_designs->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('designs');
|
||||
$x->addItems($this->export_data['designs']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('designs');
|
||||
$x->addItems($this->export_data['designs']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['documents'] = $this->company->all_documents->map(function ($document) {
|
||||
@ -265,9 +265,9 @@ $this->export_data = null;
|
||||
return $document->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('documents');
|
||||
$x->addItems($this->export_data['documents']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('documents');
|
||||
$x->addItems($this->export_data['documents']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['expense_categories'] = $this->company->expense_categories()->cursor()->map(function ($expense_category) {
|
||||
$expense_category = $this->transformArrayOfKeys($expense_category, ['user_id', 'company_id']);
|
||||
@ -275,9 +275,9 @@ $this->export_data = null;
|
||||
return $expense_category->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('expense_categories');
|
||||
$x->addItems($this->export_data['expense_categories']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('expense_categories');
|
||||
$x->addItems($this->export_data['expense_categories']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['expenses'] = $this->company->expenses()->orderBy('number', 'DESC')->cursor()->map(function ($expense) {
|
||||
@ -288,9 +288,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('expenses');
|
||||
$x->addItems($this->export_data['expenses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('expenses');
|
||||
$x->addItems($this->export_data['expenses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['group_settings'] = $this->company->group_settings->map(function ($gs) {
|
||||
@ -299,10 +299,10 @@ $this->export_data = null;
|
||||
return $gs->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('group_settings');
|
||||
$x->addItems($this->export_data['group_settings']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('group_settings');
|
||||
$x->addItems($this->export_data['group_settings']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['invoices'] = $this->company->invoices()->orderBy('number', 'DESC')->cursor()->map(function ($invoice) {
|
||||
@ -318,9 +318,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('invoices');
|
||||
$x->addItems($this->export_data['invoices']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('invoices');
|
||||
$x->addItems($this->export_data['invoices']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['invoice_invitations'] = InvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($invoice) {
|
||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'invoice_id']);
|
||||
@ -329,9 +329,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('invoice_invitations');
|
||||
$x->addItems($this->export_data['invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('invoice_invitations');
|
||||
$x->addItems($this->export_data['invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['payment_terms'] = $this->company->user_payment_terms->map(function ($term) {
|
||||
@ -340,10 +340,10 @@ $this->export_data = null;
|
||||
return $term;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('payment_terms');
|
||||
$x->addItems($this->export_data['payment_terms']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('payment_terms');
|
||||
$x->addItems($this->export_data['payment_terms']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['payments'] = $this->company->payments()->orderBy('number', 'DESC')->cursor()->map(function ($payment) {
|
||||
@ -357,9 +357,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('payments');
|
||||
$x->addItems($this->export_data['payments']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('payments');
|
||||
$x->addItems($this->export_data['payments']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['products'] = $this->company->products->map(function ($product) {
|
||||
@ -370,9 +370,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('products');
|
||||
$x->addItems($this->export_data['products']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('products');
|
||||
$x->addItems($this->export_data['products']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['projects'] = $this->company->projects()->orderBy('number', 'DESC')->cursor()->map(function ($project) {
|
||||
@ -383,9 +383,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('projects');
|
||||
$x->addItems($this->export_data['projects']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('projects');
|
||||
$x->addItems($this->export_data['projects']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['quotes'] = $this->company->quotes()->orderBy('number', 'DESC')->cursor()->map(function ($quote) {
|
||||
@ -395,10 +395,10 @@ $this->export_data = null;
|
||||
return $quote->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('quotes');
|
||||
$x->addItems($this->export_data['quotes']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('quotes');
|
||||
$x->addItems($this->export_data['quotes']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['quote_invitations'] = QuoteInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($quote) {
|
||||
@ -408,9 +408,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('quote_invitations');
|
||||
$x->addItems($this->export_data['quote_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('quote_invitations');
|
||||
$x->addItems($this->export_data['quote_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_expenses'] = $this->company->recurring_expenses()->orderBy('number', 'DESC')->cursor()->map(function ($expense) {
|
||||
@ -422,9 +422,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_expenses');
|
||||
$x->addItems($this->export_data['recurring_expenses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('recurring_expenses');
|
||||
$x->addItems($this->export_data['recurring_expenses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_invoices'] = $this->company->recurring_invoices()->orderBy('number', 'DESC')->cursor()->map(function ($ri) {
|
||||
@ -434,10 +434,10 @@ $this->export_data = null;
|
||||
return $ri->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_invoices');
|
||||
$x->addItems($this->export_data['recurring_invoices']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('recurring_invoices');
|
||||
$x->addItems($this->export_data['recurring_invoices']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_invoice_invitations'] = RecurringInvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($ri) {
|
||||
@ -447,9 +447,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_invoice_invitations');
|
||||
$x->addItems($this->export_data['recurring_invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('recurring_invoice_invitations');
|
||||
$x->addItems($this->export_data['recurring_invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
@ -467,9 +467,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('subscriptions');
|
||||
$x->addItems($this->export_data['subscriptions']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('subscriptions');
|
||||
$x->addItems($this->export_data['subscriptions']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['system_logs'] = $this->company->system_logs->map(function ($log) {
|
||||
$log->client_id = $this->encodePrimaryKey($log->client_id);
|
||||
@ -479,9 +479,9 @@ $this->export_data = null;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('system_logs');
|
||||
$x->addItems($this->export_data['system_logs']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('system_logs');
|
||||
$x->addItems($this->export_data['system_logs']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['tasks'] = $this->company->tasks()->orderBy('number', 'DESC')->cursor()->map(function ($task) {
|
||||
@ -493,9 +493,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('tasks');
|
||||
$x->addItems($this->export_data['tasks']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('tasks');
|
||||
$x->addItems($this->export_data['tasks']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['task_statuses'] = $this->company->task_statuses->map(function ($status) {
|
||||
@ -508,9 +508,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('task_statuses');
|
||||
$x->addItems($this->export_data['task_statuses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('task_statuses');
|
||||
$x->addItems($this->export_data['task_statuses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['tax_rates'] = $this->company->tax_rates->map(function ($rate) {
|
||||
@ -522,9 +522,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('tax_rates');
|
||||
$x->addItems($this->export_data['tax_rates']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('tax_rates');
|
||||
$x->addItems($this->export_data['tax_rates']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['vendors'] = $this->company->vendors()->orderBy('number', 'DESC')->cursor()->map(function ($vendor) {
|
||||
@ -532,10 +532,10 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('vendors');
|
||||
$x->addItems($this->export_data['vendors']);
|
||||
$this->export_data = null;
|
||||
|
||||
$x = $this->writer->collection('vendors');
|
||||
$x->addItems($this->export_data['vendors']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['vendor_contacts'] = VendorContact::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($vendor) {
|
||||
@ -547,9 +547,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('vendor_contacts');
|
||||
$x->addItems($this->export_data['vendor_contacts']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('vendor_contacts');
|
||||
$x->addItems($this->export_data['vendor_contacts']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['webhooks'] = $this->company->webhooks->map(function ($hook) {
|
||||
@ -560,9 +560,9 @@ $this->export_data = null;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('webhooks');
|
||||
$x->addItems($this->export_data['webhooks']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('webhooks');
|
||||
$x->addItems($this->export_data['webhooks']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['purchase_orders'] = $this->company->purchase_orders()->orderBy('number', 'DESC')->cursor()->map(function ($purchase_order) {
|
||||
@ -578,9 +578,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('purchase_orders');
|
||||
$x->addItems($this->export_data['purchase_orders']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('purchase_orders');
|
||||
$x->addItems($this->export_data['purchase_orders']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
@ -591,9 +591,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('purchase_order_invitations');
|
||||
$x->addItems($this->export_data['purchase_order_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('purchase_order_invitations');
|
||||
$x->addItems($this->export_data['purchase_order_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['bank_integrations'] = $this->company->bank_integrations()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($bank_integration) {
|
||||
$bank_integration = $this->transformArrayOfKeys($bank_integration, ['account_id','company_id', 'user_id']);
|
||||
@ -601,9 +601,9 @@ $this->export_data = null;
|
||||
return $bank_integration->makeVisible(['id','user_id','company_id','account_id','hashed_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('bank_integrations');
|
||||
$x->addItems($this->export_data['bank_integrations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('bank_integrations');
|
||||
$x->addItems($this->export_data['bank_integrations']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['bank_transactions'] = $this->company->bank_transactions()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($bank_transaction) {
|
||||
$bank_transaction = $this->transformArrayOfKeys($bank_transaction, ['company_id', 'user_id','bank_integration_id','expense_id','ninja_category_id','vendor_id']);
|
||||
@ -611,9 +611,9 @@ $this->export_data = null;
|
||||
return $bank_transaction->makeVisible(['id','user_id','company_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('bank_transactions');
|
||||
$x->addItems($this->export_data['bank_transactions']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('bank_transactions');
|
||||
$x->addItems($this->export_data['bank_transactions']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['schedulers'] = $this->company->schedulers()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($scheduler) {
|
||||
$scheduler = $this->transformArrayOfKeys($scheduler, ['company_id', 'user_id']);
|
||||
@ -621,14 +621,14 @@ $this->export_data = null;
|
||||
return $scheduler->makeVisible(['id','user_id','company_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('schedulers');
|
||||
$x->addItems($this->export_data['schedulers']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('schedulers');
|
||||
$x->addItems($this->export_data['schedulers']);
|
||||
$this->export_data = null;
|
||||
|
||||
//write to tmp and email to owner();
|
||||
|
||||
|
||||
$this->writer->end();
|
||||
$this->writer->end();
|
||||
|
||||
|
||||
$this->zipAndSend();
|
||||
@ -680,20 +680,20 @@ $this->writer->end();
|
||||
|
||||
$zip->close();
|
||||
|
||||
Storage::disk(config('filesystems.default'))->put('backups/'.str_replace(".json", ".zip",$this->file_name), file_get_contents($zip_path));
|
||||
Storage::disk(config('filesystems.default'))->put('backups/'.str_replace(".json", ".zip", $this->file_name), file_get_contents($zip_path));
|
||||
|
||||
if(file_exists($zip_path)) {
|
||||
unlink($zip_path);
|
||||
}
|
||||
|
||||
if(file_exists($this->file_name)){
|
||||
if(file_exists($this->file_name)) {
|
||||
unlink($this->file_name);
|
||||
}
|
||||
|
||||
if(Ninja::isSelfHost()) {
|
||||
$storage_path = 'backups/'.str_replace(".json", ".zip",$this->file_name);
|
||||
$storage_path = 'backups/'.str_replace(".json", ".zip", $this->file_name);
|
||||
} else {
|
||||
$storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.str_replace(".json", ".zip",$this->file_name));
|
||||
$storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.str_replace(".json", ".zip", $this->file_name));
|
||||
}
|
||||
|
||||
$url = Cache::get($this->hash);
|
||||
|
@ -338,7 +338,7 @@ class CompanyImport implements ShouldQueue
|
||||
private function unzipFile()
|
||||
{
|
||||
$path = TempFile::filePath(Storage::disk(config('filesystems.default'))->get($this->file_location), basename($this->file_location));
|
||||
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$res = $zip->open($path);
|
||||
$file_path = sys_get_temp_dir().'/'.sha1(microtime());
|
||||
@ -357,7 +357,7 @@ class CompanyImport implements ShouldQueue
|
||||
}
|
||||
|
||||
$file_path = "{$file_path}/backup.json";
|
||||
|
||||
|
||||
nlog($file_path);
|
||||
|
||||
if (! file_exists($file_path)) {
|
||||
|
@ -1,65 +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\Jobs\Cron;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\RecurringInvoice;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
/*@not used*/
|
||||
|
||||
class CompanyRecurringCron
|
||||
{
|
||||
use Dispatchable;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//multiDB environment, need to
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
MultiDB::setDB($db);
|
||||
|
||||
Company::where('is_disabled', 0)
|
||||
->whereHas('recurring_invoices', function ($query) {
|
||||
$query->where('next_send_date', '<=', now()->toDateTimeString())
|
||||
->whereNotNull('next_send_date')
|
||||
->whereNull('deleted_at')
|
||||
->where('is_deleted', false)
|
||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
->where('remaining_cycles', '!=', '0')
|
||||
->whereHas('client', function ($query) {
|
||||
$query->where('is_deleted', 0)
|
||||
->where('deleted_at', null);
|
||||
});
|
||||
})
|
||||
->cursor()->each(function ($company) {
|
||||
SendCompanyRecurring::dispatch($company->id, $company->db);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ class RecurringExpensesCron
|
||||
Auth::logout();
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
$recurring_expenses = RecurringExpense::where('next_send_date', '<=', now()->toDateTimeString())
|
||||
$recurring_expenses = RecurringExpense::query()->where('next_send_date', '<=', now()->toDateTimeString())
|
||||
->whereNotNull('next_send_date')
|
||||
->whereNull('deleted_at')
|
||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
@ -76,7 +76,7 @@ class RecurringExpensesCron
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
MultiDB::setDB($db);
|
||||
|
||||
$recurring_expenses = RecurringExpense::where('next_send_date', '<=', now()->toDateTimeString())
|
||||
$recurring_expenses = RecurringExpense::query()->where('next_send_date', '<=', now()->toDateTimeString())
|
||||
->whereNotNull('next_send_date')
|
||||
->whereNull('deleted_at')
|
||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
|
@ -48,7 +48,7 @@ class RecurringInvoicesCron
|
||||
Auth::logout();
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
$recurring_invoices = RecurringInvoice::where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
$recurring_invoices = RecurringInvoice::query()->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
->where('is_deleted', false)
|
||||
->where('remaining_cycles', '!=', '0')
|
||||
->whereNotNull('next_send_date')
|
||||
@ -87,7 +87,7 @@ class RecurringInvoicesCron
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
MultiDB::setDB($db);
|
||||
|
||||
$recurring_invoices = RecurringInvoice::where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
$recurring_invoices = RecurringInvoice::query()->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
->where('is_deleted', false)
|
||||
->where('remaining_cycles', '!=', '0')
|
||||
->whereNull('deleted_at')
|
||||
|
@ -1,74 +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\Jobs\Cron;
|
||||
|
||||
use App\Jobs\RecurringInvoice\SendRecurring;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\RecurringInvoice;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
/*@not used*/
|
||||
|
||||
class SendCompanyRecurring
|
||||
{
|
||||
use Dispatchable;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
/** @var \App\Models\Company $company */
|
||||
public $company;
|
||||
|
||||
public function __construct(private int $company_id, private string $db)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
MultiDB::setDB($this->db);
|
||||
|
||||
$recurring_invoices = Company::where('id', $this->company_id)
|
||||
->where('is_disabled', 0)
|
||||
->whereHas('recurring_invoices', function ($query) {
|
||||
$query->where('next_send_date', '<=', now()->toDateTimeString())
|
||||
->whereNotNull('next_send_date')
|
||||
->whereNull('deleted_at')
|
||||
->where('is_deleted', false)
|
||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
->where('remaining_cycles', '!=', '0')
|
||||
->whereHas('client', function ($query) {
|
||||
$query->where('is_deleted', 0)
|
||||
->where('deleted_at', null);
|
||||
});
|
||||
})
|
||||
->cursor()->each(function ($recurring_invoice) {
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
if ($recurring_invoice->company->stop_on_unpaid_recurring) {
|
||||
if ($recurring_invoice->invoices()->whereIn('status_id', [2, 3])->where('is_deleted', 0)->where('balance', '>', 0)->exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
(new SendRecurring($recurring_invoice, $recurring_invoice->company->db))->handle();
|
||||
} catch (\Exception $e) {
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id} ".$e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ class SubscriptionCron
|
||||
->whereNotNull('subscription_id')
|
||||
->cursor();
|
||||
|
||||
$invoices->each(function ($invoice) {
|
||||
$invoices->each(function (Invoice $invoice) {
|
||||
$subscription = $invoice->subscription;
|
||||
|
||||
$body = [
|
||||
@ -80,7 +80,7 @@ class SubscriptionCron
|
||||
->whereNotNull('subscription_id')
|
||||
->cursor();
|
||||
|
||||
$invoices->each(function ($invoice) {
|
||||
$invoices->each(function (Invoice $invoice) {
|
||||
$subscription = $invoice->subscription;
|
||||
|
||||
$body = [
|
||||
|
@ -99,10 +99,9 @@ class NinjaMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
$this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name);
|
||||
}elseif(isset($this->nmo->invitation->user)){
|
||||
} elseif(isset($this->nmo->invitation->user)) {
|
||||
$this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name());
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
$mailable = $this->nmo->mailable;
|
||||
|
||||
|
||||
/** May need to re-build it here */
|
||||
if(Ninja::isHosted() && method_exists($mailable, 'build')) {
|
||||
$mailable->build();
|
||||
@ -269,14 +268,14 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
if(Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') {
|
||||
//check if outlook.
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
$email = $this->nmo->to_user->email;
|
||||
$domain = explode("@", $email)[1] ?? "";
|
||||
$dns = dns_get_record($domain, DNS_MX);
|
||||
$server = $dns[0]["target"];
|
||||
if(stripos($server, "outlook.com") !== false){
|
||||
|
||||
if(stripos($server, "outlook.com") !== false) {
|
||||
|
||||
$this->mailer = 'postmark';
|
||||
$this->client_postmark_secret = config('services.postmark-outlook.token');
|
||||
|
||||
@ -286,8 +285,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -409,7 +407,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
private function setHostedMailgunMailer()
|
||||
{
|
||||
|
||||
|
||||
if (property_exists($this->nmo->settings, 'email_from_name') && strlen($this->nmo->settings->email_from_name) > 1) {
|
||||
$email_from_name = $this->nmo->settings->email_from_name;
|
||||
} else {
|
||||
|
@ -16,7 +16,6 @@ namespace App\Jobs\Mail;
|
||||
*/
|
||||
class NinjaMailerObject
|
||||
{
|
||||
|
||||
/* @var Illuminate\Mail\Mailable */
|
||||
public $mailable;
|
||||
|
||||
|
@ -34,7 +34,10 @@ use App\Notifications\Ninja\EmailBounceNotification;
|
||||
|
||||
class ProcessMailgunWebhook implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
@ -89,8 +92,9 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
{
|
||||
nlog($this->request);
|
||||
|
||||
if(!$this->request['event-data']['tags'][0])
|
||||
if(!$this->request['event-data']['tags'][0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($this->request['event-data']['tags'][0]);
|
||||
$company = Company::where('company_key', $this->request['event-data']['tags'][0])->first();
|
||||
@ -112,7 +116,7 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
if (isset($this->request['event-details']['delivery-status']['message'])) {
|
||||
$this->invitation->email_error = $this->request['event-details']['delivery-status']['message'];
|
||||
}
|
||||
|
||||
|
||||
switch ($this->request['event-data']['event']) {
|
||||
case 'delivered':
|
||||
return $this->processDelivery();
|
||||
@ -128,50 +132,50 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "7f388cf8096aa0bca1477aee9d91e156c61f8fa8282c7f1c0c",
|
||||
"timestamp": "1705376308",
|
||||
"signature": "a22b7c3dd4861e27a1664cef3611a1954c0665cfcaca9b8f35ee216243a4ce3f"
|
||||
},
|
||||
"event-data": {
|
||||
"id": "Ase7i2zsRYeDXztHGENqRA",
|
||||
"timestamp": 1521243339.873676,
|
||||
"log-level": "info",
|
||||
"event": "opened",
|
||||
"message": {
|
||||
"headers": {
|
||||
"message-id": "20130503182626.18666.16540@mail.invoicing.co"
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "7f388cf8096aa0bca1477aee9d91e156c61f8fa8282c7f1c0c",
|
||||
"timestamp": "1705376308",
|
||||
"signature": "a22b7c3dd4861e27a1664cef3611a1954c0665cfcaca9b8f35ee216243a4ce3f"
|
||||
},
|
||||
"event-data": {
|
||||
"id": "Ase7i2zsRYeDXztHGENqRA",
|
||||
"timestamp": 1521243339.873676,
|
||||
"log-level": "info",
|
||||
"event": "opened",
|
||||
"message": {
|
||||
"headers": {
|
||||
"message-id": "20130503182626.18666.16540@mail.invoicing.co"
|
||||
}
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"recipient-domain": "example.com",
|
||||
"ip": "50.56.129.169",
|
||||
"geolocation": {
|
||||
"country": "US",
|
||||
"region": "CA",
|
||||
"city": "San Francisco"
|
||||
},
|
||||
"client-info": {
|
||||
"client-os": "Linux",
|
||||
"device-type": "desktop",
|
||||
"client-name": "Chrome",
|
||||
"client-type": "browser",
|
||||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31"
|
||||
},
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"recipient-domain": "example.com",
|
||||
"ip": "50.56.129.169",
|
||||
"geolocation": {
|
||||
"country": "US",
|
||||
"region": "CA",
|
||||
"city": "San Francisco"
|
||||
},
|
||||
"client-info": {
|
||||
"client-os": "Linux",
|
||||
"device-type": "desktop",
|
||||
"client-name": "Chrome",
|
||||
"client-type": "browser",
|
||||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31"
|
||||
},
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
private function processOpen()
|
||||
{
|
||||
$this->invitation->opened_date = now();
|
||||
@ -180,8 +184,9 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
/** Prevents Gmail tracking from firing inappropriately */
|
||||
if($this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3)
|
||||
if($this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event = [
|
||||
'bounce_id' => '',
|
||||
@ -201,74 +206,74 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "70b91a64ed0f1bdf90fb9c6ea7e3c31d5792a3d0945ffc20fe",
|
||||
"timestamp": "1705376276",
|
||||
"signature": "ba96f841fc236e1bf5840b02fad512d0bd15b0731b5e6b154764c7a05f7ee999"
|
||||
},
|
||||
"event-data": {
|
||||
"id": "CPgfbmQMTCKtHW6uIWtuVe",
|
||||
"timestamp": 1521472262.908181,
|
||||
"log-level": "info",
|
||||
"event": "delivered",
|
||||
"delivery-status": {
|
||||
"tls": true,
|
||||
"mx-host": "smtp-in.example.com",
|
||||
"code": 250,
|
||||
"description": "",
|
||||
"session-seconds": 0.4331989288330078,
|
||||
"utf8": true,
|
||||
"attempt-no": 1,
|
||||
"message": "OK",
|
||||
"certificate-verified": true
|
||||
},
|
||||
"flags": {
|
||||
"is-routed": false,
|
||||
"is-authenticated": true,
|
||||
"is-system-test": false,
|
||||
"is-test-mode": false
|
||||
},
|
||||
"envelope": {
|
||||
"transport": "smtp",
|
||||
"sender": "bob@mail.invoicing.co",
|
||||
"sending-ip": "209.61.154.250",
|
||||
"targets": "alice@example.com"
|
||||
},
|
||||
"message": {
|
||||
"headers": {
|
||||
"to": "Alice <alice@example.com>",
|
||||
"message-id": "20130503182626.18666.16540@mail.invoicing.co",
|
||||
"from": "Bob <bob@mail.invoicing.co>",
|
||||
"subject": "Test delivered webhook"
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "70b91a64ed0f1bdf90fb9c6ea7e3c31d5792a3d0945ffc20fe",
|
||||
"timestamp": "1705376276",
|
||||
"signature": "ba96f841fc236e1bf5840b02fad512d0bd15b0731b5e6b154764c7a05f7ee999"
|
||||
},
|
||||
"attachments": [],
|
||||
"size": 111
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"recipient-domain": "example.com",
|
||||
"storage": {
|
||||
"url": "https://se.api.mailgun.net/v3/domains/mail.invoicing.co/messages/message_key",
|
||||
"key": "message_key"
|
||||
},
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
"event-data": {
|
||||
"id": "CPgfbmQMTCKtHW6uIWtuVe",
|
||||
"timestamp": 1521472262.908181,
|
||||
"log-level": "info",
|
||||
"event": "delivered",
|
||||
"delivery-status": {
|
||||
"tls": true,
|
||||
"mx-host": "smtp-in.example.com",
|
||||
"code": 250,
|
||||
"description": "",
|
||||
"session-seconds": 0.4331989288330078,
|
||||
"utf8": true,
|
||||
"attempt-no": 1,
|
||||
"message": "OK",
|
||||
"certificate-verified": true
|
||||
},
|
||||
"flags": {
|
||||
"is-routed": false,
|
||||
"is-authenticated": true,
|
||||
"is-system-test": false,
|
||||
"is-test-mode": false
|
||||
},
|
||||
"envelope": {
|
||||
"transport": "smtp",
|
||||
"sender": "bob@mail.invoicing.co",
|
||||
"sending-ip": "209.61.154.250",
|
||||
"targets": "alice@example.com"
|
||||
},
|
||||
"message": {
|
||||
"headers": {
|
||||
"to": "Alice <alice@example.com>",
|
||||
"message-id": "20130503182626.18666.16540@mail.invoicing.co",
|
||||
"from": "Bob <bob@mail.invoicing.co>",
|
||||
"subject": "Test delivered webhook"
|
||||
},
|
||||
"attachments": [],
|
||||
"size": 111
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"recipient-domain": "example.com",
|
||||
"storage": {
|
||||
"url": "https://se.api.mailgun.net/v3/domains/mail.invoicing.co/messages/message_key",
|
||||
"key": "message_key"
|
||||
},
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
private function processDelivery()
|
||||
{
|
||||
$this->invitation->email_status = 'delivered';
|
||||
$this->invitation->save();
|
||||
|
||||
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
if($sl) {
|
||||
@ -384,47 +389,47 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "d7be371deef49c8b187119df295e3eb17fd1974d513a4be2cb",
|
||||
"timestamp": "1705376380",
|
||||
"signature": "52f31c75b492d67be906423279e0effe563e28790ee65ba23a1b30006df649df"
|
||||
},
|
||||
"event-data": {
|
||||
"id": "-Agny091SquKnsrW2NEKUA",
|
||||
"timestamp": 1521233123.501324,
|
||||
"log-level": "warn",
|
||||
"event": "complained",
|
||||
"envelope": {
|
||||
"sending-ip": "173.193.210.33"
|
||||
},
|
||||
"flags": {
|
||||
"is-test-mode": false
|
||||
},
|
||||
"message": {
|
||||
"headers": {
|
||||
"to": "Alice <alice@example.com>",
|
||||
"message-id": "20110215055645.25246.63817@mail.invoicing.co",
|
||||
"from": "Bob <bob@mail.invoicing.co>",
|
||||
"subject": "Test complained webhook"
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "d7be371deef49c8b187119df295e3eb17fd1974d513a4be2cb",
|
||||
"timestamp": "1705376380",
|
||||
"signature": "52f31c75b492d67be906423279e0effe563e28790ee65ba23a1b30006df649df"
|
||||
},
|
||||
"attachments": [],
|
||||
"size": 111
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
"event-data": {
|
||||
"id": "-Agny091SquKnsrW2NEKUA",
|
||||
"timestamp": 1521233123.501324,
|
||||
"log-level": "warn",
|
||||
"event": "complained",
|
||||
"envelope": {
|
||||
"sending-ip": "173.193.210.33"
|
||||
},
|
||||
"flags": {
|
||||
"is-test-mode": false
|
||||
},
|
||||
"message": {
|
||||
"headers": {
|
||||
"to": "Alice <alice@example.com>",
|
||||
"message-id": "20110215055645.25246.63817@mail.invoicing.co",
|
||||
"from": "Bob <bob@mail.invoicing.co>",
|
||||
"subject": "Test complained webhook"
|
||||
},
|
||||
"attachments": [],
|
||||
"size": 111
|
||||
},
|
||||
"recipient": "alice@example.com",
|
||||
"campaigns": [],
|
||||
"tags": [
|
||||
"my_tag_1",
|
||||
"my_tag_2"
|
||||
],
|
||||
"user-variables": {
|
||||
"my_var_1": "Mailgun Variable #1",
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
private function processSpamComplaint()
|
||||
{
|
||||
$this->invitation->email_status = 'spam';
|
||||
|
@ -56,7 +56,7 @@ class TaskScheduler implements ShouldQueue
|
||||
->where('next_run', '<=', now())
|
||||
->cursor()
|
||||
->each(function ($scheduler) {
|
||||
|
||||
|
||||
nlog("Doing job {$scheduler->name}");
|
||||
|
||||
try {
|
||||
@ -81,7 +81,7 @@ class TaskScheduler implements ShouldQueue
|
||||
->where('next_run', '<=', now())
|
||||
->cursor()
|
||||
->each(function ($scheduler) {
|
||||
|
||||
|
||||
nlog("Doing job {$scheduler->name}");
|
||||
|
||||
try {
|
||||
|
@ -106,7 +106,7 @@ class EmailPayment implements ShouldQueue
|
||||
(new NinjaMailerJob($nmo))->handle();
|
||||
|
||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, $this->contact, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function emailAllContacts($email_builder): void
|
||||
|
@ -94,6 +94,7 @@ class UserEmailChanged implements ShouldQueue
|
||||
'logo' => $this->company->present()->logo(),
|
||||
'settings' => $this->settings,
|
||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||
'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user