2019-07-31 18:22:35 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-07-31 18:22:35 +02:00
|
|
|
|
|
|
|
namespace Modules\Scadenzario;
|
|
|
|
|
2020-09-22 20:28:37 +02:00
|
|
|
use Common\SimpleModelTrait;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-09-01 12:52:33 +02:00
|
|
|
use Modules\Anagrafiche\Anagrafica;
|
2019-07-31 18:22:35 +02:00
|
|
|
use Modules\Fatture\Fattura;
|
2024-05-23 11:36:25 +02:00
|
|
|
use Modules\Pagamenti\Pagamento;
|
2019-07-31 18:22:35 +02:00
|
|
|
|
|
|
|
class Scadenza extends Model
|
|
|
|
{
|
2020-09-22 20:28:37 +02:00
|
|
|
use SimpleModelTrait;
|
|
|
|
|
2019-07-31 18:22:35 +02:00
|
|
|
protected $table = 'co_scadenziario';
|
|
|
|
|
2020-02-14 11:35:44 +01:00
|
|
|
protected $dates = [
|
|
|
|
'scadenza',
|
|
|
|
'data_pagamento',
|
|
|
|
];
|
|
|
|
|
2024-03-19 18:18:11 +01:00
|
|
|
public static function build($idanagrafica = null, $descrizione = null, $importo = null, $data_scadenza = null, $id_pagamento = null, $id_banca_azienda = null, $id_banca_controparte = null, $type = 'fattura', $is_pagato = false)
|
2019-07-31 18:22:35 +02:00
|
|
|
{
|
2020-09-22 20:28:37 +02:00
|
|
|
$model = new static();
|
2019-07-31 18:22:35 +02:00
|
|
|
|
2022-09-01 12:52:33 +02:00
|
|
|
$model->idanagrafica = $idanagrafica;
|
2019-07-31 18:22:35 +02:00
|
|
|
$model->descrizione = $descrizione;
|
|
|
|
$model->scadenza = $data_scadenza;
|
|
|
|
$model->da_pagare = $importo;
|
|
|
|
$model->tipo = $type;
|
2023-11-27 11:18:54 +01:00
|
|
|
$model->id_pagamento = $id_pagamento;
|
2023-11-24 13:20:00 +01:00
|
|
|
$model->id_banca_azienda = $id_banca_azienda;
|
|
|
|
$model->id_banca_controparte = $id_banca_controparte;
|
2023-11-24 18:24:13 +01:00
|
|
|
|
2019-07-31 18:22:35 +02:00
|
|
|
$model->pagato = $is_pagato ? $importo : 0;
|
|
|
|
$model->data_pagamento = $is_pagato ? $data_scadenza : null;
|
|
|
|
|
|
|
|
$model->save();
|
|
|
|
|
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function documento()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Fattura::class, 'iddocumento');
|
|
|
|
}
|
2022-09-01 12:52:33 +02:00
|
|
|
|
|
|
|
public function anagrafica()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
|
|
|
}
|
2024-05-22 17:48:05 +02:00
|
|
|
|
|
|
|
public function pagamento()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Pagamento::class, 'id_pagamento');
|
|
|
|
}
|
2019-07-31 18:22:35 +02:00
|
|
|
}
|