1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (C) 2024 Rafael San José <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This program is free software; you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU General Public License as published by |
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
8
|
|
|
* any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Dolibarr\Code\Compta\Model; |
20
|
|
|
|
21
|
|
|
use Carbon\Carbon; |
22
|
|
|
use Dolibarr\Code\Projet\Model\Projet; |
23
|
|
|
use Dolibarr\Code\Societe\Model\Societe; |
24
|
|
|
use Dolibarr\Code\Societe\Model\SocieteRemiseExcept; |
25
|
|
|
use Dolibarr\Code\UserGroup\Model\User; |
26
|
|
|
use Dolibarr\Core\Base\Model; |
27
|
|
|
use Illuminate\Database\Eloquent\Collection; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class Facture |
31
|
|
|
* |
32
|
|
|
* @property int $rowid |
33
|
|
|
* @property string $ref |
34
|
|
|
* @property int $entity |
35
|
|
|
* @property string|null $ref_ext |
36
|
|
|
* @property string|null $ref_client |
37
|
|
|
* @property int $type |
38
|
|
|
* @property int|null $subtype |
39
|
|
|
* @property int $fk_soc |
40
|
|
|
* @property Carbon|null $datec |
41
|
|
|
* @property Carbon|null $datef |
42
|
|
|
* @property Carbon|null $date_pointoftax |
43
|
|
|
* @property Carbon|null $date_valid |
44
|
|
|
* @property Carbon|null $tms |
45
|
|
|
* @property Carbon|null $date_closing |
46
|
|
|
* @property int $paye |
47
|
|
|
* @property float|null $remise_percent |
48
|
|
|
* @property float|null $remise_absolue |
49
|
|
|
* @property float|null $remise |
50
|
|
|
* @property string|null $close_code |
51
|
|
|
* @property float|null $close_missing_amount |
52
|
|
|
* @property string|null $close_note |
53
|
|
|
* @property float|null $total_tva |
54
|
|
|
* @property float|null $localtax1 |
55
|
|
|
* @property float|null $localtax2 |
56
|
|
|
* @property float|null $revenuestamp |
57
|
|
|
* @property float|null $total_ht |
58
|
|
|
* @property float|null $total_ttc |
59
|
|
|
* @property int $fk_statut |
60
|
|
|
* @property int|null $fk_user_author |
61
|
|
|
* @property int|null $fk_user_modif |
62
|
|
|
* @property int|null $fk_user_valid |
63
|
|
|
* @property int|null $fk_user_closing |
64
|
|
|
* @property string|null $module_source |
65
|
|
|
* @property string|null $pos_source |
66
|
|
|
* @property int|null $fk_fac_rec_source |
67
|
|
|
* @property int|null $fk_facture_source |
68
|
|
|
* @property int|null $fk_projet |
69
|
|
|
* @property string|null $increment |
70
|
|
|
* @property int|null $fk_account |
71
|
|
|
* @property string|null $fk_currency |
72
|
|
|
* @property int $fk_cond_reglement |
73
|
|
|
* @property int|null $fk_mode_reglement |
74
|
|
|
* @property Carbon|null $date_lim_reglement |
75
|
|
|
* @property string|null $note_private |
76
|
|
|
* @property string|null $note_public |
77
|
|
|
* @property string|null $model_pdf |
78
|
|
|
* @property string|null $last_main_doc |
79
|
|
|
* @property int|null $fk_incoterms |
80
|
|
|
* @property string|null $location_incoterms |
81
|
|
|
* @property int|null $fk_transport_mode |
82
|
|
|
* @property float|null $prorata_discount |
83
|
|
|
* @property int|null $situation_cycle_ref |
84
|
|
|
* @property int|null $situation_counter |
85
|
|
|
* @property int|null $situation_final |
86
|
|
|
* @property float|null $retained_warranty |
87
|
|
|
* @property Carbon|null $retained_warranty_date_limit |
88
|
|
|
* @property int|null $retained_warranty_fk_cond_reglement |
89
|
|
|
* @property string|null $import_key |
90
|
|
|
* @property string|null $extraparams |
91
|
|
|
* @property int|null $fk_multicurrency |
92
|
|
|
* @property string|null $multicurrency_code |
93
|
|
|
* @property float|null $multicurrency_tx |
94
|
|
|
* @property float|null $multicurrency_total_ht |
95
|
|
|
* @property float|null $multicurrency_total_tva |
96
|
|
|
* @property float|null $multicurrency_total_ttc |
97
|
|
|
* |
98
|
|
|
* @property Facture|null $facture |
99
|
|
|
* @property Projet|null $projet |
100
|
|
|
* @property Societe $societe |
101
|
|
|
* @property User|null $user |
102
|
|
|
* @property Collection|Facture[] $factures |
103
|
|
|
* @property Collection|Facturedet[] $facturedets |
104
|
|
|
* @property Collection|Paiement[] $paiements |
105
|
|
|
* @property Collection|SocieteRemiseExcept[] $societe_remise_excepts |
106
|
|
|
*/ |
107
|
|
|
class Facture extends Model |
108
|
|
|
{ |
109
|
|
|
public $timestamps = false; |
110
|
|
|
protected $table = 'facture'; |
111
|
|
|
protected $casts = [ |
112
|
|
|
'entity' => 'int', |
113
|
|
|
'type' => 'int', |
114
|
|
|
'subtype' => 'int', |
115
|
|
|
'fk_soc' => 'int', |
116
|
|
|
'datec' => 'datetime', |
117
|
|
|
'datef' => 'datetime', |
118
|
|
|
'date_pointoftax' => 'datetime', |
119
|
|
|
'date_valid' => 'datetime', |
120
|
|
|
'tms' => 'datetime', |
121
|
|
|
'date_closing' => 'datetime', |
122
|
|
|
'paye' => 'int', |
123
|
|
|
'remise_percent' => 'float', |
124
|
|
|
'remise_absolue' => 'float', |
125
|
|
|
'remise' => 'float', |
126
|
|
|
'close_missing_amount' => 'float', |
127
|
|
|
'total_tva' => 'float', |
128
|
|
|
'localtax1' => 'float', |
129
|
|
|
'localtax2' => 'float', |
130
|
|
|
'revenuestamp' => 'float', |
131
|
|
|
'total_ht' => 'float', |
132
|
|
|
'total_ttc' => 'float', |
133
|
|
|
'fk_statut' => 'int', |
134
|
|
|
'fk_user_author' => 'int', |
135
|
|
|
'fk_user_modif' => 'int', |
136
|
|
|
'fk_user_valid' => 'int', |
137
|
|
|
'fk_user_closing' => 'int', |
138
|
|
|
'fk_fac_rec_source' => 'int', |
139
|
|
|
'fk_facture_source' => 'int', |
140
|
|
|
'fk_projet' => 'int', |
141
|
|
|
'fk_account' => 'int', |
142
|
|
|
'fk_cond_reglement' => 'int', |
143
|
|
|
'fk_mode_reglement' => 'int', |
144
|
|
|
'date_lim_reglement' => 'datetime', |
145
|
|
|
'fk_incoterms' => 'int', |
146
|
|
|
'fk_transport_mode' => 'int', |
147
|
|
|
'prorata_discount' => 'float', |
148
|
|
|
'situation_cycle_ref' => 'int', |
149
|
|
|
'situation_counter' => 'int', |
150
|
|
|
'situation_final' => 'int', |
151
|
|
|
'retained_warranty' => 'float', |
152
|
|
|
'retained_warranty_date_limit' => 'datetime', |
153
|
|
|
'retained_warranty_fk_cond_reglement' => 'int', |
154
|
|
|
'fk_multicurrency' => 'int', |
155
|
|
|
'multicurrency_tx' => 'float', |
156
|
|
|
'multicurrency_total_ht' => 'float', |
157
|
|
|
'multicurrency_total_tva' => 'float', |
158
|
|
|
'multicurrency_total_ttc' => 'float' |
159
|
|
|
]; |
160
|
|
|
|
161
|
|
|
protected $fillable = [ |
162
|
|
|
'ref', |
163
|
|
|
'entity', |
164
|
|
|
'ref_ext', |
165
|
|
|
'ref_client', |
166
|
|
|
'type', |
167
|
|
|
'subtype', |
168
|
|
|
'fk_soc', |
169
|
|
|
'datec', |
170
|
|
|
'datef', |
171
|
|
|
'date_pointoftax', |
172
|
|
|
'date_valid', |
173
|
|
|
'tms', |
174
|
|
|
'date_closing', |
175
|
|
|
'paye', |
176
|
|
|
'remise_percent', |
177
|
|
|
'remise_absolue', |
178
|
|
|
'remise', |
179
|
|
|
'close_code', |
180
|
|
|
'close_missing_amount', |
181
|
|
|
'close_note', |
182
|
|
|
'total_tva', |
183
|
|
|
'localtax1', |
184
|
|
|
'localtax2', |
185
|
|
|
'revenuestamp', |
186
|
|
|
'total_ht', |
187
|
|
|
'total_ttc', |
188
|
|
|
'fk_statut', |
189
|
|
|
'fk_user_author', |
190
|
|
|
'fk_user_modif', |
191
|
|
|
'fk_user_valid', |
192
|
|
|
'fk_user_closing', |
193
|
|
|
'module_source', |
194
|
|
|
'pos_source', |
195
|
|
|
'fk_fac_rec_source', |
196
|
|
|
'fk_facture_source', |
197
|
|
|
'fk_projet', |
198
|
|
|
'increment', |
199
|
|
|
'fk_account', |
200
|
|
|
'fk_currency', |
201
|
|
|
'fk_cond_reglement', |
202
|
|
|
'fk_mode_reglement', |
203
|
|
|
'date_lim_reglement', |
204
|
|
|
'note_private', |
205
|
|
|
'note_public', |
206
|
|
|
'model_pdf', |
207
|
|
|
'last_main_doc', |
208
|
|
|
'fk_incoterms', |
209
|
|
|
'location_incoterms', |
210
|
|
|
'fk_transport_mode', |
211
|
|
|
'prorata_discount', |
212
|
|
|
'situation_cycle_ref', |
213
|
|
|
'situation_counter', |
214
|
|
|
'situation_final', |
215
|
|
|
'retained_warranty', |
216
|
|
|
'retained_warranty_date_limit', |
217
|
|
|
'retained_warranty_fk_cond_reglement', |
218
|
|
|
'import_key', |
219
|
|
|
'extraparams', |
220
|
|
|
'fk_multicurrency', |
221
|
|
|
'multicurrency_code', |
222
|
|
|
'multicurrency_tx', |
223
|
|
|
'multicurrency_total_ht', |
224
|
|
|
'multicurrency_total_tva', |
225
|
|
|
'multicurrency_total_ttc' |
226
|
|
|
]; |
227
|
|
|
|
228
|
|
|
public function facture() |
229
|
|
|
{ |
230
|
|
|
return $this->belongsTo(Facture::class, 'fk_facture_source'); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
public function projet() |
234
|
|
|
{ |
235
|
|
|
return $this->belongsTo(Projet::class, 'fk_projet'); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function societe() |
239
|
|
|
{ |
240
|
|
|
return $this->belongsTo(Societe::class, 'fk_soc'); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
public function user() |
244
|
|
|
{ |
245
|
|
|
return $this->belongsTo(User::class, 'fk_user_valid'); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
public function factures() |
249
|
|
|
{ |
250
|
|
|
return $this->hasMany(Facture::class, 'fk_facture_source'); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function facturedets() |
254
|
|
|
{ |
255
|
|
|
return $this->hasMany(Facturedet::class, 'fk_facture'); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
public function paiements() |
259
|
|
|
{ |
260
|
|
|
return $this->belongsToMany(Paiement::class, 'alx_paiement_facture', 'fk_facture', 'fk_paiement') |
261
|
|
|
->withPivot('rowid', 'amount', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_amount'); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
public function societe_remise_excepts() |
265
|
|
|
{ |
266
|
|
|
return $this->hasMany(SocieteRemiseExcept::class, 'fk_facture_source'); |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|