You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ddt/buttons.php
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -72,19 +72,35 @@ function() {},
72
72
$stati_importabili[] = $stato['descrizione'];
73
73
}
74
74
75
-
$causali = $database->fetchArray('SELECT `title` FROM `dt_causalet` LEFT JOIN `dt_causalet_lang` ON (`dt_causalet`.`id` = `dt_causalet_lang`.`id_record`
76
-
AND `dt_causalet_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `is_importabile` = 1');
75
+
$causali = $database->fetchArray('SELECT `name` FROM `dt_causalet`
76
+
WHERE `is_importabile` = 1');
77
77
78
78
foreach ($causalias$causale) {
79
79
$causali_importabili[] = $causale['title'];
80
80
}
81
81
82
+
// Determina il tipo di documento che verrà creato applicando la stessa logica di crea_documento.php
83
+
$tipo_documento_da_creare = '';
84
+
if ($ddt->reversed) {
85
+
// Se il DDT ha una causale di tipo "reso", manteniamo la stessa direzione ma creiamo una nota di credito
86
+
if ($dir == 'entrata') {
87
+
// DDT in uscita con causale reso → nota di credito di vendita
88
+
$tipo_documento_da_creare = 'nota di credito';
89
+
} else {
90
+
// DDT in entrata con causale reso → nota di credito di acquisto
91
+
$tipo_documento_da_creare = 'nota di credito';
92
+
}
93
+
} else {
94
+
// Logica standard
95
+
$tipo_documento_da_creare = ($dir == 'entrata' ? 'fattura di vendita' : 'fattura di acquisto');
96
+
}
97
+
82
98
echo'
83
99
<div class="tip" data-widget="tooltip" title="'.tr('Il ddt è fatturabile solo se si trova negli stati _STATE_LIST_ e la relativa causale è una delle seguenti: _CAUSALE_LIST_', [
0 commit comments