2019-10-13 21:59:55 +11:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
|
*
|
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Helpers\Invoice;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class for discount calculations
|
|
|
|
|
*/
|
|
|
|
|
trait Discounter
|
|
|
|
|
{
|
|
|
|
|
|
2019-10-16 20:28:52 +11:00
|
|
|
public function discount($amount)
|
2019-10-13 21:59:55 +11:00
|
|
|
{
|
|
|
|
|
|
2019-10-17 14:14:17 +11:00
|
|
|
if($this->invoice->is_amount_discount == true){
|
2019-10-16 20:28:52 +11:00
|
|
|
return $this->invoice->discount;
|
2019-10-17 14:14:17 +11:00
|
|
|
}
|
2019-10-16 20:28:52 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
return round($amount * ($this->invoice->discount / 100), 2);
|
|
|
|
|
|
2019-10-13 21:59:55 +11:00
|
|
|
}
|
|
|
|
|
|
2019-10-16 20:28:52 +11:00
|
|
|
|
2019-10-13 21:59:55 +11:00
|
|
|
}
|