status == 'PAID' && $this->total_amount > 0 ? $this->total_amount : InvoiceAmountResponseService::amountString((new InvoiceService)->getInvoiceAmount($this->resource)); $resource = [ 'id' => $this->id, 'invoice_number' => $this->invoice_number, 'issue_date' => $this->issue_date, 'created_date' => $this->created_at, 'user_id' => $this->user_id, 'note' => $this->note, 'terms' => $this->terms, 'amount' => $amount, 'status' => $this->status, 'due_date' => $this->due_date, 'discount_type' => $this->discount_type, 'discount' => $this->discount, 'user' => $this->whenLoaded('user'), 'items' => InvoiceItemResource::collection($this->whenLoaded('items')), 'payout' => $this->whenLoaded('payout'), 'stamp' => $this->stamp, 'month_stamp' => $this->month_stamp, 'is_approved' => $this->is_approved, 'reprocessed_items' => InvoiceItemResource::collection($this->whenLoaded('reprocessedItems')) ]; return $resource; } }