Miglioramenti minori
This commit is contained in:
parent
86e9e92c8c
commit
d9aec773d5
|
@ -300,9 +300,6 @@ switch (post('op')) {
|
|||
try {
|
||||
$fattura->delete();
|
||||
|
||||
$dbo->query('DELETE FROM co_scadenze WHERE iddocumento='.prepare($id_record));
|
||||
$dbo->query('DELETE FROM co_movimenti WHERE iddocumento='.prepare($id_record));
|
||||
|
||||
// Azzeramento collegamento della rata contrattuale alla pianificazione
|
||||
$dbo->query('UPDATE co_fatturazione_contratti SET iddocumento=0 WHERE iddocumento='.prepare($id_record));
|
||||
|
||||
|
@ -350,10 +347,11 @@ switch (post('op')) {
|
|||
|
||||
case 'reopen':
|
||||
if (!empty($id_record)) {
|
||||
$dbo->query("UPDATE co_documenti SET idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione='Bozza') WHERE id=".prepare($id_record));
|
||||
elimina_movimenti($id_record, 1);
|
||||
elimina_scadenze($id_record);
|
||||
ricalcola_costiagg_fattura($id_record);
|
||||
$stato = Stato::where('descrizione', '=', 'Bozza')->first();
|
||||
|
||||
$fattura->stato()->associate($stato);
|
||||
$fattura->save();
|
||||
|
||||
flash()->info(tr('Fattura riaperta!'));
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ elseif ($record['stato'] == 'Bozza') {
|
|||
<p class="pull-left"><strong>'.tr('Scadenze').'</strong></p>
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
'.Modules::link('Scadenzario', $scadenze[0]['id'], tr('<i class="fa fa-edit tip" title="'.tr('Modifica scadenze').'"></i>'), '', 'class="btn btn-xs btn-primary"');
|
||||
'.Modules::link('Scadenzario', $fattura->gruppoScadenze->id, tr('<i class="fa fa-edit tip" title="'.tr('Modifica scadenze').'"></i>'), '', 'class="btn btn-xs btn-primary"');
|
||||
|
||||
// Ricalcola scadenze disponibile solo per fatture di acquisto
|
||||
if ($fattura->isFE() && $ricalcola && $module['name'] == 'Fatture di acquisto') {
|
||||
|
|
|
@ -29,6 +29,7 @@ if ($module['name'] == 'Fatture di vendita') {
|
|||
|
||||
if (isset($id_record)) {
|
||||
$has_access = \Util\Query::checkAccess($id_record);
|
||||
|
||||
$fattura = Fattura::with('tipo', 'stato')->find($id_record);
|
||||
$dir = $fattura->direzione;
|
||||
|
||||
|
|
|
@ -220,6 +220,9 @@ class Fattura extends Document
|
|||
|
||||
$model->save();
|
||||
|
||||
// Inizializzazione Gruppo Scadenze di riferimento
|
||||
$model->gestoreScadenze->getGruppo();
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
@ -604,6 +607,11 @@ class Fattura extends Document
|
|||
&& !in_array($this->stato['descrizione'], ['Bozza', 'Annullata']))
|
||||
|| $options[0] == 'forza_emissione'
|
||||
) {
|
||||
// Correzione descrizione per Gruppo Scadenze di riferimento
|
||||
$gruppo = $this->gruppoScadenze;
|
||||
$gruppo->descrizione = $this->getReference();
|
||||
$gruppo->save();
|
||||
|
||||
// Registrazione scadenze
|
||||
$this->registraScadenze($this->stato['descrizione'] == 'Pagato');
|
||||
|
||||
|
@ -679,7 +687,7 @@ class Fattura extends Document
|
|||
$result = parent::delete();
|
||||
|
||||
// Rimozione delle scadenza
|
||||
$this->rimuoviScadenze();
|
||||
$this->gruppoScadenze()->delete();
|
||||
|
||||
// Rimozione dei movimenti
|
||||
$this->gestoreMovimenti->rimuovi();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
namespace Modules\Fatture\Gestori;
|
||||
|
||||
use Modules\Fatture\Fattura;
|
||||
use Modules\Scadenzario\Gruppo;
|
||||
use Modules\Scadenzario\Scadenza;
|
||||
use Plugins\ImportFE\FatturaElettronica as FatturaElettronicaImport;
|
||||
use Util\XML;
|
||||
|
@ -38,6 +39,15 @@ class Scadenze
|
|||
$this->fattura = $fattura;
|
||||
}
|
||||
|
||||
public function getGruppo(){
|
||||
// Generazione Gruppo Scadenze di riferimento
|
||||
if (empty($this->fattura->gruppoScadenze)) {
|
||||
$gruppo = Gruppo::build($this->fattura->getReference(), $this->fattura);
|
||||
}
|
||||
|
||||
return $this->fattura->gruppoScadenze;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registra le scadenze della fattura.
|
||||
*
|
||||
|
@ -86,7 +96,7 @@ class Scadenze
|
|||
*/
|
||||
public function rimuovi()
|
||||
{
|
||||
database()->delete('co_scadenze', ['iddocumento' => $this->fattura->id]);
|
||||
$this->getGruppo()->rimuoviScadenze();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,20 +105,11 @@ class Scadenze
|
|||
* @param float $importo
|
||||
* @param string $data_scadenza
|
||||
* @param bool $is_pagato
|
||||
* @param string $type
|
||||
* @param string $tipo
|
||||
*/
|
||||
protected function registraScadenza(Fattura $fattura, $importo, $data_scadenza, $is_pagato, $type = 'fattura')
|
||||
protected static function registraScadenza(Fattura $fattura, $importo, $data_scadenza, $is_pagato, $tipo = 'fattura')
|
||||
{
|
||||
$numero = $fattura->numero_esterno ?: $fattura->numero;
|
||||
$descrizione = $fattura->tipo->descrizione.' numero '.$numero;
|
||||
|
||||
// TODO $descrizione Gruppo
|
||||
$scadenza = Scadenza::build($importo, $data_scadenza, $type, $is_pagato);
|
||||
|
||||
$scadenza->fattura()->associate($fattura);
|
||||
$scadenza->data_emissione = $fattura->data;
|
||||
|
||||
$scadenza->save();
|
||||
return Scadenza::build($fattura->getGruppo(), $importo, $data_scadenza, $tipo, $is_pagato);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,6 +52,30 @@ class Gruppo extends Model
|
|||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo per la gestione dei trigger alla modifica delle scadenze del gruppo.
|
||||
* @param Scadenza $trigger
|
||||
*/
|
||||
public function triggerScadenza(Scadenza $trigger){
|
||||
$this->totale_pagato = $this->scadenze()->sum('pagato');
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo per rimuovere completamente le scadenze associate al gruppo.
|
||||
* Da utilizzare per le Fatture.
|
||||
*/
|
||||
public function rimuoviScadenze() {
|
||||
$this->scadenze->delete();
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->rimuoviScadenze();
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
// Relazioni Eloquent
|
||||
|
||||
public function fattura()
|
||||
|
|
|
@ -79,6 +79,7 @@ if (!empty($fatture_generate_errore->count())) {
|
|||
}
|
||||
|
||||
// Controllo se ci sono fatture in elaborazione da più di 7 giorni per le quali non ho ancora una ricevuta
|
||||
|
||||
$data_limite = (new Carbon())->subDays(7);
|
||||
$fatture_generate = Fattura::vendita()
|
||||
->where('codice_stato_fe', 'WAIT')
|
||||
|
|
|
@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `co_gruppi_scadenze` (
|
|||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_documento` int(11) DEFAULT NULL,
|
||||
`descrizione` varchar(255) NOT NULL,
|
||||
`data_emissione` date NOT NULL,
|
||||
`data_emissione` date DEFAULT NULL,
|
||||
`totale_pagato` decimal(12, 6) NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
|
Loading…
Reference in New Issue