Fix riferimenti

This commit is contained in:
Pek5892 2024-04-12 13:22:14 +02:00
parent c9f007db16
commit c4e3c2f484
8 changed files with 38 additions and 23 deletions

View File

@ -54,7 +54,7 @@ class Bollo
$bollo = ($this->fattura->direzione == 'uscita') ? $this->fattura->bollo : setting('Importo marca da bollo');
$marca_da_bollo = 0;
if (abs($bollo) > 0 && abs($importo_righe_bollo) > setting("Soglia minima per l'applicazione della marca da bollo")) {
if ($bollo && abs($bollo) > 0 && abs($importo_righe_bollo) > setting("Soglia minima per l'applicazione della marca da bollo")) {
$marca_da_bollo = $bollo;
}

View File

@ -273,12 +273,12 @@ class Ordine extends Document
public function getReferenceNumber()
{
return $this->numero_cliente ?: ($this->numero_esterno ?: $this->numero);
return setting('Visualizza numero ordine cliente') ? ($this->numero_cliente ?: ($this->numero_esterno ?: $this->numero)) : ($this->numero_esterno ?: $this->numero);
}
public function getReferenceDate()
{
return $this->data_cliente ?: $this->data;
return setting('Visualizza numero ordine cliente') ? ($this->data_cliente ?: $this->data) : $this->data;
}
public function getReferenceRagioneSociale()

View File

@ -112,17 +112,19 @@ foreach ($primo_livello as $conto_primo) {
</div>';
// Somma dei totali
if ($conto_primo['descrizione'] == 'Patrimoniale') {
if ($totale_conto2 > 0) {
$totale_attivita[] = abs($totale_conto2);
if ($totale_conto2) {
if ($conto_primo['descrizione'] == 'Patrimoniale') {
if ($totale_conto2 > 0) {
$totale_attivita[] = abs($totale_conto2);
} else {
$totale_passivita[] = abs($totale_conto2);
}
} else {
$totale_passivita[] = abs($totale_conto2);
}
} else {
if ($totale_conto2 > 0) {
$totale_ricavi[] = abs($totale_conto2);
} else {
$totale_costi[] = abs($totale_conto2);
if ($totale_conto2 > 0) {
$totale_ricavi[] = abs($totale_conto2);
} else {
$totale_costi[] = abs($totale_conto2);
}
}
}

View File

@ -26,8 +26,8 @@ use Util\XML;
if ($fattura !== null) {
/* Per le PA EC02 e EC01 sono dei stati successivi a NE il quale a sua volta è successivo a RC. EC01 e EC02 sono definiti all'interno della ricevuta di NE che di fatto indica il rifiuto o l'accettazione. */
$stato_fe = StatoFE::find($fattura->codice_stato_fe)->id_record;
$abilita_genera = $fattura->stato->getTranslation('name') != 'Bozza' && (empty($fattura->codice_stato_fe) || intval($stato_fe['is_generabile']));
$stato_fe = StatoFE::find($fattura->codice_stato_fe);
$abilita_genera = $fattura->stato->getTranslation('name') != 'Bozza' && (empty($fattura->codice_stato_fe) || intval($stato_fe->is_generabile));
$ricevuta_principale = $fattura->getRicevutaPrincipale();
if (!empty($fattura_pa)) {

View File

@ -1419,11 +1419,13 @@ class FatturaElettronica
}
}
// $descrizione = $riga['descrizione'];
$descrizione = $riga['descrizione'];
// Aggiunta dei riferimenti ai documenti
if (setting('Riferimento dei documenti in Fattura Elettronica') && $riga->hasOriginalComponent()) {
$descrizione .= "\n".$riga->getOriginalComponent()->getDocument()->getReference();
if (setting('Riferimento dei documenti in Fattura Elettronica') == 0) {
$pos = strpos($descrizione, 'Rif.');
if ($pos !== false) {
$descrizione = substr($descrizione, 0, $pos);
}
}
$dettaglio['Descrizione'] = $descrizione;

View File

@ -230,9 +230,13 @@ abstract class Component extends Model
[$riferimento_precedente, $nuovo_riferimento] = $model->impostaOrigine($this);
// Correzione della descrizione
$attributes['descrizione'] = str_replace($riferimento_precedente, '', $attributes['descrizione']);
if (setting('Aggiungi riferimento tra documenti')) {
if (setting('Mantieni riferimenti tra tutti i documenti collegati')) {
$attributes['descrizione'] .= $nuovo_riferimento;
}
if (setting('Aggiungi riferimento tra documenti') && empty(setting('Mantieni riferimenti tra tutti i documenti collegati'))) {
$attributes['descrizione'] = $riferimento_precedente ? str_replace($riferimento_precedente, '', $attributes['descrizione']) : $attributes['descrizione'];
$attributes['descrizione'] .= $nuovo_riferimento;
}
}

View File

@ -95,8 +95,10 @@ foreach ($righe as $riga) {
if (in_array($riga->id, $riferimento)) {
if ($riga->id === $riferimento[0]) {
$riga_ordine = $database->fetchOne('SELECT numero_cliente, data_cliente FROM or_ordini WHERE id = '.prepare($riga->idordine));
if (!empty($riga_ordine['numero_cliente']) && !empty($riga_ordine['data_cliente'])) {
$text = $text.'<b>Ordine n. '.$riga_ordine['numero_cliente'].' del '.Translator::dateToLocale($riga_ordine['data_cliente']).'</b><br>';
if (!(setting('Visualizza numero ordine cliente'))) {
if (!empty($riga_ordine['numero_cliente']) && !empty($riga_ordine['data_cliente'])) {
$text = $text.'<b>Ordine n. '.$riga_ordine['numero_cliente'].' del '.Translator::dateToLocale($riga_ordine['data_cliente']).'</b><br>';
}
}
$r['descrizione'] = str_replace('Rif. '.strtolower($key), '', $r['descrizione']);
preg_match("/Rif\.(.*)/s", $r['descrizione'], $rif2);

View File

@ -188,3 +188,8 @@ ALTER TABLE `zz_hooks_lang` ADD CONSTRAINT `zz_hooks_lang_ibfk_2` FOREIGN KEY (`
ALTER TABLE `zz_groups_lang` ADD CONSTRAINT `zz_groups_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `zz_group_module_lang` ADD CONSTRAINT `zz_group_module_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `zz_cache_lang` ADD CONSTRAINT `zz_cache_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `zz_settings_lang` CHANGE `help` `help` VARCHAR(500) NULL;
-- Aggiunta impostazione per numero da visualizzare negli ordini
INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Visualizza numero ordine cliente', '1', 'boolean', '1', 'Ordini', NULL);
INSERT INTO `zz_settings_lang` (`id_record`, `id_lang`, `title`, `help`) VALUES ((SELECT `id` FROM `zz_settings` WHERE `nome` = 'Visualizza numero ordine cliente'), (SELECT `valore` FROM `zz_settings` WHERE `nome` = "Lingua"), 'Visualizza numero ordine cliente', 'Se abilitata, utilizza nei documenti il numero d\'ordine del cliente al posto del numero interno dell\'ordine');