1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

Bugfix init preventivi

This commit is contained in:
Thomas Zilio
2019-01-02 10:08:08 +01:00
parent 455ab818b1
commit a4bcde9e81
3 changed files with 28 additions and 7 deletions

View File

@@ -8,5 +8,20 @@ class TipoSessione extends Model
{ {
protected $table = 'in_tipiintervento'; protected $table = 'in_tipiintervento';
protected $primaryKey = 'idtipointervento'; protected $primaryKey = 'idtipointervento';
public $incrementing = false;
/**
* Restituisce l'identificativo.
*
* @return string
*/
public function getIdAttribute()
{
return $this->idtipointervento;
}
public function preventivi()
{
return $this->hasMany(Preventivo::class, 'idtipointervento');
}
} }

View File

@@ -8,7 +8,7 @@ use Modules\Preventivi\Components\Articolo;
use Modules\Preventivi\Components\Descrizione; use Modules\Preventivi\Components\Descrizione;
use Modules\Preventivi\Components\Riga; use Modules\Preventivi\Components\Riga;
use Modules\Preventivi\Preventivo; use Modules\Preventivi\Preventivo;
use Modules\Interventi\TipoSessione as TipoIntervento; use Modules\Interventi\TipoSessione;
switch (post('op')) { switch (post('op')) {
case 'add': case 'add':
@@ -17,7 +17,7 @@ switch (post('op')) {
$idtipointervento = post('idtipointervento'); $idtipointervento = post('idtipointervento');
$anagrafica = Anagrafica::find($idanagrafica); $anagrafica = Anagrafica::find($idanagrafica);
$tipo = TipoIntervento::find($idtipointervento); $tipo = TipoSessione::find($idtipointervento);
$preventivo = Preventivo::make($anagrafica, $tipo, $nome); $preventivo = Preventivo::make($anagrafica, $tipo, $nome);
$id_record = $preventivo->id; $id_record = $preventivo->id;

View File

@@ -4,7 +4,7 @@ namespace Modules\Preventivi;
use Common\Document; use Common\Document;
use Modules\Anagrafiche\Anagrafica; use Modules\Anagrafiche\Anagrafica;
use Modules\Interventi\TipoSessione as TipoIntervento; use Modules\Interventi\TipoSessione;
use Traits\RecordTrait; use Traits\RecordTrait;
use Util\Generator; use Util\Generator;
use Carbon\Carbon; use Carbon\Carbon;
@@ -19,12 +19,12 @@ class Preventivo extends Document
* Crea un nuovo preventivo. * Crea un nuovo preventivo.
* *
* @param Anagrafica $anagrafica * @param Anagrafica $anagrafica
* @param TipoIntervento $tipo_intervento * @param TipoIntervento $tipo_sessione
* @param string $nome * @param string $nome
* *
* @return self * @return self
*/ */
public static function make(Anagrafica $anagrafica, TipoIntervento $tipo_intervento, $nome) public static function make(Anagrafica $anagrafica, TipoSessione $tipo_sessione, $nome)
{ {
$model = parent::make(); $model = parent::make();
@@ -34,8 +34,8 @@ class Preventivo extends Document
$id_agente = $anagrafica->idagente; $id_agente = $anagrafica->idagente;
$id_pagamento = $anagrafica->idpagamento_vendite; $id_pagamento = $anagrafica->idpagamento_vendite;
$costo_orario = $tipo_intervento['costo_orario']; $costo_orario = $tipo_sessione['costo_orario'];
$costo_diritto_chiamata = $tipo_intervento['costo_diritto_chiamata']; $costo_diritto_chiamata = $tipo_sessione['costo_diritto_chiamata'];
$id_iva = setting('Iva predefinita'); $id_iva = setting('Iva predefinita');
if (empty($id_pagamento)) { if (empty($id_pagamento)) {
@@ -44,6 +44,7 @@ class Preventivo extends Document
$model->anagrafica()->associate($anagrafica); $model->anagrafica()->associate($anagrafica);
$model->stato()->associate($stato_documento); $model->stato()->associate($stato_documento);
$model->tipoSessione()->associate($tipo_sessione);
$model->numero = static::getNextNumero(); $model->numero = static::getNextNumero();
@@ -106,6 +107,11 @@ class Preventivo extends Document
return $this->belongsTo(Stato::class, 'idstato'); return $this->belongsTo(Stato::class, 'idstato');
} }
public function tipoSessione()
{
return $this->belongsTo(TipoSessione::class, 'idtipointervento');
}
public function articoli() public function articoli()
{ {
return $this->hasMany(Components\Articolo::class, 'idpreventivo'); return $this->hasMany(Components\Articolo::class, 'idpreventivo');