- feat: [barobill] 바로빌 카드/은행/홈택스 REST API 구현 - feat: [equipment] 설비관리 API 백엔드 구현 - feat: [payroll] 급여관리 계산 엔진 및 일괄 처리 API - feat: [QMS] 점검표 템플릿 관리 + 로트심사 개선 - feat: [생산/출하] 수주 단위 출하 자동생성 + 상태 흐름 개선 - feat: [receiving] 입고 성적서 파일 연결 - feat: [견적] 제어기 타입 체계 변경 - feat: [email] 테넌트 메일 설정 마이그레이션 및 모델 - feat: [pmis] 시공관리 테이블 마이그레이션 - feat: [R2] 파일 업로드 커맨드 + filesystems 설정 - feat: [배포] Jenkinsfile 롤백 기능 추가 - fix: [approval] SAM API 규칙 준수 코드 개선 - fix: [account-codes] 계정과목 중복 데이터 정리 - fix: [payroll] 일괄 생성 시 삭제된 사용자 건너뛰기 - fix: [db] codebridge DB 분리 후 깨진 FK 제약조건 제거 - refactor: [barobill] 바로빌 연동 코드 전면 개선
159 lines
4.4 KiB
PHP
159 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class HometaxInvoice extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'hometax_invoices';
|
|
|
|
// 과세유형
|
|
public const TAX_TYPE_TAXABLE = '01'; // 과세
|
|
|
|
public const TAX_TYPE_ZERO = '02'; // 영세
|
|
|
|
public const TAX_TYPE_EXEMPT = '03'; // 면세
|
|
|
|
// 영수/청구
|
|
public const PURPOSE_TYPE_RECEIPT = '01'; // 영수
|
|
|
|
public const PURPOSE_TYPE_CLAIM = '02'; // 청구
|
|
|
|
// 발급유형
|
|
public const ISSUE_TYPE_NORMAL = '01'; // 정발행
|
|
|
|
public const ISSUE_TYPE_REVERSE = '02'; // 역발행
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'nts_confirm_num',
|
|
'invoice_type',
|
|
'write_date',
|
|
'issue_date',
|
|
'send_date',
|
|
'invoicer_corp_num',
|
|
'invoicer_tax_reg_id',
|
|
'invoicer_corp_name',
|
|
'invoicer_ceo_name',
|
|
'invoicer_addr',
|
|
'invoicer_biz_type',
|
|
'invoicer_biz_class',
|
|
'invoicer_contact_id',
|
|
'invoicee_corp_num',
|
|
'invoicee_tax_reg_id',
|
|
'invoicee_corp_name',
|
|
'invoicee_ceo_name',
|
|
'invoicee_addr',
|
|
'invoicee_biz_type',
|
|
'invoicee_biz_class',
|
|
'invoicee_contact_id',
|
|
'supply_amount',
|
|
'tax_amount',
|
|
'total_amount',
|
|
'tax_type',
|
|
'purpose_type',
|
|
'issue_type',
|
|
'is_modified',
|
|
'original_nts_confirm_num',
|
|
'modify_code',
|
|
'remark1',
|
|
'remark2',
|
|
'remark3',
|
|
'item_name',
|
|
'item_count',
|
|
'item_unit_price',
|
|
'item_supply_amount',
|
|
'item_tax_amount',
|
|
'item_remark',
|
|
'account_code',
|
|
'account_name',
|
|
'deduction_type',
|
|
];
|
|
|
|
protected $casts = [
|
|
'supply_amount' => '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 ?? '',
|
|
};
|
|
}
|
|
}
|