public function recalculaMontos() { if ($this->idpedido == "" || $this->idpedido == 0) { return false; } $subtotal = 0.0; $iva = 0.0; foreach ($this->partidas as $p) { $partida = new Modpartida(); $partida->setIdpartida($p); $partida->getFromDatabase(); $subtotal += $partida->getPreciobase() * $partida->getCantidad(); $iva += $partida->getImpuesto(); } $descuento = $subtotal * floatval($this->descuentoporcentaje) / 100; $total = $subtotal - $descuento + $iva; $this->subtotal = $subtotal; $this->descuentomonto = $descuento; $this->ivamonto = $iva; $this->total = $total; $this->totalpartidas = count($this->partidas); return true; }