2019-10-16 11:28:52 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-10-16 11:28:52 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-10-16 11:28:52 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-10-16 11:28:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Helpers\Invoice;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class for discount calculations.
|
2019-10-16 11:28:52 +02:00
|
|
|
*/
|
|
|
|
trait CustomValuer
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
public function valuer($custom_value)
|
|
|
|
{
|
|
|
|
if (isset($custom_value) && is_numeric($custom_value)) {
|
|
|
|
return $custom_value;
|
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
|
|
|
return 0;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function valuerTax($custom_value, $has_custom_invoice_taxes)
|
|
|
|
{
|
2024-04-08 12:32:12 +02:00
|
|
|
|
2024-04-09 12:37:22 +02:00
|
|
|
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) {
|
2020-09-06 11:38:10 +02:00
|
|
|
return round($custom_value * ($this->invoice->tax_rate1 / 100), 2) + round($custom_value * ($this->invoice->tax_rate2 / 100), 2) + round($custom_value * ($this->invoice->tax_rate3 / 100), 2);
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2024-04-09 12:37:22 +02:00
|
|
|
|
2024-04-28 02:56:06 +02:00
|
|
|
public function multiInclusiveTax($custom_value, $has_custom_invoice_taxes) {
|
2024-04-09 12:37:22 +02:00
|
|
|
|
|
|
|
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) {
|
|
|
|
|
|
|
|
$tax = 0;
|
|
|
|
|
|
|
|
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate1 / 100))), 2);
|
|
|
|
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate2 / 100))), 2);
|
|
|
|
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate3 / 100))), 2);
|
|
|
|
|
|
|
|
return round($tax,2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
}
|