- 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] 바로빌 연동 코드 전면 개선
109 lines
3.0 KiB
PHP
109 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class BarobillCardTransaction extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'barobill_card_transactions';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'card_num',
|
|
'card_company',
|
|
'card_company_name',
|
|
'use_dt',
|
|
'use_date',
|
|
'use_time',
|
|
'approval_num',
|
|
'approval_type',
|
|
'approval_amount',
|
|
'tax',
|
|
'service_charge',
|
|
'payment_plan',
|
|
'currency_code',
|
|
'merchant_name',
|
|
'merchant_biz_num',
|
|
'merchant_addr',
|
|
'merchant_ceo',
|
|
'merchant_biz_type',
|
|
'merchant_tel',
|
|
'memo',
|
|
'use_key',
|
|
'account_code',
|
|
'account_name',
|
|
'deduction_type',
|
|
'evidence_name',
|
|
'description',
|
|
'modified_supply_amount',
|
|
'modified_tax',
|
|
'is_manual',
|
|
];
|
|
|
|
protected $casts = [
|
|
'approval_amount' => 'decimal:2',
|
|
'tax' => 'decimal:2',
|
|
'service_charge' => 'decimal:2',
|
|
'modified_supply_amount' => 'decimal:2',
|
|
'modified_tax' => 'decimal:2',
|
|
'is_manual' => 'boolean',
|
|
];
|
|
|
|
// =========================================================================
|
|
// 관계 정의
|
|
// =========================================================================
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Tenants\Tenant::class);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 접근자
|
|
// =========================================================================
|
|
|
|
/**
|
|
* 거래 고유 키 (cardNum|useDt|approvalNum|approvalAmount)
|
|
*/
|
|
public function getUniqueKeyAttribute(): string
|
|
{
|
|
return static::generateUniqueKey([
|
|
'card_num' => $this->card_num,
|
|
'use_dt' => $this->use_dt,
|
|
'approval_num' => $this->approval_num,
|
|
'approval_amount' => $this->approval_amount,
|
|
]);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 헬퍼 메서드
|
|
// =========================================================================
|
|
|
|
public static function generateUniqueKey(array $data): string
|
|
{
|
|
return implode('|', [
|
|
$data['card_num'] ?? '',
|
|
$data['use_dt'] ?? '',
|
|
$data['approval_num'] ?? '',
|
|
$data['approval_amount'] ?? '0',
|
|
]);
|
|
}
|
|
|
|
public static function getByDateRange(int $tenantId, string $startDate, string $endDate, ?string $cardNum = null)
|
|
{
|
|
$query = static::where('tenant_id', $tenantId)
|
|
->whereBetween('use_date', [$startDate, $endDate]);
|
|
|
|
if ($cardNum) {
|
|
$query->where('card_num', $cardNum);
|
|
}
|
|
|
|
return $query->orderBy('use_date')->orderBy('use_dt')->get();
|
|
}
|
|
}
|