belongsTo(InvoiceType::class); } public function rfc(): BelongsTo { return $this->belongsTo(Rfc::class); } public function usage(): BelongsTo { return $this->belongsTo(Usage::class); } public function paymentType(): BelongsTo { return $this->belongsTo(PaymentType::class); } public function paymentMethod(): BelongsTo { return $this->belongsTo(PaymentMethod::class); } public function currency(): BelongsTo { return $this->belongsTo(Currency::class); } public function status(): BelongsTo { return $this->belongsTo(Status::class); } public function cancellationType(): BelongsTo { return $this->belongsTo(CancellationType::class); } public function cancellationStatus(): BelongsTo { return $this->belongsTo(Status::class); } public function issuerRfc(): BelongsTo { return $this->belongsTo(Rfc::class); } public function receiverRfc(): BelongsTo { return $this->belongsTo(Rfc::class); } public function invoiceLines(): HasMany { return $this->hasMany(InvoiceLine::class); } public function conciliations(): HasMany { return $this->hasMany(Conciliation::class); } public function invoicePayments(): HasMany { return $this->hasMany(InvoicePayment::class); } public function getRfcAttribute() { return $this->rfc()->first()->rfc; } public function getStatusAttribute() { return $this->status()->first()->description; } public function getCancellationTypeAttribute() { return $this->cancellationType()->first()->description; } public function getCancellationStatusAttribute() { return $this->cancellationStatus()->first()->description; } public function getIssuerRfcAttribute() { return $this->issuerRfc()->first()->rfc; } public function getReceiverRfcAttribute() { return $this->receiverRfc()->first()->rfc; } public function getTotalInMxnAttribute() { if ($this->exchange_rate) { $totalMXN = $this->total * $this->exchange_rate; } else { $totalMXN = $this->total; } return $totalMXN; } public function getTaxInMxnAttribute() { if ($this->exchange_rate) { $taxMXN = $this->tax * $this->exchange_rate; } else { $taxMXN = $this->tax; } return $taxMXN; } public function getTransferredVatInMxnAttribute() { if ($this->exchange_rate) { $transferredVatMXN = $this->transferred_vat * $this->exchange_rate; } else { $transferredVatMXN = $this->transferred_vat; } return $transferredVatMXN; } public function getTransferredSinTaxInMxnAttribute() { if ($this->exchange_rate) { $transferredSinMXN = $this->transferred_sin_tax * $this->exchange_rate; } else { $transferredSinMXN = $this->transferred_sin_tax; } return $transferredSinMXN; } public function getRetainedVatInMxnAttribute() { if ($this->exchange_rate) { $retainedVatMXN = $this->retained_vat * $this->exchange_rate; } else { $retainedVatMXN = $this->retained_vat; } return $retainedVatMXN; } public function getRetainedIncomeTaxInMxnAttribute() { if ($this->exchange_rate) { $retainedIncomeTaxMXN = $this->retained_income_tax * $this->exchange_rate; } else { $retainedIncomeTaxMXN = $this->retained_income_tax; } return $retainedIncomeTaxMXN; } protected $keyType = 'string'; protected $hidden = ['rfc_id', 'status_id', 'cancellation_type_id', 'cancellation_status_id', 'issuer_rfc_id', 'receiver_rfc_id']; protected $appends = ['rfc', 'status', 'cancellation_type', 'cancellation_status', 'issuer_rfc', 'receiver_rfc', 'total_in_mxn', 'tax_in_mxn', 'transferred_vat_in_mxn', 'transferred_sin_tax_in_mxn', 'retained_vat_in_mxn', 'retained_income_tax_in_mxn']; }