mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 20:54:33 -04:00
Fixes for tests (#3184)
* fix typo * php-cs traits * CS fixer pass * Password protect User routes * Implement checks to prevent editing a deleted record * Clean up payment flows * Fixes for tests
This commit is contained in:
parent
167b503fa1
commit
f712b789ca
@ -51,8 +51,6 @@ class CreateTestData extends Command
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->invoice_repo = $invoice_repo;
|
$this->invoice_repo = $invoice_repo;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,13 +70,11 @@ class CreateTestData extends Command
|
|||||||
$this->createSmallAccount();
|
$this->createSmallAccount();
|
||||||
$this->createMediumAccount();
|
$this->createMediumAccount();
|
||||||
$this->createLargeAccount();
|
$this->createLargeAccount();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function createSmallAccount()
|
private function createSmallAccount()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->info('Creating Small Account and Company');
|
$this->info('Creating Small Account and Company');
|
||||||
|
|
||||||
$account = factory(\App\Models\Account::class)->create();
|
$account = factory(\App\Models\Account::class)->create();
|
||||||
@ -91,8 +87,7 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
$user = User::whereEmail('small@example.com')->first();
|
$user = User::whereEmail('small@example.com')->first();
|
||||||
|
|
||||||
if(!$user)
|
if (!$user) {
|
||||||
{
|
|
||||||
$user = factory(\App\Models\User::class)->create([
|
$user = factory(\App\Models\User::class)->create([
|
||||||
// 'account_id' => $account->id,
|
// 'account_id' => $account->id,
|
||||||
'email' => 'small@example.com',
|
'email' => 'small@example.com',
|
||||||
@ -123,13 +118,12 @@ class CreateTestData extends Command
|
|||||||
$this->info('Creating '.$this->count. ' clients');
|
$this->info('Creating '.$this->count. ' clients');
|
||||||
|
|
||||||
|
|
||||||
for($x=0; $x<$this->count; $x++) {
|
for ($x=0; $x<$this->count; $x++) {
|
||||||
$z = $x+1;
|
$z = $x+1;
|
||||||
$this->info("Creating client # ".$z);
|
$this->info("Creating client # ".$z);
|
||||||
|
|
||||||
$this->createClient($company, $user);
|
$this->createClient($company, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createMediumAccount()
|
private function createMediumAccount()
|
||||||
@ -146,8 +140,7 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
$user = User::whereEmail('medium@example.com')->first();
|
$user = User::whereEmail('medium@example.com')->first();
|
||||||
|
|
||||||
if(!$user)
|
if (!$user) {
|
||||||
{
|
|
||||||
$user = factory(\App\Models\User::class)->create([
|
$user = factory(\App\Models\User::class)->create([
|
||||||
// 'account_id' => $account->id,
|
// 'account_id' => $account->id,
|
||||||
'email' => 'medium@example.com',
|
'email' => 'medium@example.com',
|
||||||
@ -179,18 +172,17 @@ class CreateTestData extends Command
|
|||||||
$this->info('Creating '.$this->count. ' clients');
|
$this->info('Creating '.$this->count. ' clients');
|
||||||
|
|
||||||
|
|
||||||
for($x=0; $x<$this->count; $x++) {
|
for ($x=0; $x<$this->count; $x++) {
|
||||||
$z = $x+1;
|
$z = $x+1;
|
||||||
$this->info("Creating client # ".$z);
|
$this->info("Creating client # ".$z);
|
||||||
|
|
||||||
$this->createClient($company, $user);
|
$this->createClient($company, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createLargeAccount()
|
private function createLargeAccount()
|
||||||
{
|
{
|
||||||
$this->info('Creating Large Account and Company');
|
$this->info('Creating Large Account and Company');
|
||||||
|
|
||||||
$account = factory(\App\Models\Account::class)->create();
|
$account = factory(\App\Models\Account::class)->create();
|
||||||
$company = factory(\App\Models\Company::class)->create([
|
$company = factory(\App\Models\Company::class)->create([
|
||||||
@ -202,8 +194,7 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
$user = User::whereEmail('large@example.com')->first();
|
$user = User::whereEmail('large@example.com')->first();
|
||||||
|
|
||||||
if(!$user)
|
if (!$user) {
|
||||||
{
|
|
||||||
$user = factory(\App\Models\User::class)->create([
|
$user = factory(\App\Models\User::class)->create([
|
||||||
// 'account_id' => $account->id,
|
// 'account_id' => $account->id,
|
||||||
'email' => 'large@example.com',
|
'email' => 'large@example.com',
|
||||||
@ -235,13 +226,12 @@ class CreateTestData extends Command
|
|||||||
$this->info('Creating '.$this->count. ' clients');
|
$this->info('Creating '.$this->count. ' clients');
|
||||||
|
|
||||||
|
|
||||||
for($x=0; $x<$this->count; $x++) {
|
for ($x=0; $x<$this->count; $x++) {
|
||||||
$z = $x+1;
|
$z = $x+1;
|
||||||
$this->info("Creating client # ".$z);
|
$this->info("Creating client # ".$z);
|
||||||
|
|
||||||
$this->createClient($company, $user);
|
$this->createClient($company, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createClient($company, $user)
|
private function createClient($company, $user)
|
||||||
@ -252,25 +242,24 @@ class CreateTestData extends Command
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
factory(\App\Models\ClientContact::class,1)->create([
|
factory(\App\Models\ClientContact::class, 1)->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'is_primary' => 1
|
'is_primary' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
factory(\App\Models\ClientContact::class,rand(1,5))->create([
|
factory(\App\Models\ClientContact::class, rand(1, 5))->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $company->id
|
'company_id' => $company->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$y = $this->count * rand(1,5);
|
$y = $this->count * rand(1, 5);
|
||||||
|
|
||||||
$this->info("Creating {$y} invoices & quotes");
|
$this->info("Creating {$y} invoices & quotes");
|
||||||
|
|
||||||
for($x=0; $x<$y; $x++){
|
for ($x=0; $x<$y; $x++) {
|
||||||
|
|
||||||
$this->createInvoice($client);
|
$this->createInvoice($client);
|
||||||
$this->createQuote($client);
|
$this->createQuote($client);
|
||||||
}
|
}
|
||||||
@ -280,27 +269,24 @@ class CreateTestData extends Command
|
|||||||
{
|
{
|
||||||
$faker = \Faker\Factory::create();
|
$faker = \Faker\Factory::create();
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create($client->company->id,$client->user->id);//stub the company and user_id
|
$invoice = InvoiceFactory::create($client->company->id, $client->user->id);//stub the company and user_id
|
||||||
$invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$invoice->date = $faker->date();
|
$invoice->date = $faker->date();
|
||||||
|
|
||||||
$invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$invoice->tax_name1 = 'GST';
|
$invoice->tax_name1 = 'GST';
|
||||||
$invoice->tax_rate1 = 10.00;
|
$invoice->tax_rate1 = 10.00;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$invoice->tax_name2 = 'VAT';
|
$invoice->tax_name2 = 'VAT';
|
||||||
$invoice->tax_rate2 = 17.50;
|
$invoice->tax_rate2 = 17.50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$invoice->tax_name3 = 'CA Sales Tax';
|
$invoice->tax_name3 = 'CA Sales Tax';
|
||||||
$invoice->tax_rate3 = 5;
|
$invoice->tax_rate3 = 5;
|
||||||
}
|
}
|
||||||
@ -314,31 +300,30 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
event(new CreateInvoiceInvitation($invoice));
|
event(new CreateInvoiceInvitation($invoice));
|
||||||
|
|
||||||
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);
|
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);
|
||||||
|
|
||||||
$this->invoice_repo->markSent($invoice);
|
$this->invoice_repo->markSent($invoice);
|
||||||
|
|
||||||
CreateInvoiceInvitations::dispatch($invoice, $invoice->company);
|
CreateInvoiceInvitations::dispatch($invoice, $invoice->company);
|
||||||
|
|
||||||
if(rand(0, 1)) {
|
if (rand(0, 1)) {
|
||||||
|
$payment = PaymentFactory::create($client->company->id, $client->user->id);
|
||||||
|
$payment->date = now();
|
||||||
|
$payment->client_id = $client->id;
|
||||||
|
$payment->amount = $invoice->balance;
|
||||||
|
$payment->transaction_reference = rand(0, 500);
|
||||||
|
$payment->type_id = PaymentType::CREDIT_CARD_OTHER;
|
||||||
|
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||||
|
$payment->save();
|
||||||
|
|
||||||
$payment = PaymentFactory::create($client->company->id, $client->user->id);
|
$payment->invoices()->save($invoice);
|
||||||
$payment->date = now();
|
|
||||||
$payment->client_id = $client->id;
|
|
||||||
$payment->amount = $invoice->balance;
|
|
||||||
$payment->transaction_reference = rand(0,500);
|
|
||||||
$payment->type_id = PaymentType::CREDIT_CARD_OTHER;
|
|
||||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
|
||||||
$payment->save();
|
|
||||||
|
|
||||||
$payment->invoices()->save($invoice);
|
event(new PaymentWasCreated($payment, $payment->company));
|
||||||
|
|
||||||
event(new PaymentWasCreated($payment, $payment->company));
|
UpdateInvoicePayment::dispatchNow($payment, $payment->company);
|
||||||
|
}
|
||||||
UpdateInvoicePayment::dispatchNow($payment, $payment->company);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -346,27 +331,24 @@ class CreateTestData extends Command
|
|||||||
{
|
{
|
||||||
$faker = \Faker\Factory::create();
|
$faker = \Faker\Factory::create();
|
||||||
|
|
||||||
$quote = QuoteFactory::create($client->company->id,$client->user->id);//stub the company and user_id
|
$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id
|
||||||
$quote->client_id = $client->id;
|
$quote->client_id = $client->id;
|
||||||
$quote->date = $faker->date();
|
$quote->date = $faker->date();
|
||||||
|
|
||||||
$quote->line_items = $this->buildLineItems();
|
$quote->line_items = $this->buildLineItems();
|
||||||
$quote->uses_inclusive_taxes = false;
|
$quote->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$quote->tax_name1 = 'GST';
|
$quote->tax_name1 = 'GST';
|
||||||
$quote->tax_rate1 = 10.00;
|
$quote->tax_rate1 = 10.00;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$quote->tax_name2 = 'VAT';
|
$quote->tax_name2 = 'VAT';
|
||||||
$quote->tax_rate2 = 17.50;
|
$quote->tax_rate2 = 17.50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0,1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$quote->tax_name3 = 'CA Sales Tax';
|
$quote->tax_name3 = 'CA Sales Tax';
|
||||||
$quote->tax_rate3 = 5;
|
$quote->tax_rate3 = 5;
|
||||||
}
|
}
|
||||||
@ -380,9 +362,7 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
$quote->save();
|
$quote->save();
|
||||||
|
|
||||||
CreateQuoteInvitations::dispatch($quote, $quote->company);
|
CreateQuoteInvitations::dispatch($quote, $quote->company);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildLineItems()
|
private function buildLineItems()
|
||||||
@ -393,20 +373,17 @@ class CreateTestData extends Command
|
|||||||
$item->quantity = 1;
|
$item->quantity = 1;
|
||||||
$item->cost =10;
|
$item->cost =10;
|
||||||
|
|
||||||
if(rand(0, 1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$item->tax_name1 = 'GST';
|
$item->tax_name1 = 'GST';
|
||||||
$item->tax_rate1 = 10.00;
|
$item->tax_rate1 = 10.00;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0, 1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$item->tax_name1 = 'VAT';
|
$item->tax_name1 = 'VAT';
|
||||||
$item->tax_rate1 = 17.50;
|
$item->tax_rate1 = 17.50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand(0, 1))
|
if (rand(0, 1)) {
|
||||||
{
|
|
||||||
$item->tax_name1 = 'Sales Tax';
|
$item->tax_name1 = 'Sales Tax';
|
||||||
$item->tax_rate1 = 5;
|
$item->tax_rate1 = 5;
|
||||||
}
|
}
|
||||||
@ -414,12 +391,11 @@ class CreateTestData extends Command
|
|||||||
$line_items[] = $item;
|
$line_items[] = $item;
|
||||||
|
|
||||||
return $line_items;
|
return $line_items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function warmCache()
|
private function warmCache()
|
||||||
{
|
{
|
||||||
/* Warm up the cache !*/
|
/* Warm up the cache !*/
|
||||||
$cached_tables = config('ninja.cached_tables');
|
$cached_tables = config('ninja.cached_tables');
|
||||||
|
|
||||||
foreach ($cached_tables as $name => $class) {
|
foreach ($cached_tables as $name => $class) {
|
||||||
|
@ -64,7 +64,7 @@ class SendTestEmails extends Command
|
|||||||
$user = User::whereEmail('user@example.com')->first();
|
$user = User::whereEmail('user@example.com')->first();
|
||||||
$client = Client::all()->first();
|
$client = Client::all()->first();
|
||||||
|
|
||||||
if(!$user){
|
if (!$user) {
|
||||||
$user = factory(\App\Models\User::class)->create([
|
$user = factory(\App\Models\User::class)->create([
|
||||||
'confirmation_code' => '123',
|
'confirmation_code' => '123',
|
||||||
'email' => 'admin@business.com',
|
'email' => 'admin@business.com',
|
||||||
@ -73,12 +73,11 @@ class SendTestEmails extends Command
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$client) {
|
if (!$client) {
|
||||||
|
$client = ClientFactory::create($user->company()->id, $user->id);
|
||||||
$client = ClientFactory::create($user->company()->id, $user->id);
|
$client->save();
|
||||||
$client->save();
|
|
||||||
|
|
||||||
factory(\App\Models\ClientContact::class,1)->create([
|
factory(\App\Models\ClientContact::class, 1)->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
@ -87,7 +86,7 @@ class SendTestEmails extends Command
|
|||||||
'email' => 'exy@example.com',
|
'email' => 'exy@example.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
factory(\App\Models\ClientContact::class,1)->create([
|
factory(\App\Models\ClientContact::class, 1)->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
@ -96,14 +95,13 @@ class SendTestEmails extends Command
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cc_emails = [config('ninja.testvars.test_email')];
|
$cc_emails = [config('ninja.testvars.test_email')];
|
||||||
$bcc_emails = [config('ninja.testvars.test_email')];
|
$bcc_emails = [config('ninja.testvars.test_email')];
|
||||||
|
|
||||||
Mail::to(config('ninja.testvars.test_email'),'Mr Test')
|
Mail::to(config('ninja.testvars.test_email'), 'Mr Test')
|
||||||
->cc($cc_emails)
|
->cc($cc_emails)
|
||||||
->bcc($bcc_emails)
|
->bcc($bcc_emails)
|
||||||
//->replyTo(also_available_if_needed)
|
//->replyTo(also_available_if_needed)
|
||||||
->send(new TemplateEmail($message, $template, $user, $client));
|
->send(new TemplateEmail($message, $template, $user, $client));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,6 @@ class Kernel extends ConsoleKernel
|
|||||||
// ->hourly();
|
// ->hourly();
|
||||||
|
|
||||||
$schedule->job(new RecurringInvoicesCron)->hourly();
|
$schedule->job(new RecurringInvoicesCron)->hourly();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,50 +16,48 @@ namespace App\DataMapper;
|
|||||||
*/
|
*/
|
||||||
class BaseSettings
|
class BaseSettings
|
||||||
{
|
{
|
||||||
|
public function __construct($obj)
|
||||||
|
{
|
||||||
|
foreach ($obj as $key => $value) {
|
||||||
|
$obj->{$key} = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setCasts($obj, $casts)
|
||||||
|
{
|
||||||
|
foreach ($casts as $key => $value) {
|
||||||
|
$obj->{$key} = self::castAttribute($key, $obj->{$key});
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct($obj)
|
return $obj;
|
||||||
{
|
}
|
||||||
foreach($obj as $key => $value)
|
|
||||||
$obj->{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setCasts($obj, $casts)
|
|
||||||
{
|
|
||||||
foreach ($casts as $key => $value)
|
|
||||||
$obj->{$key} = self::castAttribute($key, $obj->{$key});
|
|
||||||
|
|
||||||
return $obj;
|
public static function castAttribute($key, $value)
|
||||||
}
|
{
|
||||||
|
switch ($key) {
|
||||||
|
case 'int':
|
||||||
|
case 'integer':
|
||||||
|
return (int) $value;
|
||||||
|
case 'real':
|
||||||
|
case 'float':
|
||||||
|
case 'double':
|
||||||
|
return (float) $value;
|
||||||
|
case 'string':
|
||||||
|
return is_null($value) ? '' : (string) $value;
|
||||||
|
case 'bool':
|
||||||
|
case 'boolean':
|
||||||
|
return (bool)($value);
|
||||||
|
case 'object':
|
||||||
|
return json_decode($value);
|
||||||
|
case 'array':
|
||||||
|
case 'json':
|
||||||
|
return json_decode($value, true);
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function castAttribute($key, $value)
|
public static function castSingleAttribute($key, $data)
|
||||||
{
|
{
|
||||||
switch ($key)
|
}
|
||||||
{
|
}
|
||||||
case 'int':
|
|
||||||
case 'integer':
|
|
||||||
return (int) $value;
|
|
||||||
case 'real':
|
|
||||||
case 'float':
|
|
||||||
case 'double':
|
|
||||||
return (float) $value;
|
|
||||||
case 'string':
|
|
||||||
return is_null($value) ? '' : (string) $value;
|
|
||||||
case 'bool':
|
|
||||||
case 'boolean':
|
|
||||||
return (bool)($value);
|
|
||||||
case 'object':
|
|
||||||
return json_decode($value);
|
|
||||||
case 'array':
|
|
||||||
case 'json':
|
|
||||||
return json_decode($value, true);
|
|
||||||
default:
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function castSingleAttribute($key, $data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -20,88 +20,82 @@ use App\Utils\TranslationHelper;
|
|||||||
* ClientSettings
|
* ClientSettings
|
||||||
*
|
*
|
||||||
* Client settings are built as a superset of Company Settings
|
* Client settings are built as a superset of Company Settings
|
||||||
*
|
*
|
||||||
* If no client settings is specified, the default company setting is used.
|
* If no client settings is specified, the default company setting is used.
|
||||||
*
|
*
|
||||||
* Client settings are passed down to the entity level where they can be further customized and then saved
|
* Client settings are passed down to the entity level where they can be further customized and then saved
|
||||||
* into the settings column of the entity, so there is no need to create additional entity level settings handlers.
|
* into the settings column of the entity, so there is no need to create additional entity level settings handlers.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ClientSettings extends BaseSettings
|
class ClientSettings extends BaseSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings which which are unique to client settings
|
* Settings which which are unique to client settings
|
||||||
*/
|
|
||||||
public $industry_id;
|
|
||||||
public $size_id;
|
|
||||||
|
|
||||||
public static $casts = [
|
|
||||||
'industry_id' => 'string',
|
|
||||||
'size_id' => 'string',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast object values and return entire class
|
|
||||||
* prevents missing properties from not being returned
|
|
||||||
* and always ensure an up to date class is returned
|
|
||||||
*
|
|
||||||
* @return \stdClass
|
|
||||||
*/
|
*/
|
||||||
public function __construct($obj)
|
public $industry_id;
|
||||||
{
|
public $size_id;
|
||||||
parent::__construct($obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public static $casts = [
|
||||||
*
|
'industry_id' => 'string',
|
||||||
* Default Client Settings scaffold
|
'size_id' => 'string',
|
||||||
*
|
];
|
||||||
* @return \stdClass
|
|
||||||
*
|
/**
|
||||||
|
* Cast object values and return entire class
|
||||||
|
* prevents missing properties from not being returned
|
||||||
|
* and always ensure an up to date class is returned
|
||||||
|
*
|
||||||
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public static function defaults() : \stdClass
|
public function __construct($obj)
|
||||||
{
|
{
|
||||||
|
parent::__construct($obj);
|
||||||
|
}
|
||||||
|
|
||||||
$data = (object)[
|
/**
|
||||||
'entity' => (string)Client::class,
|
*
|
||||||
'industry_id' => '',
|
* Default Client Settings scaffold
|
||||||
'size_id' => '',
|
*
|
||||||
];
|
* @return \stdClass
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function defaults() : \stdClass
|
||||||
|
{
|
||||||
|
$data = (object)[
|
||||||
|
'entity' => (string)Client::class,
|
||||||
|
'industry_id' => '',
|
||||||
|
'size_id' => '',
|
||||||
|
];
|
||||||
|
|
||||||
return self::setCasts($data, self::$casts);
|
return self::setCasts($data, self::$casts);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges settings from Company to Client
|
* Merges settings from Company to Client
|
||||||
*
|
*
|
||||||
* @param \stdClass $company_settings
|
* @param \stdClass $company_settings
|
||||||
* @param \stdClass $client_settings
|
* @param \stdClass $client_settings
|
||||||
* @return \stdClass of merged settings
|
* @return \stdClass of merged settings
|
||||||
*/
|
*/
|
||||||
public static function buildClientSettings($company_settings, $client_settings)
|
public static function buildClientSettings($company_settings, $client_settings)
|
||||||
{
|
{
|
||||||
|
if (!$client_settings) {
|
||||||
if(!$client_settings)
|
return $company_settings;
|
||||||
return $company_settings;
|
}
|
||||||
|
|
||||||
foreach($company_settings as $key => $value)
|
foreach ($company_settings as $key => $value) {
|
||||||
{
|
/* pseudo code
|
||||||
/* pseudo code
|
if the property exists and is a string BUT has no length, treat it as TRUE
|
||||||
if the property exists and is a string BUT has no length, treat it as TRUE
|
*/
|
||||||
*/
|
if (((property_exists($client_settings, $key) && is_string($client_settings->{$key}) && (iconv_strlen($client_settings->{$key}) <1)))
|
||||||
if( ( (property_exists($client_settings, $key) && is_string($client_settings->{$key}) && (iconv_strlen($client_settings->{$key}) <1)))
|
|| !isset($client_settings->{$key})
|
||||||
|| !isset($client_settings->{$key})
|
&& property_exists($company_settings, $key)) {
|
||||||
&& property_exists($company_settings, $key)) {
|
$client_settings->{$key} = $company_settings->{$key};
|
||||||
$client_settings->{$key} = $company_settings->{$key};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return $client_settings;
|
||||||
|
}
|
||||||
return $client_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,442 +21,435 @@ use App\Models\Company;
|
|||||||
class CompanySettings extends BaseSettings
|
class CompanySettings extends BaseSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Group settings based on functionality*/
|
/*Group settings based on functionality*/
|
||||||
|
|
||||||
/*Invoice*/
|
/*Invoice*/
|
||||||
public $auto_archive_invoice = false;
|
public $auto_archive_invoice = false;
|
||||||
public $lock_sent_invoices = false;
|
public $lock_sent_invoices = false;
|
||||||
|
|
||||||
public $enable_client_portal_tasks = false;
|
public $enable_client_portal_tasks = false;
|
||||||
public $enable_client_portal_password = false;
|
public $enable_client_portal_password = false;
|
||||||
public $enable_client_portal = true; //implemented
|
public $enable_client_portal = true; //implemented
|
||||||
public $enable_client_portal_dashboard = true; //implemented
|
public $enable_client_portal_dashboard = true; //implemented
|
||||||
public $signature_on_pdf = false;
|
public $signature_on_pdf = false;
|
||||||
public $document_email_attachment = false;
|
public $document_email_attachment = false;
|
||||||
public $send_portal_password = false;
|
public $send_portal_password = false;
|
||||||
|
|
||||||
public $timezone_id = '';
|
public $timezone_id = '';
|
||||||
public $date_format_id = '';
|
public $date_format_id = '';
|
||||||
public $military_time = false;
|
public $military_time = false;
|
||||||
|
|
||||||
public $language_id = '';
|
public $language_id = '';
|
||||||
public $show_currency_code = false;
|
public $show_currency_code = false;
|
||||||
|
|
||||||
public $company_gateway_ids = '';
|
public $company_gateway_ids = '';
|
||||||
|
|
||||||
public $currency_id = '1';
|
public $currency_id = '1';
|
||||||
|
|
||||||
public $custom_value1 = '';
|
public $custom_value1 = '';
|
||||||
public $custom_value2 = '';
|
public $custom_value2 = '';
|
||||||
public $custom_value3 = '';
|
public $custom_value3 = '';
|
||||||
public $custom_value4 = '';
|
public $custom_value4 = '';
|
||||||
|
|
||||||
public $default_task_rate = 0;
|
public $default_task_rate = 0;
|
||||||
|
|
||||||
public $payment_terms = 1;
|
public $payment_terms = 1;
|
||||||
public $send_reminders = false;
|
public $send_reminders = false;
|
||||||
|
|
||||||
public $custom_message_dashboard = '';
|
public $custom_message_dashboard = '';
|
||||||
public $custom_message_unpaid_invoice = '';
|
public $custom_message_unpaid_invoice = '';
|
||||||
public $custom_message_paid_invoice = '';
|
public $custom_message_paid_invoice = '';
|
||||||
public $custom_message_unapproved_quote = '';
|
public $custom_message_unapproved_quote = '';
|
||||||
public $auto_archive_quote = false;
|
public $auto_archive_quote = false;
|
||||||
public $auto_convert_quote = true;
|
public $auto_convert_quote = true;
|
||||||
public $auto_email_invoice = true;
|
public $auto_email_invoice = true;
|
||||||
|
|
||||||
public $inclusive_taxes = false;
|
public $inclusive_taxes = false;
|
||||||
public $quote_footer = '';
|
public $quote_footer = '';
|
||||||
|
|
||||||
public $translations;
|
public $translations;
|
||||||
|
|
||||||
public $counter_number_applied = 'when_saved'; // when_saved , when_sent , when_paid
|
public $counter_number_applied = 'when_saved'; // when_saved , when_sent , when_paid
|
||||||
public $quote_number_applied = 'when_saved'; // when_saved , when_sent
|
public $quote_number_applied = 'when_saved'; // when_saved , when_sent
|
||||||
/* Counters */
|
/* Counters */
|
||||||
public $invoice_number_pattern = '';
|
public $invoice_number_pattern = '';
|
||||||
public $invoice_number_counter = 1;
|
public $invoice_number_counter = 1;
|
||||||
|
|
||||||
public $quote_number_pattern = '';
|
public $quote_number_pattern = '';
|
||||||
public $quote_number_counter = 1;
|
public $quote_number_counter = 1;
|
||||||
|
|
||||||
public $client_number_pattern = '';
|
public $client_number_pattern = '';
|
||||||
public $client_number_counter = 1;
|
public $client_number_counter = 1;
|
||||||
|
|
||||||
public $credit_number_pattern = '';
|
public $credit_number_pattern = '';
|
||||||
public $credit_number_counter = 1;
|
public $credit_number_counter = 1;
|
||||||
|
|
||||||
public $task_number_pattern = '';
|
public $task_number_pattern = '';
|
||||||
public $task_number_counter = 1;
|
public $task_number_counter = 1;
|
||||||
|
|
||||||
public $expense_number_pattern = '';
|
public $expense_number_pattern = '';
|
||||||
public $expense_number_counter = 1;
|
public $expense_number_counter = 1;
|
||||||
|
|
||||||
public $vendor_number_pattern = '';
|
public $vendor_number_pattern = '';
|
||||||
public $vendor_number_counter = 1;
|
public $vendor_number_counter = 1;
|
||||||
|
|
||||||
public $ticket_number_pattern = '';
|
public $ticket_number_pattern = '';
|
||||||
public $ticket_number_counter = 1;
|
public $ticket_number_counter = 1;
|
||||||
|
|
||||||
public $payment_number_pattern = '';
|
public $payment_number_pattern = '';
|
||||||
public $payment_number_counter = 1;
|
public $payment_number_counter = 1;
|
||||||
|
|
||||||
|
|
||||||
public $shared_invoice_quote_counter = false;
|
public $shared_invoice_quote_counter = false;
|
||||||
public $recurring_number_prefix = 'R';
|
public $recurring_number_prefix = 'R';
|
||||||
public $reset_counter_frequency_id = '0';
|
public $reset_counter_frequency_id = '0';
|
||||||
public $reset_counter_date = '';
|
public $reset_counter_date = '';
|
||||||
public $counter_padding = 4;
|
public $counter_padding = 4;
|
||||||
|
|
||||||
public $design = 'views/pdf/design1.blade.php';
|
public $design = 'views/pdf/design1.blade.php';
|
||||||
|
|
||||||
public $invoice_terms = '';
|
public $invoice_terms = '';
|
||||||
public $quote_terms = '';
|
public $quote_terms = '';
|
||||||
public $invoice_taxes = 0;
|
public $invoice_taxes = 0;
|
||||||
public $enabled_item_tax_rates = 0;
|
public $enabled_item_tax_rates = 0;
|
||||||
public $invoice_design_id = '1';
|
public $invoice_design_id = '1';
|
||||||
public $quote_design_id = '1';
|
public $quote_design_id = '1';
|
||||||
public $invoice_footer = '';
|
public $invoice_footer = '';
|
||||||
public $invoice_labels = '';
|
public $invoice_labels = '';
|
||||||
public $tax_name1 = '';
|
public $tax_name1 = '';
|
||||||
public $tax_rate1 = 0;
|
public $tax_rate1 = 0;
|
||||||
public $tax_name2 = '';
|
public $tax_name2 = '';
|
||||||
public $tax_rate2 = 0;
|
public $tax_rate2 = 0;
|
||||||
public $tax_name3 = '';
|
public $tax_name3 = '';
|
||||||
public $tax_rate3 = 0;
|
public $tax_rate3 = 0;
|
||||||
public $payment_type_id = '1';
|
public $payment_type_id = '1';
|
||||||
public $invoice_fields = '';
|
public $invoice_fields = '';
|
||||||
|
|
||||||
public $show_accept_invoice_terms = false;
|
public $show_accept_invoice_terms = false;
|
||||||
public $show_accept_quote_terms = false;
|
public $show_accept_quote_terms = false;
|
||||||
public $require_invoice_signature = false;
|
public $require_invoice_signature = false;
|
||||||
public $require_quote_signature = false;
|
public $require_quote_signature = false;
|
||||||
|
|
||||||
//email settings
|
//email settings
|
||||||
public $email_sending_method = 'default'; //enum 'default','gmail'
|
public $email_sending_method = 'default'; //enum 'default','gmail'
|
||||||
public $gmail_sending_user_id = '0';
|
public $gmail_sending_user_id = '0';
|
||||||
|
|
||||||
public $reply_to_email = '';
|
public $reply_to_email = '';
|
||||||
public $bcc_email = '';
|
public $bcc_email = '';
|
||||||
public $pdf_email_attachment = false;
|
public $pdf_email_attachment = false;
|
||||||
public $ubl_email_attachment = false;
|
public $ubl_email_attachment = false;
|
||||||
|
|
||||||
public $email_style = 'plain'; //plain, light, dark, custom
|
public $email_style = 'plain'; //plain, light, dark, custom
|
||||||
public $email_style_custom = ''; //the template itself
|
public $email_style_custom = ''; //the template itself
|
||||||
public $email_subject_invoice = '';
|
public $email_subject_invoice = '';
|
||||||
public $email_subject_quote = '';
|
public $email_subject_quote = '';
|
||||||
public $email_subject_payment = '';
|
public $email_subject_payment = '';
|
||||||
public $email_subject_statement = '';
|
public $email_subject_statement = '';
|
||||||
public $email_template_invoice = '';
|
public $email_template_invoice = '';
|
||||||
public $email_template_quote = '';
|
public $email_template_quote = '';
|
||||||
public $email_template_payment = '';
|
public $email_template_payment = '';
|
||||||
public $email_template_statement = '';
|
public $email_template_statement = '';
|
||||||
public $email_subject_reminder1 = '';
|
public $email_subject_reminder1 = '';
|
||||||
public $email_subject_reminder2 = '';
|
public $email_subject_reminder2 = '';
|
||||||
public $email_subject_reminder3 = '';
|
public $email_subject_reminder3 = '';
|
||||||
public $email_subject_reminder_endless = '';
|
public $email_subject_reminder_endless = '';
|
||||||
public $email_template_reminder1 = '';
|
public $email_template_reminder1 = '';
|
||||||
public $email_template_reminder2 = '';
|
public $email_template_reminder2 = '';
|
||||||
public $email_template_reminder3 = '';
|
public $email_template_reminder3 = '';
|
||||||
public $email_template_reminder_endless = '';
|
public $email_template_reminder_endless = '';
|
||||||
public $email_signature = '';
|
public $email_signature = '';
|
||||||
public $enable_email_markup = true;
|
public $enable_email_markup = true;
|
||||||
|
|
||||||
|
|
||||||
public $email_subject_custom1 = '';
|
public $email_subject_custom1 = '';
|
||||||
public $email_subject_custom2 = '';
|
public $email_subject_custom2 = '';
|
||||||
public $email_subject_custom3 = '';
|
public $email_subject_custom3 = '';
|
||||||
|
|
||||||
public $email_template_custom1 = '';
|
public $email_template_custom1 = '';
|
||||||
public $email_template_custom2 = '';
|
public $email_template_custom2 = '';
|
||||||
public $email_template_custom3 = '';
|
public $email_template_custom3 = '';
|
||||||
|
|
||||||
public $enable_reminder1 = false;
|
public $enable_reminder1 = false;
|
||||||
public $enable_reminder2 = false;
|
public $enable_reminder2 = false;
|
||||||
public $enable_reminder3 = false;
|
public $enable_reminder3 = false;
|
||||||
|
|
||||||
public $num_days_reminder1 = 0;
|
public $num_days_reminder1 = 0;
|
||||||
public $num_days_reminder2 = 0;
|
public $num_days_reminder2 = 0;
|
||||||
public $num_days_reminder3 = 0;
|
public $num_days_reminder3 = 0;
|
||||||
|
|
||||||
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
|
|
||||||
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders
|
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders
|
||||||
|
|
||||||
public $late_fee_amount1 = 0;
|
public $late_fee_amount1 = 0;
|
||||||
public $late_fee_amount2 = 0;
|
public $late_fee_amount2 = 0;
|
||||||
public $late_fee_amount3 = 0;
|
public $late_fee_amount3 = 0;
|
||||||
|
|
||||||
public $endless_reminder_frequency_id = '0';
|
public $endless_reminder_frequency_id = '0';
|
||||||
|
|
||||||
public $client_online_payment_notification = true;
|
public $client_online_payment_notification = true;
|
||||||
public $client_manual_payment_notification = true;
|
public $client_manual_payment_notification = true;
|
||||||
|
|
||||||
/* Company Meta data that we can use to build sub companies*/
|
/* Company Meta data that we can use to build sub companies*/
|
||||||
|
|
||||||
public $name = '';
|
public $name = '';
|
||||||
public $company_logo = '';
|
public $company_logo = '';
|
||||||
public $website = '';
|
public $website = '';
|
||||||
public $address1 = '';
|
public $address1 = '';
|
||||||
public $address2 = '';
|
public $address2 = '';
|
||||||
public $city = '';
|
public $city = '';
|
||||||
public $state = '';
|
public $state = '';
|
||||||
public $postal_code = '';
|
public $postal_code = '';
|
||||||
public $phone = '';
|
public $phone = '';
|
||||||
public $email = '';
|
public $email = '';
|
||||||
public $country_id;
|
public $country_id;
|
||||||
public $vat_number = '';
|
public $vat_number = '';
|
||||||
public $id_number = '';
|
public $id_number = '';
|
||||||
|
|
||||||
public $page_size = 'A4';
|
public $page_size = 'A4';
|
||||||
public $font_size = 9;
|
public $font_size = 9;
|
||||||
public $primary_font = 'Roboto';
|
public $primary_font = 'Roboto';
|
||||||
public $secondary_font = 'Roboto';
|
public $secondary_font = 'Roboto';
|
||||||
public $hide_paid_to_date = false;
|
public $hide_paid_to_date = false;
|
||||||
public $embed_documents = false;
|
public $embed_documents = false;
|
||||||
public $all_pages_header = true;
|
public $all_pages_header = true;
|
||||||
public $all_pages_footer = true;
|
public $all_pages_footer = true;
|
||||||
|
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
'auto_email_invoice' => 'bool',
|
'auto_email_invoice' => 'bool',
|
||||||
'reminder_send_time' => 'int',
|
'reminder_send_time' => 'int',
|
||||||
'email_sending_method' => 'string',
|
'email_sending_method' => 'string',
|
||||||
'gmail_sending_user_id' => 'string',
|
'gmail_sending_user_id' => 'string',
|
||||||
'currency_id' => 'string',
|
'currency_id' => 'string',
|
||||||
'counter_number_applied' => 'string',
|
'counter_number_applied' => 'string',
|
||||||
'quote_number_applied' => 'string',
|
'quote_number_applied' => 'string',
|
||||||
'email_subject_custom1' => 'string',
|
'email_subject_custom1' => 'string',
|
||||||
'email_subject_custom2' => 'string',
|
'email_subject_custom2' => 'string',
|
||||||
'email_subject_custom3' => 'string',
|
'email_subject_custom3' => 'string',
|
||||||
'email_template_custom1' => 'string',
|
'email_template_custom1' => 'string',
|
||||||
'email_template_custom2' => 'string',
|
'email_template_custom2' => 'string',
|
||||||
'email_template_custom3' => 'string',
|
'email_template_custom3' => 'string',
|
||||||
'enable_reminder1' => 'bool',
|
'enable_reminder1' => 'bool',
|
||||||
'enable_reminder2' => 'bool',
|
'enable_reminder2' => 'bool',
|
||||||
'enable_reminder3' => 'bool',
|
'enable_reminder3' => 'bool',
|
||||||
'num_days_reminder1' => 'int',
|
'num_days_reminder1' => 'int',
|
||||||
'num_days_reminder2' => 'int',
|
'num_days_reminder2' => 'int',
|
||||||
'num_days_reminder3' => 'int',
|
'num_days_reminder3' => 'int',
|
||||||
'schedule_reminder1' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
'schedule_reminder1' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
'schedule_reminder2' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
'schedule_reminder2' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
'schedule_reminder3' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
'schedule_reminder3' => 'string', // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
'late_fee_amount1' => 'float',
|
'late_fee_amount1' => 'float',
|
||||||
'late_fee_amount2' => 'float',
|
'late_fee_amount2' => 'float',
|
||||||
'late_fee_amount3' => 'float',
|
'late_fee_amount3' => 'float',
|
||||||
'endless_reminder_frequency_id' => 'integer',
|
'endless_reminder_frequency_id' => 'integer',
|
||||||
'client_online_payment_notification' => 'bool',
|
'client_online_payment_notification' => 'bool',
|
||||||
'client_manual_payment_notification' => 'bool',
|
'client_manual_payment_notification' => 'bool',
|
||||||
'document_email_attachment' => 'bool',
|
'document_email_attachment' => 'bool',
|
||||||
'enable_client_portal_password' => 'bool',
|
'enable_client_portal_password' => 'bool',
|
||||||
'enable_email_markup' => 'bool',
|
'enable_email_markup' => 'bool',
|
||||||
'enable_client_portal_dashboard' => 'bool',
|
'enable_client_portal_dashboard' => 'bool',
|
||||||
'enable_client_portal' => 'bool',
|
'enable_client_portal' => 'bool',
|
||||||
'email_template_statement' => 'string',
|
'email_template_statement' => 'string',
|
||||||
'email_subject_statement' => 'string',
|
'email_subject_statement' => 'string',
|
||||||
'signature_on_pdf' => 'bool',
|
'signature_on_pdf' => 'bool',
|
||||||
'send_portal_password' => 'bool',
|
'send_portal_password' => 'bool',
|
||||||
'quote_footer' => 'string',
|
'quote_footer' => 'string',
|
||||||
'page_size' => 'string',
|
'page_size' => 'string',
|
||||||
'font_size' => 'int',
|
'font_size' => 'int',
|
||||||
'primary_font' => 'string',
|
'primary_font' => 'string',
|
||||||
'secondary_font' => 'string',
|
'secondary_font' => 'string',
|
||||||
'hide_paid_to_date' => 'bool',
|
'hide_paid_to_date' => 'bool',
|
||||||
'embed_documents' => 'bool',
|
'embed_documents' => 'bool',
|
||||||
'all_pages_header' => 'bool',
|
'all_pages_header' => 'bool',
|
||||||
'all_pages_footer' => 'bool',
|
'all_pages_footer' => 'bool',
|
||||||
'task_number_pattern' => 'string',
|
'task_number_pattern' => 'string',
|
||||||
'task_number_counter' => 'int',
|
'task_number_counter' => 'int',
|
||||||
'expense_number_pattern' => 'string',
|
'expense_number_pattern' => 'string',
|
||||||
'expense_number_counter' => 'int',
|
'expense_number_counter' => 'int',
|
||||||
'vendor_number_pattern' => 'string',
|
'vendor_number_pattern' => 'string',
|
||||||
'vendor_number_counter' => 'int',
|
'vendor_number_counter' => 'int',
|
||||||
'ticket_number_pattern' => 'string',
|
'ticket_number_pattern' => 'string',
|
||||||
'ticket_number_counter' => 'int',
|
'ticket_number_counter' => 'int',
|
||||||
'payment_number_pattern' => 'string',
|
'payment_number_pattern' => 'string',
|
||||||
'payment_number_counter' => 'int',
|
'payment_number_counter' => 'int',
|
||||||
'reply_to_email' => 'string',
|
'reply_to_email' => 'string',
|
||||||
'bcc_email' => 'string',
|
'bcc_email' => 'string',
|
||||||
'pdf_email_attachment' => 'bool',
|
'pdf_email_attachment' => 'bool',
|
||||||
'ubl_email_attachment' => 'bool',
|
'ubl_email_attachment' => 'bool',
|
||||||
'email_style' => 'string',
|
'email_style' => 'string',
|
||||||
'email_style_custom' => 'string',
|
'email_style_custom' => 'string',
|
||||||
'company_gateway_ids' => 'string',
|
'company_gateway_ids' => 'string',
|
||||||
'address1' => 'string',
|
'address1' => 'string',
|
||||||
'address2' => 'string',
|
'address2' => 'string',
|
||||||
'city' => 'string',
|
'city' => 'string',
|
||||||
'company_logo' => 'string',
|
'company_logo' => 'string',
|
||||||
'country_id' => 'string',
|
'country_id' => 'string',
|
||||||
'client_number_pattern' => 'string',
|
'client_number_pattern' => 'string',
|
||||||
'client_number_counter' => 'integer',
|
'client_number_counter' => 'integer',
|
||||||
'credit_number_pattern' => 'string',
|
'credit_number_pattern' => 'string',
|
||||||
'credit_number_counter' => 'integer',
|
'credit_number_counter' => 'integer',
|
||||||
'currency_id' => 'string',
|
'currency_id' => 'string',
|
||||||
'custom_value1' => 'string',
|
'custom_value1' => 'string',
|
||||||
'custom_value2' => 'string',
|
'custom_value2' => 'string',
|
||||||
'custom_value3' => 'string',
|
'custom_value3' => 'string',
|
||||||
'custom_value4' => 'string',
|
'custom_value4' => 'string',
|
||||||
'custom_message_dashboard' => 'string',
|
'custom_message_dashboard' => 'string',
|
||||||
'custom_message_unpaid_invoice' => 'string',
|
'custom_message_unpaid_invoice' => 'string',
|
||||||
'custom_message_paid_invoice' => 'string',
|
'custom_message_paid_invoice' => 'string',
|
||||||
'custom_message_unapproved_quote' => 'string',
|
'custom_message_unapproved_quote' => 'string',
|
||||||
'default_task_rate' => 'float',
|
'default_task_rate' => 'float',
|
||||||
'email_signature' => 'string',
|
'email_signature' => 'string',
|
||||||
'email_subject_invoice' => 'string',
|
'email_subject_invoice' => 'string',
|
||||||
'email_subject_quote' => 'string',
|
'email_subject_quote' => 'string',
|
||||||
'email_subject_payment' => 'string',
|
'email_subject_payment' => 'string',
|
||||||
'email_template_invoice' => 'string',
|
'email_template_invoice' => 'string',
|
||||||
'email_template_quote' => 'string',
|
'email_template_quote' => 'string',
|
||||||
'email_template_payment' => 'string',
|
'email_template_payment' => 'string',
|
||||||
'email_subject_reminder1' => 'string',
|
'email_subject_reminder1' => 'string',
|
||||||
'email_subject_reminder2' => 'string',
|
'email_subject_reminder2' => 'string',
|
||||||
'email_subject_reminder3' => 'string',
|
'email_subject_reminder3' => 'string',
|
||||||
'email_subject_reminder_endless' => 'string',
|
'email_subject_reminder_endless' => 'string',
|
||||||
'email_template_reminder1' => 'string',
|
'email_template_reminder1' => 'string',
|
||||||
'email_template_reminder2' => 'string',
|
'email_template_reminder2' => 'string',
|
||||||
'email_template_reminder3' => 'string',
|
'email_template_reminder3' => 'string',
|
||||||
'email_template_reminder_endless' => 'string',
|
'email_template_reminder_endless' => 'string',
|
||||||
'enable_client_portal_password' => 'bool',
|
'enable_client_portal_password' => 'bool',
|
||||||
'inclusive_taxes' => 'bool',
|
'inclusive_taxes' => 'bool',
|
||||||
'invoice_number_pattern' => 'string',
|
'invoice_number_pattern' => 'string',
|
||||||
'invoice_number_counter' => 'integer',
|
'invoice_number_counter' => 'integer',
|
||||||
'invoice_design_id' => 'string',
|
'invoice_design_id' => 'string',
|
||||||
'invoice_fields' => 'string',
|
'invoice_fields' => 'string',
|
||||||
'invoice_taxes' => 'int',
|
'invoice_taxes' => 'int',
|
||||||
'enabled_item_tax_rates' => 'int',
|
'enabled_item_tax_rates' => 'int',
|
||||||
'invoice_footer' => 'string',
|
'invoice_footer' => 'string',
|
||||||
'invoice_labels' => 'string',
|
'invoice_labels' => 'string',
|
||||||
'invoice_terms' => 'string',
|
'invoice_terms' => 'string',
|
||||||
'name' => 'string',
|
'name' => 'string',
|
||||||
'payment_terms' => 'integer',
|
'payment_terms' => 'integer',
|
||||||
'payment_type_id' => 'string',
|
'payment_type_id' => 'string',
|
||||||
'phone' => 'string',
|
'phone' => 'string',
|
||||||
'postal_code' => 'string',
|
'postal_code' => 'string',
|
||||||
'quote_design_id' => 'string',
|
'quote_design_id' => 'string',
|
||||||
'quote_number_pattern' => 'string',
|
'quote_number_pattern' => 'string',
|
||||||
'quote_number_counter' => 'integer',
|
'quote_number_counter' => 'integer',
|
||||||
'quote_terms' => 'string',
|
'quote_terms' => 'string',
|
||||||
'recurring_number_prefix' => 'string',
|
'recurring_number_prefix' => 'string',
|
||||||
'reset_counter_frequency_id' => 'integer',
|
'reset_counter_frequency_id' => 'integer',
|
||||||
'reset_counter_date' => 'string',
|
'reset_counter_date' => 'string',
|
||||||
'require_invoice_signature' => 'bool',
|
'require_invoice_signature' => 'bool',
|
||||||
'require_quote_signature' => 'bool',
|
'require_quote_signature' => 'bool',
|
||||||
'state' => 'string',
|
'state' => 'string',
|
||||||
'email' => 'string',
|
'email' => 'string',
|
||||||
'vat_number' => 'string',
|
'vat_number' => 'string',
|
||||||
'id_number' => 'string',
|
'id_number' => 'string',
|
||||||
'tax_name1' => 'string',
|
'tax_name1' => 'string',
|
||||||
'tax_name2' => 'string',
|
'tax_name2' => 'string',
|
||||||
'tax_name3' => 'string',
|
'tax_name3' => 'string',
|
||||||
'tax_rate1' => 'float',
|
'tax_rate1' => 'float',
|
||||||
'tax_rate2' => 'float',
|
'tax_rate2' => 'float',
|
||||||
'tax_rate3' => 'float',
|
'tax_rate3' => 'float',
|
||||||
'show_accept_quote_terms' => 'bool',
|
'show_accept_quote_terms' => 'bool',
|
||||||
'show_accept_invoice_terms' => 'bool',
|
'show_accept_invoice_terms' => 'bool',
|
||||||
'timezone_id' => 'string',
|
'timezone_id' => 'string',
|
||||||
'date_format_id' => 'string',
|
'date_format_id' => 'string',
|
||||||
'military_time' => 'bool',
|
'military_time' => 'bool',
|
||||||
'language_id' => 'string',
|
'language_id' => 'string',
|
||||||
'show_currency_code' => 'bool',
|
'show_currency_code' => 'bool',
|
||||||
'send_reminders' => 'bool',
|
'send_reminders' => 'bool',
|
||||||
'enable_client_portal_tasks' => 'bool',
|
'enable_client_portal_tasks' => 'bool',
|
||||||
'lock_sent_invoices' => 'bool',
|
'lock_sent_invoices' => 'bool',
|
||||||
'auto_archive_invoice' => 'bool',
|
'auto_archive_invoice' => 'bool',
|
||||||
'auto_archive_quote' => 'bool',
|
'auto_archive_quote' => 'bool',
|
||||||
'auto_convert_quote' => 'bool',
|
'auto_convert_quote' => 'bool',
|
||||||
'shared_invoice_quote_counter' => 'bool',
|
'shared_invoice_quote_counter' => 'bool',
|
||||||
'counter_padding' => 'integer',
|
'counter_padding' => 'integer',
|
||||||
'design' => 'string',
|
'design' => 'string',
|
||||||
'website' => 'string',
|
'website' => 'string',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of variables which
|
* Array of variables which
|
||||||
* cannot be modified client side
|
* cannot be modified client side
|
||||||
*/
|
|
||||||
public static $protected_fields = [
|
|
||||||
// 'credit_number_counter',
|
|
||||||
// 'invoice_number_counter',
|
|
||||||
// 'quote_number_counter',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast object values and return entire class
|
|
||||||
* prevents missing properties from not being returned
|
|
||||||
* and always ensure an up to date class is returned
|
|
||||||
*
|
|
||||||
* @return \stdClass
|
|
||||||
*/
|
*/
|
||||||
public function __construct($obj)
|
public static $protected_fields = [
|
||||||
{
|
// 'credit_number_counter',
|
||||||
// parent::__construct($obj);
|
// 'invoice_number_counter',
|
||||||
}
|
// 'quote_number_counter',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides class defaults on init
|
* Cast object values and return entire class
|
||||||
* @return object
|
* prevents missing properties from not being returned
|
||||||
*/
|
* and always ensure an up to date class is returned
|
||||||
public static function defaults() : \stdClass
|
*
|
||||||
{
|
* @return \stdClass
|
||||||
|
*/
|
||||||
$config = json_decode(config('ninja.settings'));
|
public function __construct($obj)
|
||||||
|
{
|
||||||
$data = (object)get_class_vars(CompanySettings::class);
|
// parent::__construct($obj);
|
||||||
unset($data->casts);
|
}
|
||||||
unset($data->protected_fields);
|
|
||||||
|
|
||||||
$data->timezone_id = (string)config('ninja.i18n.timezone_id');
|
/**
|
||||||
$data->currency_id = (string)config('ninja.i18n.currency_id');
|
* Provides class defaults on init
|
||||||
$data->language_id = (string)config('ninja.i18n.language_id');
|
* @return object
|
||||||
$data->payment_terms = (int)config('ninja.i18n.payment_terms');
|
*/
|
||||||
$data->military_time = (bool)config('ninja.i18n.military_time');
|
public static function defaults() : \stdClass
|
||||||
$data->date_format_id = (string)config('ninja.i18n.date_format_id');
|
{
|
||||||
$data->country_id = (string)config('ninja.i18n.country_id');
|
$config = json_decode(config('ninja.settings'));
|
||||||
$data->translations = (object) [];
|
|
||||||
|
$data = (object)get_class_vars(CompanySettings::class);
|
||||||
// $data->email_subject_invoice = EmailTemplateDefaults::emailInvoiceSubject();
|
unset($data->casts);
|
||||||
// $data->email_template_invoice = EmailTemplateDefaults:: emailInvoiceTemplate();
|
unset($data->protected_fields);
|
||||||
// $data->email_subject_quote = EmailTemplateDefaults::emailQuoteSubject();
|
|
||||||
// $data->email_subject_payment = EmailTemplateDefaults::emailPaymentSubject();
|
|
||||||
// $data->email_subject_statement = EmailTemplateDefaults::emailStatementSubject();
|
|
||||||
// $data->email_template_quote = EmailTemplateDefaults::emailQuoteTemplate();
|
|
||||||
// $data->email_template_payment = EmailTemplateDefaults::emailPaymentTemplate();
|
|
||||||
// $data->email_template_statement = EmailTemplateDefaults::emailStatementTemplate();
|
|
||||||
// $data->email_subject_reminder1 = EmailTemplateDefaults::emailReminder1Subject();
|
|
||||||
// $data->email_subject_reminder2 = EmailTemplateDefaults::emailReminder2Subject();
|
|
||||||
// $data->email_subject_reminder3 = EmailTemplateDefaults::emailReminder3Subject();
|
|
||||||
// $data->email_subject_reminder_endless = EmailTemplateDefaults::emailReminderEndlessSubject();
|
|
||||||
// $data->email_template_reminder1 = EmailTemplateDefaults::emailReminder1Template();
|
|
||||||
// $data->email_template_reminder2 = EmailTemplateDefaults::emailReminder2Template();
|
|
||||||
// $data->email_template_reminder3 = EmailTemplateDefaults::emailReminder3Template();
|
|
||||||
// $data->email_template_reminder_endless = EmailTemplateDefaults::emailReminderEndlessTemplate();
|
|
||||||
|
|
||||||
return self::setCasts($data, self::$casts);
|
|
||||||
|
|
||||||
}
|
$data->timezone_id = (string)config('ninja.i18n.timezone_id');
|
||||||
|
$data->currency_id = (string)config('ninja.i18n.currency_id');
|
||||||
|
$data->language_id = (string)config('ninja.i18n.language_id');
|
||||||
|
$data->payment_terms = (int)config('ninja.i18n.payment_terms');
|
||||||
|
$data->military_time = (bool)config('ninja.i18n.military_time');
|
||||||
|
$data->date_format_id = (string)config('ninja.i18n.date_format_id');
|
||||||
|
$data->country_id = (string)config('ninja.i18n.country_id');
|
||||||
|
$data->translations = (object) [];
|
||||||
|
|
||||||
|
// $data->email_subject_invoice = EmailTemplateDefaults::emailInvoiceSubject();
|
||||||
|
// $data->email_template_invoice = EmailTemplateDefaults:: emailInvoiceTemplate();
|
||||||
|
// $data->email_subject_quote = EmailTemplateDefaults::emailQuoteSubject();
|
||||||
|
// $data->email_subject_payment = EmailTemplateDefaults::emailPaymentSubject();
|
||||||
|
// $data->email_subject_statement = EmailTemplateDefaults::emailStatementSubject();
|
||||||
|
// $data->email_template_quote = EmailTemplateDefaults::emailQuoteTemplate();
|
||||||
|
// $data->email_template_payment = EmailTemplateDefaults::emailPaymentTemplate();
|
||||||
|
// $data->email_template_statement = EmailTemplateDefaults::emailStatementTemplate();
|
||||||
|
// $data->email_subject_reminder1 = EmailTemplateDefaults::emailReminder1Subject();
|
||||||
|
// $data->email_subject_reminder2 = EmailTemplateDefaults::emailReminder2Subject();
|
||||||
|
// $data->email_subject_reminder3 = EmailTemplateDefaults::emailReminder3Subject();
|
||||||
|
// $data->email_subject_reminder_endless = EmailTemplateDefaults::emailReminderEndlessSubject();
|
||||||
|
// $data->email_template_reminder1 = EmailTemplateDefaults::emailReminder1Template();
|
||||||
|
// $data->email_template_reminder2 = EmailTemplateDefaults::emailReminder2Template();
|
||||||
|
// $data->email_template_reminder3 = EmailTemplateDefaults::emailReminder3Template();
|
||||||
|
// $data->email_template_reminder_endless = EmailTemplateDefaults::emailReminderEndlessTemplate();
|
||||||
|
|
||||||
|
return self::setCasts($data, self::$casts);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In case we update the settings object in the future we
|
* In case we update the settings object in the future we
|
||||||
* need to provide a fallback catch on old settings objects which will
|
* need to provide a fallback catch on old settings objects which will
|
||||||
* set new properties to the object prior to being returned.
|
* set new properties to the object prior to being returned.
|
||||||
*
|
*
|
||||||
* @param object $data The settings object to be checked
|
* @param object $data The settings object to be checked
|
||||||
*/
|
*/
|
||||||
public static function setProperties($settings) :\stdClass
|
public static function setProperties($settings) :\stdClass
|
||||||
{
|
{
|
||||||
|
$company_settings = (object)get_class_vars(CompanySettings::class);
|
||||||
|
|
||||||
$company_settings = (object)get_class_vars(CompanySettings::class);
|
foreach ($company_settings as $key => $value) {
|
||||||
|
if (!property_exists($settings, $key)) {
|
||||||
foreach($company_settings as $key => $value)
|
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});
|
||||||
{
|
}
|
||||||
|
}
|
||||||
if(!property_exists($settings, $key))
|
|
||||||
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $settings;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,33 +21,30 @@ use App\Models\User;
|
|||||||
class DefaultSettings extends BaseSettings
|
class DefaultSettings extends BaseSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public static $per_page = 25;
|
public static $per_page = 25;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*
|
*
|
||||||
* //todo user specific settings / preferences.
|
* //todo user specific settings / preferences.
|
||||||
*/
|
*/
|
||||||
public static function userSettings() : \stdClass
|
public static function userSettings() : \stdClass
|
||||||
{
|
{
|
||||||
return (object)[
|
return (object)[
|
||||||
class_basename(User::class) => self::userSettingsObject(),
|
class_basename(User::class) => self::userSettingsObject(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
private static function userSettingsObject() : \stdClass
|
private static function userSettingsObject() : \stdClass
|
||||||
{
|
{
|
||||||
|
return (object)[
|
||||||
return (object)[
|
'per_page' => self::$per_page,
|
||||||
'per_page' => self::$per_page,
|
];
|
||||||
];
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -108,5 +108,3 @@ class EmailTemplateDefaults
|
|||||||
return str_replace(":", "$", ctrans('texts.'.$string));
|
return str_replace(":", "$", ctrans('texts.'.$string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,29 +13,29 @@ namespace App\DataMapper;
|
|||||||
|
|
||||||
class FeesAndLimits
|
class FeesAndLimits
|
||||||
{
|
{
|
||||||
public $min_limit = -1; //equivalent to null
|
public $min_limit = -1; //equivalent to null
|
||||||
|
|
||||||
public $max_limit = -1; //equivalent to null
|
public $max_limit = -1; //equivalent to null
|
||||||
|
|
||||||
public $fee_amount = 0;
|
public $fee_amount = 0;
|
||||||
|
|
||||||
public $fee_percent = 0;
|
public $fee_percent = 0;
|
||||||
|
|
||||||
public $fee_tax_name1 = '';
|
public $fee_tax_name1 = '';
|
||||||
|
|
||||||
public $fee_tax_name2 = '';
|
public $fee_tax_name2 = '';
|
||||||
|
|
||||||
public $fee_tax_name3 = '';
|
public $fee_tax_name3 = '';
|
||||||
|
|
||||||
public $fee_tax_rate1 = 0;
|
public $fee_tax_rate1 = 0;
|
||||||
|
|
||||||
public $fee_tax_rate2 = 0;
|
public $fee_tax_rate2 = 0;
|
||||||
|
|
||||||
public $fee_tax_rate3 = 0;
|
public $fee_tax_rate3 = 0;
|
||||||
|
|
||||||
public $fee_cap = 0;
|
public $fee_cap = 0;
|
||||||
|
|
||||||
public $adjust_fee_percent = false;
|
public $adjust_fee_percent = false;
|
||||||
|
|
||||||
//public $gateway_type_id = 1;
|
//public $gateway_type_id = 1;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ namespace App\DataMapper;
|
|||||||
|
|
||||||
class InvoiceItem
|
class InvoiceItem
|
||||||
{
|
{
|
||||||
|
|
||||||
public $quantity = 0;
|
public $quantity = 0;
|
||||||
|
|
||||||
public $cost = 0;
|
public $cost = 0;
|
||||||
|
@ -13,13 +13,13 @@ namespace App\DataMapper;
|
|||||||
|
|
||||||
class PaymentMethodMeta
|
class PaymentMethodMeta
|
||||||
{
|
{
|
||||||
public $exp_month;
|
public $exp_month;
|
||||||
|
|
||||||
public $exp_year;
|
public $exp_year;
|
||||||
|
|
||||||
public $brand;
|
public $brand;
|
||||||
|
|
||||||
public $last4;
|
public $last4;
|
||||||
|
|
||||||
public $type;
|
public $type;
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,15 @@ namespace App\DataMapper;
|
|||||||
|
|
||||||
class PaymentTransaction
|
class PaymentTransaction
|
||||||
{
|
{
|
||||||
|
public $transaction_id;
|
||||||
|
|
||||||
public $transaction_id;
|
public $gateway_response;
|
||||||
|
|
||||||
public $gateway_response;
|
public $account_gateway_id;
|
||||||
|
|
||||||
public $account_gateway_id;
|
public $type_id;
|
||||||
|
|
||||||
public $type_id;
|
public $status; // prepayment|payment|response|completed
|
||||||
|
|
||||||
public $status; // prepayment|payment|response|completed
|
public $invoices;
|
||||||
|
}
|
||||||
public $invoices;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -19,6 +19,7 @@ use Illuminate\Broadcasting\PresenceChannel;
|
|||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ClientWasArchived.
|
* Class ClientWasArchived.
|
||||||
*/
|
*/
|
||||||
|
@ -40,9 +40,7 @@ class ContactLoggedIn
|
|||||||
*/
|
*/
|
||||||
public function __construct(ClientContact $client_contact)
|
public function __construct(ClientContact $client_contact)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->client_contact = $client_contact;
|
$this->client_contact = $client_contact;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class ExpenseWasArchived.
|
* Class ExpenseWasArchived.
|
||||||
*/
|
*/
|
||||||
class ExpenseWasArchived
|
class ExpenseWasArchived
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class ExpenseWasCreated.
|
* Class ExpenseWasCreated.
|
||||||
*/
|
*/
|
||||||
class ExpenseWasCreated
|
class ExpenseWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class ExpenseWasRestored.
|
* Class ExpenseWasRestored.
|
||||||
*/
|
*/
|
||||||
class ExpenseWasRestored
|
class ExpenseWasRestored
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class ExpenseWasUpdated.
|
* Class ExpenseWasUpdated.
|
||||||
*/
|
*/
|
||||||
class ExpenseWasUpdated
|
class ExpenseWasUpdated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasArchived.
|
* Class InvoiceWasArchived.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasArchived
|
class InvoiceWasArchived
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasCreated.
|
* Class InvoiceWasCreated.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasCreated
|
class InvoiceWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasDeleted.
|
* Class InvoiceWasDeleted.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasDeleted
|
class InvoiceWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasEmailed.
|
* Class InvoiceWasEmailed.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasEmailed
|
class InvoiceWasEmailed
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasEmailedAndFailed.
|
* Class InvoiceWasEmailedAndFailed.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasEmailedAndFailed
|
class InvoiceWasEmailedAndFailed
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasMarkedSent.
|
* Class InvoiceWasMarkedSent.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasMarkedSent
|
class InvoiceWasMarkedSent
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceWasPaid.
|
* Class InvoiceWasPaid.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasPaid
|
class InvoiceWasPaid
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
|
|
||||||
namespace App\Events\Invoice;
|
namespace App\Events\Invoice;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InvoiceWasUpdated.
|
* Class InvoiceWasUpdated.
|
||||||
*/
|
*/
|
||||||
class InvoiceWasUpdated
|
class InvoiceWasUpdated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
@ -26,13 +27,15 @@ class InvoiceWasUpdated
|
|||||||
*/
|
*/
|
||||||
public $invoice;
|
public $invoice;
|
||||||
|
|
||||||
|
public $company;
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @param Invoice $invoice
|
* @param Invoice $invoice
|
||||||
*/
|
*/
|
||||||
public function __construct(Invoice $invoice)
|
public function __construct(Invoice $invoice, Company $company)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
|
$this->company = $company;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentCompleted.
|
* Class PaymentCompleted.
|
||||||
*/
|
*/
|
||||||
class PaymentCompleted
|
class PaymentCompleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentFailed.
|
* Class PaymentFailed.
|
||||||
*/
|
*/
|
||||||
class PaymentFailed
|
class PaymentFailed
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasArchived.
|
* Class PaymentWasArchived.
|
||||||
*/
|
*/
|
||||||
class PaymentWasArchived
|
class PaymentWasArchived
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasCreated.
|
* Class PaymentWasCreated.
|
||||||
*/
|
*/
|
||||||
class PaymentWasCreated
|
class PaymentWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasDeleted.
|
* Class PaymentWasDeleted.
|
||||||
*/
|
*/
|
||||||
class PaymentWasDeleted
|
class PaymentWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasRefunded.
|
* Class PaymentWasRefunded.
|
||||||
*/
|
*/
|
||||||
class PaymentWasRefunded
|
class PaymentWasRefunded
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasRestored.
|
* Class PaymentWasRestored.
|
||||||
*/
|
*/
|
||||||
class PaymentWasRestored
|
class PaymentWasRestored
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class PaymentWasVoided.
|
* Class PaymentWasVoided.
|
||||||
*/
|
*/
|
||||||
class PaymentWasVoided
|
class PaymentWasVoided
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace App\Events\Product;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class ProductWasDeleted
|
class ProductWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class QuoteWasCreated.
|
* Class QuoteWasCreated.
|
||||||
*/
|
*/
|
||||||
class QuoteWasCreated
|
class QuoteWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
public $quote;
|
public $quote;
|
||||||
|
@ -16,7 +16,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class QuoteWasDeleted.
|
* Class QuoteWasDeleted.
|
||||||
*/
|
*/
|
||||||
class QuoteWasDeleted
|
class QuoteWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
public $quote;
|
public $quote;
|
||||||
|
@ -16,7 +16,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class QuoteWasEmailed.
|
* Class QuoteWasEmailed.
|
||||||
*/
|
*/
|
||||||
class QuoteWasEmailed
|
class QuoteWasEmailed
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
public $quote;
|
public $quote;
|
||||||
|
@ -16,7 +16,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class QuoteWasRestored.
|
* Class QuoteWasRestored.
|
||||||
*/
|
*/
|
||||||
class QuoteWasRestored
|
class QuoteWasRestored
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
public $quote;
|
public $quote;
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class TaskWasArchived.
|
* Class TaskWasArchived.
|
||||||
*/
|
*/
|
||||||
class TaskWasArchived
|
class TaskWasArchived
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class TaskWasCreated.
|
* Class TaskWasCreated.
|
||||||
*/
|
*/
|
||||||
class TaskWasCreated
|
class TaskWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class TaskWasDeleted.
|
* Class TaskWasDeleted.
|
||||||
*/
|
*/
|
||||||
class TaskWasDeleted
|
class TaskWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class TaskWasRestored.
|
* Class TaskWasRestored.
|
||||||
*/
|
*/
|
||||||
class TaskWasRestored
|
class TaskWasRestored
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class TaskWasUpdated.
|
* Class TaskWasUpdated.
|
||||||
*/
|
*/
|
||||||
class TaskWasUpdated
|
class TaskWasUpdated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -39,9 +39,7 @@ class UserLoggedIn
|
|||||||
*/
|
*/
|
||||||
public function __construct($user)
|
public function __construct($user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
app/Events/Vendor/VendorWasArchived.php
vendored
2
app/Events/Vendor/VendorWasArchived.php
vendored
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class VendorWasArchived.
|
* Class VendorWasArchived.
|
||||||
*/
|
*/
|
||||||
class VendorWasArchived
|
class VendorWasArchived
|
||||||
{
|
{
|
||||||
// vendor
|
// vendor
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
2
app/Events/Vendor/VendorWasCreated.php
vendored
2
app/Events/Vendor/VendorWasCreated.php
vendored
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class VendorWasCreated.
|
* Class VendorWasCreated.
|
||||||
*/
|
*/
|
||||||
class VendorWasCreated
|
class VendorWasCreated
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
2
app/Events/Vendor/VendorWasDeleted.php
vendored
2
app/Events/Vendor/VendorWasDeleted.php
vendored
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class VendorWasDeleted.
|
* Class VendorWasDeleted.
|
||||||
*/
|
*/
|
||||||
class VendorWasDeleted
|
class VendorWasDeleted
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
2
app/Events/Vendor/VendorWasRestored.php
vendored
2
app/Events/Vendor/VendorWasRestored.php
vendored
@ -17,7 +17,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class VendorWasRestored.
|
* Class VendorWasRestored.
|
||||||
*/
|
*/
|
||||||
class VendorWasRestored
|
class VendorWasRestored
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@ -70,47 +70,32 @@ class Handler extends ExceptionHandler
|
|||||||
|
|
||||||
public function render($request, Exception $exception)
|
public function render($request, Exception $exception)
|
||||||
{
|
{
|
||||||
|
if ($exception instanceof ModelNotFoundException && $request->expectsJson()) {
|
||||||
if ($exception instanceof ModelNotFoundException && $request->expectsJson())
|
return response()->json(['message'=>'Record not found'], 400);
|
||||||
{
|
} elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
|
||||||
return response()->json(['message'=>'Record not found'],400);
|
return response()->json(['message'=>'Too many requests'], 429);
|
||||||
}
|
} elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
|
||||||
else if($exception instanceof ThrottleRequestsException && $request->expectsJson())
|
|
||||||
{
|
|
||||||
return response()->json(['message'=>'Too many requests'],429);
|
|
||||||
}
|
|
||||||
else if($exception instanceof FatalThrowableError && $request->expectsJson())
|
|
||||||
{
|
|
||||||
return response()->json(['message'=>'Fatal error'], 500);
|
return response()->json(['message'=>'Fatal error'], 500);
|
||||||
}
|
} elseif ($exception instanceof AuthorizationException) {
|
||||||
else if($exception instanceof AuthorizationException)
|
return response()->json(['message'=>'You are not authorized to view or perform this action'], 401);
|
||||||
{
|
} elseif ($exception instanceof \Illuminate\Session\TokenMismatchException) {
|
||||||
return response()->json(['message'=>'You are not authorized to view or perform this action'],401);
|
|
||||||
}
|
|
||||||
else if ($exception instanceof \Illuminate\Session\TokenMismatchException)
|
|
||||||
{
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->back()
|
->back()
|
||||||
->withInput($request->except('password', 'password_confirmation', '_token'))
|
->withInput($request->except('password', 'password_confirmation', '_token'))
|
||||||
->with([
|
->with([
|
||||||
'message' => ctrans('texts.token_expired'),
|
'message' => ctrans('texts.token_expired'),
|
||||||
'message-type' => 'danger']);
|
'message-type' => 'danger']);
|
||||||
}
|
} elseif ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
||||||
else if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
return response()->json(['message'=>'Route does not exist'], 404);
|
||||||
return response()->json(['message'=>'Route does not exist'],404);
|
} elseif ($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()) {
|
||||||
}
|
return response()->json(['message'=>'Method not support for this route'], 404);
|
||||||
else if($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()){
|
} elseif ($exception instanceof ValidationException && $request->expectsJson()) {
|
||||||
return response()->json(['message'=>'Method not support for this route'],404);
|
|
||||||
}
|
|
||||||
else if ($exception instanceof ValidationException && $request->expectsJson()) {
|
|
||||||
return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422);
|
return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422);
|
||||||
}
|
} elseif ($exception instanceof RelationNotFoundException && $request->expectsJson()) {
|
||||||
else if ($exception instanceof RelationNotFoundException && $request->expectsJson()) {
|
|
||||||
return response()->json(['message' => $exception->getMessage()], 400);
|
return response()->json(['message' => $exception->getMessage()], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,15 +15,15 @@ use App\Models\ClientContact;
|
|||||||
|
|
||||||
class ClientContactFactory
|
class ClientContactFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :ClientContact
|
public static function create(int $company_id, int $user_id) :ClientContact
|
||||||
{
|
{
|
||||||
$client_contact = new ClientContact;
|
$client_contact = new ClientContact;
|
||||||
$client_contact->first_name = "";
|
$client_contact->first_name = "";
|
||||||
$client_contact->user_id = $user_id;
|
$client_contact->user_id = $user_id;
|
||||||
$client_contact->company_id = $company_id;
|
$client_contact->company_id = $company_id;
|
||||||
$client_contact->contact_key = \Illuminate\Support\Str::random(40);
|
$client_contact->contact_key = \Illuminate\Support\Str::random(40);
|
||||||
$client_contact->id = 0;
|
$client_contact->id = 0;
|
||||||
|
|
||||||
return $client_contact;
|
return $client_contact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,24 +17,24 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class ClientFactory
|
class ClientFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :Client
|
public static function create(int $company_id, int $user_id) :Client
|
||||||
{
|
{
|
||||||
$client = new Client;
|
$client = new Client;
|
||||||
$client->company_id = $company_id;
|
$client->company_id = $company_id;
|
||||||
$client->user_id = $user_id;
|
$client->user_id = $user_id;
|
||||||
$client->name = '';
|
$client->name = '';
|
||||||
$client->website = '';
|
$client->website = '';
|
||||||
$client->private_notes = '';
|
$client->private_notes = '';
|
||||||
$client->balance = 0;
|
$client->balance = 0;
|
||||||
$client->paid_to_date = 0;
|
$client->paid_to_date = 0;
|
||||||
$client->country_id = 4;
|
$client->country_id = 4;
|
||||||
$client->is_deleted = 0;
|
$client->is_deleted = 0;
|
||||||
$client->client_hash = Str::random(40);
|
$client->client_hash = Str::random(40);
|
||||||
$client->settings = ClientSettings::defaults();
|
$client->settings = ClientSettings::defaults();
|
||||||
|
|
||||||
$client_contact = ClientContactFactory::create($company_id, $user_id);
|
$client_contact = ClientContactFactory::create($company_id, $user_id);
|
||||||
$client->contacts->add($client_contact);
|
$client->contacts->add($client_contact);
|
||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,19 @@ use App\Models\Invoice;
|
|||||||
|
|
||||||
class CloneInvoiceFactory
|
class CloneInvoiceFactory
|
||||||
{
|
{
|
||||||
public static function create(Invoice $invoice, $user_id) : ?Invoice
|
public static function create(Invoice $invoice, $user_id) : ?Invoice
|
||||||
{
|
{
|
||||||
$clone_invoice = $invoice->replicate();
|
$clone_invoice = $invoice->replicate();
|
||||||
$clone_invoice->status_id = Invoice::STATUS_DRAFT;
|
$clone_invoice->status_id = Invoice::STATUS_DRAFT;
|
||||||
$clone_invoice->number = NULL;
|
$clone_invoice->number = null;
|
||||||
$clone_invoice->date = null;
|
$clone_invoice->date = null;
|
||||||
$clone_invoice->due_date = null;
|
$clone_invoice->due_date = null;
|
||||||
$clone_invoice->partial_due_date = null;
|
$clone_invoice->partial_due_date = null;
|
||||||
$clone_invoice->user_id = $user_id;
|
$clone_invoice->user_id = $user_id;
|
||||||
$clone_invoice->balance = $invoice->amount;
|
$clone_invoice->balance = $invoice->amount;
|
||||||
$clone_invoice->line_items = $invoice->line_items;
|
$clone_invoice->line_items = $invoice->line_items;
|
||||||
$clone_invoice->backup = null;
|
$clone_invoice->backup = null;
|
||||||
|
|
||||||
return $clone_invoice;
|
return $clone_invoice;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -16,45 +16,43 @@ use App\Models\Quote;
|
|||||||
|
|
||||||
class CloneInvoiceToQuoteFactory
|
class CloneInvoiceToQuoteFactory
|
||||||
{
|
{
|
||||||
public static function create(Invoice $invoice, $user_id) : ?Quote
|
public static function create(Invoice $invoice, $user_id) : ?Quote
|
||||||
{
|
{
|
||||||
|
$quote = new Quote();
|
||||||
|
$quote->client_id = $invoice->client_id;
|
||||||
|
$quote->user_id = $user_id;
|
||||||
|
$quote->company_id = $invoice->company_id;
|
||||||
|
$quote->discount = $invoice->discount;
|
||||||
|
$quote->is_amount_discount = $invoice->is_amount_discount;
|
||||||
|
$quote->po_number = $invoice->po_number;
|
||||||
|
$quote->is_deleted = false;
|
||||||
|
$quote->backup = null;
|
||||||
|
$quote->footer = $invoice->footer;
|
||||||
|
$quote->public_notes = $invoice->public_notes;
|
||||||
|
$quote->private_notes = $invoice->private_notes;
|
||||||
|
$quote->terms = $invoice->terms;
|
||||||
|
$quote->tax_name1 = $invoice->tax_name1;
|
||||||
|
$quote->tax_rate1 = $invoice->tax_rate1;
|
||||||
|
$quote->tax_name2 = $invoice->tax_name2;
|
||||||
|
$quote->tax_rate2 = $invoice->tax_rate2;
|
||||||
|
$quote->custom_value1 = $invoice->custom_value1;
|
||||||
|
$quote->custom_value2 = $invoice->custom_value2;
|
||||||
|
$quote->custom_value3 = $invoice->custom_value3;
|
||||||
|
$quote->custom_value4 = $invoice->custom_value4;
|
||||||
|
$quote->amount = $invoice->amount;
|
||||||
|
$quote->balance = $invoice->balance;
|
||||||
|
$quote->partial = $invoice->partial;
|
||||||
|
$quote->partial_due_date = $invoice->partial_due_date;
|
||||||
|
$quote->last_viewed = $invoice->last_viewed;
|
||||||
|
|
||||||
$quote = new Quote();
|
$quote->status_id = Quote::STATUS_DRAFT;
|
||||||
$quote->client_id = $invoice->client_id;
|
$quote->number = '';
|
||||||
$quote->user_id = $user_id;
|
$quote->date = null;
|
||||||
$quote->company_id = $invoice->company_id;
|
$quote->due_date = null;
|
||||||
$quote->discount = $invoice->discount;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_amount_discount = $invoice->is_amount_discount;
|
$quote->balance = $invoice->amount;
|
||||||
$quote->po_number = $invoice->po_number;
|
$quote->line_items = $invoice->line_items;
|
||||||
$quote->is_deleted = false;
|
|
||||||
$quote->backup = null;
|
|
||||||
$quote->footer = $invoice->footer;
|
|
||||||
$quote->public_notes = $invoice->public_notes;
|
|
||||||
$quote->private_notes = $invoice->private_notes;
|
|
||||||
$quote->terms = $invoice->terms;
|
|
||||||
$quote->tax_name1 = $invoice->tax_name1;
|
|
||||||
$quote->tax_rate1 = $invoice->tax_rate1;
|
|
||||||
$quote->tax_name2 = $invoice->tax_name2;
|
|
||||||
$quote->tax_rate2 = $invoice->tax_rate2;
|
|
||||||
$quote->custom_value1 = $invoice->custom_value1;
|
|
||||||
$quote->custom_value2 = $invoice->custom_value2;
|
|
||||||
$quote->custom_value3 = $invoice->custom_value3;
|
|
||||||
$quote->custom_value4 = $invoice->custom_value4;
|
|
||||||
$quote->amount = $invoice->amount;
|
|
||||||
$quote->balance = $invoice->balance;
|
|
||||||
$quote->partial = $invoice->partial;
|
|
||||||
$quote->partial_due_date = $invoice->partial_due_date;
|
|
||||||
$quote->last_viewed = $invoice->last_viewed;
|
|
||||||
|
|
||||||
$quote->status_id = Quote::STATUS_DRAFT;
|
return $quote;
|
||||||
$quote->number = '';
|
}
|
||||||
$quote->date = null;
|
}
|
||||||
$quote->due_date = null;
|
|
||||||
$quote->partial_due_date = null;
|
|
||||||
$quote->balance = $invoice->amount;
|
|
||||||
$quote->line_items = $invoice->line_items;
|
|
||||||
|
|
||||||
return $quote;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -17,14 +17,14 @@ use App\Utils\Traits\MakesHash;
|
|||||||
|
|
||||||
class CompanyFactory
|
class CompanyFactory
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $account_id
|
* @param int $account_id
|
||||||
* @return Company
|
* @return Company
|
||||||
*/
|
*/
|
||||||
public function create(int $account_id) :Company
|
public function create(int $account_id) :Company
|
||||||
{
|
{
|
||||||
$company = new Company;
|
$company = new Company;
|
||||||
// $company->name = '';
|
// $company->name = '';
|
||||||
$company->account_id = $account_id;
|
$company->account_id = $account_id;
|
||||||
|
@ -15,15 +15,12 @@ use App\Models\CompanyGateway;
|
|||||||
|
|
||||||
class CompanyGatewayFactory
|
class CompanyGatewayFactory
|
||||||
{
|
{
|
||||||
|
public static function create(int $company_id, int $user_id) :CompanyGateway
|
||||||
public static function create(int $company_id, int $user_id) :CompanyGateway
|
{
|
||||||
{
|
|
||||||
|
|
||||||
$company_gateway = new CompanyGateway;
|
$company_gateway = new CompanyGateway;
|
||||||
$company_gateway->company_id = $company_id;
|
$company_gateway->company_id = $company_id;
|
||||||
$company_gateway->user_id = $user_id;
|
$company_gateway->user_id = $user_id;
|
||||||
|
|
||||||
return $company_gateway;
|
return $company_gateway;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,17 @@ use App\Models\CompanyLedger;
|
|||||||
|
|
||||||
class CompanyLedgerFactory
|
class CompanyLedgerFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :CompanyLedger
|
public static function create(int $company_id, int $user_id) :CompanyLedger
|
||||||
{
|
{
|
||||||
$company_ledger = new CompanyLedger;
|
$company_ledger = new CompanyLedger;
|
||||||
$company_ledger->company_id = $company_id;
|
$company_ledger->company_id = $company_id;
|
||||||
$company_ledger->user_id = $user_id;
|
$company_ledger->user_id = $user_id;
|
||||||
$company_ledger->adjustment = 0;
|
$company_ledger->adjustment = 0;
|
||||||
$company_ledger->balance = 0;
|
$company_ledger->balance = 0;
|
||||||
$company_ledger->notes = '';
|
$company_ledger->notes = '';
|
||||||
$company_ledger->hash = '';
|
$company_ledger->hash = '';
|
||||||
$company_ledger->client_id = 0;
|
$company_ledger->client_id = 0;
|
||||||
|
|
||||||
return $company_ledger;
|
return $company_ledger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,13 @@ use App\Models\CompanyUser;
|
|||||||
|
|
||||||
class CompanyUserFactory
|
class CompanyUserFactory
|
||||||
{
|
{
|
||||||
|
public static function create($user_id, $company_id, $account_id) :CompanyUser
|
||||||
public static function create($user_id, $company_id, $account_id) :CompanyUser
|
{
|
||||||
{
|
|
||||||
|
|
||||||
$company_user = new CompanyUser;
|
$company_user = new CompanyUser;
|
||||||
$company_user->user_id = $user_id;
|
$company_user->user_id = $user_id;
|
||||||
$company_user->company_id = $company_id;
|
$company_user->company_id = $company_id;
|
||||||
$company_user->account_id = $account_id;
|
$company_user->account_id = $account_id;
|
||||||
|
|
||||||
return $company_user;
|
return $company_user;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,8 @@ use App\Models\GroupSetting;
|
|||||||
|
|
||||||
class GroupSettingFactory
|
class GroupSettingFactory
|
||||||
{
|
{
|
||||||
|
public static function create(int $company_id, int $user_id) :GroupSetting
|
||||||
public static function create(int $company_id, int $user_id) :GroupSetting
|
{
|
||||||
{
|
|
||||||
|
|
||||||
$gs = new GroupSetting;
|
$gs = new GroupSetting;
|
||||||
$gs->name = '';
|
$gs->name = '';
|
||||||
$gs->company_id = $company_id;
|
$gs->company_id = $company_id;
|
||||||
@ -26,6 +24,5 @@ class GroupSettingFactory
|
|||||||
$gs->settings = '{}';
|
$gs->settings = '{}';
|
||||||
|
|
||||||
return $gs;
|
return $gs;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,39 +18,39 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class InvoiceFactory
|
class InvoiceFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :Invoice
|
public static function create(int $company_id, int $user_id) :Invoice
|
||||||
{
|
{
|
||||||
$invoice = new Invoice();
|
$invoice = new Invoice();
|
||||||
$invoice->status_id = Invoice::STATUS_DRAFT;
|
$invoice->status_id = Invoice::STATUS_DRAFT;
|
||||||
$invoice->number = null;
|
$invoice->number = null;
|
||||||
$invoice->discount = 0;
|
$invoice->discount = 0;
|
||||||
$invoice->is_amount_discount = true;
|
$invoice->is_amount_discount = true;
|
||||||
$invoice->po_number = '';
|
$invoice->po_number = '';
|
||||||
$invoice->footer = '';
|
$invoice->footer = '';
|
||||||
$invoice->terms = '';
|
$invoice->terms = '';
|
||||||
$invoice->public_notes = '';
|
$invoice->public_notes = '';
|
||||||
$invoice->private_notes = '';
|
$invoice->private_notes = '';
|
||||||
$invoice->date = null;
|
$invoice->date = null;
|
||||||
$invoice->due_date = null;
|
$invoice->due_date = null;
|
||||||
$invoice->partial_due_date = null;
|
$invoice->partial_due_date = null;
|
||||||
$invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
$invoice->line_items = json_encode([]);
|
$invoice->line_items = json_encode([]);
|
||||||
$invoice->backup = json_encode([]);
|
$invoice->backup = json_encode([]);
|
||||||
$invoice->tax_name1 = '';
|
$invoice->tax_name1 = '';
|
||||||
$invoice->tax_rate1 = 0;
|
$invoice->tax_rate1 = 0;
|
||||||
$invoice->tax_name2 = '';
|
$invoice->tax_name2 = '';
|
||||||
$invoice->tax_rate2 = 0;
|
$invoice->tax_rate2 = 0;
|
||||||
$invoice->custom_value1 = 0;
|
$invoice->custom_value1 = 0;
|
||||||
$invoice->custom_value2 = 0;
|
$invoice->custom_value2 = 0;
|
||||||
$invoice->custom_value3 = 0;
|
$invoice->custom_value3 = 0;
|
||||||
$invoice->custom_value4 = 0;
|
$invoice->custom_value4 = 0;
|
||||||
$invoice->amount = 0;
|
$invoice->amount = 0;
|
||||||
$invoice->balance = 0;
|
$invoice->balance = 0;
|
||||||
$invoice->partial = 0;
|
$invoice->partial = 0;
|
||||||
$invoice->user_id = $user_id;
|
$invoice->user_id = $user_id;
|
||||||
$invoice->company_id = $company_id;
|
$invoice->company_id = $company_id;
|
||||||
$invoice->recurring_id = null;
|
$invoice->recurring_id = null;
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,23 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class InvoiceInvitationFactory
|
class InvoiceInvitationFactory
|
||||||
{
|
{
|
||||||
|
public static function create(int $company_id, int $user_id) :InvoiceInvitation
|
||||||
|
{
|
||||||
|
$ii = new InvoiceInvitation;
|
||||||
|
$ii->company_id = $company_id;
|
||||||
|
$ii->user_id = $user_id;
|
||||||
|
$ii->client_contact_id = null;
|
||||||
|
$ii->invoice_id = null;
|
||||||
|
$ii->key = Str::random(config('ninja.key_length'));
|
||||||
|
$ii->transaction_reference = null;
|
||||||
|
$ii->message_id = null;
|
||||||
|
$ii->email_error = '';
|
||||||
|
$ii->signature_base64 = '';
|
||||||
|
$ii->signature_date = null;
|
||||||
|
$ii->sent_date = null;
|
||||||
|
$ii->viewed_date = null;
|
||||||
|
$ii->opened_date = null;
|
||||||
|
|
||||||
public static function create(int $company_id, int $user_id) :InvoiceInvitation
|
return $ii;
|
||||||
{
|
}
|
||||||
$ii = new InvoiceInvitation;
|
|
||||||
$ii->company_id = $company_id;
|
|
||||||
$ii->user_id = $user_id;
|
|
||||||
$ii->client_contact_id = null;
|
|
||||||
$ii->invoice_id = null;
|
|
||||||
$ii->key = Str::random(config('ninja.key_length'));
|
|
||||||
$ii->transaction_reference = null;
|
|
||||||
$ii->message_id = null;
|
|
||||||
$ii->email_error = '';
|
|
||||||
$ii->signature_base64 = '';
|
|
||||||
$ii->signature_date = null;
|
|
||||||
$ii->sent_date = null;
|
|
||||||
$ii->viewed_date = null;
|
|
||||||
$ii->opened_date = null;
|
|
||||||
|
|
||||||
return $ii;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12,70 +12,67 @@
|
|||||||
namespace App\Factory;
|
namespace App\Factory;
|
||||||
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
//use Faker\Generator as Faker;
|
//use Faker\Generator as Faker;
|
||||||
|
|
||||||
class InvoiceItemFactory
|
class InvoiceItemFactory
|
||||||
{
|
{
|
||||||
public static function create() :\stdClass
|
public static function create() :\stdClass
|
||||||
{
|
{
|
||||||
$item = new \stdClass;
|
$item = new \stdClass;
|
||||||
$item->quantity = 0;
|
$item->quantity = 0;
|
||||||
$item->cost = 0;
|
$item->cost = 0;
|
||||||
$item->product_key = '';
|
$item->product_key = '';
|
||||||
$item->notes = '';
|
$item->notes = '';
|
||||||
$item->discount = 0;
|
$item->discount = 0;
|
||||||
$item->is_amount_discount = true;
|
$item->is_amount_discount = true;
|
||||||
$item->tax_name1 = '';
|
$item->tax_name1 = '';
|
||||||
$item->tax_rate1 = 0;
|
$item->tax_rate1 = 0;
|
||||||
$item->tax_name2 = '';
|
$item->tax_name2 = '';
|
||||||
$item->tax_rate2 = 0;
|
$item->tax_rate2 = 0;
|
||||||
$item->tax_name3 = '';
|
$item->tax_name3 = '';
|
||||||
$item->tax_rate3 = 0;
|
$item->tax_rate3 = 0;
|
||||||
$item->sort_id = 0;
|
$item->sort_id = 0;
|
||||||
$item->line_total = 0;
|
$item->line_total = 0;
|
||||||
$item->date = Carbon::now();
|
$item->date = Carbon::now();
|
||||||
$item->custom_value1 = NULL;
|
$item->custom_value1 = null;
|
||||||
$item->custom_value2 = NULL;
|
$item->custom_value2 = null;
|
||||||
$item->custom_value3 = NULL;
|
$item->custom_value3 = null;
|
||||||
$item->custom_value4 = NULL;
|
$item->custom_value4 = null;
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Generates an array of dummy data for invoice items
|
||||||
|
* @param int $items Number of line items to create
|
||||||
|
* @return array array of objects
|
||||||
|
*/
|
||||||
|
public static function generate(int $items = 1) :array
|
||||||
|
{
|
||||||
|
$faker = \Faker\Factory::create();
|
||||||
|
|
||||||
/**
|
$data = [];
|
||||||
* Generates an array of dummy data for invoice items
|
|
||||||
* @param int $items Number of line items to create
|
|
||||||
* @return array array of objects
|
|
||||||
*/
|
|
||||||
public static function generate(int $items = 1) :array
|
|
||||||
{
|
|
||||||
$faker = \Faker\Factory::create();
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
for($x=0; $x<$items; $x++)
|
|
||||||
{
|
|
||||||
|
|
||||||
$item = self::create();
|
|
||||||
$item->quantity = $faker->numberBetween(1,10);
|
|
||||||
$item->cost = $faker->randomFloat(2, 1, 1000);
|
|
||||||
$item->line_total = $item->quantity * $item->cost;
|
|
||||||
$item->is_amount_discount = true;
|
|
||||||
$item->discount = $faker->numberBetween(1,10);
|
|
||||||
$item->notes = $faker->realText(20);
|
|
||||||
$item->product_key = $faker->word();
|
|
||||||
$item->custom_value1 = $faker->realText(10);
|
|
||||||
$item->custom_value2 = $faker->realText(10);
|
|
||||||
$item->custom_value3 = $faker->realText(10);
|
|
||||||
$item->custom_value4 = $faker->realText(10);
|
|
||||||
$item->tax_name1 = 'GST';
|
|
||||||
$item->tax_rate1 = '10.00';
|
|
||||||
|
|
||||||
$data[] = $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for ($x=0; $x<$items; $x++) {
|
||||||
|
$item = self::create();
|
||||||
|
$item->quantity = $faker->numberBetween(1, 10);
|
||||||
|
$item->cost = $faker->randomFloat(2, 1, 1000);
|
||||||
|
$item->line_total = $item->quantity * $item->cost;
|
||||||
|
$item->is_amount_discount = true;
|
||||||
|
$item->discount = $faker->numberBetween(1, 10);
|
||||||
|
$item->notes = $faker->realText(20);
|
||||||
|
$item->product_key = $faker->word();
|
||||||
|
$item->custom_value1 = $faker->realText(10);
|
||||||
|
$item->custom_value2 = $faker->realText(10);
|
||||||
|
$item->custom_value3 = $faker->realText(10);
|
||||||
|
$item->custom_value4 = $faker->realText(10);
|
||||||
|
$item->tax_name1 = 'GST';
|
||||||
|
$item->tax_rate1 = '10.00';
|
||||||
|
|
||||||
|
$data[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,44 +18,42 @@ use App\Models\RecurringInvoice;
|
|||||||
|
|
||||||
class InvoiceToRecurringInvoiceFactory
|
class InvoiceToRecurringInvoiceFactory
|
||||||
{
|
{
|
||||||
|
public static function create(Invoice $invoice) :RecurringInvoice
|
||||||
|
{
|
||||||
|
$recurring_invoice = new RecurringInvoice;
|
||||||
|
|
||||||
public static function create(Invoice $invoice) :RecurringInvoice
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_DRAFT;
|
||||||
{
|
$recurring_invoice->discount = $invoice->discount;
|
||||||
$recurring_invoice = new RecurringInvoice;
|
$recurring_invoice->number = '';
|
||||||
|
$recurring_invoice->is_amount_discount = $invoice->is_amount_discount;
|
||||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_DRAFT;
|
$recurring_invoice->po_number = $invoice->po_number;
|
||||||
$recurring_invoice->discount = $invoice->discount;
|
$recurring_invoice->footer = $invoice->footer;
|
||||||
$recurring_invoice->number = '';
|
$recurring_invoice->terms = $invoice->terms;
|
||||||
$recurring_invoice->is_amount_discount = $invoice->is_amount_discount;
|
$recurring_invoice->public_notes = $invoice->public_notes;
|
||||||
$recurring_invoice->po_number = $invoice->po_number;
|
$recurring_invoice->private_notes = $invoice->private_notes;
|
||||||
$recurring_invoice->footer = $invoice->footer;
|
$recurring_invoice->date = date_create()->format($invoice->client->date_format());
|
||||||
$recurring_invoice->terms = $invoice->terms;
|
$recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms
|
||||||
$recurring_invoice->public_notes = $invoice->public_notes;
|
$recurring_invoice->is_deleted = $invoice->is_deleted;
|
||||||
$recurring_invoice->private_notes = $invoice->private_notes;
|
$recurring_invoice->line_items = $invoice->line_items;
|
||||||
$recurring_invoice->date = date_create()->format($invoice->client->date_format());
|
$recurring_invoice->tax_name1 = $invoice->tax_name1;
|
||||||
$recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms
|
$recurring_invoice->tax_rate1 = $invoice->tax_rate1;
|
||||||
$recurring_invoice->is_deleted = $invoice->is_deleted;
|
$recurring_invoice->tax_name2 = $invoice->tax_name2;
|
||||||
$recurring_invoice->line_items = $invoice->line_items;
|
$recurring_invoice->tax_rate2 = $invoice->tax_rate2;
|
||||||
$recurring_invoice->tax_name1 = $invoice->tax_name1;
|
$recurring_invoice->custom_value1 = $invoice->custom_value1;
|
||||||
$recurring_invoice->tax_rate1 = $invoice->tax_rate1;
|
$recurring_invoice->custom_value2 = $invoice->custom_value2;
|
||||||
$recurring_invoice->tax_name2 = $invoice->tax_name2;
|
$recurring_invoice->custom_value3 = $invoice->custom_value3;
|
||||||
$recurring_invoice->tax_rate2 = $invoice->tax_rate2;
|
$recurring_invoice->custom_value4 = $invoice->custom_value4;
|
||||||
$recurring_invoice->custom_value1 = $invoice->custom_value1;
|
$recurring_invoice->amount = $invoice->amount;
|
||||||
$recurring_invoice->custom_value2 = $invoice->custom_value2;
|
$recurring_invoice->balance = $invoice->balance;
|
||||||
$recurring_invoice->custom_value3 = $invoice->custom_value3;
|
$recurring_invoice->user_id = $invoice->user_id;
|
||||||
$recurring_invoice->custom_value4 = $invoice->custom_value4;
|
$recurring_invoice->client_id = $invoice->client_id;
|
||||||
$recurring_invoice->amount = $invoice->amount;
|
$recurring_invoice->company_id = $invoice->company_id;
|
||||||
$recurring_invoice->balance = $invoice->balance;
|
$recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
||||||
$recurring_invoice->user_id = $invoice->user_id;
|
$recurring_invoice->start_date = null;
|
||||||
$recurring_invoice->client_id = $invoice->client_id;
|
$recurring_invoice->last_sent_date = null;
|
||||||
$recurring_invoice->company_id = $invoice->company_id;
|
$recurring_invoice->next_send_date = null;
|
||||||
$recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
$recurring_invoice->remaining_cycles = 0;
|
||||||
$recurring_invoice->start_date = null;
|
|
||||||
$recurring_invoice->last_sent_date = null;
|
|
||||||
$recurring_invoice->next_send_date = null;
|
|
||||||
$recurring_invoice->remaining_cycles = 0;
|
|
||||||
|
|
||||||
return $recurring_invoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $recurring_invoice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,27 +19,24 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class PaymentFactory
|
class PaymentFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :Payment
|
public static function create(int $company_id, int $user_id) :Payment
|
||||||
{
|
{
|
||||||
$payment = new Payment;
|
$payment = new Payment;
|
||||||
|
|
||||||
$payment->company_id = $company_id;
|
$payment->company_id = $company_id;
|
||||||
$payment->user_id = $user_id;
|
$payment->user_id = $user_id;
|
||||||
$payment->client_id = 0;
|
$payment->client_id = 0;
|
||||||
$payment->client_contact_id = null;
|
$payment->client_contact_id = null;
|
||||||
$payment->invitation_id = null;
|
$payment->invitation_id = null;
|
||||||
$payment->company_gateway_id = null;
|
$payment->company_gateway_id = null;
|
||||||
$payment->type_id = null;
|
$payment->type_id = null;
|
||||||
$payment->is_deleted = false;
|
$payment->is_deleted = false;
|
||||||
$payment->amount = 0;
|
$payment->amount = 0;
|
||||||
$payment->date = Carbon::now()->format('Y-m-d');
|
$payment->date = Carbon::now()->format('Y-m-d');
|
||||||
$payment->transaction_reference = null;
|
$payment->transaction_reference = null;
|
||||||
$payment->payer_id = null;
|
$payment->payer_id = null;
|
||||||
$payment->status_id = Payment::STATUS_PENDING;
|
$payment->status_id = Payment::STATUS_PENDING;
|
||||||
|
|
||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,29 +15,27 @@ use App\Models\Product;
|
|||||||
|
|
||||||
class ProductFactory
|
class ProductFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :Product
|
public static function create(int $company_id, int $user_id) :Product
|
||||||
{
|
{
|
||||||
$product = new Product;
|
$product = new Product;
|
||||||
$product->company_id = $company_id;
|
$product->company_id = $company_id;
|
||||||
$product->user_id = $user_id;
|
$product->user_id = $user_id;
|
||||||
|
|
||||||
$product->product_key = '';
|
$product->product_key = '';
|
||||||
$product->notes = '';
|
$product->notes = '';
|
||||||
$product->cost = 0;
|
$product->cost = 0;
|
||||||
$product->price = 0;
|
$product->price = 0;
|
||||||
$product->quantity = 1;
|
$product->quantity = 1;
|
||||||
$product->tax_name1 = '';
|
$product->tax_name1 = '';
|
||||||
$product->tax_rate1 = 0;
|
$product->tax_rate1 = 0;
|
||||||
$product->tax_name2 = '';
|
$product->tax_name2 = '';
|
||||||
$product->tax_rate2 = 0;
|
$product->tax_rate2 = 0;
|
||||||
$product->custom_value1 = '';
|
$product->custom_value1 = '';
|
||||||
$product->custom_value2 = '';
|
$product->custom_value2 = '';
|
||||||
$product->custom_value3 = '';
|
$product->custom_value3 = '';
|
||||||
$product->custom_value4 = '';
|
$product->custom_value4 = '';
|
||||||
$product->is_deleted = 0;
|
$product->is_deleted = 0;
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,38 +18,38 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class QuoteFactory
|
class QuoteFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :Quote
|
public static function create(int $company_id, int $user_id) :Quote
|
||||||
{
|
{
|
||||||
$quote = new Quote();
|
$quote = new Quote();
|
||||||
$quote->status_id = Quote::STATUS_DRAFT;
|
$quote->status_id = Quote::STATUS_DRAFT;
|
||||||
$quote->number = null;
|
$quote->number = null;
|
||||||
$quote->discount = 0;
|
$quote->discount = 0;
|
||||||
$quote->is_amount_discount = true;
|
$quote->is_amount_discount = true;
|
||||||
$quote->po_number = '';
|
$quote->po_number = '';
|
||||||
$quote->footer = '';
|
$quote->footer = '';
|
||||||
$quote->terms = '';
|
$quote->terms = '';
|
||||||
$quote->public_notes = '';
|
$quote->public_notes = '';
|
||||||
$quote->private_notes = '';
|
$quote->private_notes = '';
|
||||||
$quote->date = null;
|
$quote->date = null;
|
||||||
$quote->due_date = null;
|
$quote->due_date = null;
|
||||||
$quote->partial_due_date = null;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_deleted = false;
|
$quote->is_deleted = false;
|
||||||
$quote->line_items = json_encode([]);
|
$quote->line_items = json_encode([]);
|
||||||
$quote->backup = json_encode([]);
|
$quote->backup = json_encode([]);
|
||||||
$quote->tax_name1 = '';
|
$quote->tax_name1 = '';
|
||||||
$quote->tax_rate1 = 0;
|
$quote->tax_rate1 = 0;
|
||||||
$quote->tax_name2 = '';
|
$quote->tax_name2 = '';
|
||||||
$quote->tax_rate2 = 0;
|
$quote->tax_rate2 = 0;
|
||||||
$quote->custom_value1 = 0;
|
$quote->custom_value1 = 0;
|
||||||
$quote->custom_value2 = 0;
|
$quote->custom_value2 = 0;
|
||||||
$quote->custom_value3 = 0;
|
$quote->custom_value3 = 0;
|
||||||
$quote->custom_value4 = 0;
|
$quote->custom_value4 = 0;
|
||||||
$quote->amount = 0;
|
$quote->amount = 0;
|
||||||
$quote->balance = 0;
|
$quote->balance = 0;
|
||||||
$quote->partial = 0;
|
$quote->partial = 0;
|
||||||
$quote->user_id = $user_id;
|
$quote->user_id = $user_id;
|
||||||
$quote->company_id = $company_id;
|
$quote->company_id = $company_id;
|
||||||
|
|
||||||
return $quote;
|
return $quote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,23 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class QuoteInvitationFactory
|
class QuoteInvitationFactory
|
||||||
{
|
{
|
||||||
|
public static function create(int $company_id, int $user_id) :QuoteInvitation
|
||||||
|
{
|
||||||
|
$qi = new QuoteInvitation;
|
||||||
|
$qi->company_id = $company_id;
|
||||||
|
$qi->user_id = $user_id;
|
||||||
|
$qi->client_contact_id = null;
|
||||||
|
$qi->quote_id = null;
|
||||||
|
$qi->key = Str::random(config('ninja.key_length'));
|
||||||
|
$qi->transaction_reference = null;
|
||||||
|
$qi->message_id = null;
|
||||||
|
$qi->email_error = '';
|
||||||
|
$qi->signature_base64 = '';
|
||||||
|
$qi->signature_date = null;
|
||||||
|
$qi->sent_date = null;
|
||||||
|
$qi->viewed_date = null;
|
||||||
|
$qi->opened_date = null;
|
||||||
|
|
||||||
public static function create(int $company_id, int $user_id) :QuoteInvitation
|
return $qi;
|
||||||
{
|
}
|
||||||
$qi = new QuoteInvitation;
|
|
||||||
$qi->company_id = $company_id;
|
|
||||||
$qi->user_id = $user_id;
|
|
||||||
$qi->client_contact_id = null;
|
|
||||||
$qi->quote_id = null;
|
|
||||||
$qi->key = Str::random(config('ninja.key_length'));
|
|
||||||
$qi->transaction_reference = null;
|
|
||||||
$qi->message_id = null;
|
|
||||||
$qi->email_error = '';
|
|
||||||
$qi->signature_base64 = '';
|
|
||||||
$qi->signature_date = null;
|
|
||||||
$qi->sent_date = null;
|
|
||||||
$qi->viewed_date = null;
|
|
||||||
$qi->opened_date = null;
|
|
||||||
|
|
||||||
return $qi;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17,44 +17,43 @@ use App\Models\RecurringInvoice;
|
|||||||
|
|
||||||
class RecurringInvoiceFactory
|
class RecurringInvoiceFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :RecurringInvoice
|
public static function create(int $company_id, int $user_id) :RecurringInvoice
|
||||||
{
|
{
|
||||||
$invoice = new RecurringInvoice();
|
$invoice = new RecurringInvoice();
|
||||||
$invoice->status_id = RecurringInvoice::STATUS_DRAFT;
|
$invoice->status_id = RecurringInvoice::STATUS_DRAFT;
|
||||||
$invoice->discount = 0;
|
$invoice->discount = 0;
|
||||||
$invoice->is_amount_discount = true;
|
$invoice->is_amount_discount = true;
|
||||||
$invoice->po_number = '';
|
$invoice->po_number = '';
|
||||||
$invoice->number = '';
|
$invoice->number = '';
|
||||||
$invoice->footer = '';
|
$invoice->footer = '';
|
||||||
$invoice->terms = '';
|
$invoice->terms = '';
|
||||||
$invoice->public_notes = '';
|
$invoice->public_notes = '';
|
||||||
$invoice->private_notes = '';
|
$invoice->private_notes = '';
|
||||||
$invoice->date = null;
|
$invoice->date = null;
|
||||||
$invoice->due_date = null;
|
$invoice->due_date = null;
|
||||||
$invoice->partial_due_date = null;
|
$invoice->partial_due_date = null;
|
||||||
$invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
$invoice->line_items = json_encode([]);
|
$invoice->line_items = json_encode([]);
|
||||||
$invoice->backup = json_encode([]);
|
$invoice->backup = json_encode([]);
|
||||||
$invoice->tax_name1 = '';
|
$invoice->tax_name1 = '';
|
||||||
$invoice->tax_rate1 = 0;
|
$invoice->tax_rate1 = 0;
|
||||||
$invoice->tax_name2 = '';
|
$invoice->tax_name2 = '';
|
||||||
$invoice->tax_rate2 = 0;
|
$invoice->tax_rate2 = 0;
|
||||||
$invoice->custom_value1 = 0;
|
$invoice->custom_value1 = 0;
|
||||||
$invoice->custom_value2 = 0;
|
$invoice->custom_value2 = 0;
|
||||||
$invoice->custom_value3 = 0;
|
$invoice->custom_value3 = 0;
|
||||||
$invoice->custom_value4 = 0;
|
$invoice->custom_value4 = 0;
|
||||||
$invoice->amount = 0;
|
$invoice->amount = 0;
|
||||||
$invoice->balance = 0;
|
$invoice->balance = 0;
|
||||||
$invoice->partial = 0;
|
$invoice->partial = 0;
|
||||||
$invoice->user_id = $user_id;
|
$invoice->user_id = $user_id;
|
||||||
$invoice->company_id = $company_id;
|
$invoice->company_id = $company_id;
|
||||||
$invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
$invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
||||||
$invoice->start_date = null;
|
$invoice->start_date = null;
|
||||||
$invoice->last_sent_date = null;
|
$invoice->last_sent_date = null;
|
||||||
$invoice->next_send_date = null;
|
$invoice->next_send_date = null;
|
||||||
$invoice->remaining_cycles = 0;
|
$invoice->remaining_cycles = 0;
|
||||||
|
|
||||||
return $invoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $invoice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,38 +18,36 @@ use App\Models\RecurringInvoice;
|
|||||||
|
|
||||||
class recurring_invoiceToInvoiceFactory
|
class recurring_invoiceToInvoiceFactory
|
||||||
{
|
{
|
||||||
|
public static function create(RecurringInvoice $recurring_invoice) :Invoice
|
||||||
public static function create(RecurringInvoice $recurring_invoice) :Invoice
|
{
|
||||||
{
|
$invoice = new Invoice();
|
||||||
$invoice = new Invoice();
|
$invoice->status_id = Invoice::STATUS_DRAFT;
|
||||||
$invoice->status_id = Invoice::STATUS_DRAFT;
|
$invoice->discount = $recurring_invoice->discount;
|
||||||
$invoice->discount = $recurring_invoice->discount;
|
$invoice->is_amount_discount = $recurring_invoice->is_amount_discount;
|
||||||
$invoice->is_amount_discount = $recurring_invoice->is_amount_discount;
|
$invoice->po_number = $recurring_invoice->po_number;
|
||||||
$invoice->po_number = $recurring_invoice->po_number;
|
$invoice->footer = $recurring_invoice->footer;
|
||||||
$invoice->footer = $recurring_invoice->footer;
|
$invoice->terms = $recurring_invoice->terms;
|
||||||
$invoice->terms = $recurring_invoice->terms;
|
$invoice->public_notes = $recurring_invoice->public_notes;
|
||||||
$invoice->public_notes = $recurring_invoice->public_notes;
|
$invoice->private_notes = $recurring_invoice->private_notes;
|
||||||
$invoice->private_notes = $recurring_invoice->private_notes;
|
$invoice->date = date_create()->format($client->date_format());
|
||||||
$invoice->date = date_create()->format($client->date_format());
|
$invoice->due_date = $recurring_invoice->due_date; //todo calculate based on terms
|
||||||
$invoice->due_date = $recurring_invoice->due_date; //todo calculate based on terms
|
$invoice->is_deleted = $recurring_invoice->is_deleted;
|
||||||
$invoice->is_deleted = $recurring_invoice->is_deleted;
|
$invoice->line_items = $recurring_invoice->line_items;
|
||||||
$invoice->line_items = $recurring_invoice->line_items;
|
$invoice->backup = json_encode([]);
|
||||||
$invoice->backup = json_encode([]);
|
$invoice->tax_name1 = $recurring_invoice->tax_name1;
|
||||||
$invoice->tax_name1 = $recurring_invoice->tax_name1;
|
$invoice->tax_rate1 = $recurring_invoice->tax_rate1;
|
||||||
$invoice->tax_rate1 = $recurring_invoice->tax_rate1;
|
$invoice->tax_name2 = $recurring_invoice->tax_name2;
|
||||||
$invoice->tax_name2 = $recurring_invoice->tax_name2;
|
$invoice->tax_rate2 = $recurring_invoice->tax_rate2;
|
||||||
$invoice->tax_rate2 = $recurring_invoice->tax_rate2;
|
$invoice->custom_value1 = $recurring_invoice->custom_value1;
|
||||||
$invoice->custom_value1 = $recurring_invoice->custom_value1;
|
$invoice->custom_value2 = $recurring_invoice->custom_value2;
|
||||||
$invoice->custom_value2 = $recurring_invoice->custom_value2;
|
$invoice->custom_value3 = $recurring_invoice->custom_value3;
|
||||||
$invoice->custom_value3 = $recurring_invoice->custom_value3;
|
$invoice->custom_value4 = $recurring_invoice->custom_value4;
|
||||||
$invoice->custom_value4 = $recurring_invoice->custom_value4;
|
$invoice->amount = $recurring_invoice->amount;
|
||||||
$invoice->amount = $recurring_invoice->amount;
|
$invoice->balance = $recurring_invoice->balance;
|
||||||
$invoice->balance = $recurring_invoice->balance;
|
$invoice->user_id = $recurring_invoice->user_id;
|
||||||
$invoice->user_id = $recurring_invoice->user_id;
|
$invoice->company_id = $recurring_invoice->company_id;
|
||||||
$invoice->company_id = $recurring_invoice->company_id;
|
$invoice->recurring_id = $recurring_invoice->id;
|
||||||
$invoice->recurring_id = $recurring_invoice->id;
|
|
||||||
|
return $invoice;
|
||||||
return $invoice;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,43 +17,42 @@ use App\Models\RecurringQuote;
|
|||||||
|
|
||||||
class RecurringQuoteFactory
|
class RecurringQuoteFactory
|
||||||
{
|
{
|
||||||
public static function create(int $company_id, int $user_id) :RecurringQuote
|
public static function create(int $company_id, int $user_id) :RecurringQuote
|
||||||
{
|
{
|
||||||
$quote = new RecurringQuote();
|
$quote = new RecurringQuote();
|
||||||
$quote->status_id = RecurringQuote::STATUS_DRAFT;
|
$quote->status_id = RecurringQuote::STATUS_DRAFT;
|
||||||
$quote->discount = 0;
|
$quote->discount = 0;
|
||||||
$quote->is_amount_discount = true;
|
$quote->is_amount_discount = true;
|
||||||
$quote->po_number = '';
|
$quote->po_number = '';
|
||||||
$quote->footer = '';
|
$quote->footer = '';
|
||||||
$quote->terms = '';
|
$quote->terms = '';
|
||||||
$quote->public_notes = '';
|
$quote->public_notes = '';
|
||||||
$quote->private_notes = '';
|
$quote->private_notes = '';
|
||||||
$quote->date = null;
|
$quote->date = null;
|
||||||
$quote->due_date = null;
|
$quote->due_date = null;
|
||||||
$quote->partial_due_date = null;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_deleted = false;
|
$quote->is_deleted = false;
|
||||||
$quote->line_items = json_encode([]);
|
$quote->line_items = json_encode([]);
|
||||||
$quote->backup = json_encode([]);
|
$quote->backup = json_encode([]);
|
||||||
$quote->tax_name1 = '';
|
$quote->tax_name1 = '';
|
||||||
$quote->tax_rate1 = 0;
|
$quote->tax_rate1 = 0;
|
||||||
$quote->tax_name2 = '';
|
$quote->tax_name2 = '';
|
||||||
$quote->tax_rate2 = 0;
|
$quote->tax_rate2 = 0;
|
||||||
$quote->custom_value1 = 0;
|
$quote->custom_value1 = 0;
|
||||||
$quote->custom_value2 = 0;
|
$quote->custom_value2 = 0;
|
||||||
$quote->custom_value3 = 0;
|
$quote->custom_value3 = 0;
|
||||||
$quote->custom_value4 = 0;
|
$quote->custom_value4 = 0;
|
||||||
$quote->amount = 0;
|
$quote->amount = 0;
|
||||||
$quote->balance = 0;
|
$quote->balance = 0;
|
||||||
$quote->partial = 0;
|
$quote->partial = 0;
|
||||||
$quote->user_id = $user_id;
|
$quote->user_id = $user_id;
|
||||||
$quote->company_id = $company_id;
|
$quote->company_id = $company_id;
|
||||||
$quote->frequency_id = RecurringQuote::FREQUENCY_MONTHLY;
|
$quote->frequency_id = RecurringQuote::FREQUENCY_MONTHLY;
|
||||||
$quote->start_date = null;
|
$quote->start_date = null;
|
||||||
$quote->last_sent_date = null;
|
$quote->last_sent_date = null;
|
||||||
$quote->next_send_date = null;
|
$quote->next_send_date = null;
|
||||||
$quote->remaining_cycles = 0;
|
$quote->remaining_cycles = 0;
|
||||||
|
|
||||||
return $quote;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $quote;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,15 @@ use App\Models\TaxRate;
|
|||||||
|
|
||||||
class TaxRateFactory
|
class TaxRateFactory
|
||||||
{
|
{
|
||||||
|
public static function create($company_id, $user_id) :TaxRate
|
||||||
|
{
|
||||||
|
$tax_rate = new TaxRate;
|
||||||
|
|
||||||
public static function create($company_id, $user_id) :TaxRate
|
$tax_rate->name = '';
|
||||||
{
|
$tax_rate->rate = '';
|
||||||
$tax_rate = new TaxRate;
|
$tax_rate->company_id = $company_id;
|
||||||
|
$tax_rate->user_id = $user_id;
|
||||||
|
|
||||||
$tax_rate->name = '';
|
return $tax_rate;
|
||||||
$tax_rate->rate = '';
|
}
|
||||||
$tax_rate->company_id = $company_id;
|
}
|
||||||
$tax_rate->user_id = $user_id;
|
|
||||||
|
|
||||||
return $tax_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -15,19 +15,19 @@ use App\Models\User;
|
|||||||
|
|
||||||
class UserFactory
|
class UserFactory
|
||||||
{
|
{
|
||||||
public static function create() :User
|
public static function create() :User
|
||||||
{
|
{
|
||||||
$user = new User;
|
$user = new User;
|
||||||
|
|
||||||
$user->first_name = '';
|
$user->first_name = '';
|
||||||
$user->last_name = '';
|
$user->last_name = '';
|
||||||
$user->phone = '';
|
$user->phone = '';
|
||||||
$user->email = '';
|
$user->email = '';
|
||||||
$user->last_login = now();
|
$user->last_login = now();
|
||||||
$user->failed_logins = 0;
|
$user->failed_logins = 0;
|
||||||
$user->signature = '';
|
$user->signature = '';
|
||||||
$user->theme_id = 0;
|
$user->theme_id = 0;
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter by balance
|
* Filter by balance
|
||||||
*
|
*
|
||||||
* @param string $balance
|
* @param string $balance
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function balance(string $balance): Builder
|
public function balance(string $balance): Builder
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter between balances
|
* Filter between balances
|
||||||
*
|
*
|
||||||
* @param string balance
|
* @param string balance
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -51,41 +51,43 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('clients.name', 'like', '%'.$filter.'%')
|
$query->where('clients.name', 'like', '%'.$filter.'%')
|
||||||
->orWhere('clients.id_number', 'like', '%'.$filter.'%')
|
->orWhere('clients.id_number', 'like', '%'.$filter.'%')
|
||||||
->orWhere('client_contacts.first_name', 'like', '%'.$filter.'%')
|
->orWhere('client_contacts.first_name', 'like', '%'.$filter.'%')
|
||||||
->orWhere('client_contacts.last_name', 'like', '%'.$filter.'%')
|
->orWhere('client_contacts.last_name', 'like', '%'.$filter.'%')
|
||||||
->orWhere('client_contacts.email', 'like', '%'.$filter.'%')
|
->orWhere('client_contacts.email', 'like', '%'.$filter.'%')
|
||||||
->orWhere('clients.custom_value1', 'like' , '%'.$filter.'%')
|
->orWhere('clients.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('clients.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('clients.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('clients.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('clients.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('clients.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('clients.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'clients';
|
$table = 'clients';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -115,7 +117,7 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -127,7 +129,7 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -181,16 +183,14 @@ class ClientFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
|
||||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||||
return $this->builder->company();
|
return $this->builder->company();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -33,7 +33,7 @@ class InvoiceFilters extends QueryFilters
|
|||||||
* - unpaid
|
* - unpaid
|
||||||
* - overdue
|
* - overdue
|
||||||
* - reversed
|
* - reversed
|
||||||
*
|
*
|
||||||
* @param string client_status The invoice status as seen by the client
|
* @param string client_status The invoice status as seen by the client
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*
|
*
|
||||||
@ -41,67 +41,74 @@ class InvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
public function client_status(string $value = '') :Builder
|
public function client_status(string $value = '') :Builder
|
||||||
{
|
{
|
||||||
if(strlen($value) == 0)
|
if (strlen($value) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$status_parameters = explode(",", $value);
|
$status_parameters = explode(",", $value);
|
||||||
|
|
||||||
if (in_array('all', $status_parameters))
|
if (in_array('all', $status_parameters)) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
if(in_array('paid', $status_parameters))
|
if (in_array('paid', $status_parameters)) {
|
||||||
$this->builder->where('status_id', Invoice::STATUS_PAID);
|
$this->builder->where('status_id', Invoice::STATUS_PAID);
|
||||||
|
}
|
||||||
|
|
||||||
if(in_array('unpaid', $status_parameters))
|
if (in_array('unpaid', $status_parameters)) {
|
||||||
$this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]);
|
$this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]);
|
||||||
//->where('due_date', '>', Carbon::now())
|
}
|
||||||
//->orWhere('partial_due_date', '>', Carbon::now());
|
//->where('due_date', '>', Carbon::now())
|
||||||
|
//->orWhere('partial_due_date', '>', Carbon::now());
|
||||||
|
|
||||||
if(in_array('overdue', $status_parameters))
|
if (in_array('overdue', $status_parameters)) {
|
||||||
$this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
$this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
->where('due_date', '<', Carbon::now())
|
->where('due_date', '<', Carbon::now())
|
||||||
->orWhere('partial_due_date', '<', Carbon::now());
|
->orWhere('partial_due_date', '<', Carbon::now());
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('invoices.number', 'like', '%'.$filter.'%')
|
$query->where('invoices.number', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.po_number', 'like', '%'.$filter.'%')
|
->orWhere('invoices.po_number', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.date', 'like', '%'.$filter.'%')
|
->orWhere('invoices.date', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.amount', 'like', '%'.$filter.'%')
|
->orWhere('invoices.amount', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.balance', 'like', '%'.$filter.'%')
|
->orWhere('invoices.balance', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('invoices.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('invoices.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('invoices.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('invoices.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('invoices.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted - legacy from V1
|
* archived, active, deleted - legacy from V1
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'invoices';
|
$table = 'invoices';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -131,7 +138,7 @@ class InvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -143,14 +150,13 @@ class InvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,37 +164,31 @@ class InvoiceFilters extends QueryFilters
|
|||||||
*
|
*
|
||||||
* We need to ensure we are using the correct company ID
|
* We need to ensure we are using the correct company ID
|
||||||
* as we could be hitting this from either the client or company auth guard
|
* as we could be hitting this from either the client or company auth guard
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
if (auth('contact')->user()) {
|
||||||
if(auth('contact')->user())
|
|
||||||
return $this->contactViewFilter();
|
return $this->contactViewFilter();
|
||||||
else
|
} else {
|
||||||
return $this->builder->company();
|
return $this->builder->company();
|
||||||
|
}
|
||||||
|
|
||||||
// return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
// return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need additional filters when showing invoices for the
|
* We need additional filters when showing invoices for the
|
||||||
* client portal. Need to automatically exclude drafts and cancelled invoices
|
* client portal. Need to automatically exclude drafts and cancelled invoices
|
||||||
*
|
*
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
private function contactViewFilter() : Builder
|
private function contactViewFilter() : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->builder
|
return $this->builder
|
||||||
->whereCompanyId(auth('contact')->user()->company->id)
|
->whereCompanyId(auth('contact')->user()->company->id)
|
||||||
->whereNotIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_CANCELLED]);
|
->whereNotIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_CANCELLED]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -24,38 +24,40 @@ class PaymentFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('payments.amount', 'like', '%'.$filter.'%')
|
$query->where('payments.amount', 'like', '%'.$filter.'%')
|
||||||
->orWhere('payments.date', 'like', '%'.$filter.'%')
|
->orWhere('payments.date', 'like', '%'.$filter.'%')
|
||||||
->orWhere('payments.custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('payments.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('payments.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('payments.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('payments.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('payments.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('payments.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('payments.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'payments';
|
$table = 'payments';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -85,7 +87,7 @@ class PaymentFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -97,29 +99,28 @@ class PaymentFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
if (auth('contact')->user()) {
|
||||||
if(auth('contact')->user())
|
|
||||||
return $this->contactViewFilter();
|
return $this->contactViewFilter();
|
||||||
else
|
} else {
|
||||||
return $this->builder->company();
|
return $this->builder->company();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,15 +128,13 @@ class PaymentFilters extends QueryFilters
|
|||||||
/**
|
/**
|
||||||
* We need additional filters when showing invoices for the
|
* We need additional filters when showing invoices for the
|
||||||
* client portal. Need to automatically exclude drafts and cancelled invoices
|
* client portal. Need to automatically exclude drafts and cancelled invoices
|
||||||
*
|
*
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
private function contactViewFilter() : Builder
|
private function contactViewFilter() : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->builder
|
return $this->builder
|
||||||
->whereCompanyId(auth('contact')->user()->company->id)
|
->whereCompanyId(auth('contact')->user()->company->id)
|
||||||
->whereIsDeleted(false);
|
->whereIsDeleted(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,38 +23,40 @@ class ProductFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('products.product_key', 'like', '%'.$filter.'%')
|
$query->where('products.product_key', 'like', '%'.$filter.'%')
|
||||||
->orWhere('products.notes', 'like', '%'.$filter.'%')
|
->orWhere('products.notes', 'like', '%'.$filter.'%')
|
||||||
->orWhere('products.custom_value1', 'like' , '%'.$filter.'%')
|
->orWhere('products.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('products.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('products.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('products.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('products.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('products.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('products.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'products';
|
$table = 'products';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -84,7 +86,7 @@ class ProductFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -96,27 +98,23 @@ class ProductFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
return $this->builder->company();
|
||||||
return $this->builder->company();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -59,9 +59,7 @@ abstract class QueryFilters
|
|||||||
*/
|
*/
|
||||||
public function __construct(Request $request)
|
public function __construct(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,20 +98,17 @@ abstract class QueryFilters
|
|||||||
*/
|
*/
|
||||||
public function filters()
|
public function filters()
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->request->all();
|
return $this->request->all();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explodes the value by delimiter
|
* Explodes the value by delimiter
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return stdClass
|
* @return stdClass
|
||||||
*/
|
*/
|
||||||
public function split($value) : stdClass
|
public function split($value) : stdClass
|
||||||
{
|
{
|
||||||
|
|
||||||
$exploded_array = explode(":", $value);
|
$exploded_array = explode(":", $value);
|
||||||
|
|
||||||
$parts = new stdClass;
|
$parts = new stdClass;
|
||||||
@ -122,18 +117,16 @@ abstract class QueryFilters
|
|||||||
$parts->operator = $this->operatorConvertor($exploded_array[1]);
|
$parts->operator = $this->operatorConvertor($exploded_array[1]);
|
||||||
|
|
||||||
return $parts;
|
return $parts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String to operator convertor
|
* String to operator convertor
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function operatorConvertor(string $operator) : string
|
private function operatorConvertor(string $operator) : string
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ($operator) {
|
switch ($operator) {
|
||||||
case 'lt':
|
case 'lt':
|
||||||
return '<';
|
return '<';
|
||||||
@ -159,15 +152,16 @@ abstract class QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the contact's client_id.
|
* Filters the query by the contact's client_id.
|
||||||
*
|
*
|
||||||
* -Can only be used on contact routes
|
* -Can only be used on contact routes
|
||||||
*
|
*
|
||||||
* @param $client_id The client Id
|
* @param $client_id The client Id
|
||||||
* @param Illuminate\Database\Query\Builder
|
* @param Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function clientFilter()
|
public function clientFilter()
|
||||||
{
|
{
|
||||||
if(auth('contact')->user())
|
if (auth('contact')->user()) {
|
||||||
return $this->builder->whereClientId(auth('contact')->user()->client->id);
|
return $this->builder->whereClientId(auth('contact')->user()->client->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,36 +23,38 @@ class QuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('quotes.custom_value1', 'like', '%'.$filter.'%')
|
$query->where('quotes.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('quotes.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('quotes.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('quotes.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('quotes.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('quotes.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('quotes.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'quotes';
|
$table = 'quotes';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -82,7 +84,7 @@ class QuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -94,27 +96,23 @@ class QuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
return $this->builder->company();
|
||||||
return $this->builder->company();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -23,36 +23,38 @@ class RecurringInvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('recurring_invoices.custom_value1', 'like', '%'.$filter.'%')
|
$query->where('recurring_invoices.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_invoices.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('recurring_invoices.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_invoices.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('recurring_invoices.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_invoices.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('recurring_invoices.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'recurring_';
|
$table = 'recurring_';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -82,7 +84,7 @@ class RecurringInvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -94,27 +96,23 @@ class RecurringInvoiceFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
return $this->builder->company();
|
||||||
return $this->builder->company();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -23,36 +23,38 @@ class RecurringQuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('recurring_quotes.custom_value1', 'like', '%'.$filter.'%')
|
$query->where('recurring_quotes.custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_quotes.custom_value2', 'like' , '%'.$filter.'%')
|
->orWhere('recurring_quotes.custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_quotes.custom_value3', 'like' , '%'.$filter.'%')
|
->orWhere('recurring_quotes.custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('recurring_quotes.custom_value4', 'like' , '%'.$filter.'%');
|
->orWhere('recurring_quotes.custom_value4', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'recurring_';
|
$table = 'recurring_';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -82,7 +84,7 @@ class RecurringQuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -94,27 +96,23 @@ class RecurringQuoteFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
|
return $this->builder->company();
|
||||||
return $this->builder->company();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -23,36 +23,38 @@ class UserFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter based on search text
|
* Filter based on search text
|
||||||
*
|
*
|
||||||
* @param string query filter
|
* @param string query filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($filter) {
|
return $this->builder->where(function ($query) use ($filter) {
|
||||||
$query->where('users.first_name', 'like', '%'.$filter.'%')
|
$query->where('users.first_name', 'like', '%'.$filter.'%')
|
||||||
->orWhere('users.last_name', 'like' , '%'.$filter.'%')
|
->orWhere('users.last_name', 'like', '%'.$filter.'%')
|
||||||
->orWhere('users.email', 'like' , '%'.$filter.'%')
|
->orWhere('users.email', 'like', '%'.$filter.'%')
|
||||||
->orWhere('users.signature', 'like' , '%'.$filter.'%');
|
->orWhere('users.signature', 'like', '%'.$filter.'%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the list based on the status
|
* Filters the list based on the status
|
||||||
* archived, active, deleted
|
* archived, active, deleted
|
||||||
*
|
*
|
||||||
* @param string filter
|
* @param string filter
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function status(string $filter = '') : Builder
|
public function status(string $filter = '') : Builder
|
||||||
{
|
{
|
||||||
if(strlen($filter) == 0)
|
if (strlen($filter) == 0) {
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
$table = 'users';
|
$table = 'users';
|
||||||
$filters = explode(',', $filter);
|
$filters = explode(',', $filter);
|
||||||
@ -82,7 +84,7 @@ class UserFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort
|
* Sorts the list based on $sort
|
||||||
*
|
*
|
||||||
* @param string sort formatted as column|asc
|
* @param string sort formatted as column|asc
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
@ -94,31 +96,27 @@ class UserFilters extends QueryFilters
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base query
|
* Returns the base query
|
||||||
*
|
*
|
||||||
* @param int company_id
|
* @param int company_id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function baseQuery(int $company_id, User $user) : Builder
|
public function baseQuery(int $company_id, User $user) : Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID
|
* Filters the query by the users company ID
|
||||||
*
|
*
|
||||||
* @param $company_id The company Id
|
* @param $company_id The company Id
|
||||||
* @return Illuminate\Database\Query\Builder
|
* @return Illuminate\Database\Query\Builder
|
||||||
*/
|
*/
|
||||||
public function entityFilter()
|
public function entityFilter()
|
||||||
{
|
{
|
||||||
//return $this->builder->user_companies()->whereCompanyId(auth()->user()->company()->id);
|
//return $this->builder->user_companies()->whereCompanyId(auth()->user()->company()->id);
|
||||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||||
return $this->builder->whereHas('company_users', function($q)
|
return $this->builder->whereHas('company_users', function ($q) {
|
||||||
{
|
|
||||||
$q->where('company_id', '=', auth()->user()->company()->id);
|
$q->where('company_id', '=', auth()->user()->company()->id);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -16,17 +16,12 @@ namespace App\Helpers\Invoice;
|
|||||||
*/
|
*/
|
||||||
trait Balancer
|
trait Balancer
|
||||||
{
|
{
|
||||||
|
public function balance($total, $invoice)
|
||||||
public function balance($total, $invoice)
|
{
|
||||||
{
|
if (isset($this->invoice->id) && $this->invoice->id >= 1) {
|
||||||
|
|
||||||
if(isset($this->invoice->id) && $this->invoice->id >= 1)
|
|
||||||
{
|
|
||||||
return round($total - ($this->invoice->amount - $this->invoice->balance), 2);
|
return round($total - ($this->invoice->amount - $this->invoice->balance), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $total;
|
return $total;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,23 +16,21 @@ namespace App\Helpers\Invoice;
|
|||||||
*/
|
*/
|
||||||
trait CustomValuer
|
trait CustomValuer
|
||||||
{
|
{
|
||||||
|
public function valuer($custom_value)
|
||||||
public function valuer($custom_value)
|
{
|
||||||
{
|
if (isset($custom_value) && is_numeric($custom_value)) {
|
||||||
|
return $custom_value;
|
||||||
if(isset($custom_value) && is_numeric($custom_value))
|
}
|
||||||
return $custom_value;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function valuerTax($custom_value, $has_custom_invoice_taxes)
|
public function valuerTax($custom_value, $has_custom_invoice_taxes)
|
||||||
{
|
{
|
||||||
if(isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes === true)
|
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes === true) {
|
||||||
return round($custom_value * ($this->invoice->tax_rate1/100) ,2) + round($custom_value * ($this->invoice->tax_rate2/100) ,2) + round($custom_value * ($this->invoice->tax_rate3/100) ,2);
|
return round($custom_value * ($this->invoice->tax_rate1/100), 2) + round($custom_value * ($this->invoice->tax_rate2/100), 2) + round($custom_value * ($this->invoice->tax_rate3/100), 2);
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,18 +16,13 @@ namespace App\Helpers\Invoice;
|
|||||||
*/
|
*/
|
||||||
trait Discounter
|
trait Discounter
|
||||||
{
|
{
|
||||||
|
public function discount($amount)
|
||||||
|
{
|
||||||
|
if ($this->invoice->is_amount_discount == true) {
|
||||||
|
return $this->invoice->discount;
|
||||||
|
}
|
||||||
|
|
||||||
public function discount($amount)
|
|
||||||
{
|
return round($amount * ($this->invoice->discount / 100), 2);
|
||||||
|
}
|
||||||
if($this->invoice->is_amount_discount == true){
|
|
||||||
return $this->invoice->discount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return round($amount * ($this->invoice->discount / 100), 2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,275 +21,261 @@ use Illuminate\Support\Collection;
|
|||||||
|
|
||||||
class InvoiceItemSum
|
class InvoiceItemSum
|
||||||
{
|
{
|
||||||
|
use NumberFormatter;
|
||||||
|
use Discounter;
|
||||||
|
use Taxer;
|
||||||
|
|
||||||
use NumberFormatter;
|
protected $invoice;
|
||||||
use Discounter;
|
|
||||||
use Taxer;
|
|
||||||
|
|
||||||
protected $invoice;
|
private $items;
|
||||||
|
|
||||||
private $items;
|
private $line_total;
|
||||||
|
|
||||||
private $line_total;
|
private $currency;
|
||||||
|
|
||||||
private $currency;
|
private $total_taxes;
|
||||||
|
|
||||||
private $total_taxes;
|
private $item;
|
||||||
|
|
||||||
private $item;
|
private $line_items;
|
||||||
|
|
||||||
private $line_items;
|
private $sub_total;
|
||||||
|
|
||||||
private $sub_total;
|
private $total_discount;
|
||||||
|
|
||||||
private $total_discount;
|
private $tax_collection;
|
||||||
|
|
||||||
private $tax_collection;
|
public function __construct($invoice)
|
||||||
|
{
|
||||||
|
$this->tax_collection = collect([]);
|
||||||
|
|
||||||
public function __construct($invoice)
|
$this->invoice = $invoice;
|
||||||
{
|
|
||||||
|
|
||||||
$this->tax_collection = collect([]);
|
$this->currency = $this->invoice->client->currency();
|
||||||
|
|
||||||
$this->invoice = $invoice;
|
$this->line_items = [];
|
||||||
|
}
|
||||||
|
|
||||||
$this->currency = $this->invoice->client->currency();
|
public function process()
|
||||||
|
{
|
||||||
|
if (!$this->invoice->line_items || !isset($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
|
||||||
|
$this->items = [];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->line_items = [];
|
$this->calcLineItems();
|
||||||
}
|
|
||||||
|
|
||||||
public function process()
|
return $this;
|
||||||
{
|
}
|
||||||
|
|
||||||
if(!$this->invoice->line_items || !isset($this->invoice->line_items) || count($this->invoice->line_items) == 0){
|
private function calcLineItems()
|
||||||
$this->items = [];
|
{
|
||||||
return $this;
|
foreach ($this->invoice->line_items as $this->item) {
|
||||||
}
|
$this->cleanLineItem()
|
||||||
|
->sumLineItem()
|
||||||
|
->setDiscount()
|
||||||
|
->calcTaxes()
|
||||||
|
->push();
|
||||||
|
}
|
||||||
|
|
||||||
$this->calcLineItems();
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
private function push()
|
||||||
}
|
{
|
||||||
|
$this->sub_total += $this->getLineTotal();
|
||||||
|
|
||||||
private function calcLineItems()
|
$this->line_items[] = $this->item;
|
||||||
{
|
|
||||||
foreach($this->invoice->line_items as $this->item)
|
|
||||||
{
|
|
||||||
$this->cleanLineItem()
|
|
||||||
->sumLineItem()
|
|
||||||
->setDiscount()
|
|
||||||
->calcTaxes()
|
|
||||||
->push();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function push()
|
private function sumLineItem()
|
||||||
{
|
{
|
||||||
|
$this->setLineTotal($this->formatValue($this->item->cost, $this->currency->precision) * $this->formatValue($this->item->quantity, $this->currency->precision));
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->sub_total += $this->getLineTotal();
|
private function setDiscount()
|
||||||
|
{
|
||||||
|
if ($this->invoice->is_amount_discount) {
|
||||||
|
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
||||||
|
} else {
|
||||||
|
$this->setLineTotal($this->getLineTotal() - $this->formatValue(round($this->item->line_total * ($this->item->discount / 100), 2), $this->currency->precision));
|
||||||
|
}
|
||||||
|
|
||||||
$this->line_items[] = $this->item;
|
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sumLineItem()
|
private function calcTaxes()
|
||||||
{
|
{
|
||||||
$this->setLineTotal($this->formatValue($this->item->cost, $this->currency->precision) * $this->formatValue($this->item->quantity, $this->currency->precision));
|
$item_tax = 0;
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setDiscount()
|
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/100));
|
||||||
{
|
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
||||||
|
|
||||||
if($this->invoice->is_amount_discount)
|
$item_tax += $item_tax_rate1_total;
|
||||||
{
|
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue(round($this->item->line_total * ($this->item->discount / 100),2), $this->currency->precision));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
if ($item_tax_rate1_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||||
return $this;
|
}
|
||||||
|
|
||||||
}
|
$item_tax_rate2_total = $this->calcAmountLineTax($this->item->tax_rate2, $amount);
|
||||||
|
|
||||||
private function calcTaxes()
|
$item_tax += $item_tax_rate2_total;
|
||||||
{
|
|
||||||
|
|
||||||
$item_tax = 0;
|
if ($item_tax_rate2_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||||
|
}
|
||||||
|
|
||||||
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/100));
|
$item_tax_rate3_total = $this->calcAmountLineTax($this->item->tax_rate3, $amount);
|
||||||
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate1_total;
|
$item_tax += $item_tax_rate3_total;
|
||||||
|
|
||||||
if($item_tax_rate1_total > 0)
|
if ($item_tax_rate3_total > 0) {
|
||||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||||
|
}
|
||||||
$item_tax_rate2_total = $this->calcAmountLineTax($this->item->tax_rate2, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate2_total;
|
|
||||||
|
|
||||||
if($item_tax_rate2_total > 0)
|
|
||||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
|
||||||
|
|
||||||
$item_tax_rate3_total = $this->calcAmountLineTax($this->item->tax_rate3, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate3_total;
|
|
||||||
|
|
||||||
if($item_tax_rate3_total > 0)
|
|
||||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
|
||||||
|
|
||||||
|
|
||||||
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));
|
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function groupTax($tax_name, $tax_rate, $tax_total)
|
private function groupTax($tax_name, $tax_rate, $tax_total)
|
||||||
{
|
{
|
||||||
$group_tax = [];
|
$group_tax = [];
|
||||||
|
|
||||||
$key = str_replace(" ", "", $tax_name.$tax_rate);
|
$key = str_replace(" ", "", $tax_name.$tax_rate);
|
||||||
|
|
||||||
$group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate.'%'];
|
$group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate.'%'];
|
||||||
|
|
||||||
$this->tax_collection->push(collect($group_tax));
|
$this->tax_collection->push(collect($group_tax));
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getTotalTaxes()
|
public function getTotalTaxes()
|
||||||
{
|
{
|
||||||
return $this->total_taxes;
|
return $this->total_taxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTotalTaxes($total)
|
public function setTotalTaxes($total)
|
||||||
{
|
{
|
||||||
$this->total_taxes = $total;
|
$this->total_taxes = $total;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLineTotal($total)
|
public function setLineTotal($total)
|
||||||
{
|
{
|
||||||
$this->item->line_total = $total;
|
$this->item->line_total = $total;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLineTotal()
|
public function getLineTotal()
|
||||||
{
|
{
|
||||||
return $this->item->line_total;
|
return $this->item->line_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLineItems()
|
public function getLineItems()
|
||||||
{
|
{
|
||||||
return $this->line_items;
|
return $this->line_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroupedTaxes()
|
public function getGroupedTaxes()
|
||||||
{
|
{
|
||||||
return $this->tax_collection;
|
return $this->tax_collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGroupedTaxes($group_taxes)
|
public function setGroupedTaxes($group_taxes)
|
||||||
{
|
{
|
||||||
$this->tax_collection = $group_taxes;
|
$this->tax_collection = $group_taxes;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubTotal()
|
public function getSubTotal()
|
||||||
{
|
{
|
||||||
return $this->sub_total;
|
return $this->sub_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSubTotal($value)
|
public function setSubTotal($value)
|
||||||
{
|
{
|
||||||
$this->sub_total = $value;
|
$this->sub_total = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice Amount Discount
|
* Invoice Amount Discount
|
||||||
*
|
*
|
||||||
* The problem, when calculating invoice level discounts,
|
* The problem, when calculating invoice level discounts,
|
||||||
* the tax collected changes.
|
* the tax collected changes.
|
||||||
*
|
*
|
||||||
* We need to synthetically reduce the line_total amounts
|
* We need to synthetically reduce the line_total amounts
|
||||||
* and recalculate the taxes and then pass back
|
* and recalculate the taxes and then pass back
|
||||||
* the updated map
|
* the updated map
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function calcTaxesWithAmountDiscount()
|
public function calcTaxesWithAmountDiscount()
|
||||||
{
|
{
|
||||||
$this->setGroupedTaxes(collect([]));
|
$this->setGroupedTaxes(collect([]));
|
||||||
|
|
||||||
$item_tax = 0;
|
$item_tax = 0;
|
||||||
|
|
||||||
foreach($this->line_items as $this->item)
|
foreach ($this->line_items as $this->item) {
|
||||||
{
|
if ($this->item->line_total == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->item->line_total == 0)
|
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/$this->sub_total));
|
||||||
continue;
|
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
||||||
|
|
||||||
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/$this->sub_total));
|
$item_tax += $item_tax_rate1_total;
|
||||||
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate1_total;
|
if ($item_tax_rate1_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||||
|
}
|
||||||
|
|
||||||
|
$item_tax_rate2_total = $this->calcAmountLineTax($this->item->tax_rate2, $amount);
|
||||||
|
|
||||||
if($item_tax_rate1_total > 0)
|
$item_tax += $item_tax_rate2_total;
|
||||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
|
||||||
|
|
||||||
$item_tax_rate2_total = $this->calcAmountLineTax($this->item->tax_rate2, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate2_total;
|
if ($item_tax_rate2_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||||
|
}
|
||||||
|
|
||||||
if($item_tax_rate2_total > 0)
|
$item_tax_rate3_total = $this->calcAmountLineTax($this->item->tax_rate3, $amount);
|
||||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
|
||||||
|
|
||||||
$item_tax_rate3_total = $this->calcAmountLineTax($this->item->tax_rate3, $amount);
|
$item_tax += $item_tax_rate3_total;
|
||||||
|
|
||||||
$item_tax += $item_tax_rate3_total;
|
if ($item_tax_rate3_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($item_tax_rate3_total > 0)
|
$this->setTotalTaxes($item_tax);
|
||||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets default values for the line_items
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
private function cleanLineItem()
|
||||||
|
{
|
||||||
|
$invoice_item = (object)get_class_vars(InvoiceItem::class);
|
||||||
|
unset($invoice_item->casts);
|
||||||
|
|
||||||
|
foreach ($invoice_item as $key => $value) {
|
||||||
|
if (!property_exists($this->item, $key) || !isset($this->item->{$key})) {
|
||||||
|
$this->item->{$key} = $value;
|
||||||
|
$this->item->{$key} = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
$this->setTotalTaxes($item_tax);
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets default values for the line_items
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
private function cleanLineItem()
|
|
||||||
{
|
|
||||||
$invoice_item = (object)get_class_vars(InvoiceItem::class);
|
|
||||||
unset($invoice_item->casts);
|
|
||||||
|
|
||||||
foreach($invoice_item as $key => $value)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(!property_exists($this->item, $key) || !isset($this->item->{$key})){
|
|
||||||
$this->item->{$key} = $value;
|
|
||||||
$this->item->{$key} = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -19,255 +19,243 @@ use Illuminate\Support\Collection;
|
|||||||
|
|
||||||
class InvoiceItemSumInclusive
|
class InvoiceItemSumInclusive
|
||||||
{
|
{
|
||||||
|
use NumberFormatter;
|
||||||
use NumberFormatter;
|
use Discounter;
|
||||||
use Discounter;
|
use Taxer;
|
||||||
use Taxer;
|
|
||||||
|
|
||||||
|
|
||||||
protected $invoice;
|
protected $invoice;
|
||||||
|
|
||||||
private $items;
|
private $items;
|
||||||
|
|
||||||
private $line_total;
|
private $line_total;
|
||||||
|
|
||||||
private $currency;
|
private $currency;
|
||||||
|
|
||||||
private $total_taxes;
|
private $total_taxes;
|
||||||
|
|
||||||
private $item;
|
private $item;
|
||||||
|
|
||||||
private $line_items;
|
private $line_items;
|
||||||
|
|
||||||
private $sub_total;
|
private $sub_total;
|
||||||
|
|
||||||
private $total_discount;
|
private $total_discount;
|
||||||
|
|
||||||
private $tax_collection;
|
private $tax_collection;
|
||||||
|
|
||||||
public function __construct($invoice)
|
public function __construct($invoice)
|
||||||
{
|
{
|
||||||
|
$this->tax_collection = collect([]);
|
||||||
|
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
|
||||||
|
$this->currency = $this->invoice->client->currency();
|
||||||
|
|
||||||
|
$this->line_items = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
if (!$this->invoice->line_items || count($this->invoice->line_items) == 0) {
|
||||||
|
$this->items = [];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->calcLineItems();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function calcLineItems()
|
||||||
|
{
|
||||||
|
foreach ($this->invoice->line_items as $this->item) {
|
||||||
|
$this->sumLineItem()
|
||||||
|
->setDiscount()
|
||||||
|
->calcTaxes()
|
||||||
|
->push();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function push()
|
||||||
|
{
|
||||||
|
$this->sub_total += $this->getLineTotal();
|
||||||
|
|
||||||
|
$this->line_items[] = $this->item;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->tax_collection = collect([]);
|
private function sumLineItem()
|
||||||
|
{
|
||||||
|
$this->setLineTotal($this->formatValue($this->item->cost, $this->currency->precision) * $this->formatValue($this->item->quantity, $this->currency->precision));
|
||||||
|
|
||||||
$this->invoice = $invoice;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->currency = $this->invoice->client->currency();
|
private function setDiscount()
|
||||||
|
{
|
||||||
|
if ($this->invoice->is_amount_discount) {
|
||||||
|
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
||||||
|
} else {
|
||||||
|
$this->setLineTotal($this->getLineTotal() - $this->formatValue(($this->item->line_total * ($this->item->discount / 100)), $this->currency->precision));
|
||||||
|
}
|
||||||
|
|
||||||
$this->line_items = [];
|
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
||||||
}
|
|
||||||
|
|
||||||
public function process()
|
return $this;
|
||||||
{
|
}
|
||||||
|
|
||||||
if(!$this->invoice->line_items || count($this->invoice->line_items) == 0){
|
/**
|
||||||
$this->items = [];
|
* Taxes effect the line totals and item costs. we decrement both on
|
||||||
return $this;
|
* application of inclusive tax rates.
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
|
private function calcTaxes()
|
||||||
|
{
|
||||||
|
$item_tax = 0;
|
||||||
|
|
||||||
$this->calcLineItems();
|
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/100));
|
||||||
|
|
||||||
return $this;
|
$item_tax_rate1_total = $this->calcInclusiveLineTax($this->item->tax_rate1, $amount);
|
||||||
}
|
|
||||||
|
|
||||||
private function calcLineItems()
|
$item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision);
|
||||||
{
|
|
||||||
foreach($this->invoice->line_items as $this->item)
|
|
||||||
{
|
|
||||||
$this->sumLineItem()
|
|
||||||
->setDiscount()
|
|
||||||
->calcTaxes()
|
|
||||||
->push();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
if ($item_tax_rate1_total > 0) {
|
||||||
}
|
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||||
|
}
|
||||||
private function push()
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->sub_total += $this->getLineTotal();
|
|
||||||
|
|
||||||
$this->line_items[] = $this->item;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function sumLineItem()
|
|
||||||
{
|
|
||||||
$this->setLineTotal($this->formatValue($this->item->cost, $this->currency->precision) * $this->formatValue($this->item->quantity, $this->currency->precision));
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setDiscount()
|
|
||||||
{
|
|
||||||
|
|
||||||
if($this->invoice->is_amount_discount)
|
|
||||||
{
|
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue(($this->item->line_total * ($this->item->discount / 100)), $this->currency->precision));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
|
|
||||||
}
|
$item_tax_rate2_total = $this->calcInclusiveLineTax($this->item->tax_rate2, $amount);
|
||||||
|
|
||||||
/**
|
$item_tax += $this->formatValue($item_tax_rate2_total, $this->currency->precision);
|
||||||
* Taxes effect the line totals and item costs. we decrement both on
|
|
||||||
* application of inclusive tax rates.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function calcTaxes()
|
|
||||||
{
|
|
||||||
|
|
||||||
$item_tax = 0;
|
if ($item_tax_rate2_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||||
|
}
|
||||||
|
|
||||||
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/100));
|
$item_tax_rate3_total = $this->calcInclusiveLineTax($this->item->tax_rate3, $amount);
|
||||||
|
|
||||||
$item_tax_rate1_total = $this->calcInclusiveLineTax($this->item->tax_rate1, $amount);
|
$item_tax += $this->formatValue($item_tax_rate3_total, $this->currency->precision);
|
||||||
|
|
||||||
$item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision);
|
if ($item_tax_rate3_total > 0) {
|
||||||
|
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||||
|
}
|
||||||
|
|
||||||
if($item_tax_rate1_total > 0)
|
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));
|
||||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
|
||||||
|
|
||||||
$item_tax_rate2_total = $this->calcInclusiveLineTax($this->item->tax_rate2, $amount);
|
|
||||||
|
|
||||||
$item_tax += $this->formatValue($item_tax_rate2_total, $this->currency->precision);
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if($item_tax_rate2_total > 0)
|
private function groupTax($tax_name, $tax_rate, $tax_total)
|
||||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
{
|
||||||
|
$group_tax = [];
|
||||||
|
|
||||||
$item_tax_rate3_total = $this->calcInclusiveLineTax($this->item->tax_rate3, $amount);
|
$key = str_replace(" ", "", $tax_name.$tax_rate);
|
||||||
|
|
||||||
$item_tax += $this->formatValue($item_tax_rate3_total, $this->currency->precision);
|
$group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate.'%'];
|
||||||
|
|
||||||
if($item_tax_rate3_total > 0)
|
$this->tax_collection->push(collect($group_tax));
|
||||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
}
|
||||||
|
|
||||||
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));
|
public function getTotalTaxes()
|
||||||
|
{
|
||||||
|
return $this->total_taxes;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
public function setTotalTaxes($total)
|
||||||
}
|
{
|
||||||
|
$this->total_taxes = $total;
|
||||||
|
|
||||||
private function groupTax($tax_name, $tax_rate, $tax_total)
|
return $this;
|
||||||
{
|
}
|
||||||
$group_tax = [];
|
|
||||||
|
|
||||||
$key = str_replace(" ", "", $tax_name.$tax_rate);
|
public function setLineTotal($total)
|
||||||
|
{
|
||||||
|
$this->item->line_total = $total;
|
||||||
|
|
||||||
$group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate.'%'];
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->tax_collection->push(collect($group_tax));
|
public function getLineTotal()
|
||||||
|
{
|
||||||
}
|
return $this->item->line_total;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTotalTaxes()
|
public function getLineItems()
|
||||||
{
|
{
|
||||||
return $this->total_taxes;
|
return $this->line_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTotalTaxes($total)
|
public function getGroupedTaxes()
|
||||||
{
|
{
|
||||||
$this->total_taxes = $total;
|
return $this->tax_collection;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
public function setGroupedTaxes($group_taxes)
|
||||||
}
|
{
|
||||||
|
$this->tax_collection = $group_taxes;
|
||||||
|
|
||||||
public function setLineTotal($total)
|
return $this;
|
||||||
{
|
}
|
||||||
$this->item->line_total = $total;
|
|
||||||
|
|
||||||
return $this;
|
public function getSubTotal()
|
||||||
}
|
{
|
||||||
|
return $this->sub_total;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLineTotal()
|
public function setSubTotal($value)
|
||||||
{
|
{
|
||||||
return $this->item->line_total;
|
$this->sub_total = $value;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLineItems()
|
/**
|
||||||
{
|
* Invoice Amount Discount
|
||||||
return $this->line_items;
|
*
|
||||||
}
|
* The problem, when calculating invoice level discounts,
|
||||||
|
* the tax collected changes.
|
||||||
|
*
|
||||||
|
* We need to synthetically reduce the line_total amounts
|
||||||
|
* and recalculate the taxes and then pass back
|
||||||
|
* the updated map
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function calcTaxesWithAmountDiscount()
|
||||||
|
{
|
||||||
|
$this->setGroupedTaxes(collect([]));
|
||||||
|
|
||||||
public function getGroupedTaxes()
|
$item_tax = 0;
|
||||||
{
|
|
||||||
return $this->tax_collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setGroupedTaxes($group_taxes)
|
foreach ($this->line_items as $this->item) {
|
||||||
{
|
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/$this->sub_total));
|
||||||
$this->tax_collection = $group_taxes;
|
$item_tax_rate1_total = $this->calcInclusiveLineTax($this->item->tax_rate1, $amount);
|
||||||
|
|
||||||
return $this;
|
$item_tax += $item_tax_rate1_total;
|
||||||
}
|
|
||||||
|
|
||||||
public function getSubTotal()
|
if ($item_tax_rate1_total > 0) {
|
||||||
{
|
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||||
return $this->sub_total;
|
}
|
||||||
}
|
|
||||||
|
$item_tax_rate2_total = $this->calcInclusiveLineTax($this->item->tax_rate2, $amount);
|
||||||
|
|
||||||
public function setSubTotal($value)
|
$item_tax += $item_tax_rate2_total;
|
||||||
{
|
|
||||||
$this->sub_total = $value;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if ($item_tax_rate2_total > 0) {
|
||||||
* Invoice Amount Discount
|
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||||
*
|
}
|
||||||
* The problem, when calculating invoice level discounts,
|
|
||||||
* the tax collected changes.
|
|
||||||
*
|
|
||||||
* We need to synthetically reduce the line_total amounts
|
|
||||||
* and recalculate the taxes and then pass back
|
|
||||||
* the updated map
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function calcTaxesWithAmountDiscount()
|
|
||||||
{
|
|
||||||
$this->setGroupedTaxes(collect([]));
|
|
||||||
|
|
||||||
$item_tax = 0;
|
$item_tax_rate3_total = $this->calcInclusiveLineTax($this->item->tax_rate3, $amount);
|
||||||
|
|
||||||
foreach($this->line_items as $this->item)
|
$item_tax += $item_tax_rate3_total;
|
||||||
{
|
|
||||||
|
|
||||||
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount/$this->sub_total));
|
if ($item_tax_rate3_total > 0) {
|
||||||
$item_tax_rate1_total = $this->calcInclusiveLineTax($this->item->tax_rate1, $amount);
|
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$item_tax += $item_tax_rate1_total;
|
$this->setTotalTaxes($item_tax);
|
||||||
|
}
|
||||||
if($item_tax_rate1_total > 0)
|
}
|
||||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
|
||||||
|
|
||||||
$item_tax_rate2_total = $this->calcInclusiveLineTax($this->item->tax_rate2, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate2_total;
|
|
||||||
|
|
||||||
if($item_tax_rate2_total > 0)
|
|
||||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
|
||||||
|
|
||||||
$item_tax_rate3_total = $this->calcInclusiveLineTax($this->item->tax_rate3, $amount);
|
|
||||||
|
|
||||||
$item_tax += $item_tax_rate3_total;
|
|
||||||
|
|
||||||
if($item_tax_rate3_total > 0)
|
|
||||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setTotalTaxes($item_tax);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -21,88 +21,85 @@ use Illuminate\Support\Collection;
|
|||||||
|
|
||||||
class InvoiceSum
|
class InvoiceSum
|
||||||
{
|
{
|
||||||
use Taxer;
|
use Taxer;
|
||||||
use Balancer;
|
use Balancer;
|
||||||
use CustomValuer;
|
use CustomValuer;
|
||||||
use Discounter;
|
use Discounter;
|
||||||
|
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
|
|
||||||
protected $invoice;
|
protected $invoice;
|
||||||
|
|
||||||
public $tax_map;
|
public $tax_map;
|
||||||
|
|
||||||
public $invoice_item;
|
public $invoice_item;
|
||||||
|
|
||||||
public $total_taxes;
|
public $total_taxes;
|
||||||
|
|
||||||
private $total;
|
private $total;
|
||||||
|
|
||||||
private $total_discount;
|
private $total_discount;
|
||||||
|
|
||||||
private $total_custom_values;
|
private $total_custom_values;
|
||||||
|
|
||||||
private $total_tax_map;
|
private $total_tax_map;
|
||||||
|
|
||||||
private $sub_total;
|
private $sub_total;
|
||||||
/**
|
/**
|
||||||
* Constructs the object with Invoice and Settings object
|
* Constructs the object with Invoice and Settings object
|
||||||
*
|
*
|
||||||
* @param \App\Models\Invoice $invoice The invoice
|
* @param \App\Models\Invoice $invoice The invoice
|
||||||
*/
|
*/
|
||||||
public function __construct($invoice)
|
public function __construct($invoice)
|
||||||
{
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
$this->invoice = $invoice;
|
|
||||||
|
|
||||||
$this->tax_map = new Collection;
|
$this->tax_map = new Collection;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function build()
|
||||||
|
{
|
||||||
|
$this->calculateLineItems()
|
||||||
|
->calculateDiscount()
|
||||||
|
->calculateCustomValues()
|
||||||
|
->calculateInvoiceTaxes()
|
||||||
|
->setTaxMap()
|
||||||
|
->calculateTotals()
|
||||||
|
->calculateBalance()
|
||||||
|
->calculatePartial();
|
||||||
|
|
||||||
public function build()
|
return $this;
|
||||||
{
|
}
|
||||||
|
|
||||||
$this->calculateLineItems()
|
private function calculateLineItems()
|
||||||
->calculateDiscount()
|
{
|
||||||
->calculateCustomValues()
|
$this->invoice_items = new InvoiceItemSum($this->invoice);
|
||||||
->calculateInvoiceTaxes()
|
$this->invoice_items->process();
|
||||||
->setTaxMap()
|
$this->invoice->line_items = $this->invoice_items->getLineItems();
|
||||||
->calculateTotals()
|
$this->total = $this->invoice_items->getSubTotal();
|
||||||
->calculateBalance()
|
$this->setSubTotal($this->invoice_items->getSubTotal());
|
||||||
->calculatePartial();
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateLineItems()
|
private function calculateDiscount()
|
||||||
{
|
{
|
||||||
$this->invoice_items = new InvoiceItemSum($this->invoice);
|
$this->total_discount = $this->discount($this->invoice_items->getSubTotal());
|
||||||
$this->invoice_items->process();
|
|
||||||
$this->invoice->line_items = $this->invoice_items->getLineItems();
|
|
||||||
$this->total = $this->invoice_items->getSubTotal();
|
|
||||||
$this->setSubTotal($this->invoice_items->getSubTotal());
|
|
||||||
|
|
||||||
return $this;
|
$this->total -= $this->total_discount;
|
||||||
}
|
|
||||||
|
|
||||||
private function calculateDiscount()
|
return $this;
|
||||||
{
|
}
|
||||||
$this->total_discount = $this->discount($this->invoice_items->getSubTotal());
|
|
||||||
|
|
||||||
$this->total -= $this->total_discount;
|
private function calculateCustomValues()
|
||||||
|
{
|
||||||
return $this;
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_taxes1);
|
||||||
}
|
|
||||||
|
|
||||||
private function calculateCustomValues()
|
|
||||||
{
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_taxes1);
|
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge1);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge1);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_taxes2);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_taxes2);
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge2);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge2);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_taxes3);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_taxes3);
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge3);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge3);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
||||||
@ -111,145 +108,142 @@ class InvoiceSum
|
|||||||
$this->total += $this->total_custom_values;
|
$this->total += $this->total_custom_values;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateInvoiceTaxes()
|
private function calculateInvoiceTaxes()
|
||||||
{
|
{
|
||||||
|
if ($this->invoice->tax_rate1 > 0) {
|
||||||
if($this->invoice->tax_rate1 > 0){
|
$tax = $this->taxer($this->total, $this->invoice->tax_rate1);
|
||||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate1);
|
$this->total_taxes += $tax;
|
||||||
$this->total_taxes += $tax;
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1 . ' ' . $this->invoice->tax_rate1.'%', 'total' => $tax];
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1 . ' ' . $this->invoice->tax_rate1.'%', 'total' => $tax];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->invoice->tax_rate2 > 0){
|
if ($this->invoice->tax_rate2 > 0) {
|
||||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate2);
|
$tax = $this->taxer($this->total, $this->invoice->tax_rate2);
|
||||||
$this->total_taxes += $tax;
|
$this->total_taxes += $tax;
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2. ' ' . $this->invoice->tax_rate2.'%', 'total' => $tax];
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2. ' ' . $this->invoice->tax_rate2.'%', 'total' => $tax];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->invoice->tax_rate3 > 0){
|
if ($this->invoice->tax_rate3 > 0) {
|
||||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate3);
|
$tax = $this->taxer($this->total, $this->invoice->tax_rate3);
|
||||||
$this->total_taxes += $tax;
|
$this->total_taxes += $tax;
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3 . ' ' . $this->invoice->tax_rate3.'%', 'total' => $tax];
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3 . ' ' . $this->invoice->tax_rate3.'%', 'total' => $tax];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the balance.
|
* Calculates the balance.
|
||||||
*
|
*
|
||||||
* @return self The balance.
|
* @return self The balance.
|
||||||
*/
|
*/
|
||||||
private function calculateBalance()
|
private function calculateBalance()
|
||||||
{
|
{
|
||||||
//$this->invoice->balance = $this->balance($this->getTotal(), $this->invoice);
|
//$this->invoice->balance = $this->balance($this->getTotal(), $this->invoice);
|
||||||
$this->setCalculatedAttributes();
|
$this->setCalculatedAttributes();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculatePartial()
|
private function calculatePartial()
|
||||||
{
|
{
|
||||||
if ( !isset($this->invoice->id) && isset($this->invoice->partial) ) {
|
if (!isset($this->invoice->id) && isset($this->invoice->partial)) {
|
||||||
$this->invoice->partial = max(0, min($this->formatValue($this->invoice->partial, 2), $this->invoice->balance));
|
$this->invoice->partial = max(0, min($this->formatValue($this->invoice->partial, 2), $this->invoice->balance));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateTotals()
|
private function calculateTotals()
|
||||||
{
|
{
|
||||||
$this->total += $this->total_taxes;
|
$this->total += $this->total_taxes;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoice()
|
public function getInvoice()
|
||||||
{
|
{
|
||||||
//Build invoice values here and return Invoice
|
//Build invoice values here and return Invoice
|
||||||
$this->setCalculatedAttributes();
|
$this->setCalculatedAttributes();
|
||||||
$this->invoice->save();
|
$this->invoice->save();
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build $this->invoice variables after
|
* Build $this->invoice variables after
|
||||||
* calculations have been performed.
|
* calculations have been performed.
|
||||||
*/
|
*/
|
||||||
private function setCalculatedAttributes()
|
private function setCalculatedAttributes()
|
||||||
{
|
{
|
||||||
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
||||||
if($this->invoice->amount != $this->invoice->balance)
|
if ($this->invoice->amount != $this->invoice->balance) {
|
||||||
{
|
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
||||||
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
|
||||||
|
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
||||||
}
|
} else {
|
||||||
else
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
}
|
||||||
|
|
||||||
/* Set new calculated total */
|
/* Set new calculated total */
|
||||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
|
|
||||||
$this->invoice->total_taxes = $this->getTotalTaxes();
|
$this->invoice->total_taxes = $this->getTotalTaxes();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubTotal()
|
public function getSubTotal()
|
||||||
{
|
{
|
||||||
return $this->sub_total;
|
return $this->sub_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSubTotal($value)
|
public function setSubTotal($value)
|
||||||
{
|
{
|
||||||
$this->sub_total = $value;
|
$this->sub_total = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalDiscount()
|
public function getTotalDiscount()
|
||||||
{
|
{
|
||||||
return $this->total_discount;
|
return $this->total_discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalTaxes()
|
public function getTotalTaxes()
|
||||||
{
|
{
|
||||||
return $this->total_taxes;
|
return $this->total_taxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalTaxMap()
|
public function getTotalTaxMap()
|
||||||
{
|
{
|
||||||
return $this->total_tax_map;
|
return $this->total_tax_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotal()
|
public function getTotal()
|
||||||
{
|
{
|
||||||
return $this->total;
|
return $this->total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxMap()
|
public function setTaxMap()
|
||||||
{
|
{
|
||||||
if($this->invoice->is_amount_discount == true)
|
if ($this->invoice->is_amount_discount == true) {
|
||||||
$this->invoice_items->calcTaxesWithAmountDiscount();
|
$this->invoice_items->calcTaxesWithAmountDiscount();
|
||||||
|
}
|
||||||
|
|
||||||
$this->tax_map = collect();
|
$this->tax_map = collect();
|
||||||
|
|
||||||
$keys = $this->invoice_items->getGroupedTaxes()->pluck('key')->unique();
|
$keys = $this->invoice_items->getGroupedTaxes()->pluck('key')->unique();
|
||||||
|
|
||||||
$values = $this->invoice_items->getGroupedTaxes();
|
$values = $this->invoice_items->getGroupedTaxes();
|
||||||
|
|
||||||
foreach($keys as $key)
|
foreach ($keys as $key) {
|
||||||
{
|
$tax_name = $values->filter(function ($value, $k) use ($key) {
|
||||||
|
|
||||||
$tax_name = $values->filter(function ($value, $k) use($key){
|
|
||||||
return $value['key'] == $key;
|
return $value['key'] == $key;
|
||||||
})->pluck('tax_name')->first();
|
})->pluck('tax_name')->first();
|
||||||
|
|
||||||
$total_line_tax = $values->filter(function ($value, $k) use($key){
|
$total_line_tax = $values->filter(function ($value, $k) use ($key) {
|
||||||
return $value['key'] == $key;
|
return $value['key'] == $key;
|
||||||
})->sum('total');
|
})->sum('total');
|
||||||
|
|
||||||
@ -261,21 +255,20 @@ class InvoiceSum
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getTaxMap()
|
public function getTaxMap()
|
||||||
{
|
{
|
||||||
return $this->tax_map;
|
return $this->tax_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBalance()
|
public function getBalance()
|
||||||
{
|
{
|
||||||
return $this->invoice->balance;
|
return $this->invoice->balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemTotalTaxes()
|
public function getItemTotalTaxes()
|
||||||
{
|
{
|
||||||
return $this->getTotalTaxes();
|
return $this->getTotalTaxes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,88 +22,86 @@ use Illuminate\Support\Collection;
|
|||||||
|
|
||||||
class InvoiceSumInclusive
|
class InvoiceSumInclusive
|
||||||
{
|
{
|
||||||
use Taxer;
|
use Taxer;
|
||||||
use Balancer;
|
use Balancer;
|
||||||
use CustomValuer;
|
use CustomValuer;
|
||||||
use Discounter;
|
use Discounter;
|
||||||
|
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
|
|
||||||
protected $invoice;
|
protected $invoice;
|
||||||
|
|
||||||
public $tax_map;
|
public $tax_map;
|
||||||
|
|
||||||
public $invoice_item;
|
public $invoice_item;
|
||||||
|
|
||||||
public $total_taxes;
|
public $total_taxes;
|
||||||
|
|
||||||
private $total;
|
private $total;
|
||||||
|
|
||||||
private $total_discount;
|
private $total_discount;
|
||||||
|
|
||||||
private $total_custom_values;
|
private $total_custom_values;
|
||||||
|
|
||||||
private $total_tax_map;
|
private $total_tax_map;
|
||||||
|
|
||||||
private $sub_total;
|
private $sub_total;
|
||||||
/**
|
/**
|
||||||
* Constructs the object with Invoice and Settings object
|
* Constructs the object with Invoice and Settings object
|
||||||
*
|
*
|
||||||
* @param \App\Models\Invoice $invoice The invoice
|
* @param \App\Models\Invoice $invoice The invoice
|
||||||
*/
|
*/
|
||||||
public function __construct($invoice)
|
public function __construct($invoice)
|
||||||
{
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
$this->invoice = $invoice;
|
|
||||||
|
|
||||||
|
|
||||||
$this->tax_map = new Collection;
|
$this->tax_map = new Collection;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function build()
|
||||||
|
{
|
||||||
public function build()
|
$this->calculateLineItems()
|
||||||
{
|
->calculateDiscount()
|
||||||
$this->calculateLineItems()
|
->calculateCustomValues()
|
||||||
->calculateDiscount()
|
->calculateInvoiceTaxes()
|
||||||
->calculateCustomValues()
|
->setTaxMap()
|
||||||
->calculateInvoiceTaxes()
|
|
||||||
->setTaxMap()
|
|
||||||
// ->calculateTotals()
|
// ->calculateTotals()
|
||||||
->calculateBalance()
|
->calculateBalance()
|
||||||
->calculatePartial();
|
->calculatePartial();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateLineItems()
|
private function calculateLineItems()
|
||||||
{
|
{
|
||||||
$this->invoice_items = new InvoiceItemSumInclusive($this->invoice);
|
$this->invoice_items = new InvoiceItemSumInclusive($this->invoice);
|
||||||
$this->invoice_items->process();
|
$this->invoice_items->process();
|
||||||
$this->invoice->line_items = $this->invoice_items->getLineItems();
|
$this->invoice->line_items = $this->invoice_items->getLineItems();
|
||||||
$this->total = $this->invoice_items->getSubTotal();
|
$this->total = $this->invoice_items->getSubTotal();
|
||||||
$this->setSubTotal($this->invoice_items->getSubTotal());
|
$this->setSubTotal($this->invoice_items->getSubTotal());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateDiscount()
|
private function calculateDiscount()
|
||||||
{
|
{
|
||||||
$this->total_discount = $this->discount($this->invoice_items->getSubTotal());
|
$this->total_discount = $this->discount($this->invoice_items->getSubTotal());
|
||||||
|
|
||||||
$this->total -= $this->total_discount;
|
$this->total -= $this->total_discount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateCustomValues()
|
private function calculateCustomValues()
|
||||||
{
|
{
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_taxes1);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_taxes1);
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge1);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge1);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_taxes2);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_taxes2);
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge2);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge2);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_taxes3);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_taxes3);
|
||||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge3);
|
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge3);
|
||||||
|
|
||||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
||||||
@ -112,156 +110,154 @@ class InvoiceSumInclusive
|
|||||||
$this->total += $this->total_custom_values;
|
$this->total += $this->total_custom_values;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateInvoiceTaxes()
|
private function calculateInvoiceTaxes()
|
||||||
{
|
{
|
||||||
$amount = $this->total;
|
$amount = $this->total;
|
||||||
|
|
||||||
if($this->invoice->discount > 0 && $this->invoice->is_amount_discount)
|
if ($this->invoice->discount > 0 && $this->invoice->is_amount_discount) {
|
||||||
$amount = $this->formatValue(($this->sub_total - $this->invoice->discount),2);
|
$amount = $this->formatValue(($this->sub_total - $this->invoice->discount), 2);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->invoice->discount > 0 && !$this->invoice->is_amount_discount)
|
if ($this->invoice->discount > 0 && !$this->invoice->is_amount_discount) {
|
||||||
$amount = $this->formatValue(($this->sub_total - ($this->sub_total * ($this->invoice->discount/100))),2);
|
$amount = $this->formatValue(($this->sub_total - ($this->sub_total * ($this->invoice->discount/100))), 2);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->invoice->tax_rate1 > 0){
|
if ($this->invoice->tax_rate1 > 0) {
|
||||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount);
|
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount);
|
||||||
$this->total_taxes += $tax;
|
$this->total_taxes += $tax;
|
||||||
|
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1 . ' ' . $this->invoice->tax_rate1.'%', 'total' => $tax];
|
|
||||||
|
|
||||||
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1 . ' ' . $this->invoice->tax_rate1.'%', 'total' => $tax];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->invoice->tax_rate2 > 0){
|
if ($this->invoice->tax_rate2 > 0) {
|
||||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount);
|
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount);
|
||||||
$this->total_taxes += $tax;
|
$this->total_taxes += $tax;
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2. ' ' . $this->invoice->tax_rate2.'%', 'total' => $tax];
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2. ' ' . $this->invoice->tax_rate2.'%', 'total' => $tax];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->invoice->tax_rate3 > 0){
|
if ($this->invoice->tax_rate3 > 0) {
|
||||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount);
|
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount);
|
||||||
$this->total_taxes += $tax;
|
$this->total_taxes += $tax;
|
||||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3 . ' ' . $this->invoice->tax_rate3.'%', 'total' => $tax];
|
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3 . ' ' . $this->invoice->tax_rate3.'%', 'total' => $tax];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the balance.
|
* Calculates the balance.
|
||||||
*
|
*
|
||||||
* @return self The balance.
|
* @return self The balance.
|
||||||
*/
|
*/
|
||||||
private function calculateBalance()
|
private function calculateBalance()
|
||||||
{
|
{
|
||||||
//$this->invoice->balance = $this->balance($this->getTotal(), $this->invoice);
|
//$this->invoice->balance = $this->balance($this->getTotal(), $this->invoice);
|
||||||
$this->setCalculatedAttributes();
|
$this->setCalculatedAttributes();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculatePartial()
|
private function calculatePartial()
|
||||||
{
|
{
|
||||||
if ( !isset($this->invoice->id) && isset($this->invoice->partial) ) {
|
if (!isset($this->invoice->id) && isset($this->invoice->partial)) {
|
||||||
$this->invoice->partial = max(0, min($this->formatValue($this->invoice->partial, 2), $this->invoice->balance));
|
$this->invoice->partial = max(0, min($this->formatValue($this->invoice->partial, 2), $this->invoice->balance));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateTotals()
|
private function calculateTotals()
|
||||||
{
|
{
|
||||||
$this->total += $this->total_taxes;
|
$this->total += $this->total_taxes;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoice()
|
public function getInvoice()
|
||||||
{
|
{
|
||||||
//Build invoice values here and return Invoice
|
//Build invoice values here and return Invoice
|
||||||
$this->setCalculatedAttributes();
|
$this->setCalculatedAttributes();
|
||||||
$this->invoice->save();
|
$this->invoice->save();
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build $this->invoice variables after
|
* Build $this->invoice variables after
|
||||||
* calculations have been performed.
|
* calculations have been performed.
|
||||||
*/
|
*/
|
||||||
private function setCalculatedAttributes()
|
private function setCalculatedAttributes()
|
||||||
{
|
{
|
||||||
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
||||||
if($this->invoice->amount != $this->invoice->balance)
|
if ($this->invoice->amount != $this->invoice->balance) {
|
||||||
{
|
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
||||||
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
|
||||||
|
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
||||||
}
|
} else {
|
||||||
else
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
}
|
||||||
|
|
||||||
/* Set new calculated total */
|
/* Set new calculated total */
|
||||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
|
|
||||||
$this->invoice->total_taxes = $this->getTotalTaxes();
|
$this->invoice->total_taxes = $this->getTotalTaxes();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubTotal()
|
public function getSubTotal()
|
||||||
{
|
{
|
||||||
return $this->sub_total;
|
return $this->sub_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSubTotal($value)
|
public function setSubTotal($value)
|
||||||
{
|
{
|
||||||
$this->sub_total = $value;
|
$this->sub_total = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalDiscount()
|
public function getTotalDiscount()
|
||||||
{
|
{
|
||||||
return $this->total_discount;
|
return $this->total_discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalTaxes()
|
public function getTotalTaxes()
|
||||||
{
|
{
|
||||||
return $this->total_taxes;
|
return $this->total_taxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalTaxMap()
|
public function getTotalTaxMap()
|
||||||
{
|
{
|
||||||
return $this->total_tax_map;
|
return $this->total_tax_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotal()
|
public function getTotal()
|
||||||
{
|
{
|
||||||
return $this->total;
|
return $this->total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxMap()
|
public function setTaxMap()
|
||||||
{
|
{
|
||||||
if($this->invoice->is_amount_discount == true)
|
if ($this->invoice->is_amount_discount == true) {
|
||||||
$this->invoice_items->calcTaxesWithAmountDiscount();
|
$this->invoice_items->calcTaxesWithAmountDiscount();
|
||||||
|
}
|
||||||
|
|
||||||
$this->tax_map = collect();
|
$this->tax_map = collect();
|
||||||
|
|
||||||
$keys = $this->invoice_items->getGroupedTaxes()->pluck('key')->unique();
|
$keys = $this->invoice_items->getGroupedTaxes()->pluck('key')->unique();
|
||||||
|
|
||||||
$values = $this->invoice_items->getGroupedTaxes();
|
$values = $this->invoice_items->getGroupedTaxes();
|
||||||
|
|
||||||
foreach($keys as $key)
|
foreach ($keys as $key) {
|
||||||
{
|
$tax_name = $values->filter(function ($value, $k) use ($key) {
|
||||||
|
|
||||||
$tax_name = $values->filter(function ($value, $k) use($key){
|
|
||||||
return $value['key'] == $key;
|
return $value['key'] == $key;
|
||||||
})->pluck('tax_name')->first();
|
})->pluck('tax_name')->first();
|
||||||
|
|
||||||
$total_line_tax = $values->filter(function ($value, $k) use($key){
|
$total_line_tax = $values->filter(function ($value, $k) use ($key) {
|
||||||
return $value['key'] == $key;
|
return $value['key'] == $key;
|
||||||
})->sum('total');
|
})->sum('total');
|
||||||
|
|
||||||
@ -273,23 +269,20 @@ class InvoiceSumInclusive
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getTaxMap()
|
public function getTaxMap()
|
||||||
{
|
{
|
||||||
return $this->tax_map;
|
return $this->tax_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBalance()
|
public function getBalance()
|
||||||
{
|
{
|
||||||
return $this->invoice->balance;
|
return $this->invoice->balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemTotalTaxes()
|
public function getItemTotalTaxes()
|
||||||
{
|
{
|
||||||
return $this->getTotalTaxes();
|
return $this->getTotalTaxes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -16,21 +16,18 @@ namespace App\Helpers\Invoice;
|
|||||||
*/
|
*/
|
||||||
trait Taxer
|
trait Taxer
|
||||||
{
|
{
|
||||||
|
public function taxer($amount, $tax_rate)
|
||||||
|
{
|
||||||
|
return round($amount * (($tax_rate ? $tax_rate : 0) / 100), 2);
|
||||||
|
}
|
||||||
|
|
||||||
public function taxer($amount, $tax_rate)
|
public function calcAmountLineTax($tax_rate, $amount)
|
||||||
{
|
{
|
||||||
return round($amount * (($tax_rate ? $tax_rate : 0) / 100), 2);
|
return $this->formatValue(($amount * $tax_rate/100), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcAmountLineTax($tax_rate, $amount)
|
|
||||||
{
|
|
||||||
return $this->formatValue(($amount * $tax_rate/100), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function calcInclusiveLineTax($tax_rate, $amount)
|
|
||||||
{
|
|
||||||
return $this->formatValue($amount - ($amount / (1 + ($tax_rate/100))), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
public function calcInclusiveLineTax($tax_rate, $amount)
|
||||||
|
{
|
||||||
|
return $this->formatValue($amount - ($amount / (1 + ($tax_rate/100))), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,4 @@ class GmailTransport extends Transport
|
|||||||
|
|
||||||
return $this->numberOfRecipients($message);
|
return $this->numberOfRecipients($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,12 @@ use Laravel\Socialite\Facades\Socialite;
|
|||||||
*/
|
*/
|
||||||
class GmailTransportConfig
|
class GmailTransportConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
/********************* We may need to fetch a new token on behalf of the client ******************************/
|
/********************* We may need to fetch a new token on behalf of the client ******************************/
|
||||||
$query = [
|
$query = [
|
||||||
'email' => 'david@invoiceninja.com',
|
'email' => 'david@invoiceninja.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
$user = MultiDB::hasUser($query);
|
$user = MultiDB::hasUser($query);
|
||||||
// $oauth_user = Socialite::driver('google')->stateless()->userFromToken($user->oauth_user_token);
|
// $oauth_user = Socialite::driver('google')->stateless()->userFromToken($user->oauth_user_token);
|
||||||
@ -38,25 +37,12 @@ class GmailTransportConfig
|
|||||||
// $user->oauth_user_token = $oauth_user->refreshToken;
|
// $user->oauth_user_token = $oauth_user->refreshToken;
|
||||||
// $user->save();
|
// $user->save();
|
||||||
|
|
||||||
Config::set('mail.driver', 'gmail');
|
Config::set('mail.driver', 'gmail');
|
||||||
Config::set('services.gmail.token', $user->oauth_user_token);
|
Config::set('services.gmail.token', $user->oauth_user_token);
|
||||||
(new MailServiceProvider(app()))->register();
|
(new MailServiceProvider(app()))->register();
|
||||||
|
|
||||||
|
|
||||||
Mail::to('david@romulus.com.au')
|
Mail::to('david@romulus.com.au')
|
||||||
->send(new SupportMessageSent('a cool message'));
|
->send(new SupportMessageSent('a cool message'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,5 +15,4 @@ class GmailTransportManager extends TransportManager
|
|||||||
|
|
||||||
return new GmailTransport($mail, $token);
|
return new GmailTransport($mail, $token);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -16,14 +16,13 @@ use Illuminate\Support\Facades\Cache;
|
|||||||
* falls back on defaults if no string exists
|
* falls back on defaults if no string exists
|
||||||
*
|
*
|
||||||
* //Cache::forever($custom_company_translated_string, 'mogly');
|
* //Cache::forever($custom_company_translated_string, 'mogly');
|
||||||
*
|
*
|
||||||
* @param string translation string key
|
* @param string translation string key
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ctrans(string $string, $replace = [], $locale = null) : string
|
function ctrans(string $string, $replace = [], $locale = null) : string
|
||||||
{
|
{
|
||||||
//todo pass through the cached version of the custom strings here else return trans();
|
//todo pass through the cached version of the custom strings here else return trans();
|
||||||
|
|
||||||
return trans($string, $replace, $locale);
|
return trans($string, $replace, $locale);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -43,8 +43,7 @@ class AccountController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// return view('signup.index');
|
// return view('signup.index');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +112,7 @@ class AccountController extends BaseController
|
|||||||
* property="privacy_policy",
|
* property="privacy_policy",
|
||||||
* description="The user accepted the privacy policy",
|
* description="The user accepted the privacy policy",
|
||||||
* type="boolean",
|
* type="boolean",
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
* property="password",
|
* property="password",
|
||||||
* example="1234567",
|
* example="1234567",
|
||||||
@ -138,7 +137,7 @@ class AccountController extends BaseController
|
|||||||
|
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="default",
|
* response="default",
|
||||||
* description="Unexpected Error",
|
* description="Unexpected Error",
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
* ),
|
* ),
|
||||||
@ -146,13 +145,11 @@ class AccountController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function store(CreateAccountRequest $request)
|
public function store(CreateAccountRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$account = CreateAccount::dispatchNow($request->all());
|
$account = CreateAccount::dispatchNow($request->all());
|
||||||
|
|
||||||
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
||||||
|
|
||||||
return $this->listResponse($ct);
|
return $this->listResponse($ct);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,14 +11,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Transformers\ActivityTransformer;
|
use App\Transformers\ActivityTransformer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ActivityController extends BaseController
|
class ActivityController extends BaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $entity_type = Activity::class;
|
protected $entity_type = Activity::class;
|
||||||
|
|
||||||
protected $entity_transformer = ActivityTransformer::class;
|
protected $entity_transformer = ActivityTransformer::class;
|
||||||
@ -66,7 +64,7 @@ class ActivityController extends BaseController
|
|||||||
|
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="default",
|
* response="default",
|
||||||
* description="Unexpected Error",
|
* description="Unexpected Error",
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
* ),
|
* ),
|
||||||
@ -83,5 +81,4 @@ class ActivityController extends BaseController
|
|||||||
|
|
||||||
return $this->listResponse($activities);
|
return $this->listResponse($activities);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -41,13 +41,14 @@ class ContactForgotPasswordController extends Controller
|
|||||||
$this->middleware('guest:contact');
|
$this->middleware('guest:contact');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the reset email form.
|
* Show the reset email form.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function showLinkRequestForm(){
|
public function showLinkRequestForm()
|
||||||
return view('portal.default.auth.passwords.email',[
|
{
|
||||||
|
return view('portal.default.auth.passwords.email', [
|
||||||
'title' => 'Client Password Reset',
|
'title' => 'Client Password Reset',
|
||||||
'passwordEmailRoute' => 'client.password.email'
|
'passwordEmailRoute' => 'client.password.email'
|
||||||
]);
|
]);
|
||||||
@ -60,6 +61,6 @@ class ContactForgotPasswordController extends Controller
|
|||||||
|
|
||||||
public function broker()
|
public function broker()
|
||||||
{
|
{
|
||||||
return Password::broker('contacts');
|
return Password::broker('contacts');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ use Route;
|
|||||||
|
|
||||||
class ContactLoginController extends Controller
|
class ContactLoginController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
use AuthenticatesUsers;
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
protected $redirectTo = '/client/dashboard';
|
protected $redirectTo = '/client/dashboard';
|
||||||
@ -32,9 +31,7 @@ class ContactLoginController extends Controller
|
|||||||
|
|
||||||
public function showLoginForm()
|
public function showLoginForm()
|
||||||
{
|
{
|
||||||
|
return view('portal.default.auth.login');
|
||||||
return view('portal.default.auth.login');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,20 +60,19 @@ class ContactLoginController extends Controller
|
|||||||
|
|
||||||
public function authenticated(Request $request, ClientContact $client)
|
public function authenticated(Request $request, ClientContact $client)
|
||||||
{
|
{
|
||||||
|
|
||||||
Auth::guard('contact')->login($client, true);
|
Auth::guard('contact')->login($client, true);
|
||||||
|
|
||||||
if(session()->get('url.intended'))
|
if (session()->get('url.intended')) {
|
||||||
return redirect(session()->get('url.intended'));
|
return redirect(session()->get('url.intended'));
|
||||||
|
}
|
||||||
|
|
||||||
return redirect(route('client.dashboard'));
|
return redirect(route('client.dashboard'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
|
|
||||||
Auth::guard('contact')->logout();
|
Auth::guard('contact')->logout();
|
||||||
|
|
||||||
return redirect('/client/login');
|
return redirect('/client/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,6 @@ class ContactResetPasswordController extends Controller
|
|||||||
|
|
||||||
public function broker()
|
public function broker()
|
||||||
{
|
{
|
||||||
return Password::broker('contacts');
|
return Password::broker('contacts');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class ForgotPasswordController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Password Reset
|
* Password Reset
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/reset_password",
|
* path="/api/v1/reset_password",
|
||||||
* operationId="reset_password",
|
* operationId="reset_password",
|
||||||
@ -93,7 +93,7 @@ class ForgotPasswordController extends Controller
|
|||||||
|
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="default",
|
* response="default",
|
||||||
* description="Unexpected Error",
|
* description="Unexpected Error",
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
* ),
|
* ),
|
||||||
@ -115,5 +115,4 @@ class ForgotPasswordController extends Controller
|
|||||||
? response()->json(['message' => 'Reset link sent to your email.', 'status' => true], 201)
|
? response()->json(['message' => 'Reset link sent to your email.', 'status' => true], 201)
|
||||||
: response()->json(['message' => 'Email not found', 'status' => false], 401);
|
: response()->json(['message' => 'Email not found', 'status' => false], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,16 +40,16 @@ class LoginController extends BaseController
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OA\Tag(
|
* @OA\Tag(
|
||||||
* name="login",
|
* name="login",
|
||||||
* description="Authentication",
|
* description="Authentication",
|
||||||
* @OA\ExternalDocumentation(
|
* @OA\ExternalDocumentation(
|
||||||
* description="Find out more",
|
* description="Find out more",
|
||||||
* url="http://docs.invoiceninja.com"
|
* url="http://docs.invoiceninja.com"
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use AuthenticatesUsers;
|
use AuthenticatesUsers;
|
||||||
use UserSessionAttributes;
|
use UserSessionAttributes;
|
||||||
@ -72,9 +72,7 @@ class LoginController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +95,7 @@ class LoginController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return Response|User Process user login.
|
* @return Response|User Process user login.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/login",
|
* path="/api/v1/login",
|
||||||
* operationId="postLogin",
|
* operationId="postLogin",
|
||||||
@ -146,7 +144,7 @@ class LoginController extends BaseController
|
|||||||
|
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="default",
|
* response="default",
|
||||||
* description="Unexpected Error",
|
* description="Unexpected Error",
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
* ),
|
* ),
|
||||||
@ -170,17 +168,13 @@ class LoginController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->attemptLogin($request)) {
|
if ($this->attemptLogin($request)) {
|
||||||
|
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
|
|
||||||
$user->setCompany($user->company_user->account->default_company);
|
$user->setCompany($user->company_user->account->default_company);
|
||||||
|
|
||||||
$ct = CompanyUser::whereUserId($user->id);
|
$ct = CompanyUser::whereUserId($user->id);
|
||||||
return $this->listResponse($ct);
|
return $this->listResponse($ct);
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
$this->incrementLoginAttempts($request);
|
$this->incrementLoginAttempts($request);
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
@ -188,15 +182,14 @@ class LoginController extends BaseController
|
|||||||
->header('X-App-Version', config('ninja.app_version'))
|
->header('X-App-Version', config('ninja.app_version'))
|
||||||
->header('X-Api-Version', config('ninja.api_version'));
|
->header('X-Api-Version', config('ninja.api_version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the data feed with the current Company User
|
* Refreshes the data feed with the current Company User
|
||||||
*
|
*
|
||||||
* @return CompanyUser Refresh Feed.
|
* @return CompanyUser Refresh Feed.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/api/v1/refresh",
|
* path="/api/v1/refresh",
|
||||||
* operationId="refresh",
|
* operationId="refresh",
|
||||||
@ -224,7 +217,7 @@ class LoginController extends BaseController
|
|||||||
|
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="default",
|
* response="default",
|
||||||
* description="Unexpected Error",
|
* description="Unexpected Error",
|
||||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||||
* ),
|
* ),
|
||||||
@ -233,8 +226,8 @@ class LoginController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function refresh(Request $request)
|
public function refresh(Request $request)
|
||||||
{
|
{
|
||||||
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
||||||
return $this->listResponse($ct);
|
return $this->listResponse($ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,28 +235,27 @@ class LoginController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function redirectToProvider(string $provider)
|
public function redirectToProvider(string $provider)
|
||||||
{
|
{
|
||||||
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
|
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
|
||||||
//
|
//
|
||||||
if(request()->has('code'))
|
if (request()->has('code')) {
|
||||||
return $this->handleProviderCallback($provider);
|
return $this->handleProviderCallback($provider);
|
||||||
else
|
} else {
|
||||||
return Socialite::driver($provider)->scopes('https://www.googleapis.com/auth/gmail.send')->redirect();
|
return Socialite::driver($provider)->scopes('https://www.googleapis.com/auth/gmail.send')->redirect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function redirectToProviderAndCreate(string $provider)
|
public function redirectToProviderAndCreate(string $provider)
|
||||||
{
|
{
|
||||||
|
|
||||||
$redirect_url = config('services.' . $provider . '.redirect') . '/create';
|
$redirect_url = config('services.' . $provider . '.redirect') . '/create';
|
||||||
|
|
||||||
if(request()->has('code'))
|
if (request()->has('code')) {
|
||||||
return $this->handleProviderCallbackAndCreate($provider);
|
return $this->handleProviderCallbackAndCreate($provider);
|
||||||
else
|
} else {
|
||||||
return Socialite::driver($provider)->scopes('https://www.googleapis.com/auth/gmail.send')->redirectUrl($redirect_url)->redirect();
|
return Socialite::driver($provider)->scopes('https://www.googleapis.com/auth/gmail.send')->redirectUrl($redirect_url)->redirect();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,23 +270,20 @@ class LoginController extends BaseController
|
|||||||
->user();
|
->user();
|
||||||
|
|
||||||
/* Handle existing users who attempt to create another account with existing OAuth credentials */
|
/* Handle existing users who attempt to create another account with existing OAuth credentials */
|
||||||
if($user = OAuth::handleAuth($socialite_user, $provider))
|
if ($user = OAuth::handleAuth($socialite_user, $provider)) {
|
||||||
{
|
|
||||||
$user->oauth_user_token = $socialite_user->refreshToken;
|
$user->oauth_user_token = $socialite_user->refreshToken;
|
||||||
$user->save();
|
$user->save();
|
||||||
Auth::login($user, true);
|
Auth::login($user, true);
|
||||||
|
|
||||||
return redirect($this->redirectTo);
|
return redirect($this->redirectTo);
|
||||||
}
|
} elseif (MultiDB::checkUserEmailExists($socialite_user->getEmail())) {
|
||||||
else if(MultiDB::checkUserEmailExists($socialite_user->getEmail()))
|
|
||||||
{
|
|
||||||
Session::flash('error', 'User exists in system, but not with this authentication method'); //todo add translations
|
Session::flash('error', 'User exists in system, but not with this authentication method'); //todo add translations
|
||||||
|
|
||||||
return view('auth.login');
|
return view('auth.login');
|
||||||
}
|
}
|
||||||
/** 3. Automagically creating a new account here. */
|
/** 3. Automagically creating a new account here. */
|
||||||
else {
|
else {
|
||||||
//todo
|
//todo
|
||||||
$name = OAuth::splitName($socialite_user->getName());
|
$name = OAuth::splitName($socialite_user->getName());
|
||||||
|
|
||||||
$new_account = [
|
$new_account = [
|
||||||
@ -317,17 +306,15 @@ class LoginController extends BaseController
|
|||||||
|
|
||||||
return redirect($this->redirectTo)->withCookie($cookie);
|
return redirect($this->redirectTo)->withCookie($cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We use this function when OAUTHING via the web interface
|
* We use this function when OAUTHING via the web interface
|
||||||
*
|
*
|
||||||
* @return redirect
|
* @return redirect
|
||||||
*/
|
*/
|
||||||
public function handleProviderCallback(string $provider)
|
public function handleProviderCallback(string $provider)
|
||||||
{
|
{
|
||||||
|
|
||||||
$redirect_url = config('services.' . $provider . '.redirect');
|
$redirect_url = config('services.' . $provider . '.redirect');
|
||||||
|
|
||||||
$socialite_user = Socialite::driver($provider)
|
$socialite_user = Socialite::driver($provider)
|
||||||
@ -335,23 +322,20 @@ class LoginController extends BaseController
|
|||||||
->stateless()
|
->stateless()
|
||||||
->user();
|
->user();
|
||||||
|
|
||||||
if($user = OAuth::handleAuth($socialite_user, $provider))
|
if ($user = OAuth::handleAuth($socialite_user, $provider)) {
|
||||||
{
|
|
||||||
$user->oauth_user_token = $socialite_user->token;
|
$user->oauth_user_token = $socialite_user->token;
|
||||||
$user->save();
|
$user->save();
|
||||||
Auth::login($user, true);
|
Auth::login($user, true);
|
||||||
|
|
||||||
return redirect($this->redirectTo);
|
return redirect($this->redirectTo);
|
||||||
}
|
} elseif (MultiDB::checkUserEmailExists($socialite_user->getEmail())) {
|
||||||
else if(MultiDB::checkUserEmailExists($socialite_user->getEmail()))
|
|
||||||
{
|
|
||||||
Session::flash('error', 'User exists in system, but not with this authentication method'); //todo add translations
|
Session::flash('error', 'User exists in system, but not with this authentication method'); //todo add translations
|
||||||
|
|
||||||
return view('auth.login');
|
return view('auth.login');
|
||||||
}
|
}
|
||||||
/** 3. Automagically creating a new account here. */
|
/** 3. Automagically creating a new account here. */
|
||||||
else {
|
else {
|
||||||
//todo
|
//todo
|
||||||
$name = OAuth::splitName($socialite_user->getName());
|
$name = OAuth::splitName($socialite_user->getName());
|
||||||
|
|
||||||
$new_account = [
|
$new_account = [
|
||||||
@ -372,25 +356,22 @@ class LoginController extends BaseController
|
|||||||
|
|
||||||
return redirect($this->redirectTo)->withCookie($cookie);
|
return redirect($this->redirectTo)->withCookie($cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A client side authentication has taken place.
|
* A client side authentication has taken place.
|
||||||
* We now digest the token and confirm authentication with
|
* We now digest the token and confirm authentication with
|
||||||
* the authentication server, the correct user object
|
* the authentication server, the correct user object
|
||||||
* is returned to us here and we send back the correct
|
* is returned to us here and we send back the correct
|
||||||
* user object payload - or error.
|
* user object payload - or error.
|
||||||
*
|
*
|
||||||
* This can be extended to a create route also - need to pass a ?create query parameter and
|
* This can be extended to a create route also - need to pass a ?create query parameter and
|
||||||
* then process the signup
|
* then process the signup
|
||||||
*
|
*
|
||||||
* return User $user
|
* return User $user
|
||||||
*/
|
*/
|
||||||
public function oauthApiLogin()
|
public function oauthApiLogin()
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = false;
|
$user = false;
|
||||||
|
|
||||||
$oauth = new OAuth();
|
$oauth = new OAuth();
|
||||||
@ -400,12 +381,9 @@ class LoginController extends BaseController
|
|||||||
if ($user) {
|
if ($user) {
|
||||||
$ct = CompanyUser::whereUserId($user);
|
$ct = CompanyUser::whereUserId($user);
|
||||||
return $this->listResponse($ct);
|
return $this->listResponse($ct);
|
||||||
// return $this->itemResponse($user);
|
// return $this->itemResponse($user);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
return $this->errorResponse(['message' => 'Invalid credentials'], 401);
|
return $this->errorResponse(['message' => 'Invalid credentials'], 401);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user