mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
commit
c7764f296e
@ -1 +1 @@
|
||||
5.5.95
|
||||
5.5.96
|
@ -190,14 +190,12 @@ class BackupUpdate extends Command
|
||||
->where('filename', '!=', '')
|
||||
->cursor()
|
||||
->each(function ($backup) {
|
||||
|
||||
$backup_bin = Storage::disk('s3')->get($backup->filename);
|
||||
|
||||
if ($backup_bin) {
|
||||
Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin);
|
||||
|
||||
nlog("Backups - Moving {$backup->filename} to {$this->option('disk')}");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -12,36 +12,36 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App;
|
||||
use Exception;
|
||||
use App\Models\User;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Quote;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\CompanyUser;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\CompanyLedger;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\VendorContact;
|
||||
use App\Models\QuoteInvitation;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\VendorContactFactory;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyLedger;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Models\User;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
use App\Utils\Ninja;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/*
|
||||
@ -176,18 +176,16 @@ class CheckData extends Command
|
||||
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)
|
||||
if ($cu->company && $cu->user) {
|
||||
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* checkOauthSanity
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function checkOauthSanity()
|
||||
|
@ -27,7 +27,6 @@ use App\Jobs\Subscription\CleanStaleInvoiceOrder;
|
||||
use App\Jobs\Util\DiskCleanup;
|
||||
use App\Jobs\Util\ReminderJob;
|
||||
use App\Jobs\Util\SchedulerCheck;
|
||||
use App\Jobs\Util\SendFailedEmails;
|
||||
use App\Jobs\Util\UpdateExchangeRates;
|
||||
use App\Jobs\Util\VersionCheck;
|
||||
use App\Models\Account;
|
||||
|
@ -84,13 +84,13 @@ class ClientSettings extends BaseSettings
|
||||
*/
|
||||
public static function buildClientSettings($company_settings, $client_settings)
|
||||
{
|
||||
|
||||
if (! $client_settings) {
|
||||
return $company_settings;
|
||||
}
|
||||
|
||||
if(is_array($client_settings))
|
||||
if (is_array($client_settings)) {
|
||||
$client_settings = (object)$client_settings;
|
||||
}
|
||||
|
||||
foreach ($company_settings as $key => $value) {
|
||||
/* pseudo code
|
||||
|
@ -11,21 +11,21 @@
|
||||
|
||||
namespace App\DataMapper\Schedule;
|
||||
|
||||
class ScheduleInvoice
|
||||
class ScheduleEntity
|
||||
{
|
||||
/**
|
||||
* Defines the template name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $template = 'schedule_invoice';
|
||||
public string $template = 'schedule_entity';
|
||||
|
||||
/**
|
||||
* Defines the template name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $entity = '';
|
||||
public string $entity = ''; // invoice, credit, quote, purchase_order
|
||||
|
||||
/**
|
||||
* Defines the template name
|
||||
@ -33,5 +33,4 @@ class ScheduleInvoice
|
||||
* @var string
|
||||
*/
|
||||
public string $entity_id = '';
|
||||
|
||||
}
|
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
|
||||
|
||||
}
|
@ -16,7 +16,6 @@ use App\Models\Company;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
@ -13,11 +13,11 @@ namespace App\Events\Invoice;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasCreated.
|
||||
|
@ -12,8 +12,8 @@
|
||||
namespace App\Export\CSV;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class BaseExport
|
||||
{
|
||||
@ -34,7 +34,6 @@ class BaseExport
|
||||
protected function filterByClients($query)
|
||||
{
|
||||
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
|
||||
|
||||
$client = Client::withTrashed()->find($this->input['client_id']);
|
||||
$this->client_description = $client->present()->name;
|
||||
return $query->where('client_id', $this->input['client_id']);
|
||||
|
@ -11,15 +11,15 @@
|
||||
|
||||
namespace App\Export\CSV;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use League\Csv\Writer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Product;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use League\Csv\Writer;
|
||||
|
||||
class ProductSalesExport extends BaseExport
|
||||
{
|
||||
@ -117,10 +117,9 @@ 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 = [
|
||||
'product' => $value,
|
||||
'product' => $value,
|
||||
'quantity' => $key->sum('quantity'),
|
||||
'markup' => $key->sum('markup'),
|
||||
'profit' => $key->sum('profit'),
|
||||
@ -183,11 +182,10 @@ class ProductSalesExport extends BaseExport
|
||||
$this->sales->push($entity);
|
||||
|
||||
return $entity;
|
||||
|
||||
}
|
||||
|
||||
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
|
||||
{
|
||||
{
|
||||
$product = $this->getProduct($entity['product_key']);
|
||||
|
||||
$entity['cost'] = $product->cost ?? 0;
|
||||
@ -199,31 +197,31 @@ class ProductSalesExport extends BaseExport
|
||||
$entity['date'] = Carbon::parse($invoice->date)->format($this->company->date_format());
|
||||
|
||||
$entity['discount'] = $this->calculateDiscount($invoice, $entity);
|
||||
$entity['markup'] = round(((($entity['price'] - $entity['discount'] - $entity['cost']) / $unit_cost) * 100),2);
|
||||
$entity['markup'] = round(((($entity['price'] - $entity['discount'] - $entity['cost']) / $unit_cost) * 100), 2);
|
||||
|
||||
$entity['net_total'] = $entity['price'] - $entity['discount'];
|
||||
$entity['profit'] = $entity['price'] - $entity['discount'] - $entity['cost'];
|
||||
|
||||
if(strlen($entity['tax_name1']) > 1) {
|
||||
if (strlen($entity['tax_name1']) > 1) {
|
||||
$entity['tax_name1'] = $entity['tax_name1'] . ' [' . $entity['tax_rate1'] . '%]';
|
||||
$entity['tax_amount1'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate1']);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$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_amount2'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate2']);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$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_amount3'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate3']);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$entity['tax_amount3'] = 0;
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
@ -240,13 +238,11 @@ class ProductSalesExport extends BaseExport
|
||||
{
|
||||
$amount = $amount - ($amount * ($invoice->discount / 100));
|
||||
|
||||
if($invoice->uses_inclusive_taxes) {
|
||||
if ($invoice->uses_inclusive_taxes) {
|
||||
return round($amount - ($amount / (1 + ($tax_rate / 100))), 2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return round(($amount * $tax_rate / 100), 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -258,15 +254,15 @@ class ProductSalesExport extends BaseExport
|
||||
* @param mixed $entity
|
||||
* @return float
|
||||
*/
|
||||
private function calculateDiscount(Invoice $invoice , $entity) :float
|
||||
private function calculateDiscount(Invoice $invoice, $entity) :float
|
||||
{
|
||||
if($entity['discount'] == 0)
|
||||
if ($entity['discount'] == 0) {
|
||||
return 0;
|
||||
|
||||
if($invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||
return $entity['discount'];
|
||||
}
|
||||
elseif(!$invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||
|
||||
if ($invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||
return $entity['discount'];
|
||||
} elseif (!$invoice->is_amount_discount && $entity['discount'] != 0) {
|
||||
return round($entity['line_total'] * ($entity['discount'] / 100), 2);
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ class CreditFilters extends QueryFilters
|
||||
->orWhere('credits.custom_value2', 'like', '%'.$filter.'%')
|
||||
->orWhere('credits.custom_value3', 'like', '%'.$filter.'%')
|
||||
->orWhere('credits.custom_value4', 'like', '%'.$filter.'%')
|
||||
->orWhereHas('client', function ($q) use ($filter){
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
->orWhereHas('client', function ($q) use ($filter) {
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ class InvoiceFilters extends QueryFilters
|
||||
if (in_array('overdue', $status_parameters)) {
|
||||
$query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
->where('due_date', '<', Carbon::now())
|
||||
->orWhere('due_date', null)
|
||||
->orWhere('partial_due_date', '<', Carbon::now());
|
||||
}
|
||||
});
|
||||
@ -109,8 +108,8 @@ class InvoiceFilters extends QueryFilters
|
||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||
->orWhereHas('client', function ($q) use ($filter){
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
->orWhereHas('client', function ($q) use ($filter) {
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class PaymentFilters extends QueryFilters
|
||||
* Sorts the list based on $sort.
|
||||
*
|
||||
* formatted as column|asc
|
||||
*
|
||||
*
|
||||
* @param string $sort
|
||||
* @return Builder
|
||||
*/
|
||||
|
@ -63,8 +63,8 @@ class PurchaseOrderFilters extends QueryFilters
|
||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if (count($status_parameters) >=1) {
|
||||
$query->whereIn('status_id', $status_parameters);
|
||||
if (count($po_status) >=1) {
|
||||
$query->whereIn('status_id', $po_status);
|
||||
}
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ class PurchaseOrderFilters extends QueryFilters
|
||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||
->orWhereHas('vendor', function ($q) use ($filter){
|
||||
->orWhereHas('vendor', function ($q) use ($filter) {
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
});
|
||||
});
|
||||
|
@ -38,9 +38,9 @@ class QuoteFilters extends QueryFilters
|
||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||
->orWhereHas('client', function ($q) use ($filter){
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
});
|
||||
->orWhereHas('client', function ($q) use ($filter) {
|
||||
$q->where('name', 'like', '%'.$filter.'%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ class AccountController extends BaseController
|
||||
$truth->setUser(auth()->user());
|
||||
$truth->setCompany($ct->first()->company);
|
||||
|
||||
return $this->listResponse($ct->fresh());
|
||||
return $this->listResponse($ct);
|
||||
}
|
||||
|
||||
public function update(UpdateAccountRequest $request, Account $account)
|
||||
|
@ -377,7 +377,7 @@ class LoginController extends BaseController
|
||||
|
||||
if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) {
|
||||
auth()->user()->companies->each(function ($company) {
|
||||
if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->where('is_system',true)->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();
|
||||
}
|
||||
});
|
||||
|
@ -531,7 +531,6 @@ class BankTransactionController extends BaseController
|
||||
*/
|
||||
public function match(MatchBankTransactionRequest $request)
|
||||
{
|
||||
|
||||
$bts = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
||||
|
||||
return $this->listResponse($bts);
|
||||
|
@ -12,24 +12,24 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\View\View;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use App\PaymentDrivers\Stripe\BankTransfer;
|
||||
use App\Services\ClientPortal\InstantPayment;
|
||||
use App\Services\Subscription\SubscriptionService;
|
||||
use App\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.
|
||||
@ -64,15 +64,14 @@ class PaymentController extends Controller
|
||||
$data = 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')) {
|
||||
$stripe = $payment->company_gateway->driver($payment->client);
|
||||
$payment_intent = $stripe->getPaymentIntent($payment->transaction_reference);
|
||||
|
||||
$bt = new BankTransfer($stripe);
|
||||
|
||||
match($payment->currency->code){
|
||||
match ($payment->currency->code) {
|
||||
'MXN' => $data = $bt->formatDataforMx($payment_intent),
|
||||
'EUR' => $data = $bt->formatDataforEur($payment_intent),
|
||||
'JPY' => $data = $bt->formatDataforJp($payment_intent),
|
||||
|
@ -15,7 +15,6 @@ namespace App\Http\Controllers\ClientPortal;
|
||||
use App\Events\Payment\Methods\MethodDeleted;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClientPortal\PaymentMethod\CreatePaymentMethodRequest;
|
||||
use App\Http\Requests\ClientPortal\PaymentMethod\VerifyPaymentMethodRequest;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
|
@ -12,16 +12,16 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Utils\Number;
|
||||
use Illuminate\View\View;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
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.
|
||||
@ -38,7 +38,6 @@ class PrePaymentController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => ctrans('texts.amount'). " " .auth()->guard('contact')->user()->client->currency()->code." (".auth()->guard('contact')->user()->client->currency()->symbol . ")",
|
||||
'allows_recurring' => auth()->guard('contact')->user()->client->getSetting('client_initiated_payments_recurring'),
|
||||
@ -51,7 +50,6 @@ class PrePaymentController extends Controller
|
||||
|
||||
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;
|
||||
@ -114,7 +112,5 @@ class PrePaymentController extends Controller
|
||||
];
|
||||
|
||||
return $this->render('invoices.payment', $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ class QuoteController extends Controller
|
||||
if ($process) {
|
||||
foreach ($quotes as $quote) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,6 @@ class SubscriptionPurchaseController extends Controller
|
||||
|
||||
public function upgrade(Subscription $subscription, Request $request)
|
||||
{
|
||||
|
||||
App::setLocale($subscription->company->locale());
|
||||
|
||||
/* Make sure the contact is logged into the correct company for this subscription */
|
||||
|
@ -11,37 +11,37 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyUser;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\Uploadable;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Jobs\Company\CreateCompany;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Mail\Company\CompanyDeleted;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Turbo124\Beacon\Facades\LightLogs;
|
||||
use App\Repositories\CompanyRepository;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use App\DataMapper\Analytics\AccountDeleted;
|
||||
use App\Transformers\CompanyUserTransformer;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Http\Requests\Company\CreateCompanyRequest;
|
||||
use App\Http\Requests\Company\DefaultCompanyRequest;
|
||||
use App\Http\Requests\Company\DestroyCompanyRequest;
|
||||
use App\Http\Requests\Company\EditCompanyRequest;
|
||||
use App\Http\Requests\Company\ShowCompanyRequest;
|
||||
use App\Http\Requests\Company\StoreCompanyRequest;
|
||||
use App\Http\Requests\Company\CreateCompanyRequest;
|
||||
use App\Http\Requests\Company\UpdateCompanyRequest;
|
||||
use App\Http\Requests\Company\UploadCompanyRequest;
|
||||
use App\Http\Requests\Company\DefaultCompanyRequest;
|
||||
use App\Http\Requests\Company\DestroyCompanyRequest;
|
||||
use App\Jobs\Company\CreateCompany;
|
||||
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Mail\Company\CompanyDeleted;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Repositories\CompanyRepository;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use App\Transformers\CompanyUserTransformer;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use App\Utils\Traits\Uploadable;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Turbo124\Beacon\Facades\LightLogs;
|
||||
|
||||
/**
|
||||
* Class CompanyController.
|
||||
@ -489,8 +489,7 @@ class CompanyController extends BaseController
|
||||
|
||||
try {
|
||||
Storage::disk(config('filesystems.default'))->deleteDirectory($company->company_key);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
|
||||
$account->delete();
|
||||
@ -502,9 +501,6 @@ class CompanyController extends BaseController
|
||||
LightLogs::create(new AccountDeleted())
|
||||
->increment()
|
||||
->batch();
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
$company_id = $company->id;
|
||||
|
||||
|
@ -11,26 +11,26 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Quote;
|
||||
use App\Events\Credit\CreditWasEmailed;
|
||||
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\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Services\Email\Email;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Jobs\Entity\EmailEntity;
|
||||
use App\Models\Quote;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Services\Email\Email;
|
||||
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\InvoiceTransformer;
|
||||
use App\Http\Requests\Email\SendEmailRequest;
|
||||
use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
|
||||
use App\Transformers\PurchaseOrderTransformer;
|
||||
use App\Transformers\QuoteTransformer;
|
||||
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
|
||||
@ -136,8 +136,9 @@ class EmailController extends BaseController
|
||||
$mo->email_template_body = $request->input('template');
|
||||
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
||||
|
||||
if($request->has('cc_email'))
|
||||
if ($request->has('cc_email')) {
|
||||
$mo->cc[] = new Address($request->cc_email);
|
||||
}
|
||||
|
||||
// if ($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order' || $entity == 'App\Models\PurchaseOrder') {
|
||||
// return $this->sendPurchaseOrder($entity_obj, $data, $template);
|
||||
@ -152,7 +153,6 @@ class EmailController extends BaseController
|
||||
$mo->invitation_id = $invitation->id;
|
||||
|
||||
Email::dispatch($mo, $invitation->company);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -193,7 +193,7 @@ class EmailController extends BaseController
|
||||
$this->entity_transformer = RecurringInvoiceTransformer::class;
|
||||
}
|
||||
|
||||
if($entity_obj instanceof PurchaseOrder){
|
||||
if ($entity_obj instanceof PurchaseOrder) {
|
||||
$this->entity_type = PurchaseOrder::class;
|
||||
$this->entity_transformer = PurchaseOrderTransformer::class;
|
||||
}
|
||||
@ -217,8 +217,7 @@ class EmailController extends BaseController
|
||||
|
||||
private function resolveClass(string $entity): string
|
||||
{
|
||||
|
||||
match($entity){
|
||||
match ($entity) {
|
||||
'invoice' => $class = Invoice::class,
|
||||
'App\Models\Invoice' => $class = Invoice::class,
|
||||
'credit' => $class = Credit::class,
|
||||
@ -232,6 +231,5 @@ class EmailController extends BaseController
|
||||
};
|
||||
|
||||
return $class;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -163,19 +163,15 @@ class ImportController extends Controller
|
||||
$bestDelimiter = ' ';
|
||||
$count = 0;
|
||||
foreach ($delimiters as $delimiter) {
|
||||
|
||||
// if (substr_count($csvfile, $delimiter) > $count) {
|
||||
// $count = substr_count($csvfile, $delimiter);
|
||||
// $bestDelimiter = $delimiter;
|
||||
// }
|
||||
|
||||
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
|
||||
if (substr_count(strstr($csvfile, "\n", true), $delimiter) > $count) {
|
||||
$count = substr_count($csvfile, $delimiter);
|
||||
$bestDelimiter = $delimiter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return $bestDelimiter;
|
||||
}
|
||||
|
@ -11,13 +11,13 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use stdClass;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Account;
|
||||
use App\Utils\CurlUtils;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Request;
|
||||
use stdClass;
|
||||
|
||||
class LicenseController extends BaseController
|
||||
{
|
||||
@ -89,6 +89,10 @@ class LicenseController extends BaseController
|
||||
$license_key = request()->input('license_key');
|
||||
$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";
|
||||
$data = trim(CurlUtils::get($url));
|
||||
|
||||
@ -149,21 +153,19 @@ class LicenseController extends BaseController
|
||||
return response()->json($error, 400);
|
||||
}
|
||||
|
||||
public function v5ClaimLicense(Request $request)
|
||||
public function v5ClaimLicense(string $license_key)
|
||||
{
|
||||
$this->checkLicense();
|
||||
|
||||
/* 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( "https://invoicing.co/claim_license", [
|
||||
'license_key' => $request->input('license_key'),
|
||||
$response = Http::get("https://invoicing.co/claim_license", [
|
||||
'license_key' => $license_key,
|
||||
'product_id' => 3,
|
||||
]);
|
||||
|
||||
if($response->successful()) {
|
||||
|
||||
if ($response->successful()) {
|
||||
$payload = $response->json();
|
||||
|
||||
$account = auth()->user()->account;
|
||||
@ -179,8 +181,7 @@ class LicenseController extends BaseController
|
||||
];
|
||||
|
||||
return response()->json($error, 200);
|
||||
}else {
|
||||
|
||||
} else {
|
||||
$error = [
|
||||
'message' => trans('texts.white_label_license_error'),
|
||||
'errors' => new stdClass,
|
||||
@ -188,7 +189,6 @@ class LicenseController extends BaseController
|
||||
|
||||
return response()->json($error, 400);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$error = [
|
||||
@ -197,7 +197,6 @@ class LicenseController extends BaseController
|
||||
];
|
||||
|
||||
return response()->json($error, 400);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -210,6 +209,5 @@ class LicenseController extends BaseController
|
||||
$account->plan_expires = null;
|
||||
$account->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Credit;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
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 PdfMakerDesign;
|
||||
use App\Services\PdfMaker\PdfMaker;
|
||||
use App\Services\Preview\StubBuilder;
|
||||
use App\Utils\HostedPDF\NinjaPdf;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
|
@ -11,29 +11,29 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Account;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Factory\RecurringInvoiceFactory;
|
||||
use App\Filters\RecurringInvoiceFilters;
|
||||
use App\Jobs\RecurringInvoice\UpdateRecurring;
|
||||
use App\Repositories\RecurringInvoiceRepository;
|
||||
use App\Transformers\RecurringInvoiceTransformer;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
|
||||
use App\Factory\RecurringInvoiceFactory;
|
||||
use App\Filters\RecurringInvoiceFilters;
|
||||
use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\BulkRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\EditRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\ShowRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest;
|
||||
use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest;
|
||||
use App\Jobs\RecurringInvoice\UpdateRecurring;
|
||||
use App\Models\Account;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Repositories\RecurringInvoiceRepository;
|
||||
use App\Transformers\RecurringInvoiceTransformer;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Class RecurringInvoiceController.
|
||||
@ -406,10 +406,9 @@ class RecurringInvoiceController extends BaseController
|
||||
*/
|
||||
public function bulk(BulkRecurringInvoiceRequest $request)
|
||||
{
|
||||
|
||||
$percentage_increase = request()->has('percentage_increase') ? request()->input('percentage_increase') : 0;
|
||||
|
||||
if(in_array($request->action, ['increase_prices', 'update_prices'])) {
|
||||
if (in_array($request->action, ['increase_prices', 'update_prices'])) {
|
||||
UpdateRecurring::dispatch($request->ids, auth()->user()->company(), auth()->user(), $request->action, $percentage_increase);
|
||||
|
||||
return response()->json(['message' => 'Update in progress.'], 200);
|
||||
@ -417,7 +416,7 @@ class RecurringInvoiceController extends BaseController
|
||||
|
||||
$recurring_invoices = RecurringInvoice::withTrashed()->find($request->ids);
|
||||
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) use($request){
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) use ($request) {
|
||||
if (auth()->user()->can('edit', $recurring_invoice)) {
|
||||
$this->performAction($recurring_invoice, $request->action, true);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Factory\SchedulerFactory;
|
||||
use App\Filters\SchedulerFilters;
|
||||
use App\Http\Requests\TaskScheduler\DestroySchedulerRequest;
|
||||
use App\Http\Requests\TaskScheduler\CreateSchedulerRequest;
|
||||
use App\Http\Requests\TaskScheduler\DestroySchedulerRequest;
|
||||
use App\Http\Requests\TaskScheduler\ShowSchedulerRequest;
|
||||
use App\Http\Requests\TaskScheduler\StoreSchedulerRequest;
|
||||
use App\Http\Requests\TaskScheduler\UpdateSchedulerRequest;
|
||||
|
@ -12,22 +12,22 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Webhook;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Factory\WebhookFactory;
|
||||
use App\Filters\WebhookFilters;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Http\Requests\Webhook\CreateWebhookRequest;
|
||||
use App\Http\Requests\Webhook\DestroyWebhookRequest;
|
||||
use App\Http\Requests\Webhook\EditWebhookRequest;
|
||||
use App\Http\Requests\Webhook\RetryWebhookRequest;
|
||||
use App\Http\Requests\Webhook\ShowWebhookRequest;
|
||||
use App\Http\Requests\Webhook\StoreWebhookRequest;
|
||||
use App\Http\Requests\Webhook\UpdateWebhookRequest;
|
||||
use App\Jobs\Util\WebhookSingle;
|
||||
use App\Models\Webhook;
|
||||
use App\Repositories\BaseRepository;
|
||||
use App\Transformers\WebhookTransformer;
|
||||
use App\Http\Requests\Webhook\EditWebhookRequest;
|
||||
use App\Http\Requests\Webhook\ShowWebhookRequest;
|
||||
use App\Http\Requests\Webhook\RetryWebhookRequest;
|
||||
use App\Http\Requests\Webhook\StoreWebhookRequest;
|
||||
use App\Http\Requests\Webhook\CreateWebhookRequest;
|
||||
use App\Http\Requests\Webhook\UpdateWebhookRequest;
|
||||
use App\Http\Requests\Webhook\DestroyWebhookRequest;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class WebhookController extends BaseController
|
||||
{
|
||||
@ -493,7 +493,7 @@ class WebhookController extends BaseController
|
||||
|
||||
public function retry(RetryWebhookRequest $request, Webhook $webhook)
|
||||
{
|
||||
match($request->entity) {
|
||||
match ($request->entity) {
|
||||
'invoice' => $includes ='client',
|
||||
'payment' => $includes ='invoices,client',
|
||||
'project' => $includes ='client',
|
||||
@ -506,7 +506,7 @@ class WebhookController extends BaseController
|
||||
|
||||
$entity = $class::withTrashed()->where('id', $this->decodePrimaryKey($request->entity_id))->company()->first();
|
||||
|
||||
if(!$entity){
|
||||
if (!$entity) {
|
||||
return response()->json(['message' => ctrans('texts.record_not_found')], 400);
|
||||
}
|
||||
|
||||
|
@ -11,54 +11,55 @@
|
||||
|
||||
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\CheckClientExistence;
|
||||
use App\Http\Middleware\CheckForMaintenanceMode;
|
||||
use App\Http\Middleware\ClientPortalEnabled;
|
||||
use App\Http\Middleware\ContactSetDb;
|
||||
use App\Http\Middleware\QueryLogging;
|
||||
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\EncryptCookies;
|
||||
use App\Http\Middleware\SessionDomains;
|
||||
use App\Http\Middleware\ContactKeyLogin;
|
||||
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\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\VerifyHash;
|
||||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
||||
use App\Http\Middleware\ContactTokenAuth;
|
||||
use Illuminate\Auth\Middleware\Authorize;
|
||||
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
||||
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
||||
use App\Http\Middleware\SetDbByCompanyKey;
|
||||
use App\Http\Middleware\PasswordProtection;
|
||||
use App\Http\Middleware\ClientPortalEnabled;
|
||||
use App\Http\Middleware\CheckClientExistence;
|
||||
use App\Http\Middleware\VendorContactKeyLogin;
|
||||
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 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\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
|
||||
{
|
||||
@ -75,9 +76,7 @@ class Kernel extends HttpKernel
|
||||
TrimStrings::class,
|
||||
ConvertEmptyStringsToNull::class,
|
||||
TrustProxies::class,
|
||||
// \Illuminate\Http\Middleware\HandleCors::class,
|
||||
Cors::class,
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
@ -140,7 +139,6 @@ class Kernel extends HttpKernel
|
||||
'cors' => Cors::class,
|
||||
'guest' => RedirectIfAuthenticated::class,
|
||||
'signed' => ValidateSignature::class,
|
||||
'throttle' => ThrottleRequests::class,
|
||||
'verified' => EnsureEmailIsVerified::class,
|
||||
'query_logging' => QueryLogging::class,
|
||||
'token_auth' => TokenAuth::class,
|
||||
@ -152,7 +150,6 @@ class Kernel extends HttpKernel
|
||||
'email_db' => SetEmailDb::class,
|
||||
'invite_db' => SetInviteDb::class,
|
||||
'password_protected' => PasswordProtection::class,
|
||||
'signed' => ValidateSignature::class,
|
||||
'portal_enabled' => ClientPortalEnabled::class,
|
||||
'url_db' => UrlSetDb::class,
|
||||
'web_db' => SetWebDb::class,
|
||||
@ -162,7 +159,6 @@ class Kernel extends HttpKernel
|
||||
'vendor_locale' => VendorLocale::class,
|
||||
'contact_register' => ContactRegister::class,
|
||||
'verify_hash' => VerifyHash::class,
|
||||
'shop_token_auth' => ShopTokenAuth::class,
|
||||
'phantom_secret' => PhantomSecret::class,
|
||||
'contact_key_login' => ContactKeyLogin::class,
|
||||
'vendor_contact_key_login' => VendorContactKeyLogin::class,
|
||||
@ -170,6 +166,7 @@ class Kernel extends HttpKernel
|
||||
'user_verified' => UserVerified::class,
|
||||
'document_db' => SetDocumentDb::class,
|
||||
'session_domain' => SessionDomains::class,
|
||||
//we dyanamically add the throttle middleware in RouteServiceProvider
|
||||
];
|
||||
|
||||
protected $middlewarePriority = [
|
||||
@ -189,7 +186,6 @@ class Kernel extends HttpKernel
|
||||
ContactTokenAuth::class,
|
||||
ContactKeyLogin::class,
|
||||
Authenticate::class,
|
||||
ShopTokenAuth::class,
|
||||
ContactRegister::class,
|
||||
PhantomSecret::class,
|
||||
CheckClientExistence::class,
|
||||
@ -199,4 +195,5 @@ class Kernel extends HttpKernel
|
||||
SubstituteBindings::class,
|
||||
ContactAccount::class,
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -11,24 +11,24 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
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\DataMapper\ClientSettings;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\DataMapper\ClientSettings;
|
||||
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\Cache;
|
||||
use App\Mail\ContactPasswordlessLogin;
|
||||
use App\Repositories\ClientRepository;
|
||||
use App\Repositories\ClientContactRepository;
|
||||
use App\Services\Subscription\SubscriptionService;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
|
||||
class BillingPortalPurchase extends Component
|
||||
{
|
||||
@ -401,7 +401,7 @@ class BillingPortalPurchase extends Component
|
||||
$context = 'purchase';
|
||||
|
||||
// if(Ninja::isHosted() && $this->subscription->service()->recurring_products()->first()?->id == SubscriptionService::WHITE_LABEL) {
|
||||
if(Ninja::isHosted() && $this->subscription->service()->recurring_products()->first()?->product_key == 'whitelabel') {
|
||||
if (Ninja::isHosted() && $this->subscription->service()->recurring_products()->first()?->product_key == 'whitelabel') {
|
||||
$context = 'whitelabel';
|
||||
}
|
||||
|
||||
|
@ -172,8 +172,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
$this->contact = auth()->guard('contact')->user();
|
||||
$this->authenticated = true;
|
||||
$this->payment_started = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->bundle = collect();
|
||||
}
|
||||
|
||||
@ -276,7 +275,6 @@ class BillingPortalPurchasev2 extends Component
|
||||
*/
|
||||
public function handleCoupon()
|
||||
{
|
||||
|
||||
$this->resetErrorBag('coupon');
|
||||
$this->resetValidation('coupon');
|
||||
|
||||
@ -311,7 +309,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
'description' => $p->notes,
|
||||
'product_key' => $p->product_key,
|
||||
'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),
|
||||
'total' => $total,
|
||||
'qty' => $qty,
|
||||
@ -329,7 +327,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
'description' => $p->notes,
|
||||
'product_key' => $p->product_key,
|
||||
'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),
|
||||
'total' => $total,
|
||||
'qty' => $qty,
|
||||
@ -352,7 +350,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
'description' => $p->notes,
|
||||
'product_key' => $p->product_key,
|
||||
'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),
|
||||
'total' => $total,
|
||||
'qty' => $qty,
|
||||
@ -375,7 +373,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
'description' => $p->notes,
|
||||
'product_key' => $p->product_key,
|
||||
'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),
|
||||
'total' => $total,
|
||||
'qty' => $qty,
|
||||
|
@ -232,8 +232,9 @@ class RequiredClientInfo extends Component
|
||||
if ($cg && $cg->update_details) {
|
||||
$payment_gateway = $cg->driver($this->client)->init();
|
||||
|
||||
if(method_exists($payment_gateway, "updateCustomer"))
|
||||
if (method_exists($payment_gateway, "updateCustomer")) {
|
||||
$payment_gateway->updateCustomer();
|
||||
}
|
||||
}
|
||||
|
||||
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 = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadBankTransactionRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -38,10 +38,11 @@ class StoreClientRequest extends Request
|
||||
|
||||
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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$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*/
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadClientRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -15,7 +15,6 @@ class StorePrePaymentRequest extends FormRequest
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,5 +29,4 @@ class StorePrePaymentRequest extends FormRequest
|
||||
'amount' => 'required|bail|',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,10 +29,11 @@ class UploadCompanyRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -43,10 +43,11 @@ class StoreCreditRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -42,10 +42,11 @@ class UpdateCreditRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadCreditRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadExpenseRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadGroupSettingRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -37,10 +37,11 @@ class StoreInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -39,10 +39,11 @@ class UpdateInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
@ -45,6 +46,5 @@ class UploadInvoiceRequest extends Request
|
||||
|
||||
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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$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);
|
||||
}
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadPaymentRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -12,10 +12,6 @@
|
||||
namespace App\Http\Requests\Preview;
|
||||
|
||||
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\MakesHash;
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace App\Http\Requests\Preview;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
|
@ -28,10 +28,11 @@ class StoreProductRequest extends Request
|
||||
|
||||
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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace App\Http\Requests\Product;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Product;
|
||||
use App\Utils\Traits\ChecksEntityStatus;
|
||||
|
||||
class UpdateProductRequest extends Request
|
||||
@ -31,10 +30,11 @@ class UpdateProductRequest extends Request
|
||||
|
||||
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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -28,10 +28,11 @@ class UploadProductRequest extends Request
|
||||
public function 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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace App\Http\Requests\Project;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Project;
|
||||
|
||||
class CreateProjectRequest extends Request
|
||||
{
|
||||
@ -24,6 +24,5 @@ class CreateProjectRequest extends Request
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->can('create', Project::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ class ShowProjectRequest extends Request
|
||||
{
|
||||
// return auth()->user()->isAdmin();
|
||||
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);
|
||||
}
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$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);
|
||||
}
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadProjectRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -47,10 +47,11 @@ class StorePurchaseOrderRequest extends Request
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
$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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -50,10 +50,11 @@ class UpdatePurchaseOrderRequest extends Request
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
$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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadPurchaseOrderRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$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;
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -37,10 +37,11 @@ class UpdateQuoteRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadQuoteRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -48,10 +48,11 @@ class StoreRecurringExpenseRequest extends Request
|
||||
$rules['tax_amount2'] = '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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -48,10 +48,11 @@ class UpdateRecurringExpenseRequest extends Request
|
||||
$rules['tax_amount3'] = 'numeric';
|
||||
$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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadRecurringExpenseRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -38,10 +38,11 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -38,10 +38,11 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadRecurringInvoiceRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -37,10 +37,11 @@ class StoreRecurringQuoteRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -37,10 +37,11 @@ class UpdateRecurringQuoteRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadRecurringQuoteRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -58,6 +58,5 @@ class GenericReportRequest extends Request
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +59,11 @@ class StoreTaskRequest 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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -66,10 +66,11 @@ class UpdateTaskRequest 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;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -43,6 +43,8 @@ class StoreSchedulerRequest extends Request
|
||||
'parameters.date_range' => 'bail|sometimes|string|in:last7_days,last30_days,last365_days,this_month,last_month,this_quarter,last_quarter,this_year,last_year,custom',
|
||||
'parameters.start_date' => ['bail', 'sometimes', 'date:Y-m-d', 'required_if:parameters.date_rate,custom'],
|
||||
'parameters.end_date' => ['bail', 'sometimes', 'date:Y-m-d', 'required_if:parameters.date_rate,custom', 'after_or_equal:parameters.start_date'],
|
||||
'parameters.entity' => ['bail', 'sometimes', 'string', 'in:invoice,credit,quote,purchase_order'],
|
||||
'parameters.entity_id' => ['bail', 'sometimes', 'string'],
|
||||
];
|
||||
|
||||
return $rules;
|
||||
|
@ -12,11 +12,9 @@
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class DetachCompanyUserRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -41,10 +41,11 @@ class StoreVendorRequest extends Request
|
||||
|
||||
$rules['currency_id'] = 'bail|required|exists:currencies,id';
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
@ -57,7 +58,6 @@ class StoreVendorRequest extends Request
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
if (!array_key_exists('currency_id', $input) || empty($input['currency_id'])) {
|
||||
|
@ -44,10 +44,11 @@ class UpdateVendorRequest extends Request
|
||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
||||
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -29,10 +29,11 @@ class UploadVendorRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if($this->file('documents') && is_array($this->file('documents')))
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->file_validation;
|
||||
elseif($this->file('documents'))
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->file_validation;
|
||||
}
|
||||
|
||||
if ($this->file('file') && is_array($this->file('file'))) {
|
||||
$rules['file.*'] = $this->file_validation;
|
||||
|
@ -84,17 +84,15 @@ class PaymentAppliedValidAmount implements Rule
|
||||
|
||||
$inv = $inv_collection->firstWhere('id', $invoice['invoice_id']);
|
||||
|
||||
if($inv->balance < $invoice['amount']) {
|
||||
|
||||
if ($inv->balance < $invoice['amount']) {
|
||||
$this->message = 'Amount cannot be greater than invoice balance';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(round($payment_amounts, 3) >= round($invoice_amounts, 3)) {
|
||||
if (round($payment_amounts, 3) >= round($invoice_amounts, 3)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class PortalComposer
|
||||
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
|
||||
}
|
||||
|
||||
// if(property_exists($this->settings, 'client_initiated_payments') && $this->settings->client_initiated_payments) {
|
||||
// if (property_exists($this->settings, 'client_initiated_payments') && $this->settings->client_initiated_payments) {
|
||||
$data[] = ['title' => ctrans('texts.pre_payment'), 'url' => 'client.pre_payments.index', 'icon' => 'dollar-sign'];
|
||||
// }
|
||||
|
||||
|
@ -130,12 +130,10 @@ class BaseImport
|
||||
// $count = substr_count($csvfile, $delimiter);
|
||||
// $bestDelimiter = $delimiter;
|
||||
// }
|
||||
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
|
||||
if (substr_count(strstr($csvfile, "\n", true), $delimiter) > $count) {
|
||||
$count = substr_count($csvfile, $delimiter);
|
||||
$bestDelimiter = $delimiter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $bestDelimiter;
|
||||
}
|
||||
@ -641,8 +639,6 @@ class BaseImport
|
||||
|
||||
public function preTransform(array $data, $entity_type)
|
||||
{
|
||||
|
||||
|
||||
$keys = array_shift($data);
|
||||
ksort($keys);
|
||||
|
||||
@ -666,11 +662,10 @@ class BaseImport
|
||||
ksort($keys);
|
||||
|
||||
$data = array_map(function ($row) use ($keys) {
|
||||
|
||||
$row_count = count($row);
|
||||
$key_count = count($keys);
|
||||
|
||||
if($key_count > $row_count) {
|
||||
if ($key_count > $row_count) {
|
||||
$row = array_pad($row, $key_count, ' ');
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,8 @@ class CreateAccount
|
||||
|
||||
NinjaMailerJob::dispatch($nmo, true);
|
||||
|
||||
// \Modules\Admin\Jobs\Account\NinjaUser::dispatch([], $sp035a66);
|
||||
|
||||
(new \Modules\Admin\Jobs\Account\NinjaUser([], $sp035a66))->handle();
|
||||
}
|
||||
|
||||
|
@ -68,39 +68,23 @@ class AdjustProductInventory implements ShouldQueue
|
||||
// $p->saveQuietly();
|
||||
// }
|
||||
|
||||
collect($this->invoice->line_items)->filter(function ($item){
|
||||
collect($this->invoice->line_items)->filter(function ($item) {
|
||||
return $item->type_id == '1';
|
||||
})->each(function ($i){
|
||||
|
||||
})->each(function ($i) {
|
||||
$p = Product::where('product_key', $i->product_key)->where('company_id', $this->company->id)->first();
|
||||
|
||||
if ($p) {
|
||||
|
||||
$p->in_stock_quantity += $i->quantity;
|
||||
|
||||
$p->saveQuietly();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function handleRestoredInvoice()
|
||||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
// foreach ($this->invoice->line_items as $item) {
|
||||
// $p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
|
||||
|
||||
// if (! $p) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// $p->in_stock_quantity -= $item->quantity;
|
||||
// $p->saveQuietly();
|
||||
// }
|
||||
|
||||
collect($this->invoice->line_items)->filter(function ($item) {
|
||||
return $item->type_id == '1';
|
||||
})->each(function ($i) {
|
||||
@ -112,8 +96,6 @@ class AdjustProductInventory implements ShouldQueue
|
||||
$p->saveQuietly();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
@ -123,24 +105,6 @@ class AdjustProductInventory implements ShouldQueue
|
||||
|
||||
private function newInventoryAdjustment()
|
||||
{
|
||||
// $line_items = $this->invoice->line_items;
|
||||
|
||||
// foreach ($line_items as $item) {
|
||||
// $p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->where('in_stock_quantity', '>', 0)->first();
|
||||
|
||||
// if (! $p) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// $p->in_stock_quantity -= $item->quantity;
|
||||
// $p->saveQuietly();
|
||||
|
||||
// if ($this->company->stock_notification && $p->stock_notification && $p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) {
|
||||
// $this->notifyStockLevels($p, 'product');
|
||||
// } elseif ($this->company->stock_notification && $p->stock_notification && $this->company->inventory_notification_threshold && $p->in_stock_quantity <= $this->company->inventory_notification_threshold) {
|
||||
// $this->notifyStocklevels($p, 'company');
|
||||
// }
|
||||
// }
|
||||
|
||||
collect($this->invoice->line_items)->filter(function ($item) {
|
||||
return $item->type_id == '1';
|
||||
@ -151,33 +115,22 @@ class AdjustProductInventory implements ShouldQueue
|
||||
$p->in_stock_quantity -= $i->quantity;
|
||||
|
||||
$p->saveQuietly();
|
||||
nlog($p->stock_notification_threshold);
|
||||
nlog($p->in_stock_quantity);
|
||||
nlog($p->stock_notification_threshold);
|
||||
|
||||
if ($this->company->stock_notification && $p->stock_notification && $p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) {
|
||||
$this->notifyStockLevels($p, 'product');
|
||||
} elseif ($this->company->stock_notification && $p->stock_notification && $this->company->inventory_notification_threshold && $p->in_stock_quantity <= $this->company->inventory_notification_threshold) {
|
||||
$this->notifyStocklevels($p, 'company');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function existingInventoryAdjustment()
|
||||
{
|
||||
// foreach ($this->old_invoice as $item) {
|
||||
// $p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
|
||||
|
||||
// if (! $p) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// $p->in_stock_quantity += $item->quantity;
|
||||
// $p->saveQuietly();
|
||||
// }
|
||||
|
||||
|
||||
collect($this->invoice->line_items)->filter(function ($item) {
|
||||
return $item->type_id == '1';
|
||||
})->each(function ($i) {
|
||||
@ -189,8 +142,6 @@ class AdjustProductInventory implements ShouldQueue
|
||||
$p->saveQuietly();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function notifyStocklevels(Product $product, string $notification_level)
|
||||
@ -201,7 +152,7 @@ class AdjustProductInventory implements ShouldQueue
|
||||
$nmo->settings = $this->company->settings;
|
||||
|
||||
$this->company->company_users->each(function ($cu) use ($product, $nmo) {
|
||||
if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user'])) {
|
||||
if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user'])) {
|
||||
$nmo->to_user = $cu->user;
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
}
|
||||
|
@ -584,8 +584,9 @@ class NinjaMailerJob implements ShouldQueue
|
||||
$guzzle = new \GuzzleHttp\Client();
|
||||
$url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
|
||||
|
||||
if(!$user->oauth_user_refresh_token || $user->oauth_user_refresh_token == '')
|
||||
if (!$user->oauth_user_refresh_token || $user->oauth_user_refresh_token == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$token = json_decode($guzzle->post($url, [
|
||||
'form_params' => [
|
||||
|
@ -21,8 +21,9 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Turbo124\Beacon\Facades\LightLogs;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Turbo124\Beacon\Facades\LightLogs;
|
||||
|
||||
class AdjustEmailQuota implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
@ -78,14 +79,11 @@ class AdjustEmailQuota implements ShouldQueue
|
||||
|
||||
$keys = $redis->keys($prefix);
|
||||
|
||||
if(is_array($keys))
|
||||
{
|
||||
if (is_array($keys)) {
|
||||
$redis->pipeline(function ($pipe) use ($keys) {
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$pipe->del($key);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
$keys = null;
|
||||
@ -101,7 +99,5 @@ class AdjustEmailQuota implements ShouldQueue
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,6 @@ class SendReminders implements ShouldQueue
|
||||
|
||||
EmailEntity::dispatch($invitation, $invitation->company, $template)->delay(10);
|
||||
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $template));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -73,8 +73,9 @@ class EmailPayment implements ShouldQueue
|
||||
|
||||
$this->payment->load('invoices');
|
||||
|
||||
if(!$this->contact)
|
||||
if (!$this->contact) {
|
||||
$this->contact = $this->payment->client->contacts()->first();
|
||||
}
|
||||
|
||||
$this->contact->load('client');
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user