Breakdown   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 26
c 2
b 0
f 0
dl 0
loc 61
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseAmount() 0 3 1
A getRegimeType() 0 3 1
A getOperationType() 0 3 1
A getTaxRate() 0 3 1
A invoice() 0 3 1
A newFactory() 0 3 1
A getTaxAmount() 0 3 1
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
The trait Illuminate\Database\Eloquent\Factories\HasFactory requires the property $factoryClass which is not provided by Squareetlabs\VeriFactu\Models\Breakdown.
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
Bug introduced by
The property value does not exist on string.
Loading history...
56
    }
57
58
    public function getOperationType(): string
59
    {
60
        return $this->operation_type?->value ?? 'S1';
0 ignored issues
show
Bug introduced by
The property value does not exist on string.
Loading history...
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
}