'integer', 'tax_amount' => 'integer', 'total_amount' => 'integer', 'item_count' => 'integer', 'item_unit_price' => 'integer', 'item_supply_amount' => 'integer', 'item_tax_amount' => 'integer', 'is_modified' => 'boolean', 'write_date' => 'date', 'issue_date' => 'date', 'send_date' => 'date', ]; // ========================================================================= // 관계 정의 // ========================================================================= public function tenant(): BelongsTo { return $this->belongsTo(\App\Models\Tenants\Tenant::class); } public function journals(): HasMany { return $this->hasMany(HometaxInvoiceJournal::class, 'hometax_invoice_id'); } // ========================================================================= // 스코프 // ========================================================================= public function scopeSales($query) { return $query->where('invoice_type', 'sales'); } public function scopePurchase($query) { return $query->where('invoice_type', 'purchase'); } public function scopePeriod($query, string $startDate, string $endDate) { return $query->whereBetween('write_date', [$startDate, $endDate]); } // ========================================================================= // 접근자 // ========================================================================= public function getTaxTypeNameAttribute(): string { return match ($this->tax_type) { self::TAX_TYPE_TAXABLE => '과세', self::TAX_TYPE_ZERO => '영세', self::TAX_TYPE_EXEMPT => '면세', default => $this->tax_type ?? '', }; } public function getPurposeTypeNameAttribute(): string { return match ($this->purpose_type) { self::PURPOSE_TYPE_RECEIPT => '영수', self::PURPOSE_TYPE_CLAIM => '청구', default => $this->purpose_type ?? '', }; } public function getIssueTypeNameAttribute(): string { return match ($this->issue_type) { self::ISSUE_TYPE_NORMAL => '정발행', self::ISSUE_TYPE_REVERSE => '역발행', default => $this->issue_type ?? '', }; } }