mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:57:35 -05:00 
			
		
		
		
	Merge pull request #7395 from turbo124/v5-develop
Payable invoice filters
This commit is contained in:
		
						commit
						e7aedf1270
					
				@ -138,6 +138,18 @@ class InvoiceFilters extends QueryFilters
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function payable(string $client_id)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (strlen($client_id) == 0) {
 | 
				
			||||||
 | 
					            return $this->builder;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->builder->whereIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
 | 
				
			||||||
 | 
					                             ->where('balance', '>', 0)
 | 
				
			||||||
 | 
					                             ->where('is_deleted', 0)
 | 
				
			||||||
 | 
					                             ->where('client_id', $this->decodePrimaryKey($client_id));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sorts the list based on $sort.
 | 
					     * Sorts the list based on $sort.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -158,7 +158,11 @@ class UpdateClientRequest extends Request
 | 
				
			|||||||
                unset($settings->{$key});
 | 
					                unset($settings->{$key});
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($key == 'default_task_rate'){
 | 
					            //26-04-2022 - In case settings are returned as array instead of object
 | 
				
			||||||
 | 
					            if($key == 'default_task_rate' && is_array($settings)){
 | 
				
			||||||
 | 
					                $settings['default_task_rate'] = floatval($value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            elseif($key == 'default_task_rate' && is_object($settings)) {
 | 
				
			||||||
                $settings->default_task_rate = floatval($value);
 | 
					                $settings->default_task_rate = floatval($value);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -181,6 +181,65 @@ class BaseImport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			} catch (\Exception $ex) {
 | 
								} catch (\Exception $ex) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if(\DB::connection(config('database.default'))->transactionLevel() > 0)
 | 
				
			||||||
 | 
										\DB::connection(config('database.default'))->rollBack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if ($ex instanceof ImportException) {
 | 
				
			||||||
 | 
										$message = $ex->getMessage();
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										report($ex);
 | 
				
			||||||
 | 
										$message = 'Unknown error';
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									$this->error_array[$entity_type][] = [
 | 
				
			||||||
 | 
										$entity_type => $record,
 | 
				
			||||||
 | 
										'error' => $message,
 | 
				
			||||||
 | 
									];
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return $count;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function ingestProducts($data, $entity_type)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							$count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							foreach ($data as $key => $record) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								try {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									$entity = $this->transformer->transform($record);
 | 
				
			||||||
 | 
									$validator = $this->request_name::runFormRequest($entity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if ($validator->fails()) {
 | 
				
			||||||
 | 
										$this->error_array[$entity_type][] = [
 | 
				
			||||||
 | 
											$entity_type => $record,
 | 
				
			||||||
 | 
											'error' => $validator->errors()->all(),
 | 
				
			||||||
 | 
										];
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if($this->transformer->hasProduct($entity['product_key'])) 
 | 
				
			||||||
 | 
											$product = $this->transformer->getProduct($entity['product_key']);
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											$product = $this->factory_name::create($this->company->id,$this->getUserIDForRecord($entity));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										$entity = $this->repository->save(
 | 
				
			||||||
 | 
											array_diff_key($entity, ['user_id' => false]),
 | 
				
			||||||
 | 
											$product
 | 
				
			||||||
 | 
										);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										$entity->saveQuietly();
 | 
				
			||||||
 | 
										$count++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								} catch (\Exception $ex) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if(\DB::connection(config('database.default'))->transactionLevel() > 0)
 | 
				
			||||||
 | 
										\DB::connection(config('database.default'))->rollBack();
 | 
				
			||||||
 | 
									
 | 
				
			||||||
				if ($ex instanceof ImportException) {
 | 
									if ($ex instanceof ImportException) {
 | 
				
			||||||
					$message = $ex->getMessage();
 | 
										$message = $ex->getMessage();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
@ -309,6 +368,10 @@ class BaseImport
 | 
				
			|||||||
					);
 | 
										);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} catch (\Exception $ex) {
 | 
								} catch (\Exception $ex) {
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									if(\DB::connection(config('database.default'))->transactionLevel() > 0)
 | 
				
			||||||
 | 
										\DB::connection(config('database.default'))->rollBack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if ($ex instanceof ImportException) {
 | 
									if ($ex instanceof ImportException) {
 | 
				
			||||||
					$message = $ex->getMessage();
 | 
										$message = $ex->getMessage();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
@ -506,6 +569,8 @@ class BaseImport
 | 
				
			|||||||
			'company' => $this->company,
 | 
								'company' => $this->company,
 | 
				
			||||||
		];
 | 
							];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nlog($this->company->company_users);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$nmo = new NinjaMailerObject;
 | 
							$nmo = new NinjaMailerObject;
 | 
				
			||||||
		$nmo->mailable = new ImportCompleted($this->company, $data);
 | 
							$nmo->mailable = new ImportCompleted($this->company, $data);
 | 
				
			||||||
		$nmo->company = $this->company;
 | 
							$nmo->company = $this->company;
 | 
				
			||||||
 | 
				
			|||||||
@ -116,7 +116,7 @@ class Csv extends BaseImport implements ImportInterface
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->transformer = new ProductTransformer($this->company);
 | 
					        $this->transformer = new ProductTransformer($this->company);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $product_count = $this->ingest($data, $entity_type);
 | 
					        $product_count = $this->ingestProducts($data, $entity_type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->entity_count['products'] = $product_count;
 | 
					        $this->entity_count['products'] = $product_count;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -199,20 +199,16 @@ class BaseTransformer
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return string
 | 
					     * @return string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getProduct($data, $key, $field, $default = false)
 | 
					    public function getProduct($key)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $product = $this->company
 | 
					        $product = $this->company
 | 
				
			||||||
            ->products()
 | 
					            ->products()
 | 
				
			||||||
            ->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,''))  = ?", [
 | 
					            ->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,''))  = ?", [
 | 
				
			||||||
                strtolower(str_replace(' ', '', $data->{$key})),
 | 
					                strtolower(str_replace(' ', '', $key)),
 | 
				
			||||||
            ])
 | 
					            ])
 | 
				
			||||||
            ->first();
 | 
					            ->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($product) {
 | 
					        return $product;
 | 
				
			||||||
            return $product->{$field} ?: $default;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $default;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -241,7 +241,6 @@ class Import implements ShouldQueue
 | 
				
			|||||||
            $this->company->account->companies()->update(['is_large' => true]);
 | 
					            $this->company->account->companies()->update(['is_large' => true]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->company->client_registration_fields = \App\DataMapper\ClientRegistrationFields::generate();
 | 
					        $this->company->client_registration_fields = \App\DataMapper\ClientRegistrationFields::generate();
 | 
				
			||||||
        $this->company->save();
 | 
					        $this->company->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -948,6 +947,11 @@ class Import implements ShouldQueue
 | 
				
			|||||||
                RecurringInvoiceFactory::create($this->company->id, $modified['user_id'])
 | 
					                RecurringInvoiceFactory::create($this->company->id, $modified['user_id'])
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if($invoice->status_id == 4 && $invoice->remaining_cycles == -1){
 | 
				
			||||||
 | 
					                $invoice->status_id =2;
 | 
				
			||||||
 | 
					                $invoice->save();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $key = "recurring_invoices_{$resource['id']}";
 | 
					            $key = "recurring_invoices_{$resource['id']}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->ids['recurring_invoices'][$key] = [
 | 
					            $this->ids['recurring_invoices'][$key] = [
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,10 @@ class CompanyDeleted extends Mailable
 | 
				
			|||||||
    public function build()
 | 
					    public function build()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->account->default_company->getLocale());
 | 
					
 | 
				
			||||||
 | 
					        if($this->company)
 | 
				
			||||||
 | 
					            App::setLocale($this->company->getLocale());
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
        $t = app('translator');
 | 
					        $t = app('translator');
 | 
				
			||||||
        $t->replace(Ninja::transformTranslations($this->settings));
 | 
					        $t->replace(Ninja::transformTranslations($this->settings));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -479,7 +479,6 @@ class Company extends BaseModel
 | 
				
			|||||||
    public function owner()
 | 
					    public function owner()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->company_users()->withTrashed()->where('is_owner', true)->first()->user;
 | 
					        return $this->company_users()->withTrashed()->where('is_owner', true)->first()->user;
 | 
				
			||||||
        //return $this->company_users->where('is_owner', true)->first()->user;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function resolveRouteBinding($value, $field = null)
 | 
					    public function resolveRouteBinding($value, $field = null)
 | 
				
			||||||
 | 
				
			|||||||
@ -176,7 +176,7 @@ class AuthorizePaymentMethod
 | 
				
			|||||||
                $billto->setCountry($this->authorize->client->country->name);
 | 
					                $billto->setCountry($this->authorize->client->country->name);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $billto->setPhoneNumber($this->authorize->client->phone);
 | 
					            $billto->setPhoneNumber(substr($this->authorize->client->phone,0,20));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Create a new Customer Payment Profile object
 | 
					        // Create a new Customer Payment Profile object
 | 
				
			||||||
 | 
				
			|||||||
@ -445,7 +445,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if(count($searchResults) == 1){
 | 
					        if(count($searchResults) == 1){
 | 
				
			||||||
            $customer = $searchResults->data[0];
 | 
					            $customer = $searchResults->data[0];
 | 
				
			||||||
            $this->updateStripeCustomer($customer);
 | 
					           // $this->updateStripeCustomer($customer);
 | 
				
			||||||
            return $customer; 
 | 
					            return $customer; 
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -105,7 +105,7 @@ class MarkPaid extends AbstractService
 | 
				
			|||||||
        /* Get the last record for the client and set the current balance*/
 | 
					        /* Get the last record for the client and set the current balance*/
 | 
				
			||||||
            $client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first();
 | 
					            $client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first();
 | 
				
			||||||
            $client->paid_to_date += $payment->amount;
 | 
					            $client->paid_to_date += $payment->amount;
 | 
				
			||||||
            $client->balance += $payment->amount * -1;
 | 
					            $client->balance -= $payment->amount;
 | 
				
			||||||
            $client->save();
 | 
					            $client->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }, 1);
 | 
					        }, 1);
 | 
				
			||||||
 | 
				
			|||||||
@ -51,7 +51,7 @@ class TriggeredActions extends AbstractService
 | 
				
			|||||||
        }        
 | 
					        }        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->request->has('approve') && $this->request->input('approve') == 'true' && in_array($this->quote->status_id, [Quote::STATUS_SENT, Quote::STATUS_DRAFT])) {
 | 
					        if ($this->request->has('approve') && $this->request->input('approve') == 'true' && in_array($this->quote->status_id, [Quote::STATUS_SENT, Quote::STATUS_DRAFT])) {
 | 
				
			||||||
            $this->quote = $this->quote->service()->convert()->save();
 | 
					            $this->quote = $this->quote->service()->approveWithNoCoversion()->save();
 | 
				
			||||||
        }        
 | 
					        }        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
				
			|||||||
@ -213,9 +213,9 @@ class HtmlEngine
 | 
				
			|||||||
        $data['$gross_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getGrossSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
 | 
					        $data['$gross_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getGrossSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($this->entity->uses_inclusive_taxes)
 | 
					        if($this->entity->uses_inclusive_taxes)
 | 
				
			||||||
            $data['$net_subtotal'] = ['value' => Number::formatMoney(($this->entity_calc->getSubTotal() - $this->entity->total_taxes), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
 | 
					            $data['$net_subtotal'] = ['value' => Number::formatMoney(($this->entity_calc->getSubTotal() - $this->entity->total_taxes - $this->entity_calc->getTotalDiscount()), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            $data['$net_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
 | 
					            $data['$net_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal() - $this->entity_calc->getTotalDiscount(), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data['$invoice.subtotal'] = &$data['$subtotal'];
 | 
					        $data['$invoice.subtotal'] = &$data['$subtotal'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -81,9 +81,31 @@ class SystemHealth
 | 
				
			|||||||
            'pdf_engine' => (string) self::getPdfEngine(),
 | 
					            'pdf_engine' => (string) self::getPdfEngine(),
 | 
				
			||||||
            'queue' => (string) config('queue.default'),
 | 
					            'queue' => (string) config('queue.default'),
 | 
				
			||||||
            'trailing_slash' => (bool) self::checkUrlState(),
 | 
					            'trailing_slash' => (bool) self::checkUrlState(),
 | 
				
			||||||
 | 
					            'file_permissions' => (string) self::checkFileSystem()
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static function checkFileSystem()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $directoryIterator = new \RecursiveDirectoryIterator(base_path(), \RecursiveDirectoryIterator::SKIP_DOTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(strpos($file->getPathname(), '.git') !== false)
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //nlog($file->getPathname());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($file->isFile() && ! $file->isWritable()) {
 | 
				
			||||||
 | 
					                return "{$file->getFileName()} is not writable";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 'Ok';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static function checkUrlState()
 | 
					    public static function checkUrlState()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (env('APP_URL') && substr(env('APP_URL'), -1) == '/')
 | 
					        if (env('APP_URL') && substr(env('APP_URL'), -1) == '/')
 | 
				
			||||||
 | 
				
			|||||||
@ -301,17 +301,29 @@ trait MakesInvoiceValues
 | 
				
			|||||||
            $data[$key][$table_type . ".{$_table_type}2"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}2", $item->custom_value2, $this->client);
 | 
					            $data[$key][$table_type . ".{$_table_type}2"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}2", $item->custom_value2, $this->client);
 | 
				
			||||||
            $data[$key][$table_type . ".{$_table_type}3"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}3", $item->custom_value3, $this->client);
 | 
					            $data[$key][$table_type . ".{$_table_type}3"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}3", $item->custom_value3, $this->client);
 | 
				
			||||||
            $data[$key][$table_type . ".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->client);
 | 
					            $data[$key][$table_type . ".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->client);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 08-02-2022 - fix for regression below
 | 
					 | 
				
			||||||
            // $data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            $data[$key][$table_type.'.quantity'] = ($item->quantity == 0) ? '' : Number::formatValueNoTrailingZeroes($item->quantity, $this->client->currency());
 | 
					            if($item->quantity > 0 || $item->cost > 0){
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            $data[$key][$table_type.'.unit_cost'] = ($item->cost == 0) ? '' : Number::formatMoneyNoRounding($item->cost, $this->client);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $data[$key][$table_type.'.cost'] = ($item->cost == 0) ? '' : Number::formatMoney($item->cost, $this->client);
 | 
					                $data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $this->client->currency());
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.unit_cost'] = Number::formatMoneyNoRounding($item->cost, $this->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $data[$key][$table_type.'.line_total'] =  ($item->line_total == 0) ? '' :Number::formatMoney($item->line_total, $this->client);
 | 
					                $data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.line_total'] =  Number::formatMoney($item->line_total, $this->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.quantity'] = '';
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.unit_cost'] = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.cost'] = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $data[$key][$table_type.'.line_total'] =  '';
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(property_exists($item, 'gross_line_total'))
 | 
					            if(property_exists($item, 'gross_line_total'))
 | 
				
			||||||
                $data[$key][$table_type.'.gross_line_total'] =  ($item->gross_line_total == 0) ? '' :Number::formatMoney($item->gross_line_total, $this->client);
 | 
					                $data[$key][$table_type.'.gross_line_total'] =  ($item->gross_line_total == 0) ? '' :Number::formatMoney($item->gross_line_total, $this->client);
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,191 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Database\Migrations\Migration;
 | 
				
			||||||
 | 
					use Illuminate\Database\Schema\Blueprint;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ConvertCustomFieldsColumnFromVarcharToText extends Migration
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Run the migrations.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function up()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        set_time_limit(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('credits', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('client_contacts', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('clients', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('clients', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('documents', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('expenses', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('invoices', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('payments', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('products', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('projects', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('quotes', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('recurring_invoices', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('recurring_quotes', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('recurring_expenses', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('tasks', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('users', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('vendors', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::table('vendor_contacts', function (Blueprint $table) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->text('custom_value1')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value2')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					            $table->text('custom_value3')->change();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Reverse the migrations.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function down()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -22,6 +22,7 @@ use App\Utils\Traits\MakesHash;
 | 
				
			|||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
 | 
					use Illuminate\Foundation\Testing\DatabaseTransactions;
 | 
				
			||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
 | 
					use Illuminate\Routing\Middleware\ThrottleRequests;
 | 
				
			||||||
use Illuminate\Support\Facades\Cache;
 | 
					use Illuminate\Support\Facades\Cache;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Session;
 | 
				
			||||||
use Illuminate\Support\Str;
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
use Tests\MockAccountData;
 | 
					use Tests\MockAccountData;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
@ -34,12 +35,14 @@ class ZohoTest extends TestCase
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    use MakesHash;
 | 
					    use MakesHash;
 | 
				
			||||||
    use MockAccountData;
 | 
					    use MockAccountData;
 | 
				
			||||||
    use DatabaseTransactions;
 | 
					    // use DatabaseTransactions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function setUp(): void
 | 
					    public function setUp(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        parent::setUp();
 | 
					        parent::setUp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Session::start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->withoutMiddleware(ThrottleRequests::class);
 | 
					        $this->withoutMiddleware(ThrottleRequests::class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        config(['database.default' => config('ninja.db.default')]);
 | 
					        config(['database.default' => config('ninja.db.default')]);
 | 
				
			||||||
@ -120,7 +123,7 @@ class ZohoTest extends TestCase
 | 
				
			|||||||
        Cache::put($hash . '-client', base64_encode($csv), 360);
 | 
					        Cache::put($hash . '-client', base64_encode($csv), 360);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $csv_importer = new Zoho($data, $this->company);
 | 
					        $csv_importer = new Zoho($data, $this->company);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $count = $csv_importer->import('client');
 | 
					        $count = $csv_importer->import('client');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $base_transformer = new BaseTransformer($this->company);
 | 
					        $base_transformer = new BaseTransformer($this->company);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user