diff --git a/app/Helpers/Invoice/InvoiceCalc.php b/app/Helpers/Invoice/InvoiceCalc.php index 92a1344e5b01..a343362b50d1 100644 --- a/app/Helpers/Invoice/InvoiceCalc.php +++ b/app/Helpers/Invoice/InvoiceCalc.php @@ -194,7 +194,7 @@ class InvoiceCalc */ private function calcLineItems() { - if(!$this->invoice->line_items || count($this->invoice->line_items) == 0) + if(!$this->invoice->line_items || !property_exists($this->invoice, 'line_items') || count($this->invoice->line_items) == 0) return $this; $new_line_items = []; diff --git a/app/Http/Requests/Invoice/StoreInvoiceRequest.php b/app/Http/Requests/Invoice/StoreInvoiceRequest.php index a8e64ef0531e..0b8dc6b00881 100644 --- a/app/Http/Requests/Invoice/StoreInvoiceRequest.php +++ b/app/Http/Requests/Invoice/StoreInvoiceRequest.php @@ -14,9 +14,12 @@ namespace App\Http\Requests\Invoice; use App\Http\Requests\Request; use App\Models\ClientContact; use App\Models\Invoice; +use App\Utils\Traits\MakesHash; class StoreInvoiceRequest extends Request { + use MakesHash; + /** * Determine if the user is authorized to make this request. * @@ -30,7 +33,7 @@ class StoreInvoiceRequest extends Request public function rules() { - //$this->sanitize(); + $this->sanitize(); return [ 'client_id' => 'required', @@ -40,5 +43,15 @@ class StoreInvoiceRequest extends Request ]; } + public function sanitize() + { + $input = $this->all(); + + $input['client_id'] = $this->decodePrimaryKey($input['client_id']); + + $this->replace($input); + + return $this->all(); + } } diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index f6e79f5cde3d..8149fe3b0866 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -33,6 +33,9 @@ class UpdateInvoiceRequest extends Request public function rules() { + + //$this->sanitize(); + return [ 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx', //'client_id' => 'required|integer', @@ -40,4 +43,21 @@ class UpdateInvoiceRequest extends Request ]; } + public function sanitize() + { + $input = $this->all(); + + // $this->replace($input); + + return $this->all(); + } + + public function sanitize() + { + $input = $this->all(); + + $this->replace($input); + + return $this->all(); + } } \ No newline at end of file diff --git a/app/Jobs/Invoice/StoreInvoice.php b/app/Jobs/Invoice/StoreInvoice.php index 8a6d4f235af7..2ad6bc879ba1 100644 --- a/app/Jobs/Invoice/StoreInvoice.php +++ b/app/Jobs/Invoice/StoreInvoice.php @@ -65,7 +65,7 @@ class StoreInvoice implements ShouldQueue $payment = false; /* Test if we should auto-bill the invoice */ - if((bool)$this->invoice->settings->auto_bill) + if(property_exists($this->invoice->settings, 'auto_bill') && (bool)$this->invoice->settings->auto_bill) { $this->invoice = $invoice_repo->markSent($this->invoice); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 202fdd587cf4..00a5e4201328 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -66,7 +66,7 @@ class Invoice extends BaseModel 'tax_name3', 'tax_rate3', 'is_amount_discount', - 'invoice_footer', + 'footer', 'partial', 'partial_due_date', 'custom_value1', diff --git a/app/Transformers/InvoiceTransformer.php b/app/Transformers/InvoiceTransformer.php index bff8c5cbdfda..7b4c1c8df9cc 100644 --- a/app/Transformers/InvoiceTransformer.php +++ b/app/Transformers/InvoiceTransformer.php @@ -85,7 +85,7 @@ class InvoiceTransformer extends EntityTransformer 'id' => $this->encodePrimaryKey($invoice->id), 'amount' => (float) $invoice->amount ?: '', 'balance' => (float) $invoice->balance ?: '', - 'client_id' => (string) $invoice->client_id, + 'client_id' => (string) $this->encodePrimaryKey($invoice->client_id), 'status_id' => (string) ($invoice->status_id ?: 1), 'updated_at' => $invoice->updated_at, 'archived_at' => $invoice->deleted_at, diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index f068f4c6f65e..1f39a49d3b01 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -283,6 +283,9 @@ trait MakesInvoiceValues $columns = $this->transformColumnsForLineItems($columns); + if(!is_array($this->line_items)); + return $data; + $items = $this->transformLineItems($this->line_items); foreach($items as $item)