Miglioramenti importazione FE

This commit is contained in:
Thomas Zilio 2019-07-22 15:45:36 +02:00
parent c9213f71d9
commit 066c4ae714
5 changed files with 29 additions and 14 deletions

View File

@ -117,8 +117,21 @@ if (empty($record['is_fiscale'])) {
</div>
<div class="col-md-2">
{[ "type": "date", "label": "<?php echo tr('Data competenza'); ?>", "name": "data_competenza", "required": 0, "value": "$data_competenza$" ]}
{[ "type": "date", "label": "<?php echo tr('Data competenza'); ?>", "name": "data_competenza", "required": 0, "value": "$data_competenza$", "min-date": "$data_registrazione$" ]}
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#data_registrazione").on("dp.change", function (e) {
var data = $("#data_competenza");
data.data("DateTimePicker").minDate(e.date);
if(data.data("DateTimePicker").date() < e.date){
data.data("DateTimePicker").date(e.date);
}
})
});
</script>
<?php
} ?>

View File

@ -5,6 +5,7 @@ include_once __DIR__.'/../../core.php';
use Plugins\ImportFE\FatturaElettronica;
use Plugins\ImportFE\Interaction;
$file = null;
switch (filter('op')) {
case 'save':
$content = file_get_contents($_FILES['blob']['tmp_name']);
@ -13,7 +14,7 @@ switch (filter('op')) {
// no break
case 'prepare':
if (!isset($file)) {
$name = get('name');
$name = filter('name');
$file = Interaction::getImportXML($name);
}

View File

@ -19,6 +19,7 @@ if (!empty($list)) {
<tr>
<th>'.tr('Descrizione').'</th>
<th class="text-center">'.tr('Fornitore').'</th>
<th class="text-center">'.tr('Data di registrazione').'</th>
<th class="text-center">'.tr('Totale imponibile').'</th>
<th width="20%" class="text-center">#</th>
</tr>
@ -27,15 +28,18 @@ if (!empty($list)) {
foreach ($list as $element) {
$name = $element['name'];
$data = $element['date_sent'] ?: '';
echo '
<tr>';
if (file_exists($directory.'/'.$name)) {
echo '
<td>
<p>'.$name.'</p>
</td>
<td class="text-center">-</td>
<td class="text-center">-</td>
<td class="text-center">-</td>
@ -76,6 +80,7 @@ if (!empty($list)) {
</td>
<td>'.$element['sender'].'</td>
<td>'.dateFormat($element['date_sent']).'</td>
<td class="text-right">'.moneyFormat($element['amount']).'</td>
<td class="text-center">
@ -86,7 +91,7 @@ if (!empty($list)) {
echo '
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$name.'\')">
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$name.'\', \''.$data.'\')">
<i class="fa fa-download"></i> '.tr('Importa').'
</button>
</td>
@ -103,7 +108,7 @@ if (!empty($list)) {
echo '
<script>
function download(button, file) {
function download(button, file, data_registrazione) {
var restore = buttonLoading(button);
$.ajax({
@ -119,7 +124,7 @@ function download(button, file) {
data = JSON.parse(data);
if (!data.already) {
launch_modal("'.tr('Righe fattura').'", globals.rootdir + "/actions.php?id_module=" + globals.id_module + "&id_plugin=" + '.$id_plugin.' + "&op=list&filename=" + data.filename);
launch_modal("'.tr('Righe fattura').'", globals.rootdir + "/actions.php?id_module=" + globals.id_module + "&id_plugin=" + '.$id_plugin.' + "&op=list&filename=" + data.filename +"&data_registrazione=" + data_registrazione);
buttonRestore(button, restore);
} else {
swal({

View File

@ -86,7 +86,7 @@ echo '
echo '
<div class="row" >
<div class="col-md-6">
{[ "type": "date", "label": "'.tr('Data ricezione').'", "name": "data_registrazione", "required": 0, "value": "" ]}
{[ "type": "date", "label": "'.tr('Data di registrazione').'", "name": "data_registrazione", "required": 1, "value": "'.get('data_registrazione').'", "max-date": "-now-", "min-date": "'.$dati_generali['Data'].'", "readonly": "'.(intval(get('data_registrazione') != null)).'" ]}
</div>';
// Riferimenti ad altre fatture
@ -100,7 +100,7 @@ if (in_array($dati_generali['TipoDocumento'], ['TD04', 'TD05'])) {
WHERE
co_tipidocumento.dir = 'uscita' AND
(co_documenti.data BETWEEN NOW() - INTERVAL 1 YEAR AND NOW()) AND
co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE co_tipidocumento.descrizione != 'Bozza') AND
co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione != 'Bozza') AND
co_documenti.idanagrafica = ".prepare($anagrafica->id);
echo '
@ -117,7 +117,7 @@ if (in_array($dati_generali['TipoDocumento'], ['TD04', 'TD05'])) {
WHERE
co_tipidocumento.dir = 'uscita' AND
(co_documenti.data BETWEEN NOW() - INTERVAL 1 YEAR AND NOW()) AND
co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE co_tipidocumento.descrizione != 'Bozza') AND
co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione != 'Bozza') AND
co_documenti.id_segment = (SELECT id FROM zz_segments WHERE name = 'Fatture pro-forma' AND id_module = ".prepare($id_module).') AND
co_documenti.idanagrafica = '.prepare($anagrafica->id);

View File

@ -303,13 +303,9 @@ class FatturaElettronica
// Riferimento per nota di credito e debito
$fattura->ref_documento = $ref_fattura ?: null;
// Per il destinatario, la data di ricezione della fattura assume grande rilievo ai fini IVA, poiché determina la decorrenza dei termini per poter esercitare il diritto alla detrazione.
// Per il destinatario, la data di registrazione della fattura assume grande rilievo ai fini IVA, poiché determina la decorrenza dei termini per poter esercitare il diritto alla detrazione.
// La data di ricezione della fattura è contenuta allinterno della “ricevuta di consegna” visibile al trasmittente della stessa.
if (empty($data_registrazione)) {
$fattura->data_registrazione = $dati_generali['Data'];
} else {
$fattura->data_registrazione = $data_registrazione;
}
$fattura->data_registrazione = $data_registrazione;
$fattura->data_competenza = $fattura->data_registrazione;
$stato_documento = StatoFattura::where('descrizione', 'Emessa')->first();