mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for line items (#3028)
This commit is contained in:
parent
004d39cc73
commit
13e104c1d9
@ -63,7 +63,7 @@ class InvoiceItemSum
|
||||
public function process()
|
||||
{
|
||||
|
||||
if(!$this->invoice->line_items || count($this->invoice->line_items) == 0){
|
||||
if(!$this->invoice->line_items || !isset($this->invoice->line_items) || count($this->invoice->line_items) == 0){
|
||||
$this->items = [];
|
||||
return $this;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ class InvoiceSum
|
||||
|
||||
public function build()
|
||||
{
|
||||
|
||||
$this->calculateLineItems()
|
||||
->calculateDiscount()
|
||||
->calculateCustomValues()
|
||||
@ -99,17 +100,17 @@ class InvoiceSum
|
||||
|
||||
private function calculateCustomValues()
|
||||
{
|
||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_value1, $this->invoice->custom_surcharge_taxes1);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value1);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value2, $this->invoice->custom_surcharge_taxes2);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value2);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value3, $this->invoice->custom_surcharge_taxes3);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value3);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value4, $this->invoice->custom_surcharge_taxes4);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value4);
|
||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge4);
|
||||
|
||||
$this->total += $this->total_custom_values;
|
||||
|
||||
|
@ -100,17 +100,17 @@ class InvoiceSumInclusive
|
||||
|
||||
private function calculateCustomValues()
|
||||
{
|
||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_value1, $this->invoice->custom_surcharge_taxes1);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value1);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value2, $this->invoice->custom_surcharge_taxes2);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value2);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value3, $this->invoice->custom_surcharge_taxes3);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value3);
|
||||
$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_taxes += $this->valuerTax($this->invoice->custom_value4, $this->invoice->custom_surcharge_taxes4);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_value4);
|
||||
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_taxes4);
|
||||
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge4);
|
||||
|
||||
$this->total += $this->total_custom_values;
|
||||
|
||||
|
@ -39,6 +39,10 @@
|
||||
* @OA\Property(property="last_viewed", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="custom_surcharge1", type="number", format="float", example="10.00", description="First Custom Surcharge"),
|
||||
* @OA\Property(property="custom_surcharge2", type="number", format="float", example="10.00", description="Second Custom Surcharge"),
|
||||
* @OA\Property(property="custom_surcharge3", type="number", format="float", example="10.00", description="Third Custom Surcharge"),
|
||||
* @OA\Property(property="custom_surcharge4", type="number", format="float", example="10.00", description="Fourth Custom Surcharge"),
|
||||
* @OA\Property(property="custom_surcharge_taxes", type="boolean", example=true, description="Toggles charging taxes on custom surcharge amounts"),
|
||||
* )
|
||||
*/
|
@ -34,7 +34,6 @@ class StoreInvoiceRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$this->sanitize();
|
||||
|
||||
return [
|
||||
'client_id' => 'required',
|
||||
// 'invoice_type_id' => 'integer',
|
||||
@ -47,8 +46,8 @@ class StoreInvoiceRequest extends Request
|
||||
$input = $this->all();
|
||||
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
$input['line_items'] = isset($input['line_items']) ?: [];
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $input['line_items'] : [];
|
||||
//$input['line_items'] = json_encode($input['line_items']);
|
||||
$this->replace($input);
|
||||
|
||||
return $this->all();
|
||||
|
@ -57,7 +57,6 @@ class InvoiceRepository extends BaseRepository
|
||||
$starting_amount = $invoice->amount;
|
||||
|
||||
$invoice->fill($data);
|
||||
|
||||
$invoice->save();
|
||||
|
||||
if(isset($data['client_contacts']))
|
||||
|
@ -116,12 +116,12 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'custom_value4' => (string) $invoice->custom_value4 ?: '',
|
||||
'has_tasks' => (bool) $invoice->has_tasks,
|
||||
'has_expenses' => (bool) $invoice->has_expenses,
|
||||
'custom_surcharge1' => $invoice->custom_surcharge1 ?: '',
|
||||
'custom_surcharge2' => $invoice->custom_surcharge2 ?: '',
|
||||
'custom_surcharge3' => $invoice->custom_surcharge3 ?: '',
|
||||
'custom_surcharge4' => $invoice->custom_surcharge4 ?: '',
|
||||
'custom_surcharge1' => (float)$invoice->custom_surcharge1,
|
||||
'custom_surcharge2' => (float)$invoice->custom_surcharge2,
|
||||
'custom_surcharge3' => (float)$invoice->custom_surcharge3,
|
||||
'custom_surcharge4' => (float)$invoice->custom_surcharge4,
|
||||
'custom_surcharge_taxes' => (bool) $invoice->custom_surcharge_taxes,
|
||||
'line_items' => $invoice->line_items ?: '',
|
||||
'line_items' => $invoice->line_items ?: (array)[],
|
||||
'backup' => $invoice->backup ?: '',
|
||||
'settings' => $invoice->settings ?: '',
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user