mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
fixes for storing invoice
This commit is contained in:
parent
0e3059f17f
commit
9cc31195f7
@ -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 = [];
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -66,7 +66,7 @@ class Invoice extends BaseModel
|
||||
'tax_name3',
|
||||
'tax_rate3',
|
||||
'is_amount_discount',
|
||||
'invoice_footer',
|
||||
'footer',
|
||||
'partial',
|
||||
'partial_due_date',
|
||||
'custom_value1',
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user