mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-17 03:51:06 +01:00
Merge branch 'master' into 2.4.11
This commit is contained in:
commit
9ca4748bcd
@ -28,7 +28,7 @@ foreach ($righe as $row) {
|
||||
// Valori assoluti
|
||||
$riga['qta'] = abs($riga['qta']);
|
||||
$riga['prezzo_unitario_acquisto'] = abs($riga['prezzo_unitario_acquisto']);
|
||||
$riga['totale_imponibile'] = ($fattura->isNotaDiAccredito() ? -$row->totale_imponibile : $row->totale_imponibile);
|
||||
$riga['totale_imponibile'] = ($fattura->isNota() ? -$row->totale_imponibile : $row->totale_imponibile);
|
||||
$riga['sconto_unitario'] = abs($riga['sconto_unitario']);
|
||||
$riga['sconto'] = abs($riga['sconto']);
|
||||
$riga['iva'] = abs($riga['iva']);
|
||||
@ -136,7 +136,7 @@ foreach ($righe as $row) {
|
||||
}
|
||||
|
||||
// Aggiunta dei riferimenti ai documenti
|
||||
if ($fattura->isNotaDiAccredito()) {
|
||||
if ($fattura->isNota() && !empty($record['ref_documento'])) {
|
||||
$data = $dbo->fetchArray("SELECT IF(numero_esterno != '', numero_esterno, numero) AS numero, data FROM co_documenti WHERE id = ".prepare($record['ref_documento']));
|
||||
|
||||
$text = tr('Rif. fattura _NUM_ del _DATE_', [
|
||||
@ -256,7 +256,7 @@ foreach ($righe as $row) {
|
||||
echo "
|
||||
<div class='input-group-btn'>";
|
||||
|
||||
if (!$fattura->isNotaDiAccredito() && $row->isArticolo() && $riga['abilita_serial'] && (empty($riga['idddt']) || empty($riga['idintervento']))) {
|
||||
if (!$fattura->isNota() && $row->isArticolo() && $riga['abilita_serial'] && (empty($riga['idddt']) || empty($riga['idintervento']))) {
|
||||
echo "
|
||||
<a class='btn btn-primary btn-xs'data-toggle='tooltip' title='Aggiorna SN...' onclick=\"launch_modal( 'Aggiorna SN', '".$structure->fileurl('add_serial.php').'?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$riga['id'].'&idarticolo='.$riga['idarticolo']."', 1 );\"><i class='fa fa-barcode' aria-hidden='true'></i></a>";
|
||||
}
|
||||
@ -265,7 +265,7 @@ foreach ($righe as $row) {
|
||||
<a class='btn btn-xs btn-info' data-toggle='modal' data-title='".tr('Dati Fattura Elettronica')."' data-href='".$structure->fileurl('fe/row-fe.php').'?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$riga['id']."'>
|
||||
<i class='fa fa-file-code-o '></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a class='btn btn-xs btn-warning' title='Modifica questa riga...' onclick=\"launch_modal( 'Modifica riga', '".$structure->fileurl('row-edit.php').'?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$riga['id']."', 1 );\">
|
||||
<i class='fa fa-edit'></i>
|
||||
</a>
|
||||
|
@ -349,8 +349,8 @@ class Fattura extends Document
|
||||
$direzione = $this->tipo->dir;
|
||||
|
||||
foreach ($rate as $rata) {
|
||||
$importo = $direzione == 'uscita' ? -$rata['importo'] : $rata['importo'];
|
||||
$scadenza = $rata['scadenza'];
|
||||
$importo = $direzione == 'uscita' ? -$rata['importo'] : $rata['importo'];
|
||||
|
||||
self::registraScadenza($this, $importo, $scadenza, $is_pagato);
|
||||
}
|
||||
@ -466,7 +466,7 @@ class Fattura extends Document
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotaDiAccredito()
|
||||
public function isNota()
|
||||
{
|
||||
return $this->tipo->reversed == 1;
|
||||
}
|
||||
|
@ -1042,11 +1042,9 @@ class FatturaElettronica
|
||||
$aliquota = $riga->aliquota ?: $iva_descrizioni;
|
||||
$percentuale = floatval($aliquota->percentuale);
|
||||
|
||||
if ($documento->isNotaDiAccredito()) {
|
||||
$dettaglio['PrezzoTotale'] = -$riga->totale_imponibile ?: 0;
|
||||
} else {
|
||||
$dettaglio['PrezzoTotale'] = $riga->totale_imponibile ?: 0;
|
||||
}
|
||||
$prezzo_totale = $documento->isNota() ? -$riga->totale_imponibile : $riga->totale_imponibile;
|
||||
$dettaglio['PrezzoTotale'] = $prezzo_totale;
|
||||
|
||||
$dettaglio['AliquotaIVA'] = $percentuale;
|
||||
|
||||
if (!empty($riga['idritenutaacconto']) && empty($riga['is_descrizione'])) {
|
||||
@ -1110,16 +1108,18 @@ class FatturaElettronica
|
||||
return $item->aliquota->percentuale;
|
||||
});
|
||||
foreach ($riepiloghi_percentuale as $riepilogo) {
|
||||
//(imponibile-sconto) + rivalsa inps
|
||||
$totale = round(($riepilogo->sum('imponibile') - $riepilogo->sum('sconto')) + $riepilogo->sum('rivalsa_inps'), 2);
|
||||
$totale = round($riepilogo->sum('totale_imponibile') + $riepilogo->sum('rivalsa_inps'), 2);
|
||||
$imposta = round($riepilogo->sum('iva') + $riepilogo->sum('iva_rivalsa_inps'), 2);
|
||||
|
||||
$totale = $documento->isNota() ? -$totale : $totale;
|
||||
$imposta = $documento->isNota() ? -$imposta : $imposta;
|
||||
|
||||
$dati = $riepilogo->first()->aliquota;
|
||||
|
||||
$iva = [
|
||||
'AliquotaIVA' => $dati['percentuale'],
|
||||
'ImponibileImporto' => abs($totale),
|
||||
'Imposta' => abs($imposta),
|
||||
'ImponibileImporto' => $totale,
|
||||
'Imposta' => $imposta,
|
||||
'EsigibilitaIVA' => $dati['esigibilita'],
|
||||
];
|
||||
|
||||
@ -1147,17 +1147,19 @@ class FatturaElettronica
|
||||
return $item->aliquota->codice_natura_fe;
|
||||
});
|
||||
foreach ($riepiloghi_natura as $riepilogo) {
|
||||
//(imponibile-sconto) + rivalsa inps
|
||||
$totale = round(($riepilogo->sum('imponibile') - $riepilogo->sum('sconto')) + $riepilogo->sum('rivalsa_inps'), 2);
|
||||
$totale = round($riepilogo->sum('totale_imponibile') + $riepilogo->sum('rivalsa_inps'), 2);
|
||||
$imposta = round($riepilogo->sum('iva') + $riepilogo->sum('iva_rivalsa_inps'), 2);
|
||||
|
||||
$totale = $documento->isNota() ? -$totale : $totale;
|
||||
$imposta = $documento->isNota() ? -$imposta : $imposta;
|
||||
|
||||
$dati = $riepilogo->first()->aliquota;
|
||||
|
||||
$iva = [
|
||||
'AliquotaIVA' => 0,
|
||||
'Natura' => $dati->codice_natura_fe,
|
||||
'ImponibileImporto' => abs($totale),
|
||||
'Imposta' => abs($imposta),
|
||||
'ImponibileImporto' => $totale,
|
||||
'Imposta' => $imposta,
|
||||
'EsigibilitaIVA' => $dati->esigibilita,
|
||||
'RiferimentoNormativo' => $dati->descrizione,
|
||||
];
|
||||
|
@ -115,6 +115,10 @@ class FatturaOrdinaria extends FatturaElettronica
|
||||
$qta = $riga['Quantita'] ?: 1;
|
||||
$qta = $riga['PrezzoUnitario'] < 0 ? -$qta : $qta;
|
||||
|
||||
if ($fattura->isNota()) {
|
||||
$qta = -$qta;
|
||||
}
|
||||
|
||||
// Prezzo e quantità
|
||||
$obj->prezzo_unitario_vendita = $prezzo;
|
||||
$obj->qta = $qta;
|
||||
@ -172,7 +176,7 @@ class FatturaOrdinaria extends FatturaElettronica
|
||||
$dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento'];
|
||||
$totale_documento = $dati_generali['ImportoTotaleDocumento'];
|
||||
|
||||
$diff = $totale_documento ? floatval($totale_documento) - $fattura->totale : $totale_righe - $fattura->totale_imponibile;
|
||||
$diff = $totale_documento ? floatval($totale_documento) - abs($fattura->totale) : $totale_righe - abs($fattura->totale_imponibile);
|
||||
if (!empty($diff)) {
|
||||
// Rimozione dell'IVA calcolata automaticamente dal gestionale
|
||||
$iva_arrotondamento = database()->fetchOne('SELECT * FROM co_iva WHERE id='.prepare($iva[0]));
|
||||
|
@ -111,6 +111,10 @@ class FatturaSemplificata extends FatturaElettronica
|
||||
$qta = 1;
|
||||
$qta = $riga['Importo'] < 0 ? -$qta : $qta;
|
||||
|
||||
if ($fattura->isNota()) {
|
||||
$qta = -$qta;
|
||||
}
|
||||
|
||||
// Prezzo e quantità
|
||||
$obj->prezzo_unitario_vendita = $prezzo;
|
||||
$obj->qta = $qta;
|
||||
|
Loading…
x
Reference in New Issue
Block a user