1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Models/Presenters/InvoicePresenter.php

76 lines
1.8 KiB
PHP
Raw Normal View History

2019-08-29 06:07:04 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
2019-08-29 06:07:04 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-08-29 06:07:04 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2019-08-29 06:07:04 +02:00
*/
namespace App\Models\Presenters;
2019-09-05 07:04:52 +02:00
use App\Utils\Number;
use App\Utils\Traits\MakesDates;
2019-08-29 06:07:04 +02:00
/**
* Class InvoicePresenter.
2019-08-29 06:07:04 +02:00
*
* For convenience and to allow users to easiliy
2019-08-29 06:07:04 +02:00
* customise their invoices, we provide all possible
* invoice variables to be available from this presenter.
*
* Shortcuts to other presenters are here to facilitate
2019-08-29 06:07:04 +02:00
* a clean UI / UX
*/
class InvoicePresenter extends EntityPresenter
{
use MakesDates;
public function amount()
{
return Number::formatMoney($this->balance, $this->client);
}
public function invoice_number()
{
if ($this->number != '') {
return $this->number;
} else {
return '';
}
}
2021-06-16 08:41:29 +02:00
public function rBits()
{
$properties = new \stdClass();
$properties->terms_text = $this->terms;
$properties->note = $this->public_notes;
$properties->itemized_receipt = [];
foreach ($this->line_items as $item) {
$properties->itemized_receipt[] = $this->itemRbits($item);
}
$data = new stdClass();
$data->receive_time = time();
$data->type = 'transaction_details';
$data->source = 'user';
$data->properties = $properties;
return [$data];
}
public function itemRbits($item)
{
$data = new stdClass();
$data->description = $item->notes;
$data->item_price = floatval($item->cost);
$data->quantity = floatval($item->quantity);
$data->amount = round($data->item_price * $data->quantity, 2);
return $data;
}
2019-08-29 06:07:04 +02:00
}