mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-13 01:50:46 +01:00
Aggiunta trasformazione fatture pro-forma
This commit is contained in:
parent
625c30c123
commit
eb15efd632
@ -1333,6 +1333,12 @@ switch (post('op')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'transform':
|
||||||
|
$fattura->id_segment = post('id_segment');
|
||||||
|
$fattura->save();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,3 +32,12 @@ if ($dir == 'entrata' && empty($record['ref_documento']) && $record['stato'] ==
|
|||||||
</ul>
|
</ul>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($record['is_fiscale'])) {
|
||||||
|
$msg = '{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_module.'\' AND is_fiscale = 1 ORDER BY name" ]}';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<button type="button" class="btn btn-warning ask" data-msg="'.tr('Vuoi trasformare questa fattura pro-forma in una di tipo fiscale?').'<br>'.prepareToField(\HTMLBuilder\HTMLBuilder::replace($msg)).'" data-op="transform" data-button="'.tr('Trasforma').'" data-class="btn btn-lg btn-warning" data-backto="record-edit">
|
||||||
|
<i class="fa fa-upload"></i> '.tr('Trasforma in fattura fiscale').'
|
||||||
|
</button>';
|
||||||
|
}
|
||||||
|
@ -88,6 +88,9 @@ if ($dir == 'entrata') {
|
|||||||
$query = 'SELECT * FROM co_statidocumento';
|
$query = 'SELECT * FROM co_statidocumento';
|
||||||
if (empty($record['is_fiscale'])) {
|
if (empty($record['is_fiscale'])) {
|
||||||
$query .= " WHERE descrizione = 'Bozza'";
|
$query .= " WHERE descrizione = 'Bozza'";
|
||||||
|
|
||||||
|
$plugin = $dbo->fetchArray("SELECT id FROM zz_plugins WHERE name='Fatturazione Elettronica' AND idmodule_to = ".prepare($id_module));
|
||||||
|
echo '<script>$("#link-tab_'.$plugin[0]['id'].'").addClass("disabled");</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -34,10 +34,6 @@ class Fattura extends Model
|
|||||||
|
|
||||||
$database = database();
|
$database = database();
|
||||||
|
|
||||||
// Calcolo dei numeri fattura
|
|
||||||
$numero = static::getNumero($data, $direzione, $id_segment);
|
|
||||||
$numero_esterno = static::getNumeroSecondario($data, $direzione, $id_segment);
|
|
||||||
|
|
||||||
if ($direzione == 'entrata') {
|
if ($direzione == 'entrata') {
|
||||||
$id_conto = setting('Conto predefinito fatture di vendita');
|
$id_conto = setting('Conto predefinito fatture di vendita');
|
||||||
$conto = 'vendite';
|
$conto = 'vendite';
|
||||||
@ -68,12 +64,16 @@ class Fattura extends Model
|
|||||||
|
|
||||||
$id_sede = $database->selectOne('an_anagrafiche', 'idsede_fatturazione', ['idanagrafica' => $id_anagrafica])['idsede_fatturazione'];
|
$id_sede = $database->selectOne('an_anagrafiche', 'idsede_fatturazione', ['idanagrafica' => $id_anagrafica])['idsede_fatturazione'];
|
||||||
|
|
||||||
// Salvataggio delle informazioni
|
$model->anagrafica()->associate($anagrafica);
|
||||||
$model->numero = $numero;
|
$model->tipo()->associate($tipo_documento);
|
||||||
$model->numero_esterno = $numero_esterno;
|
$model->stato()->associate($stato_documento);
|
||||||
$model->data = $data;
|
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
// Salvataggio delle informazioni
|
||||||
|
$model->data = $data;
|
||||||
$model->id_segment = $id_segment;
|
$model->id_segment = $id_segment;
|
||||||
|
|
||||||
$model->idconto = $id_conto;
|
$model->idconto = $id_conto;
|
||||||
$model->idsede = $id_sede;
|
$model->idsede = $id_sede;
|
||||||
|
|
||||||
@ -83,16 +83,34 @@ class Fattura extends Model
|
|||||||
if (!empty($id_banca)) {
|
if (!empty($id_banca)) {
|
||||||
$model->idbanca = $id_banca;
|
$model->idbanca = $id_banca;
|
||||||
}
|
}
|
||||||
|
|
||||||
$model->anagrafica()->associate($anagrafica);
|
|
||||||
$model->tipo()->associate($tipo_documento);
|
|
||||||
$model->stato()->associate($stato_documento);
|
|
||||||
|
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imposta il sezionale relativo alla fattura e calcola il relativo numero.
|
||||||
|
* **Attenzione**: la data deve inserita prima!
|
||||||
|
*
|
||||||
|
* @param [type] $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setIdSegmentAttribute($value)
|
||||||
|
{
|
||||||
|
$previous = $this->id_segment;
|
||||||
|
|
||||||
|
$this->attributes['id_segment'] = $value;
|
||||||
|
|
||||||
|
// Calcolo dei numeri fattura
|
||||||
|
if ($value != $previous) {
|
||||||
|
$direzione = $this->tipo()->dir;
|
||||||
|
$data = $this->data;
|
||||||
|
|
||||||
|
$this->numero = static::getNumero($data, $direzione, $value);
|
||||||
|
$this->numero_esterno = static::getNumeroSecondario($data, $direzione, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calcola il nuovo numero di fattura.
|
* Calcola il nuovo numero di fattura.
|
||||||
*
|
*
|
||||||
|
@ -144,7 +144,7 @@ return [
|
|||||||
'text' => tr('Crea fattura'),
|
'text' => tr('Crea fattura'),
|
||||||
'data' => [
|
'data' => [
|
||||||
'title' => tr('Vuoi davvero generare le fatture per questi interventi?'),
|
'title' => tr('Vuoi davvero generare le fatture per questi interventi?'),
|
||||||
'msg' => '<br>{[ "type": "checkbox", "placeholder": "'.tr('Aggiungere alle fatture esistenti non ancora emesse?').'", "name": "accodare" ]}
|
'msg' => tr('Verranno fatturati gli interventi completati non inseriti in preventivi e contratti').'.<br>{[ "type": "checkbox", "placeholder": "'.tr('Aggiungere alle fatture esistenti non ancora emesse?').'", "name": "accodare" ]}
|
||||||
<br>{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}',
|
<br>{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}',
|
||||||
'button' => tr('Crea fatture'),
|
'button' => tr('Crea fatture'),
|
||||||
'class' => 'btn btn-lg btn-warning',
|
'class' => 'btn btn-lg btn-warning',
|
||||||
|
@ -138,6 +138,8 @@ abstract class Row extends Description
|
|||||||
protected function fixSconto()
|
protected function fixSconto()
|
||||||
{
|
{
|
||||||
$this->attributes['sconto'] = $this->sconto;
|
$this->attributes['sconto'] = $this->sconto;
|
||||||
|
|
||||||
|
$this->fixIva();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,6 +194,7 @@ abstract class Row extends Description
|
|||||||
$this->attributes['qta'] = $value;
|
$this->attributes['qta'] = $value;
|
||||||
|
|
||||||
$this->fixSubtotale();
|
$this->fixSubtotale();
|
||||||
|
$this->fixSconto();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,6 +207,7 @@ abstract class Row extends Description
|
|||||||
$this->costo_unitario = $value;
|
$this->costo_unitario = $value;
|
||||||
|
|
||||||
$this->fixSubtotale();
|
$this->fixSubtotale();
|
||||||
|
$this->fixSconto();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user