1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-18 04:20:50 +01:00

Bugfix righe documento FE

This commit is contained in:
Thomas Zilio 2018-07-09 14:53:02 +02:00
parent c87f79d91e
commit 17140aa241

View File

@ -20,8 +20,6 @@ class FatturaElettronica
protected $cliente = []; protected $cliente = [];
/** @var array Informazioni sul documento */ /** @var array Informazioni sul documento */
protected $documento = []; protected $documento = [];
/** @var array Informazioni sulle righe del documento */
protected $righe_documento = [];
/** @var array Stato di validazione interna dell'XML della fattura */ /** @var array Stato di validazione interna dell'XML della fattura */
protected $is_valid = null; protected $is_valid = null;
@ -83,22 +81,6 @@ class FatturaElettronica
return $this->documento; return $this->documento;
} }
/**
* Restituisce le informazioni relative alle righe del documento.
*
* @return array
*/
public function getRigheDocumento()
{
if (empty($this->righe_documento)) {
$database = \Database::getConnection();
$this->righe_documento = $database->select('co_righe_documenti', '*', ['iddocumento' => $this->getDocumento()['idanagrafica']]);
}
return $this->righe_documento;
}
/** /**
* Restituisce lo stato di validazione interna dell'XML della fattura. * Restituisce lo stato di validazione interna dell'XML della fattura.
* *
@ -314,13 +296,14 @@ class FatturaElettronica
* *
* @return array * @return array
*/ */
protected static function getDatiBeniServizi($documento, $righe_documento) protected static function getDatiBeniServizi($documento)
{ {
$database = \Database::getConnection(); $database = \Database::getConnection();
$result = []; $result = [];
// Righe del documento // Righe del documento
$righe_documento = $database->select('co_righe_documenti', '*', ['iddocumento' => $documento['id']]);
foreach ($righe_documento as $numero => $riga) { foreach ($righe_documento as $numero => $riga) {
$prezzo_unitario = $riga['subtotale'] / $riga['qta']; $prezzo_unitario = $riga['subtotale'] / $riga['qta'];
$prezzo_totale = $riga['subtotale'] - $riga['sconto']; $prezzo_totale = $riga['subtotale'] - $riga['sconto'];
@ -420,11 +403,10 @@ class FatturaElettronica
protected static function getBody($fattura) protected static function getBody($fattura)
{ {
$documento = $fattura->getDocumento(); $documento = $fattura->getDocumento();
$righe_documento = $fattura->getRigheDocumento();
$result = [ $result = [
'DatiGenerali' => self::getDatiDocumento($documento), 'DatiGenerali' => self::getDatiDocumento($documento),
'DatiBeniServizi' => self::getDatiBeniServizi($documento, $righe_documento), 'DatiBeniServizi' => self::getDatiBeniServizi($documento),
'DatiPagamento' => self::getDatiPagamento($documento), 'DatiPagamento' => self::getDatiPagamento($documento),
]; ];