mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Bugfix init preventivi
This commit is contained in:
parent
455ab818b1
commit
a4bcde9e81
@ -8,5 +8,20 @@ class TipoSessione extends Model
|
||||
{
|
||||
protected $table = 'in_tipiintervento';
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use Modules\Preventivi\Components\Articolo;
|
||||
use Modules\Preventivi\Components\Descrizione;
|
||||
use Modules\Preventivi\Components\Riga;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
use Modules\Interventi\TipoSessione as TipoIntervento;
|
||||
use Modules\Interventi\TipoSessione;
|
||||
|
||||
switch (post('op')) {
|
||||
case 'add':
|
||||
@ -17,7 +17,7 @@ switch (post('op')) {
|
||||
$idtipointervento = post('idtipointervento');
|
||||
|
||||
$anagrafica = Anagrafica::find($idanagrafica);
|
||||
$tipo = TipoIntervento::find($idtipointervento);
|
||||
$tipo = TipoSessione::find($idtipointervento);
|
||||
|
||||
$preventivo = Preventivo::make($anagrafica, $tipo, $nome);
|
||||
$id_record = $preventivo->id;
|
||||
|
@ -4,7 +4,7 @@ namespace Modules\Preventivi;
|
||||
|
||||
use Common\Document;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Interventi\TipoSessione as TipoIntervento;
|
||||
use Modules\Interventi\TipoSessione;
|
||||
use Traits\RecordTrait;
|
||||
use Util\Generator;
|
||||
use Carbon\Carbon;
|
||||
@ -19,12 +19,12 @@ class Preventivo extends Document
|
||||
* Crea un nuovo preventivo.
|
||||
*
|
||||
* @param Anagrafica $anagrafica
|
||||
* @param TipoIntervento $tipo_intervento
|
||||
* @param TipoIntervento $tipo_sessione
|
||||
* @param string $nome
|
||||
*
|
||||
* @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();
|
||||
|
||||
@ -34,8 +34,8 @@ class Preventivo extends Document
|
||||
$id_agente = $anagrafica->idagente;
|
||||
$id_pagamento = $anagrafica->idpagamento_vendite;
|
||||
|
||||
$costo_orario = $tipo_intervento['costo_orario'];
|
||||
$costo_diritto_chiamata = $tipo_intervento['costo_diritto_chiamata'];
|
||||
$costo_orario = $tipo_sessione['costo_orario'];
|
||||
$costo_diritto_chiamata = $tipo_sessione['costo_diritto_chiamata'];
|
||||
|
||||
$id_iva = setting('Iva predefinita');
|
||||
if (empty($id_pagamento)) {
|
||||
@ -44,6 +44,7 @@ class Preventivo extends Document
|
||||
|
||||
$model->anagrafica()->associate($anagrafica);
|
||||
$model->stato()->associate($stato_documento);
|
||||
$model->tipoSessione()->associate($tipo_sessione);
|
||||
|
||||
$model->numero = static::getNextNumero();
|
||||
|
||||
@ -106,6 +107,11 @@ class Preventivo extends Document
|
||||
return $this->belongsTo(Stato::class, 'idstato');
|
||||
}
|
||||
|
||||
public function tipoSessione()
|
||||
{
|
||||
return $this->belongsTo(TipoSessione::class, 'idtipointervento');
|
||||
}
|
||||
|
||||
public function articoli()
|
||||
{
|
||||
return $this->hasMany(Components\Articolo::class, 'idpreventivo');
|
||||
|
Loading…
x
Reference in New Issue
Block a user