1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-17 03:51:06 +01:00

Bugfix bulk ddt in fattura e aggiunta fatturazione ddt acquisto

This commit is contained in:
Fabio Lovato 2018-08-08 09:32:20 +02:00
parent 74c0109175
commit f277086aba

View File

@ -10,13 +10,21 @@ switch (post('op')) {
$totale_n_ddt = 0; $totale_n_ddt = 0;
// Informazioni della fattura // Informazioni della fattura
if( $dir == 'entrata' ){
$tipo_documento = $dbo->selectOne('co_tipidocumento', 'id', ['descrizione' => 'Fattura immediata di vendita'])['id']; $tipo_documento = $dbo->selectOne('co_tipidocumento', 'id', ['descrizione' => 'Fattura immediata di vendita'])['id'];
$dir = 'entrata'; $module_name = 'Fatture di vendita';
$idconto = get_var('Conto predefinito fatture di vendita');
} else {
$tipo_documento = $dbo->selectOne('co_tipidocumento', 'id', ['descrizione' => 'Fattura immediata di acquisto'])['id'];
$module_name = 'Fatture di acquisto';
$idconto = get_var('Conto predefinito fatture di acquisto');
}
$idiva = get_var('Iva predefinita'); $idiva = get_var('Iva predefinita');
$data = date('Y-m-d'); $data = date('Y-m-d');
// Segmenti // Segmenti
$id_fatture = Modules::get('Fatture di vendita')['id']; $id_fatture = Modules::get($module_name)['id'];
if (!isset($_SESSION['m'.$id_fatture]['id_segment'])) { if (!isset($_SESSION['m'.$id_fatture]['id_segment'])) {
$segments = Modules::getSegments($id_fatture); $segments = Modules::getSegments($id_fatture);
$_SESSION['m'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; $_SESSION['m'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null;
@ -38,8 +46,6 @@ switch (post('op')) {
$numero = get_new_numerofattura($data); $numero = get_new_numerofattura($data);
$numero_esterno = get_new_numerosecondariofattura($data); $numero_esterno = get_new_numerosecondariofattura($data);
$idconto = get_var('Conto predefinito fatture di vendita');
$campo = ($dir == 'entrata') ? 'idpagamento_vendite' : 'idpagamento_acquisti'; $campo = ($dir == 'entrata') ? 'idpagamento_vendite' : 'idpagamento_acquisti';
// Tipo di pagamento predefinito dall'anagrafica // Tipo di pagamento predefinito dall'anagrafica
@ -68,12 +74,11 @@ switch (post('op')) {
$id_documento = $dbo->lastInsertedID(); $id_documento = $dbo->lastInsertedID();
$id_documento_cliente[$id_anagrafica] = $id_documento; $id_documento_cliente[$id_anagrafica] = $id_documento;
++$totale_n_ddt;
} }
// Inserimento righe // Inserimento righe
foreach ($righe as $riga) { foreach ($righe as $riga) {
++$totale_n_ddt;
$qta = $riga['qta'] - $riga['qta_evasa']; $qta = $riga['qta'] - $riga['qta_evasa'];
if ($qta > 0) { if ($qta > 0) {
@ -147,8 +152,7 @@ $operations = [
'delete-bulk' => tr('Elimina selezionati'), 'delete-bulk' => tr('Elimina selezionati'),
]; ];
if (Modules::get('Ddt di vendita')['id'] == $id_module) { $operations['crea_fattura'] = [
$operations['crea_fattura'] = [
'text' => tr('Crea fattura'), 'text' => tr('Crea fattura'),
'data' => [ 'data' => [
'msg' => tr('Vuoi davvero creare una fattura per questi interventi?'), 'msg' => tr('Vuoi davvero creare una fattura per questi interventi?'),
@ -156,7 +160,6 @@ if (Modules::get('Ddt di vendita')['id'] == $id_module) {
'class' => 'btn btn-lg btn-warning', 'class' => 'btn btn-lg btn-warning',
'blank' => false, 'blank' => false,
], ],
]; ];
}
return $operations; return $operations;