feat(webstatement): update print statement functionalities
- Menambahkan kolom `remarks` pada tabel print_statement_logs untuk menyimpan catatan tambahan. - Mengubah validasi periode pada `PrintStatementRequest` untuk mencegah request duplikasi periode. - Memperbaiki tampilan di `statements.index` dan `statements.show` agar lebih responsif dan informatif. - Mengubah logika download statement untuk mendukung file range periode dalam format zip. - Menambahkan logika cek file statement berdasarkan ketersediaan file di storage SFTP. - Menghapus file legacy `create.blade.php` yang tidak lagi digunakan. - Menyesuaikan ikon menu dari `calendar` ke `printer` agar lebih relevan. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Webstatement\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Modules\Webstatement\Models\PrintStatementLog as Statement;
|
||||
|
||||
class PrintStatementRequest extends FormRequest
|
||||
{
|
||||
@@ -27,11 +29,38 @@
|
||||
'branch_code' => ['required', 'string', 'exists:branches,code'],
|
||||
'account_number' => ['required', 'string'],
|
||||
'is_period_range' => ['sometimes', 'boolean'],
|
||||
'period_from' => ['required', 'string', 'regex:/^\d{6}$/'], // YYYYMM format
|
||||
'period_from' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/^\d{6}$/', // YYYYMM format
|
||||
// Prevent duplicate requests with same account number and period
|
||||
function ($attribute, $value, $fail) {
|
||||
$query = Statement::where('account_number', $this->input('account_number'))
|
||||
->where('authorization_status', '!=', 'rejected')
|
||||
->where('period_from', $value);
|
||||
|
||||
// If this is an update request, exclude the current record
|
||||
if ($this->route('statement')) {
|
||||
$query->where('id', '!=', $this->route('statement'));
|
||||
}
|
||||
|
||||
// If period_to is provided, check for overlapping periods
|
||||
if ($this->input('period_to')) {
|
||||
$query->where(function ($q) use ($value) {
|
||||
$q->where('period_from', '<=', $this->input('period_to'))
|
||||
->where('period_to', '>=', $value);
|
||||
});
|
||||
}
|
||||
|
||||
if ($query->exists()) {
|
||||
$fail('A statement request with this account number and period already exists.');
|
||||
}
|
||||
}
|
||||
],
|
||||
];
|
||||
|
||||
// If it's a period range, require period_to
|
||||
if ($this->input('is_period_range')) {
|
||||
if ($this->input('period_to')) {
|
||||
$rules['period_to'] = [
|
||||
'required',
|
||||
'string',
|
||||
@@ -71,10 +100,24 @@
|
||||
protected function prepareForValidation()
|
||||
: void
|
||||
{
|
||||
// Convert is_period_range to boolean if it exists
|
||||
if ($this->has('is_period_range')) {
|
||||
if($this->has('period_from')){
|
||||
//conver to YYYYMM format
|
||||
$this->merge([
|
||||
'is_period_range' => filter_var($this->is_period_range, FILTER_VALIDATE_BOOLEAN),
|
||||
'period_from' => substr($this->period_from, 0, 4).substr($this->period_from, 5, 2),
|
||||
]);
|
||||
}
|
||||
|
||||
if($this->has('period_to')){
|
||||
//conver to YYYYMM format
|
||||
$this->merge([
|
||||
'period_to' => substr($this->period_to, 0, 4).substr($this->period_to, 5, 2),
|
||||
]);
|
||||
}
|
||||
|
||||
// Convert is_period_range to boolean if it exists
|
||||
if ($this->has('period_to')) {
|
||||
$this->merge([
|
||||
'is_period_range' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user