mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 07:57:33 -05:00 
			
		
		
		
	
						commit
						ce696f7950
					
				@ -1 +1 @@
 | 
				
			|||||||
5.2.13
 | 
					5.2.14
 | 
				
			||||||
@ -91,6 +91,8 @@ class CreateAccount extends Command
 | 
				
			|||||||
        $account = Account::factory()->create();
 | 
					        $account = Account::factory()->create();
 | 
				
			||||||
        $company = Company::factory()->create([
 | 
					        $company = Company::factory()->create([
 | 
				
			||||||
            'account_id' => $account->id,
 | 
					            'account_id' => $account->id,
 | 
				
			||||||
 | 
					            'portal_domain' => config('ninja.app_url'),
 | 
				
			||||||
 | 
					            'portal_mode' => 'domain',
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $account->default_company_id = $company->id;
 | 
					        $account->default_company_id = $company->id;
 | 
				
			||||||
 | 
				
			|||||||
@ -174,8 +174,8 @@ class ReminderJob implements ShouldQueue
 | 
				
			|||||||
        /**Refresh Invoice values*/
 | 
					        /**Refresh Invoice values*/
 | 
				
			||||||
        $invoice = $invoice->calc()->getInvoice();
 | 
					        $invoice = $invoice->calc()->getInvoice();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->client->service()->updateBalance($this->invoice->balance - $temp_invoice_balance)->save();
 | 
					        $invoice->client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save();
 | 
				
			||||||
        $invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$this->invoice->number}");
 | 
					        $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$this->invoice->number}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $invoice;
 | 
					        return $invoice;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ class CreditCreatedNotification implements ShouldQueue
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        MultiDB::setDb($event->company->db);
 | 
					        MultiDB::setDb($event->company->db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $first_notification_sent = true;
 | 
					        // $first_notification_sent = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $credit = $event->credit;
 | 
					        $credit = $event->credit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -60,7 +60,7 @@ class CreditCreatedNotification implements ShouldQueue
 | 
				
			|||||||
            $methods = $this->findUserNotificationTypes($credit->invitations()->first(), $company_user, 'credit', ['all_notifications', 'credit_created', 'credit_created_all']);
 | 
					            $methods = $this->findUserNotificationTypes($credit->invitations()->first(), $company_user, 'credit', ['all_notifications', 'credit_created', 'credit_created_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
					            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods)) !== false) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
@ -69,7 +69,7 @@ class CreditCreatedNotification implements ShouldQueue
 | 
				
			|||||||
                NinjaMailerJob::dispatch($nmo);
 | 
					                NinjaMailerJob::dispatch($nmo);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                /* This prevents more than one notification being sent */
 | 
					                /* This prevents more than one notification being sent */
 | 
				
			||||||
                $first_notification_sent = false;
 | 
					                // $first_notification_sent = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* Override the methods in the Notification Class */
 | 
					            /* Override the methods in the Notification Class */
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ class CreditEmailedNotification implements ShouldQueue
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        MultiDB::setDb($event->company->db);
 | 
					        MultiDB::setDb($event->company->db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $first_notification_sent = true;
 | 
					        // $first_notification_sent = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $credit = $event->invitation->credit;
 | 
					        $credit = $event->invitation->credit;
 | 
				
			||||||
        $credit->last_sent_date = now();
 | 
					        $credit->last_sent_date = now();
 | 
				
			||||||
@ -56,14 +56,15 @@ class CreditEmailedNotification implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']);
 | 
					            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods)) !== false) {
 | 
				
			||||||
 | 
					            // if (($key = array_search('mail', $methods))) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $nmo->to_user = $user;
 | 
					                $nmo->to_user = $user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                NinjaMailerJob::dispatch($nmo);
 | 
					                NinjaMailerJob::dispatch($nmo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $first_notification_sent = false;
 | 
					                // $first_notification_sent = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // $notification->method = $methods;
 | 
					            // $notification->method = $methods;
 | 
				
			||||||
 | 
				
			|||||||
@ -52,24 +52,23 @@ class InvoiceCreatedNotification implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            /* The User */
 | 
					            /* The User */
 | 
				
			||||||
            $user = $company_user->user;
 | 
					            $user = $company_user->user;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            /* This is only here to handle the alternate message channels - ie Slack */
 | 
					            /* This is only here to handle the alternate message channels - ie Slack */
 | 
				
			||||||
            // $notification = new EntitySentNotification($event->invitation, 'invoice');
 | 
					            // $notification = new EntitySentNotification($event->invitation, 'invoice');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* Returns an array of notification methods */
 | 
					            /* Returns an array of notification methods */
 | 
				
			||||||
            $methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']);
 | 
					            $methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
					            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            // if (($key = array_search('mail', $methods))) {
 | 
				
			||||||
 | 
					            if (($key = array_search('mail', $methods)) !== false) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                
 | 
					 | 
				
			||||||
                $nmo->to_user = $user;
 | 
					                $nmo->to_user = $user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                NinjaMailerJob::dispatch($nmo);
 | 
					                NinjaMailerJob::dispatch($nmo);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                /* This prevents more than one notification being sent */
 | 
					                /* This prevents more than one notification being sent */
 | 
				
			||||||
                $first_notification_sent = false;
 | 
					                $first_notification_sent = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* Override the methods in the Notification Class */
 | 
					            /* Override the methods in the Notification Class */
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ class InvoiceEmailedNotification implements ShouldQueue
 | 
				
			|||||||
            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
 | 
					            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
					            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods))) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,7 @@ class InvoiceFailedEmailNotification
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
 | 
					            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods))) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $nmo->to_user = $user;
 | 
					                $nmo->to_user = $user;
 | 
				
			||||||
 | 
				
			|||||||
@ -60,7 +60,7 @@ class QuoteCreatedNotification implements ShouldQueue
 | 
				
			|||||||
            $methods = $this->findUserNotificationTypes($quote->invitations()->first(), $company_user, 'quote', ['all_notifications', 'quote_created', 'quote_created_all']);
 | 
					            $methods = $this->findUserNotificationTypes($quote->invitations()->first(), $company_user, 'quote', ['all_notifications', 'quote_created', 'quote_created_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
					            /* If one of the methods is email then we fire the EntitySentMailer */
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods))) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ class QuoteEmailedNotification implements ShouldQueue
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        MultiDB::setDb($event->company->db);
 | 
					        MultiDB::setDb($event->company->db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $first_notification_sent = true;
 | 
					        // $first_notification_sent = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $quote = $event->invitation->quote;
 | 
					        $quote = $event->invitation->quote;
 | 
				
			||||||
        $quote->last_sent_date = now();
 | 
					        $quote->last_sent_date = now();
 | 
				
			||||||
@ -57,7 +57,7 @@ class QuoteEmailedNotification implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']);
 | 
					            $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
 | 
					            if (($key = array_search('mail', $methods)) !== false) {
 | 
				
			||||||
                unset($methods[$key]);
 | 
					                unset($methods[$key]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
@ -65,7 +65,7 @@ class QuoteEmailedNotification implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                NinjaMailerJob::dispatch($nmo);
 | 
					                NinjaMailerJob::dispatch($nmo);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                $first_notification_sent = false;
 | 
					                // $first_notification_sent = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // $notification->method = $methods;
 | 
					            // $notification->method = $methods;
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ class EntityCreatedObject
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public $entity;
 | 
					    public $entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $contact;
 | 
					    public $client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -49,7 +49,7 @@ class EntityCreatedObject
 | 
				
			|||||||
        /* Set customized translations _NOW_ */
 | 
					        /* Set customized translations _NOW_ */
 | 
				
			||||||
        $t->replace(Ninja::transformTranslations($this->entity->company->settings));
 | 
					        $t->replace(Ninja::transformTranslations($this->entity->company->settings));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->contact = $this->entity->invitations()->first()->contact;
 | 
					        $this->client = $this->entity->client;
 | 
				
			||||||
        $this->company = $this->entity->company;
 | 
					        $this->company = $this->entity->company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->setTemplate();
 | 
					        $this->setTemplate();
 | 
				
			||||||
@ -100,7 +100,7 @@ class EntityCreatedObject
 | 
				
			|||||||
            ctrans(
 | 
					            ctrans(
 | 
				
			||||||
                $this->template_subject,
 | 
					                $this->template_subject,
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                        'client' => $this->contact->present()->name(),
 | 
					                        'client' => $this->client->present()->name(),
 | 
				
			||||||
                        'invoice' => $this->entity->number,
 | 
					                        'invoice' => $this->entity->number,
 | 
				
			||||||
                    ]
 | 
					                    ]
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
@ -112,7 +112,7 @@ class EntityCreatedObject
 | 
				
			|||||||
                $this->template_body,
 | 
					                $this->template_body,
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    'amount' => $this->getAmount(),
 | 
					                    'amount' => $this->getAmount(),
 | 
				
			||||||
                    'client' => $this->contact->present()->name(),
 | 
					                    'client' => $this->client->present()->name(),
 | 
				
			||||||
                    'invoice' => $this->entity->number,
 | 
					                    'invoice' => $this->entity->number,
 | 
				
			||||||
                ]
 | 
					                ]
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
				
			|||||||
@ -19,13 +19,13 @@ class TestMailServer extends Mailable
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 //   use Queueable, SerializesModels;
 | 
					 //   use Queueable, SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $message;
 | 
					    public $support_messages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $from_email;
 | 
					    public $from_email;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($message, $from_email)
 | 
					    public function __construct($support_messages, $from_email)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->message = $message;
 | 
					        $this->support_messages = $support_messages;
 | 
				
			||||||
        $this->from_email = $from_email;
 | 
					        $this->from_email = $from_email;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -39,7 +39,7 @@ class TestMailServer extends Mailable
 | 
				
			|||||||
        return $this->from(config('mail.from.address'), config('mail.from.name'))
 | 
					        return $this->from(config('mail.from.address'), config('mail.from.name'))
 | 
				
			||||||
            ->subject(ctrans('texts.email'))
 | 
					            ->subject(ctrans('texts.email'))
 | 
				
			||||||
            ->markdown('email.support.message', [
 | 
					            ->markdown('email.support.message', [
 | 
				
			||||||
                'message' => $this->message,
 | 
					                'support_message' => $this->support_messages,
 | 
				
			||||||
                'system_info' => '',
 | 
					                'system_info' => '',
 | 
				
			||||||
                'laravel_log' => [],
 | 
					                'laravel_log' => [],
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
 | 
				
			|||||||
@ -87,10 +87,10 @@ class Gateway extends StaticModel
 | 
				
			|||||||
            case 20:
 | 
					            case 20:
 | 
				
			||||||
            case 56:
 | 
					            case 56:
 | 
				
			||||||
                return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
 | 
					                return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
 | 
				
			||||||
                    GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable']],
 | 
					                    GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable','charge.succeeded']],
 | 
				
			||||||
                    GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
 | 
					                    GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
 | 
				
			||||||
                    GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
 | 
					                    GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
 | 
				
			||||||
                    GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable']]]; //Stripe
 | 
					                    GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']]]; //Stripe
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 39:
 | 
					            case 39:
 | 
				
			||||||
                return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Checkout
 | 
					                return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Checkout
 | 
				
			||||||
 | 
				
			|||||||
@ -105,7 +105,7 @@ class ACH
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->stripe->init();
 | 
					        $this->stripe->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $bank_account = Customer::retrieveSource($request->customer, $request->source, $this->stripe->stripe_connect_auth);
 | 
					        $bank_account = Customer::retrieveSource($request->customer, ['source' => $request->source], $this->stripe->stripe_connect_auth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $bank_account->verify(['amounts' => request()->transactions]);
 | 
					            $bank_account->verify(['amounts' => request()->transactions]);
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,7 @@ trait CompanySettingsSaver
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function saveSettings($settings, $entity)
 | 
					    public function saveSettings($settings, $entity)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* No Settings, No Save!*/
 | 
					        /* No Settings, No Save!*/
 | 
				
			||||||
        if (! $settings) {
 | 
					        if (! $settings) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
@ -58,6 +59,8 @@ trait CompanySettingsSaver
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(property_exists($settings, 'translations'))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
        //this pass will handle any null values that are in the translations
 | 
					        //this pass will handle any null values that are in the translations
 | 
				
			||||||
            foreach ($settings->translations as $key => $value) {
 | 
					            foreach ($settings->translations as $key => $value) {
 | 
				
			||||||
                if (is_null($settings->translations[$key])) {
 | 
					                if (is_null($settings->translations[$key])) {
 | 
				
			||||||
@ -66,6 +69,7 @@ trait CompanySettingsSaver
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $company_settings->translations = $settings->translations;
 | 
					            $company_settings->translations = $settings->translations;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity->settings = $company_settings;
 | 
					        $entity->settings = $company_settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,7 @@ use App\Models\Task;
 | 
				
			|||||||
use App\Models\Timezone;
 | 
					use App\Models\Timezone;
 | 
				
			||||||
use App\Models\Vendor;
 | 
					use App\Models\Vendor;
 | 
				
			||||||
use Illuminate\Support\Carbon;
 | 
					use Illuminate\Support\Carbon;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Class GeneratesCounter.
 | 
					 * Class GeneratesCounter.
 | 
				
			||||||
@ -343,17 +344,24 @@ trait GeneratesCounter
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $check = false;
 | 
					        $check = false;
 | 
				
			||||||
 | 
					        $check_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        do {
 | 
					        do {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $number = $this->padCounter($counter, $padding);
 | 
					            $number = $this->padCounter($counter, $padding);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $number = $this->applyNumberPattern($entity, $number, $pattern);
 | 
					            $number = $this->applyNumberPattern($entity, $number, $pattern);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $number = $this->prefixCounter($number, $prefix);
 | 
					            $number = $this->prefixCounter($number, $prefix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $check = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->first();
 | 
					            $check = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->exists();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $counter++;
 | 
					            $counter++;
 | 
				
			||||||
 | 
					            $check_counter++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if($check_counter > 100)
 | 
				
			||||||
 | 
					                return $number . "_" . Str::random(5);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } while ($check);
 | 
					        } while ($check);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $number;
 | 
					        return $number;
 | 
				
			||||||
@ -364,7 +372,7 @@ trait GeneratesCounter
 | 
				
			|||||||
    public function checkNumberAvailable($class, $entity, $number) :bool
 | 
					    public function checkNumberAvailable($class, $entity, $number) :bool
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($entity = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->first()) 
 | 
					        if ($entity = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->exists()) 
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Models\Language;
 | 
				
			||||||
 | 
					use Illuminate\Database\Migrations\Migration;
 | 
				
			||||||
 | 
					use Illuminate\Database\Schema\Blueprint;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ChangeEnglishLanguagesTables extends Migration
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Run the migrations.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function up()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if($language = Language::find(1))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            $language->name = 'English - United States';
 | 
				
			||||||
 | 
					            $language->save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Reverse the migrations.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function down()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -24,7 +24,7 @@ class LanguageSeeder extends Seeder
 | 
				
			|||||||
        // https://www.loc.gov/standards/iso639-2/php/code_list.php
 | 
					        // https://www.loc.gov/standards/iso639-2/php/code_list.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $languages = [
 | 
					        $languages = [
 | 
				
			||||||
            ['id' => 1, 'name' => 'English', 'locale' => 'en'],
 | 
					            ['id' => 1, 'name' => 'English - United States', 'locale' => 'en'],
 | 
				
			||||||
            ['id' => 2, 'name' => 'Italian', 'locale' => 'it'],
 | 
					            ['id' => 2, 'name' => 'Italian', 'locale' => 'it'],
 | 
				
			||||||
            ['id' => 3, 'name' => 'German', 'locale' => 'de'],
 | 
					            ['id' => 3, 'name' => 'German', 'locale' => 'de'],
 | 
				
			||||||
            ['id' => 4, 'name' => 'French', 'locale' => 'fr'],
 | 
					            ['id' => 4, 'name' => 'French', 'locale' => 'fr'],
 | 
				
			||||||
 | 
				
			|||||||
@ -100,6 +100,7 @@ class CompanyTest extends TestCase
 | 
				
			|||||||
        $settings->invoice_design_id = '2';
 | 
					        $settings->invoice_design_id = '2';
 | 
				
			||||||
        $settings->quote_design_id = '1';
 | 
					        $settings->quote_design_id = '1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nlog($settings);
 | 
				
			||||||
        $company->settings = $settings;
 | 
					        $company->settings = $settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user