Hoan thien core finance v2
This commit is contained in:
@@ -137,6 +137,24 @@ class ContractForm
|
||||
KeyValue::make('discount_details')
|
||||
->label('Bảng chi tiết chiết khấu (Dạng Key-Value)')
|
||||
->columnSpanFull(),
|
||||
|
||||
Placeholder::make('final_value_display')
|
||||
->label('Giá trị sau chiết khấu')
|
||||
->columnSpanFull()
|
||||
->content(function ($record, $get) {
|
||||
$totalValue = $record ? (float) $record->total_value : (float) ($get('total_value') ?? 0);
|
||||
$discountDetails = $record ? $record->discount_details : ($get('discount_details') ?? []);
|
||||
|
||||
if ($totalValue <= 0) {
|
||||
return new HtmlString("<div style='font-size: 0.9rem; color: #9ca3af;'>Chưa có giá trị hợp đồng để tính chiết khấu.</div>");
|
||||
}
|
||||
|
||||
$result = \App\Services\DiscountEngine::calculate($totalValue, $discountDetails);
|
||||
$final = number_format($result['final_value']);
|
||||
$discount = number_format($result['discount_amount']);
|
||||
|
||||
return new HtmlString("<div style='font-size: 1.1rem; font-weight: bold; color: #16a34a;'>{$final} VNĐ</div><div style='font-size: 0.8rem; color: #9ca3af;'>Đã chiết khấu: {$discount} VNĐ</div>");
|
||||
}),
|
||||
]),
|
||||
|
||||
Section::make('Thông tin quản lý & Khách hàng')
|
||||
@@ -166,8 +184,8 @@ class ContractForm
|
||||
->placeholder('Chọn mẫu để tự động tạo lịch trình...')
|
||||
->options(PaymentTemplate::pluck('name', 'id'))
|
||||
->searchable()
|
||||
->dehydrated(false)
|
||||
->helperText('Lưu ý: Chỉ chọn nếu bạn muốn khởi tạo lại lịch trình thanh toán.'),
|
||||
->hiddenOn('edit')
|
||||
->helperText('Hệ thống sẽ tự động tạo lịch thanh toán sau khi lưu hợp đồng.'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user