mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
842a598948
@ -1 +1 @@
|
|||||||
5.5.88
|
5.5.102
|
@ -190,14 +190,12 @@ class BackupUpdate extends Command
|
|||||||
->where('filename', '!=', '')
|
->where('filename', '!=', '')
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($backup) {
|
->each(function ($backup) {
|
||||||
|
|
||||||
$backup_bin = Storage::disk('s3')->get($backup->filename);
|
$backup_bin = Storage::disk('s3')->get($backup->filename);
|
||||||
|
|
||||||
if ($backup_bin) {
|
if ($backup_bin) {
|
||||||
Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin);
|
Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin);
|
||||||
|
|
||||||
nlog("Backups - Moving {$backup->filename} to {$this->option('disk')}");
|
nlog("Backups - Moving {$backup->filename} to {$this->option('disk')}");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use App\Models\Client;
|
|||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyLedger;
|
use App\Models\CompanyLedger;
|
||||||
|
use App\Models\CompanyToken;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
@ -160,16 +161,33 @@ class CheckData extends Command
|
|||||||
|
|
||||||
private function checkCompanyTokens()
|
private function checkCompanyTokens()
|
||||||
{
|
{
|
||||||
CompanyUser::doesnthave('token')->cursor()->each(function ($cu) {
|
// CompanyUser::whereDoesntHave('token', function ($query){
|
||||||
if ($cu->user) {
|
// return $query->where('is_system', 1);
|
||||||
$this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}");
|
// })->cursor()->each(function ($cu){
|
||||||
|
// if ($cu->user) {
|
||||||
|
// $this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}");
|
||||||
|
// (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||||
|
// } else {
|
||||||
|
// $this->logMessage("Dangling User ID # {$cu->id}");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
CompanyUser::query()->cursor()->each(function ($cu) {
|
||||||
|
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
||||||
|
$this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}");
|
||||||
|
|
||||||
|
if ($cu->company && $cu->user) {
|
||||||
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||||
} else {
|
}
|
||||||
$this->logMessage("Dangling User ID # {$cu->id}");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checkOauthSanity
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function checkOauthSanity()
|
private function checkOauthSanity()
|
||||||
{
|
{
|
||||||
User::where('oauth_provider_id', '1')->cursor()->each(function ($user) {
|
User::where('oauth_provider_id', '1')->cursor()->each(function ($user) {
|
||||||
|
@ -188,6 +188,7 @@ class DemoMode extends Command
|
|||||||
$company_token->account_id = $account->id;
|
$company_token->account_id = $account->id;
|
||||||
$company_token->name = 'test token';
|
$company_token->name = 'test token';
|
||||||
$company_token->token = 'TOKEN';
|
$company_token->token = 'TOKEN';
|
||||||
|
$company_token->is_system = true;
|
||||||
$company_token->save();
|
$company_token->save();
|
||||||
|
|
||||||
$u2->companies()->attach($company->id, [
|
$u2->companies()->attach($company->id, [
|
||||||
|
@ -51,8 +51,8 @@ class ReactBuilder extends Command
|
|||||||
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||||
|
|
||||||
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
||||||
if (str_contains($file->getFileName(), '.js') && !strpos($file->getFileName(), '.json')) {
|
if ($file->getExtension() == 'js') {
|
||||||
if (str_contains($file->getFileName(), 'index.')) {
|
if (str_contains($file->getFileName(), 'index-')) {
|
||||||
$includes .= '<script type="module" crossorigin src="/react/'.$file->getFileName().'"></script>'."\n";
|
$includes .= '<script type="module" crossorigin src="/react/'.$file->getFileName().'"></script>'."\n";
|
||||||
} else {
|
} else {
|
||||||
$includes .= '<link rel="modulepreload" href="/react/'.$file->getFileName().'">'."\n";
|
$includes .= '<link rel="modulepreload" href="/react/'.$file->getFileName().'">'."\n";
|
||||||
|
@ -27,7 +27,6 @@ use App\Jobs\Subscription\CleanStaleInvoiceOrder;
|
|||||||
use App\Jobs\Util\DiskCleanup;
|
use App\Jobs\Util\DiskCleanup;
|
||||||
use App\Jobs\Util\ReminderJob;
|
use App\Jobs\Util\ReminderJob;
|
||||||
use App\Jobs\Util\SchedulerCheck;
|
use App\Jobs\Util\SchedulerCheck;
|
||||||
use App\Jobs\Util\SendFailedEmails;
|
|
||||||
use App\Jobs\Util\UpdateExchangeRates;
|
use App\Jobs\Util\UpdateExchangeRates;
|
||||||
use App\Jobs\Util\VersionCheck;
|
use App\Jobs\Util\VersionCheck;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
|
@ -84,13 +84,13 @@ class ClientSettings extends BaseSettings
|
|||||||
*/
|
*/
|
||||||
public static function buildClientSettings($company_settings, $client_settings)
|
public static function buildClientSettings($company_settings, $client_settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (! $client_settings) {
|
if (! $client_settings) {
|
||||||
return $company_settings;
|
return $company_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($client_settings))
|
if (is_array($client_settings)) {
|
||||||
$client_settings = (object)$client_settings;
|
$client_settings = (object)$client_settings;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($company_settings as $key => $value) {
|
foreach ($company_settings as $key => $value) {
|
||||||
/* pseudo code
|
/* pseudo code
|
||||||
|
@ -449,6 +449,8 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $mailgun_domain = '';
|
public $mailgun_domain = '';
|
||||||
|
|
||||||
|
public $mailgun_endpoint = 'api.mailgun.net'; //api.eu.mailgun.net
|
||||||
|
|
||||||
public $auto_bill_standard_invoices = false;
|
public $auto_bill_standard_invoices = false;
|
||||||
|
|
||||||
public $email_alignment = 'center'; // center , left, right
|
public $email_alignment = 'center'; // center , left, right
|
||||||
@ -467,7 +469,17 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $show_task_item_description = false;
|
public $show_task_item_description = false;
|
||||||
|
|
||||||
|
public $client_initiated_payments = false;
|
||||||
|
|
||||||
|
public $client_initiated_payments_minimum = 0;
|
||||||
|
|
||||||
|
public $sync_invoice_quote_columns = true;
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
|
'mailgun_endpoint' => 'string',
|
||||||
|
'client_initiated_payments' => 'bool',
|
||||||
|
'client_initiated_payments_minimum' => 'float',
|
||||||
|
'sync_invoice_quote_columns' => 'bool',
|
||||||
'show_task_item_description' => 'bool',
|
'show_task_item_description' => 'bool',
|
||||||
'allow_billable_task_items' => 'bool',
|
'allow_billable_task_items' => 'bool',
|
||||||
'accept_client_input_quote_approval' => 'bool',
|
'accept_client_input_quote_approval' => 'bool',
|
||||||
@ -493,7 +505,6 @@ class CompanySettings extends BaseSettings
|
|||||||
'purchase_order_design_id' => 'string',
|
'purchase_order_design_id' => 'string',
|
||||||
'purchase_order_footer' => 'string',
|
'purchase_order_footer' => 'string',
|
||||||
'purchase_order_number_pattern' => 'string',
|
'purchase_order_number_pattern' => 'string',
|
||||||
'purchase_order_number_counter' => 'int',
|
|
||||||
'page_numbering_alignment' => 'string',
|
'page_numbering_alignment' => 'string',
|
||||||
'page_numbering' => 'bool',
|
'page_numbering' => 'bool',
|
||||||
'auto_archive_invoice_cancelled' => 'bool',
|
'auto_archive_invoice_cancelled' => 'bool',
|
||||||
@ -525,7 +536,6 @@ class CompanySettings extends BaseSettings
|
|||||||
'reminder_send_time' => 'int',
|
'reminder_send_time' => 'int',
|
||||||
'email_sending_method' => 'string',
|
'email_sending_method' => 'string',
|
||||||
'gmail_sending_user_id' => 'string',
|
'gmail_sending_user_id' => 'string',
|
||||||
'currency_id' => 'string',
|
|
||||||
'counter_number_applied' => 'string',
|
'counter_number_applied' => 'string',
|
||||||
'quote_number_applied' => 'string',
|
'quote_number_applied' => 'string',
|
||||||
'email_subject_custom1' => 'string',
|
'email_subject_custom1' => 'string',
|
||||||
@ -907,6 +917,15 @@ class CompanySettings extends BaseSettings
|
|||||||
'$product.tax',
|
'$product.tax',
|
||||||
'$product.line_total',
|
'$product.line_total',
|
||||||
],
|
],
|
||||||
|
'product_quote_columns' => [
|
||||||
|
'$product.item',
|
||||||
|
'$product.description',
|
||||||
|
'$product.unit_cost',
|
||||||
|
'$product.quantity',
|
||||||
|
'$product.discount',
|
||||||
|
'$product.tax',
|
||||||
|
'$product.line_total',
|
||||||
|
],
|
||||||
'task_columns' =>[
|
'task_columns' =>[
|
||||||
'$task.service',
|
'$task.service',
|
||||||
'$task.description',
|
'$task.description',
|
||||||
|
36
app/DataMapper/Schedule/EmailRecord.php
Normal file
36
app/DataMapper/Schedule/EmailRecord.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?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\DataMapper\Schedule;
|
||||||
|
|
||||||
|
class EmailRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Defines the template name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $template = 'email_record';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the template name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $entity = ''; // invoice, credit, quote, purchase_order
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the template name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $entity_id = '';
|
||||||
|
}
|
28
app/DataMapper/Tax/ClientTaxData.php
Normal file
28
app/DataMapper/Tax/ClientTaxData.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClientTaxData
|
||||||
|
*
|
||||||
|
* Definition for the client tax data
|
||||||
|
*/
|
||||||
|
class ClientTaxData
|
||||||
|
{
|
||||||
|
public int $updated_at;
|
||||||
|
|
||||||
|
public function __construct(public Response $origin, public Response $destination)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
28
app/DataMapper/Tax/CompanyTaxData.php
Normal file
28
app/DataMapper/Tax/CompanyTaxData.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CompanyTaxData
|
||||||
|
*
|
||||||
|
* Definition for the company tax data structure
|
||||||
|
*/
|
||||||
|
class CompanyTaxData
|
||||||
|
{
|
||||||
|
public int $updated_at;
|
||||||
|
|
||||||
|
public function __construct(public Response $origin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
28
app/DataMapper/Tax/InvoiceTaxData.php
Normal file
28
app/DataMapper/Tax/InvoiceTaxData.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceTaxData
|
||||||
|
*
|
||||||
|
* Definition for the invoice tax data structure
|
||||||
|
*/
|
||||||
|
class InvoiceTaxData
|
||||||
|
{
|
||||||
|
public int $updated_at;
|
||||||
|
|
||||||
|
public function __construct(public Response $origin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
17
app/DataMapper/Tax/RuleInterface.php
Normal file
17
app/DataMapper/Tax/RuleInterface.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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\DataMapper\Tax;
|
||||||
|
|
||||||
|
interface RuleInterface
|
||||||
|
{
|
||||||
|
public function run();
|
||||||
|
}
|
66
app/DataMapper/Tax/ZipTax/Response.php
Normal file
66
app/DataMapper/Tax/ZipTax/Response.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\DataMapper\Tax\ZipTax;
|
||||||
|
|
||||||
|
class Response
|
||||||
|
{
|
||||||
|
public string $version = 'v40';
|
||||||
|
|
||||||
|
public int $rCode = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ["results" => [
|
||||||
|
* [
|
||||||
|
* "geoPostalCode" => "92582",
|
||||||
|
* "geoCity" => "SAN JACINTO",
|
||||||
|
* "geoCounty" => "RIVERSIDE",
|
||||||
|
* "geoState" => "CA",
|
||||||
|
* "taxSales" => 0.0875,
|
||||||
|
* "taxUse" => 0.0875,
|
||||||
|
* "txbService" => "N",
|
||||||
|
* "txbFreight" => "N",
|
||||||
|
* "stateSalesTax" => 0.06,
|
||||||
|
* "stateUseTax" => 0.06,
|
||||||
|
* "citySalesTax" => 0.01,
|
||||||
|
* "cityUseTax" => 0.01,
|
||||||
|
* "cityTaxCode" => "874",
|
||||||
|
* "countySalesTax" => 0.0025,
|
||||||
|
* "countyUseTax" => 0.0025,
|
||||||
|
* "countyTaxCode" => "",
|
||||||
|
* "districtSalesTax" => 0.015,
|
||||||
|
* "districtUseTax" => 0.015,
|
||||||
|
* "district1Code" => "26",
|
||||||
|
* "district1SalesTax" => 0,
|
||||||
|
* "district1UseTax" => 0,
|
||||||
|
* "district2Code" => "26",
|
||||||
|
* "district2SalesTax" => 0.005,
|
||||||
|
* "district2UseTax" => 0.005,
|
||||||
|
* "district3Code" => "",
|
||||||
|
* "district3SalesTax" => 0,
|
||||||
|
* "district3UseTax" => 0,
|
||||||
|
* "district4Code" => "33",
|
||||||
|
* "district4SalesTax" => 0.01,
|
||||||
|
* "district4UseTax" => 0.01,
|
||||||
|
* "district5Code" => "",
|
||||||
|
* "district5SalesTax" => 0,
|
||||||
|
* "district5UseTax" => 0,
|
||||||
|
* "originDestination" => "D",
|
||||||
|
* ],
|
||||||
|
* ]
|
||||||
|
* ];
|
||||||
|
*
|
||||||
|
* @var mixed[]
|
||||||
|
*/
|
||||||
|
public array $results = [];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
96
app/DataMapper/Tax/de/Rule.php
Normal file
96
app/DataMapper/Tax/de/Rule.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?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\DataMapper\Tax\de;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\RuleInterface;
|
||||||
|
|
||||||
|
class Rule implements RuleInterface
|
||||||
|
{
|
||||||
|
public float $vat_rate = 19;
|
||||||
|
|
||||||
|
public float $vat_threshold = 10000;
|
||||||
|
|
||||||
|
public float $vat_reduced_rate = 7;
|
||||||
|
|
||||||
|
public float $vat_reduced_threshold = 10000;
|
||||||
|
|
||||||
|
public float $at_vat_rate = 20; // Austria
|
||||||
|
|
||||||
|
public float $be_vat_rate = 21; // Belgium
|
||||||
|
|
||||||
|
public float $bg_vat_rate = 20; // Bulgaria
|
||||||
|
|
||||||
|
public float $hr_vat_rate = 25; // Croatia
|
||||||
|
|
||||||
|
public float $cy_vat_rate = 19; // Cyprus
|
||||||
|
|
||||||
|
public float $cz_vat_rate = 21; // Czech Republic
|
||||||
|
|
||||||
|
public float $dk_vat_rate = 25; // Denmark
|
||||||
|
|
||||||
|
public float $ee_vat_rate = 20; // Estonia
|
||||||
|
|
||||||
|
public float $fi_vat_rate = 24; // Finland
|
||||||
|
|
||||||
|
public float $fr_vat_rate = 20; // France
|
||||||
|
|
||||||
|
public float $de_vat_rate = 19; // Germany
|
||||||
|
|
||||||
|
public float $gr_vat_rate = 24; // Greece
|
||||||
|
|
||||||
|
public float $hu_vat_rate = 27; // Hungary
|
||||||
|
|
||||||
|
public float $ie_vat_rate = 23; // Ireland
|
||||||
|
|
||||||
|
public float $it_vat_rate = 22; // Italy
|
||||||
|
|
||||||
|
public float $lv_vat_rate = 21; // Latvia
|
||||||
|
|
||||||
|
public float $lt_vat_rate = 21; // Lithuania
|
||||||
|
|
||||||
|
public float $lu_vat_rate = 17; // Luxembourg
|
||||||
|
|
||||||
|
public float $mt_vat_rate = 18; // Malta
|
||||||
|
|
||||||
|
public float $nl_vat_rate = 21; // Netherlands
|
||||||
|
|
||||||
|
public float $pl_vat_rate = 23; // Poland
|
||||||
|
|
||||||
|
public float $pt_vat_rate = 23; // Portugal
|
||||||
|
|
||||||
|
public float $ro_vat_rate = 19; // Romania
|
||||||
|
|
||||||
|
public float $sk_vat_rate = 20; // Slovakia
|
||||||
|
|
||||||
|
public float $si_vat_rate = 22; // Slovenia
|
||||||
|
|
||||||
|
public float $es_vat_rate = 21; // Spain
|
||||||
|
|
||||||
|
public float $se_vat_rate = 25; // Sweden
|
||||||
|
|
||||||
|
public float $gb_vat_rate = 20; // United Kingdom
|
||||||
|
|
||||||
|
public bool $consumer_tax_exempt = false;
|
||||||
|
|
||||||
|
public bool $business_tax_exempt = true;
|
||||||
|
|
||||||
|
public bool $eu_business_tax_exempt = true;
|
||||||
|
|
||||||
|
public bool $foreign_business_tax_exempt = true;
|
||||||
|
|
||||||
|
public bool $foreign_consumer_tax_exempt = true;
|
||||||
|
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
70
app/DataMapper/Tax/us/Rule.php
Normal file
70
app/DataMapper/Tax/us/Rule.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?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\DataMapper\Tax\us;
|
||||||
|
|
||||||
|
class Rule
|
||||||
|
{
|
||||||
|
|
||||||
|
public float $al_sales_tax_rate = 4; // Alabama
|
||||||
|
public float $ak_sales_tax_rate = 0; // Alaska
|
||||||
|
public float $az_sales_tax_rate = 5.6; // Arizona
|
||||||
|
public float $ar_sales_tax_rate = 6.5; // Arkansas
|
||||||
|
public float $ca_sales_tax_rate = 7.25; // California - https://services.maps.cdtfa.ca.gov/api/taxrate/GetRateByAddress?address=2444+s+alameda+st&city=los+angeles&zip=90058
|
||||||
|
public float $co_sales_tax_rate = 2.9; // Colorado
|
||||||
|
public float $ct_sales_tax_rate = 6.35; // Connecticut
|
||||||
|
public float $de_sales_tax_rate = 0; // Delaware
|
||||||
|
public float $fl_sales_tax_rate = 6; // Florida
|
||||||
|
public float $ga_sales_tax_rate = 4; // Georgia
|
||||||
|
public float $hi_sales_tax_rate = 4; // Hawaii
|
||||||
|
public float $id_sales_tax_rate = 6; // Idaho
|
||||||
|
public float $il_sales_tax_rate = 6.25; // Illinois
|
||||||
|
public float $in_sales_tax_rate = 7; // Indiana
|
||||||
|
public float $ia_sales_tax_rate = 6; // Iowa
|
||||||
|
public float $ks_sales_tax_rate = 6.5; // Kansas
|
||||||
|
public float $ky_sales_tax_rate = 6; // Kentucky
|
||||||
|
public float $la_sales_tax_rate = 4.45; // Louisiana
|
||||||
|
public float $me_sales_tax_rate = 5.5; // Maine
|
||||||
|
public float $md_sales_tax_rate = 6; // Maryland
|
||||||
|
public float $ma_sales_tax_rate = 6.25; // Massachusetts
|
||||||
|
public float $mi_sales_tax_rate = 6; // Michigan
|
||||||
|
public float $mn_sales_tax_rate = 6.875; // Minnesota
|
||||||
|
public float $ms_sales_tax_rate = 7; // Mississippi
|
||||||
|
public float $mo_sales_tax_rate = 4.225; // Missouri
|
||||||
|
public float $mt_sales_tax_rate = 0; // Montana
|
||||||
|
public float $ne_sales_tax_rate = 5.5; // Nebraska
|
||||||
|
public float $nv_sales_tax_rate = 6.85; // Nevada
|
||||||
|
public float $nh_sales_tax_rate = 0; // New Hampshire
|
||||||
|
public float $nj_sales_tax_rate = 6.625; // New Jersey
|
||||||
|
public float $nm_sales_tax_rate = 5.125; // New Mexico
|
||||||
|
public float $ny_sales_tax_rate = 4; // New York
|
||||||
|
public float $nc_sales_tax_rate = 4.75; // North Carolina
|
||||||
|
public float $nd_sales_tax_rate = 5; // North Dakota
|
||||||
|
public float $oh_sales_tax_rate = 5.75; // Ohio
|
||||||
|
public float $ok_sales_tax_rate = 4.5; // Oklahoma
|
||||||
|
public float $or_sales_tax_rate = 0; // Oregon
|
||||||
|
public float $pa_sales_tax_rate = 6; // Pennsylvania
|
||||||
|
public float $ri_sales_tax_rate = 7; // Rhode Island
|
||||||
|
public float $sc_sales_tax_rate = 6; // South Carolina
|
||||||
|
public float $sd_sales_tax_rate = 4.5; // South Dakota
|
||||||
|
public float $tn_sales_tax_rate = 7; // Tennessee
|
||||||
|
public float $tx_sales_tax_rate = 6.25; // Texas
|
||||||
|
public float $ut_sales_tax_rate = 4.7; // Utah
|
||||||
|
public float $vt_sales_tax_rate = 6; // Vermont
|
||||||
|
public float $va_sales_tax_rate = 5.3; // Virginia
|
||||||
|
public float $wa_sales_tax_rate = 6.5; // Washington
|
||||||
|
public float $wv_sales_tax_rate = 6; // West Virginia
|
||||||
|
public float $wi_sales_tax_rate = 5; // Wisconsin
|
||||||
|
public float $wy_sales_tax_rate = 4; // Wyoming
|
||||||
|
public float $dc_sales_tax_rate = 6; // District of Columbia
|
||||||
|
public float $pr_sales_tax_rate = 11.5; // Puerto Rico
|
||||||
|
|
||||||
|
}
|
@ -13,14 +13,18 @@ namespace App\Events\Invoice;
|
|||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InvoiceWasCreated.
|
* Class InvoiceWasCreated.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasCreated
|
class InvoiceWasCreated implements ShouldBroadcast
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Invoice
|
* @var Invoice
|
||||||
@ -44,4 +48,25 @@ class InvoiceWasCreated
|
|||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
$this->event_vars = $event_vars;
|
$this->event_vars = $event_vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return PrivateChannel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['simple-channel'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data to broadcast.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function broadcastWith(): array
|
||||||
|
{
|
||||||
|
return ['id' => 'value'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
namespace App\Export\CSV;
|
namespace App\Export\CSV;
|
||||||
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class BaseExport
|
class BaseExport
|
||||||
{
|
{
|
||||||
@ -34,7 +34,6 @@ class BaseExport
|
|||||||
protected function filterByClients($query)
|
protected function filterByClients($query)
|
||||||
{
|
{
|
||||||
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
|
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
|
||||||
|
|
||||||
$client = Client::withTrashed()->find($this->input['client_id']);
|
$client = Client::withTrashed()->find($this->input['client_id']);
|
||||||
$this->client_description = $client->present()->name;
|
$this->client_description = $client->present()->name;
|
||||||
return $query->where('client_id', $this->input['client_id']);
|
return $query->where('client_id', $this->input['client_id']);
|
||||||
|
@ -34,6 +34,8 @@ class InvoiceItemExport extends BaseExport
|
|||||||
'amount' => 'amount',
|
'amount' => 'amount',
|
||||||
'balance' => 'balance',
|
'balance' => 'balance',
|
||||||
'client' => 'client_id',
|
'client' => 'client_id',
|
||||||
|
'client_number' => 'client.number',
|
||||||
|
'client_id_number' => 'client.id_number',
|
||||||
'custom_surcharge1' => 'custom_surcharge1',
|
'custom_surcharge1' => 'custom_surcharge1',
|
||||||
'custom_surcharge2' => 'custom_surcharge2',
|
'custom_surcharge2' => 'custom_surcharge2',
|
||||||
'custom_surcharge3' => 'custom_surcharge3',
|
'custom_surcharge3' => 'custom_surcharge3',
|
||||||
@ -198,6 +200,8 @@ class InvoiceItemExport extends BaseExport
|
|||||||
|
|
||||||
// if(in_array('client_id', $this->input['report_keys']))
|
// if(in_array('client_id', $this->input['report_keys']))
|
||||||
$entity['client'] = $invoice->client->present()->name();
|
$entity['client'] = $invoice->client->present()->name();
|
||||||
|
$entity['client_id_number'] = $invoice->client->id_number;
|
||||||
|
$entity['client_number'] = $invoice->client->number;
|
||||||
|
|
||||||
// if(in_array('status_id', $this->input['report_keys']))
|
// if(in_array('status_id', $this->input['report_keys']))
|
||||||
$entity['status'] = $invoice->stringStatus($invoice->status_id);
|
$entity['status'] = $invoice->stringStatus($invoice->status_id);
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace App\Export\CSV;
|
namespace App\Export\CSV;
|
||||||
|
|
||||||
use App\Utils\Ninja;
|
use App\Libraries\MultiDB;
|
||||||
use League\Csv\Writer;
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Libraries\MultiDB;
|
use App\Utils\Ninja;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use League\Csv\Writer;
|
||||||
|
|
||||||
class ProductSalesExport extends BaseExport
|
class ProductSalesExport extends BaseExport
|
||||||
{
|
{
|
||||||
@ -118,7 +118,6 @@ class ProductSalesExport extends BaseExport
|
|||||||
|
|
||||||
|
|
||||||
$grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) {
|
$grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) {
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'product' => $value,
|
'product' => $value,
|
||||||
'quantity' => $key->sum('quantity'),
|
'quantity' => $key->sum('quantity'),
|
||||||
@ -183,7 +182,6 @@ class ProductSalesExport extends BaseExport
|
|||||||
$this->sales->push($entity);
|
$this->sales->push($entity);
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
|
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
|
||||||
@ -207,23 +205,23 @@ class ProductSalesExport extends BaseExport
|
|||||||
if (strlen($entity['tax_name1']) > 1) {
|
if (strlen($entity['tax_name1']) > 1) {
|
||||||
$entity['tax_name1'] = $entity['tax_name1'] . ' [' . $entity['tax_rate1'] . '%]';
|
$entity['tax_name1'] = $entity['tax_name1'] . ' [' . $entity['tax_rate1'] . '%]';
|
||||||
$entity['tax_amount1'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate1']);
|
$entity['tax_amount1'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate1']);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$entity['tax_amount1'] = 0;
|
$entity['tax_amount1'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($entity['tax_name2']) > 1) {
|
if (strlen($entity['tax_name2']) > 1) {
|
||||||
$entity['tax_name2'] = $entity['tax_name2'] . ' [' . $entity['tax_rate2'] . '%]';
|
$entity['tax_name2'] = $entity['tax_name2'] . ' [' . $entity['tax_rate2'] . '%]';
|
||||||
$entity['tax_amount2'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate2']);
|
$entity['tax_amount2'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate2']);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$entity['tax_amount2'] = 0;
|
$entity['tax_amount2'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($entity['tax_name3']) > 1) {
|
if (strlen($entity['tax_name3']) > 1) {
|
||||||
$entity['tax_name3'] = $entity['tax_name3'] . ' [' . $entity['tax_rate3'] . '%]';
|
$entity['tax_name3'] = $entity['tax_name3'] . ' [' . $entity['tax_rate3'] . '%]';
|
||||||
$entity['tax_amount3'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate3']);
|
$entity['tax_amount3'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate3']);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$entity['tax_amount3'] = 0;
|
$entity['tax_amount3'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
@ -242,11 +240,9 @@ class ProductSalesExport extends BaseExport
|
|||||||
|
|
||||||
if ($invoice->uses_inclusive_taxes) {
|
if ($invoice->uses_inclusive_taxes) {
|
||||||
return round($amount - ($amount / (1 + ($tax_rate / 100))), 2);
|
return round($amount - ($amount / (1 + ($tax_rate / 100))), 2);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return round(($amount * $tax_rate / 100), 2);
|
return round(($amount * $tax_rate / 100), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -260,13 +256,13 @@ class ProductSalesExport extends BaseExport
|
|||||||
*/
|
*/
|
||||||
private function calculateDiscount(Invoice $invoice, $entity) :float
|
private function calculateDiscount(Invoice $invoice, $entity) :float
|
||||||
{
|
{
|
||||||
if($entity['discount'] == 0)
|
if ($entity['discount'] == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($invoice->is_amount_discount && $entity['discount'] != 0) {
|
if ($invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||||
return $entity['discount'];
|
return $entity['discount'];
|
||||||
}
|
} elseif (!$invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||||
elseif(!$invoice->is_amount_discount && $entity['discount'] != 0) {
|
|
||||||
return round($entity['line_total'] * ($entity['discount'] / 100), 2);
|
return round($entity['line_total'] * ($entity['discount'] / 100), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class DesignFactory
|
|||||||
$design->is_active = true;
|
$design->is_active = true;
|
||||||
$design->is_custom = true;
|
$design->is_custom = true;
|
||||||
$design->name = '';
|
$design->name = '';
|
||||||
$design->design = '';
|
$design->design = '[]';
|
||||||
|
|
||||||
return $design;
|
return $design;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class RecurringInvoiceFactory
|
|||||||
$invoice->remaining_cycles = -1;
|
$invoice->remaining_cycles = -1;
|
||||||
$invoice->paid_to_date = 0;
|
$invoice->paid_to_date = 0;
|
||||||
$invoice->auto_bill_enabled = false;
|
$invoice->auto_bill_enabled = false;
|
||||||
|
$invoice->is_proforma = false;
|
||||||
$invoice->auto_bill = 'off';
|
$invoice->auto_bill = 'off';
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
@ -46,6 +46,7 @@ class RecurringInvoiceToInvoiceFactory
|
|||||||
$invoice->custom_value4 = $recurring_invoice->custom_value4;
|
$invoice->custom_value4 = $recurring_invoice->custom_value4;
|
||||||
$invoice->amount = $recurring_invoice->amount;
|
$invoice->amount = $recurring_invoice->amount;
|
||||||
$invoice->uses_inclusive_taxes = $recurring_invoice->uses_inclusive_taxes;
|
$invoice->uses_inclusive_taxes = $recurring_invoice->uses_inclusive_taxes;
|
||||||
|
$invoice->is_proforma = $recurring_invoice->is_proforma;
|
||||||
|
|
||||||
$invoice->custom_surcharge1 = $recurring_invoice->custom_surcharge1;
|
$invoice->custom_surcharge1 = $recurring_invoice->custom_surcharge1;
|
||||||
$invoice->custom_surcharge2 = $recurring_invoice->custom_surcharge2;
|
$invoice->custom_surcharge2 = $recurring_invoice->custom_surcharge2;
|
||||||
|
@ -85,7 +85,10 @@ class CreditFilters extends QueryFilters
|
|||||||
->orWhere('credits.custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('credits.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('credits.custom_value2', 'like', '%'.$filter.'%')
|
->orWhere('credits.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('credits.custom_value3', 'like', '%'.$filter.'%')
|
->orWhere('credits.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('credits.custom_value4', 'like', '%'.$filter.'%');
|
->orWhere('credits.custom_value4', 'like', '%'.$filter.'%')
|
||||||
|
->orWhereHas('client', function ($q) use ($filter) {
|
||||||
|
$q->where('name', 'like', '%'.$filter.'%');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,10 @@ class InvoiceFilters extends QueryFilters
|
|||||||
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value4', 'like', '%'.$filter.'%');
|
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||||
|
->orWhereHas('client', function ($q) use ($filter) {
|
||||||
|
$q->where('name', 'like', '%'.$filter.'%');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +131,7 @@ class InvoiceFilters extends QueryFilters
|
|||||||
*/
|
*/
|
||||||
public function upcoming(): Builder
|
public function upcoming(): Builder
|
||||||
{
|
{
|
||||||
return $this->builder
|
return $this->builder->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
$query->whereNull('due_date')
|
$query->whereNull('due_date')
|
||||||
->orWhere('due_date', '>', now());
|
->orWhere('due_date', '>', now());
|
||||||
|
@ -63,8 +63,8 @@ class PurchaseOrderFilters extends QueryFilters
|
|||||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($status_parameters) >=1) {
|
if (count($po_status) >=1) {
|
||||||
$query->whereIn('status_id', $status_parameters);
|
$query->whereIn('status_id', $po_status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -93,7 +93,10 @@ class PurchaseOrderFilters extends QueryFilters
|
|||||||
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value4', 'like', '%'.$filter.'%');
|
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||||
|
->orWhereHas('vendor', function ($q) use ($filter) {
|
||||||
|
$q->where('name', 'like', '%'.$filter.'%');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,10 @@ class QuoteFilters extends QueryFilters
|
|||||||
->orwhere('custom_value1', 'like', '%'.$filter.'%')
|
->orwhere('custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value4', 'like', '%'.$filter.'%');
|
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||||
|
->orWhereHas('client', function ($q) use ($filter) {
|
||||||
|
$q->where('name', 'like', '%'.$filter.'%');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ class InvoiceSum
|
|||||||
|
|
||||||
private $precision;
|
private $precision;
|
||||||
|
|
||||||
|
public InvoiceItemSum $invoice_items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object with Invoice and Settings object.
|
* Constructs the object with Invoice and Settings object.
|
||||||
*
|
*
|
||||||
|
@ -147,14 +147,17 @@ class AccountController extends BaseController
|
|||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
$cu = CompanyUser::where('user_id', auth()->user()->id);
|
||||||
|
|
||||||
|
$company_user = $cu->first();
|
||||||
|
|
||||||
$truth = app()->make(TruthSource::class);
|
$truth = app()->make(TruthSource::class);
|
||||||
$truth->setCompanyUser($ct->first());
|
$truth->setCompanyUser($company_user);
|
||||||
$truth->setUser(auth()->user());
|
$truth->setUser($company_user->user);
|
||||||
$truth->setCompany($ct->first()->company);
|
$truth->setCompany($company_user->company);
|
||||||
|
$truth->setCompanyToken($company_user->tokens()->where('user_id', $company_user->user_id)->where('company_id', $company_user->company_id)->first());
|
||||||
|
|
||||||
return $this->listResponse($ct);
|
return $this->listResponse($cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(UpdateAccountRequest $request, Account $account)
|
public function update(UpdateAccountRequest $request, Account $account)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
*
|
*
|
||||||
@ -15,7 +16,6 @@ use App\DataMapper\Analytics\LoginFailure;
|
|||||||
use App\DataMapper\Analytics\LoginSuccess;
|
use App\DataMapper\Analytics\LoginSuccess;
|
||||||
use App\Events\User\UserLoggedIn;
|
use App\Events\User\UserLoggedIn;
|
||||||
use App\Http\Controllers\BaseController;
|
use App\Http\Controllers\BaseController;
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Requests\Login\LoginRequest;
|
use App\Http\Requests\Login\LoginRequest;
|
||||||
use App\Jobs\Account\CreateAccount;
|
use App\Jobs\Account\CreateAccount;
|
||||||
use App\Jobs\Company\CreateCompanyToken;
|
use App\Jobs\Company\CreateCompanyToken;
|
||||||
@ -23,8 +23,6 @@ use App\Libraries\MultiDB;
|
|||||||
use App\Libraries\OAuth\OAuth;
|
use App\Libraries\OAuth\OAuth;
|
||||||
use App\Libraries\OAuth\Providers\Google;
|
use App\Libraries\OAuth\Providers\Google;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\CompanyToken;
|
use App\Models\CompanyToken;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@ -38,7 +36,6 @@ use Illuminate\Database\Eloquent\Builder;
|
|||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Laravel\Socialite\Facades\Socialite;
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
use Microsoft\Graph\Model;
|
use Microsoft\Graph\Model;
|
||||||
use PragmaRX\Google2FA\Google2FA;
|
use PragmaRX\Google2FA\Google2FA;
|
||||||
@ -46,18 +43,7 @@ use Turbo124\Beacon\Facades\LightLogs;
|
|||||||
|
|
||||||
class LoginController extends BaseController
|
class LoginController extends BaseController
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @OA\Tag(
|
|
||||||
* name="login",
|
|
||||||
* description="Authentication",
|
|
||||||
* @OA\ExternalDocumentation(
|
|
||||||
* description="Find out more",
|
|
||||||
* url="https://invoiceninja.github.io"
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
use AuthenticatesUsers;
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
use UserSessionAttributes;
|
use UserSessionAttributes;
|
||||||
use LoginCache;
|
use LoginCache;
|
||||||
|
|
||||||
@ -89,7 +75,7 @@ class LoginController extends BaseController
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return void
|
* @return void
|
||||||
* deprecated .1 API ONLY we don't need to set any session variables
|
* @deprecated .1 API ONLY we don't need to set any session variables
|
||||||
*/
|
*/
|
||||||
public function authenticated(Request $request, User $user): void
|
public function authenticated(Request $request, User $user): void
|
||||||
{
|
{
|
||||||
@ -99,63 +85,8 @@ class LoginController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* Login via API.
|
* Login via API.
|
||||||
*
|
*
|
||||||
* @param Request $request The request
|
* @param LoginRequest $request The request
|
||||||
*
|
|
||||||
* @return Response|User Process user login.
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @OA\Post(
|
|
||||||
* path="/api/v1/login",
|
|
||||||
* operationId="postLogin",
|
|
||||||
* tags={"login"},
|
|
||||||
* summary="Attempts authentication",
|
|
||||||
* description="Returns a CompanyUser object on success",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-SECRET"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include_static"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/clear_cache"),
|
|
||||||
* @OA\RequestBody(
|
|
||||||
* description="User credentials",
|
|
||||||
* required=true,
|
|
||||||
* @OA\MediaType(
|
|
||||||
* mediaType="application/json",
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(
|
|
||||||
* property="email",
|
|
||||||
* description="The user email address",
|
|
||||||
* type="string",
|
|
||||||
* ),
|
|
||||||
* @OA\Property(
|
|
||||||
* property="password",
|
|
||||||
* example="1234567",
|
|
||||||
* description="The user password must meet minimum criteria ~ >6 characters",
|
|
||||||
* type="string"
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="The Company User response",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/CompanyUser"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
public function apiLogin(LoginRequest $request)
|
public function apiLogin(LoginRequest $request)
|
||||||
{
|
{
|
||||||
@ -175,7 +106,7 @@ class LoginController extends BaseController
|
|||||||
if ($this->attemptLogin($request)) {
|
if ($this->attemptLogin($request)) {
|
||||||
LightLogs::create(new LoginSuccess())
|
LightLogs::create(new LoginSuccess())
|
||||||
->increment()
|
->increment()
|
||||||
->queue();
|
->batch();
|
||||||
|
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
|
|
||||||
@ -221,7 +152,7 @@ class LoginController extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
LightLogs::create(new LoginFailure())
|
LightLogs::create(new LoginFailure())
|
||||||
->increment()
|
->increment()
|
||||||
->queue();
|
->batch();
|
||||||
|
|
||||||
$this->incrementLoginAttempts($request);
|
$this->incrementLoginAttempts($request);
|
||||||
|
|
||||||
@ -237,38 +168,6 @@ class LoginController extends BaseController
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return CompanyUser Refresh Feed.
|
* @return CompanyUser Refresh Feed.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @OA\Post(
|
|
||||||
* path="/api/v1/refresh",
|
|
||||||
* operationId="refresh",
|
|
||||||
* tags={"refresh"},
|
|
||||||
* summary="Refreshes the dataset",
|
|
||||||
* description="Refreshes the dataset",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include_static"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/clear_cache"),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="The Company User response",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/CompanyUser"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
public function refresh(Request $request)
|
public function refresh(Request $request)
|
||||||
{
|
{
|
||||||
@ -478,7 +377,7 @@ class LoginController extends BaseController
|
|||||||
|
|
||||||
if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) {
|
if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) {
|
||||||
auth()->user()->companies->each(function ($company) {
|
auth()->user()->companies->each(function ($company) {
|
||||||
if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) {
|
if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->where('is_system', true)->exists()) {
|
||||||
(new CreateCompanyToken($company, auth()->user(), 'Google_O_Auth'))->handle();
|
(new CreateCompanyToken($company, auth()->user(), 'Google_O_Auth'))->handle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -499,7 +398,6 @@ class LoginController extends BaseController
|
|||||||
return response()->json(['message' => 'Invalid response from oauth server, no access token in response.'], 400);
|
return response()->json(['message' => 'Invalid response from oauth server, no access token in response.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$graph = new \Microsoft\Graph\Graph();
|
$graph = new \Microsoft\Graph\Graph();
|
||||||
$graph->setAccessToken($accessToken);
|
$graph->setAccessToken($accessToken);
|
||||||
|
|
||||||
@ -536,7 +434,9 @@ class LoginController extends BaseController
|
|||||||
return $this->existingLoginUser($user->getId(), 'microsoft');
|
return $this->existingLoginUser($user->getId(), 'microsoft');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Signup!
|
// Signup!
|
||||||
|
if (request()->has('create') && request()->input('create') == 'true') {
|
||||||
$new_account = [
|
$new_account = [
|
||||||
'first_name' => $user->getGivenName() ?: '',
|
'first_name' => $user->getGivenName() ?: '',
|
||||||
'last_name' => $user->getSurname() ?: '',
|
'last_name' => $user->getSurname() ?: '',
|
||||||
@ -549,6 +449,9 @@ class LoginController extends BaseController
|
|||||||
return $this->createNewAccount($new_account);
|
return $this->createNewAccount($new_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => 'User not found. If you believe this is an error, please send an email to contact@invoiceninja.com'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return response()->json(['message' => 'Unable to authenticate this user'], 400);
|
return response()->json(['message' => 'Unable to authenticate this user'], 400);
|
||||||
}
|
}
|
||||||
@ -640,6 +543,7 @@ class LoginController extends BaseController
|
|||||||
return $this->existingLoginUser($google->harvestSubField($user), 'google');
|
return $this->existingLoginUser($google->harvestSubField($user), 'google');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request()->has('create') && request()->input('create') == 'true') {
|
||||||
//user not found anywhere - lets sign them up.
|
//user not found anywhere - lets sign them up.
|
||||||
$name = OAuth::splitName($google->harvestName($user));
|
$name = OAuth::splitName($google->harvestName($user));
|
||||||
|
|
||||||
@ -655,6 +559,9 @@ class LoginController extends BaseController
|
|||||||
return $this->createNewAccount($new_account);
|
return $this->createNewAccount($new_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => 'User not found. If you believe this is an error, please send an email to contact@invoiceninja.com'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
->json(['message' => ctrans('texts.invalid_credentials')], 401)
|
->json(['message' => ctrans('texts.invalid_credentials')], 401)
|
||||||
->header('X-App-Version', config('ninja.app_version'))
|
->header('X-App-Version', config('ninja.app_version'))
|
||||||
|
@ -1,81 +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\Http\Controllers\Auth;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
|
|
||||||
class RegisterController extends Controller
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Register Controller
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| This controller handles the registration of new users as well as their
|
|
||||||
| validation and creation. By default this controller uses a trait to
|
|
||||||
| provide this functionality without requiring any additional code.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
use RegistersUsers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Where to redirect users after registration.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $redirectTo = '/dashboard';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new controller instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->middleware('guest');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a validator for an incoming registration request.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return \Illuminate\Contracts\Validation\Validator
|
|
||||||
*/
|
|
||||||
protected function validator(array $data)
|
|
||||||
{
|
|
||||||
return Validator::make($data, [
|
|
||||||
'first_name' => 'required|string|max:255',
|
|
||||||
'email' => 'required|string|email|max:255|unique:users',
|
|
||||||
'password' => 'required|string|min:6|confirmed',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new user instance after a valid registration.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return \App\User
|
|
||||||
*/
|
|
||||||
protected function create(array $data)
|
|
||||||
{
|
|
||||||
return User::create([
|
|
||||||
'first_name' => $data['first_name'],
|
|
||||||
'email' => $data['email'],
|
|
||||||
'password' => Hash::make($data['password']),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,16 +28,13 @@ class VendorContactLoginController extends Controller
|
|||||||
|
|
||||||
public function catch()
|
public function catch()
|
||||||
{
|
{
|
||||||
$data = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->render('purchase_orders.catch');
|
return $this->render('purchase_orders.catch');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
Auth::guard('vendor')->logout();
|
Auth::guard('vendor')->logout();
|
||||||
|
|
||||||
request()->session()->invalidate();
|
request()->session()->invalidate();
|
||||||
|
|
||||||
return redirect('/vendors');
|
return redirect('/vendors');
|
||||||
|
@ -1,50 +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\Http\Controllers\Auth;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
|
||||||
use Illuminate\Routing\Controller;
|
|
||||||
|
|
||||||
class VerificationController extends Controller
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Email Verification Controller
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| This controller is responsible for handling email verification for any
|
|
||||||
| user that recently registered with the application. Emails may also
|
|
||||||
| be resent if the user did not receive the original email message.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
use VerifiesEmails;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Where to redirect users after verification.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $redirectTo = '/dashboard';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new controller instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->middleware('auth');
|
|
||||||
$this->middleware('signed')->only('verify');
|
|
||||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
|
||||||
}
|
|
||||||
}
|
|
@ -276,8 +276,6 @@ class YodleeController extends BaseController
|
|||||||
{
|
{
|
||||||
//this is the main hook we use for notifications
|
//this is the main hook we use for notifications
|
||||||
|
|
||||||
nlog("data refresh");
|
|
||||||
nlog($request->all());
|
|
||||||
|
|
||||||
return response()->json(['message' => 'Success'], 200);
|
return response()->json(['message' => 'Success'], 200);
|
||||||
|
|
||||||
|
@ -531,7 +531,6 @@ class BankTransactionController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function match(MatchBankTransactionRequest $request)
|
public function match(MatchBankTransactionRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$bts = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
$bts = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
||||||
|
|
||||||
return $this->listResponse($bts);
|
return $this->listResponse($bts);
|
||||||
|
@ -33,6 +33,7 @@ use App\Utils\Statics;
|
|||||||
use App\Utils\Traits\AppSetup;
|
use App\Utils\Traits\AppSetup;
|
||||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use League\Fractal\Manager;
|
use League\Fractal\Manager;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
@ -565,7 +566,7 @@ class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Mini Load Query
|
* Mini Load Query
|
||||||
*
|
*
|
||||||
* @param mixed $query
|
* @param Builder $query
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function miniLoadResponse($query)
|
protected function miniLoadResponse($query)
|
||||||
@ -667,7 +668,7 @@ class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Passes back the miniloaded data response
|
* Passes back the miniloaded data response
|
||||||
*
|
*
|
||||||
* @param mixed $query
|
* @param Builder $query
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function timeConstrainedResponse($query)
|
protected function timeConstrainedResponse($query)
|
||||||
@ -912,8 +913,7 @@ class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
* List response
|
* List response
|
||||||
*
|
*
|
||||||
* @param mixed $query
|
* @param Builder $query
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function listResponse($query)
|
protected function listResponse($query)
|
||||||
{
|
{
|
||||||
@ -927,24 +927,26 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
$query->with($includes);
|
$query->with($includes);
|
||||||
|
|
||||||
if (auth()->user() && ! auth()->user()->hasPermission('view_'.Str::snake(class_basename($this->entity_type)))) {
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if ($user && ! $user->hasPermission('view_'.Str::snake(class_basename($this->entity_type)))) {
|
||||||
if (in_array($this->entity_type, [User::class])) {
|
if (in_array($this->entity_type, [User::class])) {
|
||||||
$query->where('id', auth()->user()->id);
|
$query->where('id', $user->id);
|
||||||
} elseif (in_array($this->entity_type, [BankTransactionRule::class,CompanyGateway::class, TaxRate::class, BankIntegration::class, Scheduler::class, BankTransaction::class, Webhook::class, ExpenseCategory::class])) { //table without assigned_user_id
|
} elseif (in_array($this->entity_type, [BankTransactionRule::class,CompanyGateway::class, TaxRate::class, BankIntegration::class, Scheduler::class, BankTransaction::class, Webhook::class, ExpenseCategory::class])) { //table without assigned_user_id
|
||||||
if ($this->entity_type == BankIntegration::class && !auth()->user()->isSuperUser() && auth()->user()->hasIntersectPermissions(['create_bank_transaction','edit_bank_transaction','view_bank_transaction'])) {
|
if ($this->entity_type == BankIntegration::class && !$user->isSuperUser() && $user->hasIntersectPermissions(['create_bank_transaction','edit_bank_transaction','view_bank_transaction'])) {
|
||||||
$query->exclude(["balance"]);
|
$query->exclude(["balance"]);
|
||||||
} //allows us to selective display bank integrations back to the user if they can view / create bank transactions but without the bank balance being present in the response
|
} //allows us to selective display bank integrations back to the user if they can view / create bank transactions but without the bank balance being present in the response
|
||||||
else {
|
else {
|
||||||
$query->where('user_id', '=', auth()->user()->id);
|
$query->where('user_id', '=', $user->id);
|
||||||
}
|
}
|
||||||
} elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) {
|
} elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) {
|
||||||
// nlog($this->entity_type);
|
// nlog($this->entity_type);
|
||||||
} else {
|
} else {
|
||||||
$query->where('user_id', '=', auth()->user()->id)->orWhere('assigned_user_id', auth()->user()->id);
|
$query->where('user_id', '=', $user->id)->orWhere('assigned_user_id', $user->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->entity_type == Client::class && auth()->user()->hasExcludedPermissions($this->client_excludable_permissions, $this->client_excludable_overrides)) {
|
if ($this->entity_type == Client::class && $user->hasExcludedPermissions($this->client_excludable_permissions, $this->client_excludable_overrides)) {
|
||||||
$query->exclude($this->client_exclusion_fields);
|
$query->exclude($this->client_exclusion_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,7 +1012,6 @@ class BaseController extends Controller
|
|||||||
* Item Response
|
* Item Response
|
||||||
*
|
*
|
||||||
* @param mixed $item
|
* @param mixed $item
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function itemResponse($item)
|
protected function itemResponse($item)
|
||||||
{
|
{
|
||||||
@ -1087,7 +1088,7 @@ class BaseController extends Controller
|
|||||||
{
|
{
|
||||||
if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) {
|
if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) {
|
||||||
//always redirect invoicing.co to invoicing.co
|
//always redirect invoicing.co to invoicing.co
|
||||||
if (Ninja::isHosted() && !in_array(request()->getSchemeAndHttpHost(), ['https://staging.invoicing.co', 'https://invoicing.co', 'https://demo.invoicing.co'])) {
|
if (Ninja::isHosted() && !in_array(request()->getSchemeAndHttpHost(), ['https://staging.invoicing.co', 'https://invoicing.co', 'https://demo.invoicing.co', 'https://invoiceninja.net'])) {
|
||||||
return redirect()->secure('https://invoicing.co');
|
return redirect()->secure('https://invoicing.co');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,6 @@ class InvoiceController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Pay one or more invoices.
|
* Pay one or more invoices.
|
||||||
*
|
*
|
||||||
* @param ProcessInvoicesInBulkRequest $request
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function catch_bulk()
|
public function catch_bulk()
|
||||||
{
|
{
|
||||||
|
@ -12,24 +12,24 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\ClientPortal;
|
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\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use Illuminate\View\View;
|
|
||||||
use App\Models\GatewayType;
|
|
||||||
use App\Models\PaymentHash;
|
use App\Models\PaymentHash;
|
||||||
use App\Models\PaymentType;
|
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\PaymentDrivers\Stripe\BankTransfer;
|
||||||
use App\Services\ClientPortal\InstantPayment;
|
use App\Services\ClientPortal\InstantPayment;
|
||||||
use App\Services\Subscription\SubscriptionService;
|
use App\Services\Subscription\SubscriptionService;
|
||||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PaymentController.
|
* Class PaymentController.
|
||||||
@ -65,7 +65,6 @@ class PaymentController extends Controller
|
|||||||
$gateway = false;
|
$gateway = false;
|
||||||
|
|
||||||
if ($payment->gateway_type_id == GatewayType::DIRECT_DEBIT && $payment->type_id == PaymentType::DIRECT_DEBIT) {
|
if ($payment->gateway_type_id == GatewayType::DIRECT_DEBIT && $payment->type_id == PaymentType::DIRECT_DEBIT) {
|
||||||
|
|
||||||
if (method_exists($payment->company_gateway->driver($payment->client), 'getPaymentIntent')) {
|
if (method_exists($payment->company_gateway->driver($payment->client), 'getPaymentIntent')) {
|
||||||
$stripe = $payment->company_gateway->driver($payment->client);
|
$stripe = $payment->company_gateway->driver($payment->client);
|
||||||
$payment_intent = $stripe->getPaymentIntent($payment->transaction_reference);
|
$payment_intent = $stripe->getPaymentIntent($payment->transaction_reference);
|
||||||
@ -87,7 +86,7 @@ class PaymentController extends Controller
|
|||||||
return $this->render('payments.show', [
|
return $this->render('payments.show', [
|
||||||
'payment' => $payment,
|
'payment' => $payment,
|
||||||
'bank_details' => $payment_intent ? $data : false,
|
'bank_details' => $payment_intent ? $data : false,
|
||||||
'currency' => strtolower($payment->currency->code),
|
'currency' => $payment->currency ? strtolower($payment->currency->code) : strtolower($payment->client->currency()->code),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ namespace App\Http\Controllers\ClientPortal;
|
|||||||
use App\Events\Payment\Methods\MethodDeleted;
|
use App\Events\Payment\Methods\MethodDeleted;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\ClientPortal\PaymentMethod\CreatePaymentMethodRequest;
|
use App\Http\Requests\ClientPortal\PaymentMethod\CreatePaymentMethodRequest;
|
||||||
use App\Http\Requests\ClientPortal\PaymentMethod\VerifyPaymentMethodRequest;
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
|
120
app/Http/Controllers/ClientPortal/PrePaymentController.php
Normal file
120
app/Http/Controllers/ClientPortal/PrePaymentController.php
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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\ClientPortal;
|
||||||
|
|
||||||
|
use App\DataMapper\InvoiceItem;
|
||||||
|
use App\Factory\InvoiceFactory;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\ClientPortal\PrePayments\StorePrePaymentRequest;
|
||||||
|
use App\Repositories\InvoiceRepository;
|
||||||
|
use App\Utils\Number;
|
||||||
|
use App\Utils\Traits\MakesDates;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PrePaymentController.
|
||||||
|
*/
|
||||||
|
class PrePaymentController extends Controller
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
use MakesDates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the list of payments.
|
||||||
|
*
|
||||||
|
* @return Factory|View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$client = auth()->guard('contact')->user()->client;
|
||||||
|
$minimum = $client->getSetting('client_initiated_payments_minimum');
|
||||||
|
$minimum_amount = $minimum == 0 ? "" : Number::formatMoney($minimum, $client);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => ctrans('texts.amount'). " " .$client->currency()->code." (".auth()->guard('contact')->user()->client->currency()->symbol . ")",
|
||||||
|
'allows_recurring' => true,
|
||||||
|
'minimum' => $minimum,
|
||||||
|
'minimum_amount' => $minimum_amount,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->render('pre_payments.index', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(StorePrePaymentRequest $request)
|
||||||
|
{
|
||||||
|
$invoice = InvoiceFactory::create(auth()->guard('contact')->user()->company_id, auth()->guard('contact')->user()->user_id);
|
||||||
|
$invoice->due_date = now()->format('Y-m-d');
|
||||||
|
$invoice->is_proforma = true;
|
||||||
|
$invoice->client_id = auth()->guard('contact')->user()->client_id;
|
||||||
|
|
||||||
|
$line_item = new InvoiceItem();
|
||||||
|
$line_item->cost = (float)$request->amount;
|
||||||
|
$line_item->quantity = 1;
|
||||||
|
$line_item->product_key = ctrans('texts.pre_payment');
|
||||||
|
$line_item->notes = $request->notes;
|
||||||
|
$line_item->type_id = '1';
|
||||||
|
|
||||||
|
$items = [];
|
||||||
|
$items[] = $line_item;
|
||||||
|
$invoice->line_items = $items;
|
||||||
|
$invoice->number = ctrans('texts.pre_payment') . " " . now()->format('Y-m-d : H:i:s');
|
||||||
|
|
||||||
|
$invoice_repo = new InvoiceRepository();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'client_id' => $invoice->client_id,
|
||||||
|
'quantity' => 1,
|
||||||
|
'date' => now()->format('Y-m-d'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$invoice = $invoice_repo->save($data, $invoice)
|
||||||
|
->service()
|
||||||
|
->markSent()
|
||||||
|
->applyNumber()
|
||||||
|
->fillDefaults()
|
||||||
|
->save();
|
||||||
|
|
||||||
|
$total = $invoice->balance;
|
||||||
|
|
||||||
|
//format totals
|
||||||
|
$formatted_total = Number::formatMoney($invoice->amount, auth()->guard('contact')->user()->client);
|
||||||
|
|
||||||
|
$payment_methods = auth()->guard('contact')->user()->client->service()->getPaymentMethods($request->amount);
|
||||||
|
|
||||||
|
//if there is only one payment method -> lets return straight to the payment page
|
||||||
|
$invoices = collect();
|
||||||
|
$invoices->push($invoice);
|
||||||
|
|
||||||
|
$invoices->map(function ($invoice) {
|
||||||
|
$invoice->balance = Number::formatValue($invoice->balance, $invoice->client->currency());
|
||||||
|
return $invoice;
|
||||||
|
});
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'settings' => auth()->guard('contact')->user()->client->getMergedSettings(),
|
||||||
|
'invoices' => $invoices,
|
||||||
|
'formatted_total' => $formatted_total,
|
||||||
|
'payment_methods' => $payment_methods,
|
||||||
|
'hashed_ids' => $invoices->pluck('hashed_id'),
|
||||||
|
'total' => $total,
|
||||||
|
'pre_payment' => true,
|
||||||
|
'frequency_id' => $request->frequency_id,
|
||||||
|
'remaining_cycles' => $request->remaining_cycles,
|
||||||
|
'is_recurring' => $request->is_recurring == 'on' ? true : false,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->render('invoices.payment', $data);
|
||||||
|
}
|
||||||
|
}
|
@ -178,7 +178,7 @@ class QuoteController extends Controller
|
|||||||
if ($process) {
|
if ($process) {
|
||||||
foreach ($quotes as $quote) {
|
foreach ($quotes as $quote) {
|
||||||
if (request()->has('user_input') && strlen(request()->input('user_input')) > 2) {
|
if (request()->has('user_input') && strlen(request()->input('user_input')) > 2) {
|
||||||
$quote->public_notes .= $quote->public_notes . "\n" . request()->input('user_input');
|
$quote->po_number = substr(request()->input('user_input'), 0, 180);
|
||||||
$quote->saveQuietly();
|
$quote->saveQuietly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,22 +19,28 @@ use App\Utils\Ninja;
|
|||||||
|
|
||||||
class SubscriptionController extends Controller
|
class SubscriptionController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* This function is used to display the subscription page.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
|
||||||
|
*/
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$count = RecurringInvoice::query()
|
// $count = RecurringInvoice::query()
|
||||||
->where('client_id', auth()->guard('contact')->user()->client->id)
|
// ->where('client_id', auth()->guard('contact')->user()->client->id)
|
||||||
->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
// ->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
||||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
// ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||||
->where('is_deleted', 0)
|
// ->where('is_deleted', 0)
|
||||||
->whereNotNull('subscription_id')
|
// ->whereNotNull('subscription_id')
|
||||||
->withTrashed()
|
// ->withTrashed()
|
||||||
->count();
|
// ->count();
|
||||||
|
|
||||||
if ($count == 0) {
|
// if ($count == 0) {
|
||||||
return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
|
// return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return render('subscriptions.index');
|
return render('subscriptions.index');
|
||||||
}
|
}
|
||||||
@ -44,7 +50,6 @@ class SubscriptionController extends Controller
|
|||||||
*
|
*
|
||||||
* @param ShowRecurringInvoiceRequest $request
|
* @param ShowRecurringInvoiceRequest $request
|
||||||
* @param RecurringInvoice $recurring_invoice
|
* @param RecurringInvoice $recurring_invoice
|
||||||
* @return Factory|View
|
|
||||||
*/
|
*/
|
||||||
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,6 @@ class SubscriptionPurchaseController extends Controller
|
|||||||
|
|
||||||
public function upgrade(Subscription $subscription, Request $request)
|
public function upgrade(Subscription $subscription, Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
App::setLocale($subscription->company->locale());
|
App::setLocale($subscription->company->locale());
|
||||||
|
|
||||||
/* Make sure the contact is logged into the correct company for this subscription */
|
/* Make sure the contact is logged into the correct company for this subscription */
|
||||||
|
@ -40,6 +40,7 @@ use App\Utils\Traits\SavesDocuments;
|
|||||||
use App\Utils\Traits\Uploadable;
|
use App\Utils\Traits\Uploadable;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Turbo124\Beacon\Facades\LightLogs;
|
use Turbo124\Beacon\Facades\LightLogs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,6 +487,11 @@ class CompanyController extends BaseController
|
|||||||
$company_user->forceDelete();
|
$company_user->forceDelete();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
Storage::disk(config('filesystems.default'))->deleteDirectory($company->company_key);
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$account->delete();
|
$account->delete();
|
||||||
|
|
||||||
if (Ninja::isHosted()) {
|
if (Ninja::isHosted()) {
|
||||||
@ -494,7 +500,7 @@ class CompanyController extends BaseController
|
|||||||
|
|
||||||
LightLogs::create(new AccountDeleted())
|
LightLogs::create(new AccountDeleted())
|
||||||
->increment()
|
->increment()
|
||||||
->queue();
|
->batch();
|
||||||
} else {
|
} else {
|
||||||
$company_id = $company->id;
|
$company_id = $company->id;
|
||||||
|
|
||||||
@ -511,6 +517,12 @@ class CompanyController extends BaseController
|
|||||||
$nmo->to_user = auth()->user();
|
$nmo->to_user = auth()->user();
|
||||||
(new NinjaMailerJob($nmo, true))->handle();
|
(new NinjaMailerJob($nmo, true))->handle();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Storage::disk(config('filesystems.default'))->deleteDirectory($company->company_key);
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$company->delete();
|
$company->delete();
|
||||||
|
|
||||||
//If we are deleting the default companies, we'll need to make a new company the default.
|
//If we are deleting the default companies, we'll need to make a new company the default.
|
||||||
|
@ -11,26 +11,27 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Utils\Ninja;
|
use App\Events\Credit\CreditWasEmailed;
|
||||||
use App\Models\Quote;
|
use App\Events\Quote\QuoteWasEmailed;
|
||||||
|
use App\Http\Requests\Email\SendEmailRequest;
|
||||||
|
use App\Jobs\Entity\EmailEntity;
|
||||||
|
use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Services\Email\Email;
|
use App\Models\Quote;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Jobs\Entity\EmailEntity;
|
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
|
use App\Services\Email\Email;
|
||||||
use App\Services\Email\EmailObject;
|
use App\Services\Email\EmailObject;
|
||||||
use App\Events\Quote\QuoteWasEmailed;
|
|
||||||
use App\Transformers\QuoteTransformer;
|
|
||||||
use App\Events\Credit\CreditWasEmailed;
|
|
||||||
use App\Transformers\CreditTransformer;
|
use App\Transformers\CreditTransformer;
|
||||||
use App\Transformers\InvoiceTransformer;
|
use App\Transformers\InvoiceTransformer;
|
||||||
use App\Http\Requests\Email\SendEmailRequest;
|
|
||||||
use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
|
|
||||||
use App\Transformers\PurchaseOrderTransformer;
|
use App\Transformers\PurchaseOrderTransformer;
|
||||||
|
use App\Transformers\QuoteTransformer;
|
||||||
use App\Transformers\RecurringInvoiceTransformer;
|
use App\Transformers\RecurringInvoiceTransformer;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Mail\Mailables\Address;
|
||||||
|
|
||||||
class EmailController extends BaseController
|
class EmailController extends BaseController
|
||||||
{
|
{
|
||||||
@ -135,6 +136,9 @@ class EmailController extends BaseController
|
|||||||
$mo->email_template_body = $request->input('template');
|
$mo->email_template_body = $request->input('template');
|
||||||
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
||||||
|
|
||||||
|
if ($request->has('cc_email') && $request->cc_email) {
|
||||||
|
$mo->cc[] = new Address($request->cc_email);
|
||||||
|
}
|
||||||
|
|
||||||
// if ($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order' || $entity == 'App\Models\PurchaseOrder') {
|
// if ($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order' || $entity == 'App\Models\PurchaseOrder') {
|
||||||
// return $this->sendPurchaseOrder($entity_obj, $data, $template);
|
// return $this->sendPurchaseOrder($entity_obj, $data, $template);
|
||||||
@ -149,7 +153,6 @@ class EmailController extends BaseController
|
|||||||
$mo->invitation_id = $invitation->id;
|
$mo->invitation_id = $invitation->id;
|
||||||
|
|
||||||
Email::dispatch($mo, $invitation->company);
|
Email::dispatch($mo, $invitation->company);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -214,7 +217,6 @@ class EmailController extends BaseController
|
|||||||
|
|
||||||
private function resolveClass(string $entity): string
|
private function resolveClass(string $entity): string
|
||||||
{
|
{
|
||||||
|
|
||||||
match ($entity) {
|
match ($entity) {
|
||||||
'invoice' => $class = Invoice::class,
|
'invoice' => $class = Invoice::class,
|
||||||
'App\Models\Invoice' => $class = Invoice::class,
|
'App\Models\Invoice' => $class = Invoice::class,
|
||||||
@ -229,6 +231,5 @@ class EmailController extends BaseController
|
|||||||
};
|
};
|
||||||
|
|
||||||
return $class;
|
return $class;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,6 @@ class ImportController extends Controller
|
|||||||
$bestDelimiter = ' ';
|
$bestDelimiter = ' ';
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($delimiters as $delimiter) {
|
foreach ($delimiters as $delimiter) {
|
||||||
|
|
||||||
// if (substr_count($csvfile, $delimiter) > $count) {
|
// if (substr_count($csvfile, $delimiter) > $count) {
|
||||||
// $count = substr_count($csvfile, $delimiter);
|
// $count = substr_count($csvfile, $delimiter);
|
||||||
// $bestDelimiter = $delimiter;
|
// $bestDelimiter = $delimiter;
|
||||||
@ -173,9 +172,6 @@ class ImportController extends Controller
|
|||||||
$count = substr_count($csvfile, $delimiter);
|
$count = substr_count($csvfile, $delimiter);
|
||||||
$bestDelimiter = $delimiter;
|
$bestDelimiter = $delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return $bestDelimiter;
|
return $bestDelimiter;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use stdClass;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Utils\CurlUtils;
|
use App\Utils\CurlUtils;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Http\Request;
|
use stdClass;
|
||||||
|
|
||||||
class LicenseController extends BaseController
|
class LicenseController extends BaseController
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ class LicenseController extends BaseController
|
|||||||
* ),
|
* ),
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function indexx()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->checkLicense();
|
$this->checkLicense();
|
||||||
|
|
||||||
@ -89,6 +89,10 @@ class LicenseController extends BaseController
|
|||||||
$license_key = request()->input('license_key');
|
$license_key = request()->input('license_key');
|
||||||
$product_id = 3;
|
$product_id = 3;
|
||||||
|
|
||||||
|
if(substr($license_key, 0, 3) == 'v5_') {
|
||||||
|
return $this->v5ClaimLicense($license_key, $product_id);
|
||||||
|
}
|
||||||
|
|
||||||
$url = config('ninja.license_url')."/claim_license?license_key={$license_key}&product_id={$product_id}&get_date=true";
|
$url = config('ninja.license_url')."/claim_license?license_key={$license_key}&product_id={$product_id}&get_date=true";
|
||||||
$data = trim(CurlUtils::get($url));
|
$data = trim(CurlUtils::get($url));
|
||||||
|
|
||||||
@ -149,21 +153,19 @@ class LicenseController extends BaseController
|
|||||||
return response()->json($error, 400);
|
return response()->json($error, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function v5ClaimLicense(Request $request)
|
public function v5ClaimLicense(string $license_key)
|
||||||
{
|
{
|
||||||
$this->checkLicense();
|
$this->checkLicense();
|
||||||
|
|
||||||
/* Catch claim license requests */
|
/* Catch claim license requests */
|
||||||
if (config('ninja.environment') == 'selfhost' && request()->has('license_key')) {
|
if (config('ninja.environment') == 'selfhost') {
|
||||||
|
|
||||||
// $response = Http::get( "http://ninja.test:8000/claim_license", [
|
// $response = Http::get( "http://ninja.test:8000/claim_license", [
|
||||||
$response = Http::get("https://invoicing.co/claim_license", [
|
$response = Http::get("https://invoicing.co/claim_license", [
|
||||||
'license_key' => $request->input('license_key'),
|
'license_key' => $license_key,
|
||||||
'product_id' => 3,
|
'product_id' => 3,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
|
|
||||||
$payload = $response->json();
|
$payload = $response->json();
|
||||||
|
|
||||||
$account = auth()->user()->account;
|
$account = auth()->user()->account;
|
||||||
@ -180,7 +182,6 @@ class LicenseController extends BaseController
|
|||||||
|
|
||||||
return response()->json($error, 200);
|
return response()->json($error, 200);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$error = [
|
$error = [
|
||||||
'message' => trans('texts.white_label_license_error'),
|
'message' => trans('texts.white_label_license_error'),
|
||||||
'errors' => new stdClass,
|
'errors' => new stdClass,
|
||||||
@ -188,7 +189,6 @@ class LicenseController extends BaseController
|
|||||||
|
|
||||||
return response()->json($error, 400);
|
return response()->json($error, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = [
|
$error = [
|
||||||
@ -197,7 +197,6 @@ class LicenseController extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
return response()->json($error, 400);
|
return response()->json($error, 400);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,6 +209,5 @@ class LicenseController extends BaseController
|
|||||||
$account->plan_expires = null;
|
$account->plan_expires = null;
|
||||||
$account->save();
|
$account->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ use App\Libraries\MultiDB;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\GroupSetting;
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
@ -37,7 +36,6 @@ use App\Services\PdfMaker\Design;
|
|||||||
use App\Services\PdfMaker\Design as PdfDesignModel;
|
use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||||
use App\Services\PdfMaker\PdfMaker;
|
use App\Services\PdfMaker\PdfMaker;
|
||||||
use App\Services\Preview\StubBuilder;
|
|
||||||
use App\Utils\HostedPDF\NinjaPdf;
|
use App\Utils\HostedPDF\NinjaPdf;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
|
@ -16,6 +16,7 @@ use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
|
|||||||
use App\Factory\RecurringInvoiceFactory;
|
use App\Factory\RecurringInvoiceFactory;
|
||||||
use App\Filters\RecurringInvoiceFilters;
|
use App\Filters\RecurringInvoiceFilters;
|
||||||
use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest;
|
||||||
|
use App\Http\Requests\RecurringInvoice\BulkRecurringInvoiceRequest;
|
||||||
use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest;
|
||||||
use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest;
|
||||||
use App\Http\Requests\RecurringInvoice\EditRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\EditRecurringInvoiceRequest;
|
||||||
@ -23,6 +24,7 @@ use App\Http\Requests\RecurringInvoice\ShowRecurringInvoiceRequest;
|
|||||||
use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest;
|
||||||
use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest;
|
||||||
use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest;
|
||||||
|
use App\Jobs\RecurringInvoice\UpdateRecurring;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
use App\Repositories\RecurringInvoiceRepository;
|
use App\Repositories\RecurringInvoiceRepository;
|
||||||
@ -392,50 +394,6 @@ class RecurringInvoiceController extends BaseController
|
|||||||
*
|
*
|
||||||
* @param DestroyRecurringInvoiceRequest $request
|
* @param DestroyRecurringInvoiceRequest $request
|
||||||
* @param RecurringInvoice $recurring_invoice
|
* @param RecurringInvoice $recurring_invoice
|
||||||
*
|
|
||||||
* @return Response
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
* @OA\Delete(
|
|
||||||
* path="/api/v1/recurring_invoices/{id}",
|
|
||||||
* operationId="deleteRecurringInvoice",
|
|
||||||
* tags={"recurring_invoices"},
|
|
||||||
* summary="Deletes a RecurringInvoice",
|
|
||||||
* description="Handles the deletion of an RecurringInvoice by id",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
||||||
* @OA\Parameter(
|
|
||||||
* name="id",
|
|
||||||
* in="path",
|
|
||||||
* description="The RecurringInvoice Hashed ID",
|
|
||||||
* example="D2J234DFA",
|
|
||||||
* required=true,
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="string",
|
|
||||||
* format="string",
|
|
||||||
* ),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="Returns a HTTP status",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
*
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
public function destroy(DestroyRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
public function destroy(DestroyRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
||||||
{
|
{
|
||||||
@ -445,195 +403,30 @@ class RecurringInvoiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OA\Get(
|
|
||||||
* path="/api/v1/recurring_invoice/{invitation_key}/download",
|
|
||||||
* operationId="downloadRecurringInvoice",
|
|
||||||
* tags={"invoices"},
|
|
||||||
* summary="Download a specific invoice by invitation key",
|
|
||||||
* description="Downloads a specific invoice",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
||||||
* @OA\Parameter(
|
|
||||||
* name="invitation_key",
|
|
||||||
* in="path",
|
|
||||||
* description="The Recurring Invoice Invitation Key",
|
|
||||||
* example="D2J234DFA",
|
|
||||||
* required=true,
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="string",
|
|
||||||
* format="string",
|
|
||||||
* ),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="Returns the recurring invoice pdf",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
*
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
* @param $invitation_key
|
|
||||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
|
||||||
*/
|
*/
|
||||||
public function downloadPdf($invitation_key)
|
public function bulk(BulkRecurringInvoiceRequest $request)
|
||||||
{
|
{
|
||||||
$invitation = $this->recurring_invoice_repo->getInvitationByKey($invitation_key);
|
$percentage_increase = request()->has('percentage_increase') ? request()->input('percentage_increase') : 0;
|
||||||
$contact = $invitation->contact;
|
|
||||||
$recurring_invoice = $invitation->recurring_invoice;
|
|
||||||
|
|
||||||
$file = $recurring_invoice->service()->getInvoicePdf($contact);
|
if (in_array($request->action, ['increase_prices', 'update_prices'])) {
|
||||||
|
UpdateRecurring::dispatch($request->ids, auth()->user()->company(), auth()->user(), $request->action, $percentage_increase);
|
||||||
|
|
||||||
return response()->streamDownload(function () use ($file) {
|
return response()->json(['message' => 'Update in progress.'], 200);
|
||||||
echo Storage::get($file);
|
|
||||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$recurring_invoices = RecurringInvoice::withTrashed()->find($request->ids);
|
||||||
* Perform bulk actions on the list view.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @OA\Post(
|
|
||||||
* path="/api/v1/recurring_invoices/bulk",
|
|
||||||
* operationId="bulkRecurringInvoices",
|
|
||||||
* tags={"recurring_invoices"},
|
|
||||||
* summary="Performs bulk actions on an array of recurring_invoices",
|
|
||||||
* description="",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/index"),
|
|
||||||
* @OA\RequestBody(
|
|
||||||
* description="Hashed IDs",
|
|
||||||
* required=true,
|
|
||||||
* @OA\MediaType(
|
|
||||||
* mediaType="application/json",
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="array",
|
|
||||||
* @OA\Items(
|
|
||||||
* type="integer",
|
|
||||||
* description="Array of hashed IDs to be bulk 'actioned",
|
|
||||||
* example="[0,1,2,3]",
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="The RecurringInvoice response",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/RecurringInvoice"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
|
|
||||||
* ),
|
$recurring_invoices->each(function ($recurring_invoice, $key) use ($request) {
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function bulk()
|
|
||||||
{
|
|
||||||
$action = request()->input('action');
|
|
||||||
|
|
||||||
$ids = request()->input('ids');
|
|
||||||
|
|
||||||
$recurring_invoices = RecurringInvoice::withTrashed()->find($this->transformKeys($ids));
|
|
||||||
|
|
||||||
$recurring_invoices->each(function ($recurring_invoice, $key) use ($action) {
|
|
||||||
if (auth()->user()->can('edit', $recurring_invoice)) {
|
if (auth()->user()->can('edit', $recurring_invoice)) {
|
||||||
$this->performAction($recurring_invoice, $action, true);
|
$this->performAction($recurring_invoice, $request->action, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this->listResponse(RecurringInvoice::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
return $this->listResponse(RecurringInvoice::withTrashed()->whereIn('id', $request->ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recurring Invoice Actions.
|
* Recurring Invoice Actions.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @OA\Get(
|
|
||||||
* path="/api/v1/recurring_invoices/{id}/{action}",
|
|
||||||
* operationId="actionRecurringInvoice",
|
|
||||||
* tags={"recurring_invoices"},
|
|
||||||
* summary="Performs a custom action on an RecurringInvoice",
|
|
||||||
* description="Performs a custom action on an RecurringInvoice.
|
|
||||||
|
|
||||||
The current range of actions are as follows
|
|
||||||
- clone_to_RecurringInvoice
|
|
||||||
- clone_to_quote
|
|
||||||
- history
|
|
||||||
- delivery_note
|
|
||||||
- mark_paid
|
|
||||||
- download
|
|
||||||
- archive
|
|
||||||
- delete
|
|
||||||
- email",
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
||||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
||||||
* @OA\Parameter(
|
|
||||||
* name="id",
|
|
||||||
* in="path",
|
|
||||||
* description="The RecurringInvoice Hashed ID",
|
|
||||||
* example="D2J234DFA",
|
|
||||||
* required=true,
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="string",
|
|
||||||
* format="string",
|
|
||||||
* ),
|
|
||||||
* ),
|
|
||||||
* @OA\Parameter(
|
|
||||||
* name="action",
|
|
||||||
* in="path",
|
|
||||||
* description="The action string to be performed",
|
|
||||||
* example="clone_to_quote",
|
|
||||||
* required=true,
|
|
||||||
* @OA\Schema(
|
|
||||||
* type="string",
|
|
||||||
* format="string",
|
|
||||||
* ),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="Returns the RecurringInvoice object",
|
|
||||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
||||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/RecurringInvoice"),
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=422,
|
|
||||||
* description="Validation error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
||||||
*
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response="default",
|
|
||||||
* description="Unexpected Error",
|
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
||||||
* ),
|
|
||||||
* )
|
|
||||||
* @param ActionRecurringInvoiceRequest $request
|
* @param ActionRecurringInvoiceRequest $request
|
||||||
* @param RecurringInvoice $recurring_invoice
|
* @param RecurringInvoice $recurring_invoice
|
||||||
* @param $action
|
* @param $action
|
||||||
@ -763,4 +556,29 @@ class RecurringInvoiceController extends BaseController
|
|||||||
|
|
||||||
return $this->itemResponse($recurring_invoice->fresh());
|
return $this->itemResponse($recurring_invoice->fresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadPdf(string $invitation_key)
|
||||||
|
{
|
||||||
|
$invitation = $this->recurring_invoice_repo->getInvitationByKey($invitation_key);
|
||||||
|
|
||||||
|
if (! $invitation) {
|
||||||
|
return response()->json(['message' => 'no record found'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact = $invitation->contact;
|
||||||
|
$invoice = $invitation->recurring_invoice;
|
||||||
|
|
||||||
|
$file = $invoice->service()->getInvoicePdf($contact);
|
||||||
|
|
||||||
|
$headers = ['Content-Type' => 'application/pdf'];
|
||||||
|
|
||||||
|
if (request()->input('inline') == 'true') {
|
||||||
|
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->streamDownload(function () use ($file) {
|
||||||
|
echo Storage::get($file);
|
||||||
|
}, basename($file), $headers);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ class SubdomainController extends BaseController
|
|||||||
'beta',
|
'beta',
|
||||||
'prometh',
|
'prometh',
|
||||||
'license',
|
'license',
|
||||||
|
'socket',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -13,8 +13,8 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Factory\SchedulerFactory;
|
use App\Factory\SchedulerFactory;
|
||||||
use App\Filters\SchedulerFilters;
|
use App\Filters\SchedulerFilters;
|
||||||
use App\Http\Requests\TaskScheduler\DestroySchedulerRequest;
|
|
||||||
use App\Http\Requests\TaskScheduler\CreateSchedulerRequest;
|
use App\Http\Requests\TaskScheduler\CreateSchedulerRequest;
|
||||||
|
use App\Http\Requests\TaskScheduler\DestroySchedulerRequest;
|
||||||
use App\Http\Requests\TaskScheduler\ShowSchedulerRequest;
|
use App\Http\Requests\TaskScheduler\ShowSchedulerRequest;
|
||||||
use App\Http\Requests\TaskScheduler\StoreSchedulerRequest;
|
use App\Http\Requests\TaskScheduler\StoreSchedulerRequest;
|
||||||
use App\Http\Requests\TaskScheduler\UpdateSchedulerRequest;
|
use App\Http\Requests\TaskScheduler\UpdateSchedulerRequest;
|
||||||
|
@ -592,9 +592,9 @@ class UserController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function detach(DetachCompanyUserRequest $request, User $user)
|
public function detach(DetachCompanyUserRequest $request, User $user)
|
||||||
{
|
{
|
||||||
if ($request->entityIsDeleted($user)) {
|
// if ($request->entityIsDeleted($user)) {
|
||||||
return $request->disallowUpdate();
|
// return $request->disallowUpdate();
|
||||||
}
|
// }
|
||||||
|
|
||||||
$company_user = CompanyUser::whereUserId($user->id)
|
$company_user = CompanyUser::whereUserId($user->id)
|
||||||
->whereCompanyId(auth()->user()->companyId())
|
->whereCompanyId(auth()->user()->companyId())
|
||||||
|
@ -17,14 +17,17 @@ use App\Filters\WebhookFilters;
|
|||||||
use App\Http\Requests\Webhook\CreateWebhookRequest;
|
use App\Http\Requests\Webhook\CreateWebhookRequest;
|
||||||
use App\Http\Requests\Webhook\DestroyWebhookRequest;
|
use App\Http\Requests\Webhook\DestroyWebhookRequest;
|
||||||
use App\Http\Requests\Webhook\EditWebhookRequest;
|
use App\Http\Requests\Webhook\EditWebhookRequest;
|
||||||
|
use App\Http\Requests\Webhook\RetryWebhookRequest;
|
||||||
use App\Http\Requests\Webhook\ShowWebhookRequest;
|
use App\Http\Requests\Webhook\ShowWebhookRequest;
|
||||||
use App\Http\Requests\Webhook\StoreWebhookRequest;
|
use App\Http\Requests\Webhook\StoreWebhookRequest;
|
||||||
use App\Http\Requests\Webhook\UpdateWebhookRequest;
|
use App\Http\Requests\Webhook\UpdateWebhookRequest;
|
||||||
|
use App\Jobs\Util\WebhookSingle;
|
||||||
use App\Models\Webhook;
|
use App\Models\Webhook;
|
||||||
use App\Repositories\BaseRepository;
|
use App\Repositories\BaseRepository;
|
||||||
use App\Transformers\WebhookTransformer;
|
use App\Transformers\WebhookTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class WebhookController extends BaseController
|
class WebhookController extends BaseController
|
||||||
{
|
{
|
||||||
@ -487,4 +490,28 @@ class WebhookController extends BaseController
|
|||||||
|
|
||||||
return $this->listResponse(Webhook::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
return $this->listResponse(Webhook::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function retry(RetryWebhookRequest $request, Webhook $webhook)
|
||||||
|
{
|
||||||
|
match ($request->entity) {
|
||||||
|
'invoice' => $includes ='client',
|
||||||
|
'payment' => $includes ='invoices,client',
|
||||||
|
'project' => $includes ='client',
|
||||||
|
'purchase_order' => $includes ='vendor',
|
||||||
|
'quote' => $includes ='client',
|
||||||
|
default => $includes = ''
|
||||||
|
};
|
||||||
|
|
||||||
|
$class = 'App\Models\\'.ucfirst(Str::camel($request->entity));
|
||||||
|
|
||||||
|
$entity = $class::withTrashed()->where('id', $this->decodePrimaryKey($request->entity_id))->company()->first();
|
||||||
|
|
||||||
|
if (!$entity) {
|
||||||
|
return response()->json(['message' => ctrans('texts.record_not_found')], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebhookSingle::dispatchSync($webhook->id, $entity, auth()->user()->company()->db, $includes);
|
||||||
|
|
||||||
|
return $this->itemResponse($webhook);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,54 +11,55 @@
|
|||||||
|
|
||||||
namespace App\Http;
|
namespace App\Http;
|
||||||
|
|
||||||
use App\Http\Middleware\ApiSecretCheck;
|
use App\Utils\Ninja;
|
||||||
|
use App\Http\Middleware\Cors;
|
||||||
|
use App\Http\Middleware\SetDb;
|
||||||
|
use App\Http\Middleware\Locale;
|
||||||
|
use App\Http\Middleware\SetWebDb;
|
||||||
|
use App\Http\Middleware\UrlSetDb;
|
||||||
|
use App\Http\Middleware\TokenAuth;
|
||||||
|
use App\Http\Middleware\SetEmailDb;
|
||||||
|
use App\Http\Middleware\VerifyHash;
|
||||||
|
use App\Http\Middleware\SetInviteDb;
|
||||||
|
use App\Http\Middleware\TrimStrings;
|
||||||
use App\Http\Middleware\Authenticate;
|
use App\Http\Middleware\Authenticate;
|
||||||
use App\Http\Middleware\CheckClientExistence;
|
use App\Http\Middleware\ContactSetDb;
|
||||||
use App\Http\Middleware\CheckForMaintenanceMode;
|
use App\Http\Middleware\QueryLogging;
|
||||||
use App\Http\Middleware\ClientPortalEnabled;
|
use App\Http\Middleware\TrustProxies;
|
||||||
|
use App\Http\Middleware\UserVerified;
|
||||||
|
use App\Http\Middleware\VendorLocale;
|
||||||
|
use App\Http\Middleware\PhantomSecret;
|
||||||
|
use App\Http\Middleware\SetDocumentDb;
|
||||||
|
use App\Http\Middleware\ApiSecretCheck;
|
||||||
use App\Http\Middleware\ContactAccount;
|
use App\Http\Middleware\ContactAccount;
|
||||||
|
use App\Http\Middleware\EncryptCookies;
|
||||||
|
use App\Http\Middleware\SessionDomains;
|
||||||
use App\Http\Middleware\ContactKeyLogin;
|
use App\Http\Middleware\ContactKeyLogin;
|
||||||
use App\Http\Middleware\ContactRegister;
|
use App\Http\Middleware\ContactRegister;
|
||||||
use App\Http\Middleware\ContactSetDb;
|
|
||||||
use App\Http\Middleware\ContactTokenAuth;
|
|
||||||
use App\Http\Middleware\Cors;
|
|
||||||
use App\Http\Middleware\EncryptCookies;
|
|
||||||
use App\Http\Middleware\Locale;
|
|
||||||
use App\Http\Middleware\PasswordProtection;
|
|
||||||
use App\Http\Middleware\PhantomSecret;
|
|
||||||
use App\Http\Middleware\QueryLogging;
|
|
||||||
use App\Http\Middleware\RedirectIfAuthenticated;
|
|
||||||
use App\Http\Middleware\SessionDomains;
|
|
||||||
use App\Http\Middleware\SetDb;
|
|
||||||
use App\Http\Middleware\SetDbByCompanyKey;
|
|
||||||
use App\Http\Middleware\SetDocumentDb;
|
|
||||||
use App\Http\Middleware\SetDomainNameDb;
|
use App\Http\Middleware\SetDomainNameDb;
|
||||||
use App\Http\Middleware\SetEmailDb;
|
|
||||||
use App\Http\Middleware\SetInviteDb;
|
|
||||||
use App\Http\Middleware\SetWebDb;
|
|
||||||
use App\Http\Middleware\Shop\ShopTokenAuth;
|
|
||||||
use App\Http\Middleware\TokenAuth;
|
|
||||||
use App\Http\Middleware\TrimStrings;
|
|
||||||
use App\Http\Middleware\TrustProxies;
|
|
||||||
use App\Http\Middleware\UrlSetDb;
|
|
||||||
use App\Http\Middleware\UserVerified;
|
|
||||||
use App\Http\Middleware\VendorContactKeyLogin;
|
|
||||||
use App\Http\Middleware\VendorLocale;
|
|
||||||
use App\Http\Middleware\VerifyCsrfToken;
|
use App\Http\Middleware\VerifyCsrfToken;
|
||||||
use App\Http\Middleware\VerifyHash;
|
use App\Http\Middleware\ContactTokenAuth;
|
||||||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
|
||||||
use Illuminate\Auth\Middleware\Authorize;
|
use Illuminate\Auth\Middleware\Authorize;
|
||||||
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
|
use App\Http\Middleware\SetDbByCompanyKey;
|
||||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
use App\Http\Middleware\PasswordProtection;
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use App\Http\Middleware\ClientPortalEnabled;
|
||||||
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
use App\Http\Middleware\CheckClientExistence;
|
||||||
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
use App\Http\Middleware\VendorContactKeyLogin;
|
||||||
use Illuminate\Http\Middleware\SetCacheHeaders;
|
use Illuminate\Http\Middleware\SetCacheHeaders;
|
||||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
||||||
use Illuminate\Routing\Middleware\ValidateSignature;
|
|
||||||
use Illuminate\Session\Middleware\StartSession;
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
|
use App\Http\Middleware\CheckForMaintenanceMode;
|
||||||
|
use App\Http\Middleware\RedirectIfAuthenticated;
|
||||||
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
use Illuminate\Routing\Middleware\ValidateSignature;
|
||||||
|
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
|
||||||
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
||||||
|
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
||||||
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||||
|
use Illuminate\Routing\Middleware\ThrottleRequestsWithRedis;
|
||||||
|
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
||||||
|
|
||||||
class Kernel extends HttpKernel
|
class Kernel extends HttpKernel
|
||||||
{
|
{
|
||||||
@ -75,9 +76,7 @@ class Kernel extends HttpKernel
|
|||||||
TrimStrings::class,
|
TrimStrings::class,
|
||||||
ConvertEmptyStringsToNull::class,
|
ConvertEmptyStringsToNull::class,
|
||||||
TrustProxies::class,
|
TrustProxies::class,
|
||||||
// \Illuminate\Http\Middleware\HandleCors::class,
|
|
||||||
Cors::class,
|
Cors::class,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,7 +139,6 @@ class Kernel extends HttpKernel
|
|||||||
'cors' => Cors::class,
|
'cors' => Cors::class,
|
||||||
'guest' => RedirectIfAuthenticated::class,
|
'guest' => RedirectIfAuthenticated::class,
|
||||||
'signed' => ValidateSignature::class,
|
'signed' => ValidateSignature::class,
|
||||||
'throttle' => ThrottleRequests::class,
|
|
||||||
'verified' => EnsureEmailIsVerified::class,
|
'verified' => EnsureEmailIsVerified::class,
|
||||||
'query_logging' => QueryLogging::class,
|
'query_logging' => QueryLogging::class,
|
||||||
'token_auth' => TokenAuth::class,
|
'token_auth' => TokenAuth::class,
|
||||||
@ -152,7 +150,6 @@ class Kernel extends HttpKernel
|
|||||||
'email_db' => SetEmailDb::class,
|
'email_db' => SetEmailDb::class,
|
||||||
'invite_db' => SetInviteDb::class,
|
'invite_db' => SetInviteDb::class,
|
||||||
'password_protected' => PasswordProtection::class,
|
'password_protected' => PasswordProtection::class,
|
||||||
'signed' => ValidateSignature::class,
|
|
||||||
'portal_enabled' => ClientPortalEnabled::class,
|
'portal_enabled' => ClientPortalEnabled::class,
|
||||||
'url_db' => UrlSetDb::class,
|
'url_db' => UrlSetDb::class,
|
||||||
'web_db' => SetWebDb::class,
|
'web_db' => SetWebDb::class,
|
||||||
@ -162,7 +159,6 @@ class Kernel extends HttpKernel
|
|||||||
'vendor_locale' => VendorLocale::class,
|
'vendor_locale' => VendorLocale::class,
|
||||||
'contact_register' => ContactRegister::class,
|
'contact_register' => ContactRegister::class,
|
||||||
'verify_hash' => VerifyHash::class,
|
'verify_hash' => VerifyHash::class,
|
||||||
'shop_token_auth' => ShopTokenAuth::class,
|
|
||||||
'phantom_secret' => PhantomSecret::class,
|
'phantom_secret' => PhantomSecret::class,
|
||||||
'contact_key_login' => ContactKeyLogin::class,
|
'contact_key_login' => ContactKeyLogin::class,
|
||||||
'vendor_contact_key_login' => VendorContactKeyLogin::class,
|
'vendor_contact_key_login' => VendorContactKeyLogin::class,
|
||||||
@ -170,6 +166,7 @@ class Kernel extends HttpKernel
|
|||||||
'user_verified' => UserVerified::class,
|
'user_verified' => UserVerified::class,
|
||||||
'document_db' => SetDocumentDb::class,
|
'document_db' => SetDocumentDb::class,
|
||||||
'session_domain' => SessionDomains::class,
|
'session_domain' => SessionDomains::class,
|
||||||
|
//we dyanamically add the throttle middleware in RouteServiceProvider
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $middlewarePriority = [
|
protected $middlewarePriority = [
|
||||||
@ -189,7 +186,6 @@ class Kernel extends HttpKernel
|
|||||||
ContactTokenAuth::class,
|
ContactTokenAuth::class,
|
||||||
ContactKeyLogin::class,
|
ContactKeyLogin::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
ShopTokenAuth::class,
|
|
||||||
ContactRegister::class,
|
ContactRegister::class,
|
||||||
PhantomSecret::class,
|
PhantomSecret::class,
|
||||||
CheckClientExistence::class,
|
CheckClientExistence::class,
|
||||||
@ -199,4 +195,5 @@ class Kernel extends HttpKernel
|
|||||||
SubstituteBindings::class,
|
SubstituteBindings::class,
|
||||||
ContactAccount::class,
|
ContactAccount::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,24 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
use App\Utils\Ninja;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use Livewire\Component;
|
|
||||||
use App\Libraries\MultiDB;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use App\Models\Subscription;
|
|
||||||
use App\Models\ClientContact;
|
|
||||||
use App\Factory\ClientFactory;
|
use App\Factory\ClientFactory;
|
||||||
use App\Jobs\Mail\NinjaMailerJob;
|
use App\Jobs\Mail\NinjaMailerJob;
|
||||||
use App\DataMapper\ClientSettings;
|
|
||||||
use App\Jobs\Mail\NinjaMailerObject;
|
use App\Jobs\Mail\NinjaMailerObject;
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Mail\ContactPasswordlessLogin;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Subscription;
|
||||||
|
use App\Repositories\ClientContactRepository;
|
||||||
|
use App\Repositories\ClientRepository;
|
||||||
|
use App\Services\Subscription\SubscriptionService;
|
||||||
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use App\Mail\ContactPasswordlessLogin;
|
use Illuminate\Support\Str;
|
||||||
use App\Repositories\ClientRepository;
|
use Livewire\Component;
|
||||||
use App\Repositories\ClientContactRepository;
|
|
||||||
use App\Services\Subscription\SubscriptionService;
|
|
||||||
|
|
||||||
class BillingPortalPurchase extends Component
|
class BillingPortalPurchase extends Component
|
||||||
{
|
{
|
||||||
|
@ -172,8 +172,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
$this->contact = auth()->guard('contact')->user();
|
$this->contact = auth()->guard('contact')->user();
|
||||||
$this->authenticated = true;
|
$this->authenticated = true;
|
||||||
$this->payment_started = true;
|
$this->payment_started = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->bundle = collect();
|
$this->bundle = collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +275,6 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
*/
|
*/
|
||||||
public function handleCoupon()
|
public function handleCoupon()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->resetErrorBag('coupon');
|
$this->resetErrorBag('coupon');
|
||||||
$this->resetValidation('coupon');
|
$this->resetValidation('coupon');
|
||||||
|
|
||||||
@ -311,7 +309,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
'description' => $p->notes,
|
'description' => $p->notes,
|
||||||
'product_key' => $p->product_key,
|
'product_key' => $p->product_key,
|
||||||
'unit_cost' => $p->price,
|
'unit_cost' => $p->price,
|
||||||
'product' => nl2br(substr($p->notes, 0, 50)),
|
'product' => substr(strip_tags($p->markdownNotes()), 0, 50),
|
||||||
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
|
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
@ -329,7 +327,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
'description' => $p->notes,
|
'description' => $p->notes,
|
||||||
'product_key' => $p->product_key,
|
'product_key' => $p->product_key,
|
||||||
'unit_cost' => $p->price,
|
'unit_cost' => $p->price,
|
||||||
'product' => nl2br(substr($p->notes, 0, 50)),
|
'product' => substr(strip_tags($p->markdownNotes()), 0, 50),
|
||||||
'price' => Number::formatMoney($total, $this->subscription->company),
|
'price' => Number::formatMoney($total, $this->subscription->company),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
@ -352,7 +350,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
'description' => $p->notes,
|
'description' => $p->notes,
|
||||||
'product_key' => $p->product_key,
|
'product_key' => $p->product_key,
|
||||||
'unit_cost' => $p->price,
|
'unit_cost' => $p->price,
|
||||||
'product' => nl2br(substr($p->notes, 0, 50)),
|
'product' => substr(strip_tags($p->markdownNotes()), 0, 50),
|
||||||
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
|
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
@ -375,7 +373,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
'description' => $p->notes,
|
'description' => $p->notes,
|
||||||
'product_key' => $p->product_key,
|
'product_key' => $p->product_key,
|
||||||
'unit_cost' => $p->price,
|
'unit_cost' => $p->price,
|
||||||
'product' => nl2br(substr($p->notes, 0, 50)),
|
'product' => substr(strip_tags($p->markdownNotes()), 0, 50),
|
||||||
'price' => Number::formatMoney($total, $this->subscription->company),
|
'price' => Number::formatMoney($total, $this->subscription->company),
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
|
@ -232,8 +232,9 @@ class RequiredClientInfo extends Component
|
|||||||
if ($cg && $cg->update_details) {
|
if ($cg && $cg->update_details) {
|
||||||
$payment_gateway = $cg->driver($this->client)->init();
|
$payment_gateway = $cg->driver($this->client)->init();
|
||||||
|
|
||||||
// if(method_exists($payment_gateway, "updateCustomer"))
|
if (method_exists($payment_gateway, "updateCustomer")) {
|
||||||
// $payment_gateway->updateCustomer();
|
$payment_gateway->updateCustomer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
124
app/Http/Middleware/ThrottleRequestsWithPredis.php
Normal file
124
app/Http/Middleware/ThrottleRequestsWithPredis.php
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Cache\RateLimiter;
|
||||||
|
use Illuminate\Redis\Limiters\DurationLimiter;
|
||||||
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
|
|
||||||
|
class ThrottleRequestsWithPredis extends ThrottleRequests
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Redis factory implementation.
|
||||||
|
*
|
||||||
|
* @var \Illuminate\Contracts\Redis\Factory
|
||||||
|
*/
|
||||||
|
protected $redis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp of the end of the current duration by key.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $decaysAt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of remaining slots by key.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $remaining = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new request throttler.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Cache\RateLimiter $limiter
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(RateLimiter $limiter)
|
||||||
|
{
|
||||||
|
parent::__construct($limiter);
|
||||||
|
|
||||||
|
$this->redis = \Illuminate\Support\Facades\Redis::connection('sentinel-cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param array $limits
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Http\Exceptions\ThrottleRequestsException
|
||||||
|
*/
|
||||||
|
protected function handleRequest($request, Closure $next, array $limits)
|
||||||
|
{
|
||||||
|
foreach ($limits as $limit) {
|
||||||
|
if ($this->tooManyAttempts($limit->key, $limit->maxAttempts, $limit->decayMinutes)) {
|
||||||
|
throw $this->buildException($request, $limit->key, $limit->maxAttempts, $limit->responseCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $next($request);
|
||||||
|
|
||||||
|
foreach ($limits as $limit) {
|
||||||
|
$response = $this->addHeaders(
|
||||||
|
$response,
|
||||||
|
$limit->maxAttempts,
|
||||||
|
$this->calculateRemainingAttempts($limit->key, $limit->maxAttempts)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given key has been "accessed" too many times.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param int $maxAttempts
|
||||||
|
* @param int $decayMinutes
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function tooManyAttempts($key, $maxAttempts, $decayMinutes)
|
||||||
|
{
|
||||||
|
$limiter = new DurationLimiter(
|
||||||
|
$this->redis,
|
||||||
|
$key,
|
||||||
|
$maxAttempts,
|
||||||
|
$decayMinutes * 60
|
||||||
|
);
|
||||||
|
|
||||||
|
return tap(! $limiter->acquire(), function () use ($key, $limiter) {
|
||||||
|
[$this->decaysAt[$key], $this->remaining[$key]] = [
|
||||||
|
$limiter->decaysAt, $limiter->remaining,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the number of remaining attempts.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param int $maxAttempts
|
||||||
|
* @param int|null $retryAfter
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function calculateRemainingAttempts($key, $maxAttempts, $retryAfter = null)
|
||||||
|
{
|
||||||
|
return is_null($retryAfter) ? $this->remaining[$key] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of seconds until the lock is released.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function getTimeUntilNextRetry($key)
|
||||||
|
{
|
||||||
|
return $this->decaysAt[$key] - $this->currentTime();
|
||||||
|
}
|
||||||
|
}
|
@ -29,10 +29,11 @@ class UploadBankIntegrationRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadBankTransactionRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -38,10 +38,11 @@ class StoreClientRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -38,10 +38,11 @@ class UpdateClientRequest extends Request
|
|||||||
{
|
{
|
||||||
/* Ensure we have a client name, and that all emails are unique*/
|
/* Ensure we have a client name, and that all emails are unique*/
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadClientRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\ClientPortal\PrePayments;
|
||||||
|
|
||||||
|
use App\Http\ViewComposers\PortalComposer;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StorePrePaymentRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'notes' => 'required|bail|',
|
||||||
|
'amount' => 'required|bail|gte:minimum_amount',
|
||||||
|
'minimum_amount' => '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -29,10 +29,11 @@ class UploadCompanyRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -43,10 +43,11 @@ class StoreCreditRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -42,10 +42,11 @@ class UpdateCreditRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadCreditRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -32,7 +32,7 @@ class StoreDesignRequest extends Request
|
|||||||
return [
|
return [
|
||||||
//'name' => 'required',
|
//'name' => 'required',
|
||||||
'name' => 'required|unique:designs,name,null,null,company_id,'.auth()->user()->companyId(),
|
'name' => 'required|unique:designs,name,null,null,company_id,'.auth()->user()->companyId(),
|
||||||
'design' => 'required',
|
'design' => 'required|array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class SendEmailRequest extends Request
|
|||||||
'template' => 'bail|required',
|
'template' => 'bail|required',
|
||||||
'entity' => 'bail|required',
|
'entity' => 'bail|required',
|
||||||
'entity_id' => 'bail|required',
|
'entity_id' => 'bail|required',
|
||||||
|
'cc_email' => 'bail|sometimes|email|nullable',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,11 @@ class UploadExpenseRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadGroupSettingRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -37,10 +37,11 @@ class StoreInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -39,10 +39,11 @@ class UpdateInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
@ -45,6 +46,5 @@ class UploadInvoiceRequest extends Request
|
|||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,11 @@ class StorePaymentRequest extends Request
|
|||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -44,10 +44,11 @@ class UpdatePaymentRequest extends Request
|
|||||||
$rules['number'] = Rule::unique('payments')->where('company_id', auth()->user()->company()->id)->ignore($this->payment->id);
|
$rules['number'] = Rule::unique('payments')->where('company_id', auth()->user()->company()->id)->ignore($this->payment->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadPaymentRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -47,6 +47,7 @@ class DesignPreviewRequest extends Request
|
|||||||
'settings' => 'sometimes',
|
'settings' => 'sometimes',
|
||||||
'group_id' => 'sometimes',
|
'group_id' => 'sometimes',
|
||||||
'client_id' => 'sometimes',
|
'client_id' => 'sometimes',
|
||||||
|
'design' => 'bail|sometimes|array'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
namespace App\Http\Requests\Preview;
|
namespace App\Http\Requests\Preview;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Credit;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\Quote;
|
|
||||||
use App\Models\RecurringInvoice;
|
|
||||||
use App\Utils\Traits\CleanLineItems;
|
use App\Utils\Traits\CleanLineItems;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace App\Http\Requests\Preview;
|
namespace App\Http\Requests\Preview;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\PurchaseOrder;
|
|
||||||
use App\Utils\Traits\CleanLineItems;
|
use App\Utils\Traits\CleanLineItems;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
@ -28,10 +28,11 @@ class StoreProductRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace App\Http\Requests\Product;
|
namespace App\Http\Requests\Product;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Product;
|
|
||||||
use App\Utils\Traits\ChecksEntityStatus;
|
use App\Utils\Traits\ChecksEntityStatus;
|
||||||
|
|
||||||
class UpdateProductRequest extends Request
|
class UpdateProductRequest extends Request
|
||||||
@ -31,10 +30,11 @@ class UpdateProductRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -28,10 +28,11 @@ class UploadProductRequest extends Request
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\Project;
|
namespace App\Http\Requests\Project;
|
||||||
|
|
||||||
use App\Models\Project;
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Project;
|
||||||
|
|
||||||
class CreateProjectRequest extends Request
|
class CreateProjectRequest extends Request
|
||||||
{
|
{
|
||||||
@ -24,6 +24,5 @@ class CreateProjectRequest extends Request
|
|||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->can('create', Project::class);
|
return auth()->user()->can('create', Project::class);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ class ShowProjectRequest extends Request
|
|||||||
{
|
{
|
||||||
// return auth()->user()->isAdmin();
|
// return auth()->user()->isAdmin();
|
||||||
return auth()->user()->can('view', $this->project);
|
return auth()->user()->can('view', $this->project);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,10 +42,11 @@ class StoreProjectRequest extends Request
|
|||||||
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id);
|
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -37,10 +37,11 @@ class UpdateProjectRequest extends Request
|
|||||||
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
|
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadProjectRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -47,10 +47,11 @@ class StorePurchaseOrderRequest extends Request
|
|||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -50,10 +50,11 @@ class UpdatePurchaseOrderRequest extends Request
|
|||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadPurchaseOrderRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -39,10 +39,11 @@ class StoreQuoteRequest extends Request
|
|||||||
|
|
||||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -37,10 +37,11 @@ class UpdateQuoteRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadQuoteRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -48,10 +48,11 @@ class StoreRecurringExpenseRequest extends Request
|
|||||||
$rules['tax_amount2'] = 'numeric';
|
$rules['tax_amount2'] = 'numeric';
|
||||||
$rules['tax_amount3'] = 'numeric';
|
$rules['tax_amount3'] = 'numeric';
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -48,10 +48,11 @@ class UpdateRecurringExpenseRequest extends Request
|
|||||||
$rules['tax_amount3'] = 'numeric';
|
$rules['tax_amount3'] = 'numeric';
|
||||||
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -29,10 +29,11 @@ class UploadRecurringExpenseRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
<?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\RecurringInvoice;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class BulkRecurringInvoiceRequest extends Request
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ids' => ['required','bail','array',Rule::exists('recurring_invoices', 'id')->where('company_id', auth()->user()->company()->id)],
|
||||||
|
'action' => 'in:archive,restore,delete,increase_prices,update_prices,start,stop,send_now',
|
||||||
|
'percentage_increase' => 'required_if:action,increase_prices|numeric|min:0|max:100',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
if (isset($input['ids'])) {
|
||||||
|
$input['ids'] = $this->transformKeys($input['ids']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
}
|
||||||
|
}
|
@ -38,10 +38,11 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if($this->file('documents') && is_array($this->file('documents')))
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
elseif($this->file('documents'))
|
} elseif ($this->file('documents')) {
|
||||||
$rules['documents'] = $this->file_validation;
|
$rules['documents'] = $this->file_validation;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->file('file') && is_array($this->file('file'))) {
|
if ($this->file('file') && is_array($this->file('file'))) {
|
||||||
$rules['file.*'] = $this->file_validation;
|
$rules['file.*'] = $this->file_validation;
|
||||||
|
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