diff options
Diffstat (limited to 'classes/Offer.php')
-rw-r--r-- | classes/Offer.php | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/classes/Offer.php b/classes/Offer.php index 0ef2881..e24154f 100644 --- a/classes/Offer.php +++ b/classes/Offer.php @@ -211,7 +211,7 @@ class Offer extends Model{ * * Total: the sum of subtotal and total * - * @param int $what Any of Calculatable::SUBTOTAL, Calculatable::VAT and Calculatable::TOTAL + * @param int $what Any of CALCULATABLE_SUBTOTAL, CALCULATABLE_VAT and CALCULATABLE_TOTAL * @param int $round How many decimals to round the result on * @param bool $format Whether to format the number nicely (for output) or not (for calculations) * @@ -219,28 +219,28 @@ class Offer extends Model{ * * @return float|bool The calculated value rounded to $round decimals, or false on incorrect input */ - public function calculate($what = Calculatable::TOTAL, $round = 2, $format = true) { + public function calculate($what = CALCULATABLE_TOTAL, $round = 2, $format = true) { $return = 0; switch ($what) { - case Calculatable::SUBTOTAL: + case CALCULATABLE_SUBTOTAL: foreach ($this->getAssignments() as $assignment) { - $return += $assignment->calculate(Calculatable::SUBTOTAL, $round + 1, false); + $return += $assignment->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false); } foreach ($this->getDiscounts() as $discount) { - $return += $discount->calculate(Calculatable::SUBTOTAL, $round + 1, false); + $return += $discount->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false); } break; - case Calculatable::VAT: + case CALCULATABLE_VAT: $assignments = $this->getAssignments(); foreach ($assignments as $assignment) { - $return += $assignment->calculate(Calculatable::VAT, $round + 1, false); + $return += $assignment->calculate(CALCULATABLE_VAT, $round + 1, false); } foreach ($this->getDiscounts() as $discount) { - $return += $discount->calculate(Calculatable::VAT, $round + 1, false); + $return += $discount->calculate(CALCULATABLE_VAT, $round + 1, false); } break; - case Calculatable::TOTAL: - $return = $this->calculate(Calculatable::SUBTOTAL, $round + 1, false) + $this->calculate(Calculatable::VAT, $round + 1, false); + case CALCULATABLE_TOTAL: + $return = $this->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false) + $this->calculate(CALCULATABLE_VAT, $round + 1, false); break; default: return false; @@ -372,9 +372,9 @@ class Offer extends Model{ foreach ($this->getDiscounts() as $discount) $list[] = array( $discount->title, - $discount->calculate(Calculatable::SUBTOTAL), + $discount->calculate(CALCULATABLE_SUBTOTAL), $discount->VAT_percentage . "%", - $discount->calculate(Calculatable::TOTAL) + $discount->calculate(CALCULATABLE_TOTAL) ); $pdf = new Correspondence(); @@ -462,7 +462,7 @@ class Offer extends Model{ $pdf->SetFont('','B'); $pdf->Cell($width[1] + $width[2],7,$pdf->_('amount')); $pdf->SetFont('',''); - $pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(Calculatable::SUBTOTAL),'',0,'R'); + $pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(CALCULATABLE_SUBTOTAL),'',0,'R'); $pdf->Ln(); foreach ($btw as $p => $m) { @@ -479,7 +479,7 @@ class Offer extends Model{ $pdf->SetFont('','B'); $pdf->Cell($width[1] + $width[2],7,$pdf->_('total')); $pdf->SetFont('',''); - $pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(Calculatable::TOTAL),'T',0,'R'); + $pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(CALCULATABLE_TOTAL),'T',0,'R'); $pdf->Ln(); // Footer @@ -517,7 +517,7 @@ class Offer extends Model{ $pdf->Cell(17.5,5); $pdf->Cell(40,5,$invoice_nr); $pdf->Cell(17.5,5); - $pdf->Cell(40,5,correspondence::valuta() . $this->calculate(Calculatable::TOTAL)); + $pdf->Cell(40,5,correspondence::valuta() . $this->calculate(CALCULATABLE_TOTAL)); $pdf->SetY($oldY + 14); |