squareetlabs /
LaravelVerifactu
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Squareetlabs\VeriFactu\Models; |
||
| 6 | |||
| 7 | use Illuminate\Database\Eloquent\Model; |
||
| 8 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
| 9 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
||
| 10 | use Squareetlabs\VeriFactu\Enums\TaxType; |
||
| 11 | use Squareetlabs\VeriFactu\Enums\RegimeType; |
||
| 12 | use Squareetlabs\VeriFactu\Enums\OperationType; |
||
| 13 | use Squareetlabs\VeriFactu\Contracts\VeriFactuBreakdown; |
||
| 14 | |||
| 15 | class Breakdown extends Model implements VeriFactuBreakdown |
||
| 16 | { |
||
| 17 | use HasFactory; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 18 | use SoftDeletes; |
||
| 19 | |||
| 20 | protected static function newFactory() |
||
| 21 | { |
||
| 22 | return \Database\Factories\Squareetlabs\VeriFactu\Models\BreakdownFactory::new(); |
||
| 23 | } |
||
| 24 | |||
| 25 | protected $table = 'breakdowns'; |
||
| 26 | |||
| 27 | protected $fillable = [ |
||
| 28 | 'invoice_id', |
||
| 29 | 'tax_type', |
||
| 30 | 'regime_type', |
||
| 31 | 'operation_type', |
||
| 32 | 'tax_rate', |
||
| 33 | 'base_amount', |
||
| 34 | 'tax_amount', |
||
| 35 | ]; |
||
| 36 | |||
| 37 | protected $casts = [ |
||
| 38 | 'tax_type' => TaxType::class, |
||
| 39 | 'regime_type' => RegimeType::class, |
||
| 40 | 'operation_type' => OperationType::class, |
||
| 41 | 'tax_rate' => 'decimal:2', |
||
| 42 | 'base_amount' => 'decimal:2', |
||
| 43 | 'tax_amount' => 'decimal:2', |
||
| 44 | ]; |
||
| 45 | |||
| 46 | public function invoice() |
||
| 47 | { |
||
| 48 | return $this->belongsTo(Invoice::class); |
||
| 49 | } |
||
| 50 | |||
| 51 | // VeriFactuBreakdown Contract Implementation |
||
| 52 | |||
| 53 | public function getRegimeType(): string |
||
| 54 | { |
||
| 55 | return $this->regime_type?->value ?? '01'; |
||
|
0 ignored issues
–
show
|
|||
| 56 | } |
||
| 57 | |||
| 58 | public function getOperationType(): string |
||
| 59 | { |
||
| 60 | return $this->operation_type?->value ?? 'S1'; |
||
|
0 ignored issues
–
show
|
|||
| 61 | } |
||
| 62 | |||
| 63 | public function getTaxRate(): float |
||
| 64 | { |
||
| 65 | return (float) $this->tax_rate; |
||
| 66 | } |
||
| 67 | |||
| 68 | public function getBaseAmount(): float |
||
| 69 | { |
||
| 70 | return (float) $this->base_amount; |
||
| 71 | } |
||
| 72 | |||
| 73 | public function getTaxAmount(): float |
||
| 74 | { |
||
| 75 | return (float) $this->tax_amount; |
||
| 76 | } |
||
| 77 | } |