|
@@ -376,6 +376,13 @@ class RecordOUT extends Component
|
|
|
// Option 1: Use current date and time as the invoice number
|
|
// Option 1: Use current date and time as the invoice number
|
|
|
$invoiceNumber = 'USC-' . date('YmdHis');
|
|
$invoiceNumber = 'USC-' . date('YmdHis');
|
|
|
|
|
|
|
|
|
|
+ if (empty($this->data_pagamento) || $this->data_pagamento == '1970-01-01') {
|
|
|
|
|
+ $this->data_pagamento = null;
|
|
|
|
|
+ Log::info("Setting data_pagamento to NULL in store");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Log::info("Using data_pagamento: " . $this->data_pagamento);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$this->validate();
|
|
$this->validate();
|
|
|
try {
|
|
try {
|
|
|
$record = \App\Models\Record::create([
|
|
$record = \App\Models\Record::create([
|
|
@@ -384,7 +391,7 @@ class RecordOUT extends Component
|
|
|
//'causal_id' => $this->causal_id,
|
|
//'causal_id' => $this->causal_id,
|
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
|
'date' => $this->date,
|
|
'date' => $this->date,
|
|
|
- 'data_pagamento' => date("Y-m-d", strtotime($this->data_pagamento)),
|
|
|
|
|
|
|
+ 'data_pagamento' =>$this->data_pagamento,
|
|
|
//'month' => $this->month,
|
|
//'month' => $this->month,
|
|
|
//'year' => $this->year,
|
|
//'year' => $this->year,
|
|
|
//'note' => $this->note,
|
|
//'note' => $this->note,
|
|
@@ -430,6 +437,26 @@ class RecordOUT extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function setDataPagamentoAttribute($value)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Convert empty values to NULL
|
|
|
|
|
+ if (empty($value) || $value == '1970-01-01' || $value == '0000-00-00') {
|
|
|
|
|
+ $this->attributes['data_pagamento'] = null;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $this->attributes['data_pagamento'] = $value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Optional: Also add an accessor to prevent returning 1970-01-01
|
|
|
|
|
+ public function getDataPagamentoAttribute($value)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Return null instead of Unix epoch date
|
|
|
|
|
+ if ($value == '1970-01-01' || $value == '0000-00-00') {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function edit($id)
|
|
public function edit($id)
|
|
|
{
|
|
{
|
|
|
if (!isset($_GET["from"]) && $this->fromPage == '')
|
|
if (!isset($_GET["from"]) && $this->fromPage == '')
|
|
@@ -448,7 +475,7 @@ class RecordOUT extends Component
|
|
|
//$this->causal_id = $record->causal_id;
|
|
//$this->causal_id = $record->causal_id;
|
|
|
$this->payment_method_id = $record->payment_method_id;
|
|
$this->payment_method_id = $record->payment_method_id;
|
|
|
$this->date = date("Y-m-d", strtotime($record->date));
|
|
$this->date = date("Y-m-d", strtotime($record->date));
|
|
|
- $this->data_pagamento = date("Y-m-d", strtotime($record->data_pagamento));
|
|
|
|
|
|
|
+ $this->data_pagamento = $record->data_pagamento;
|
|
|
//$this->month = $record->month;
|
|
//$this->month = $record->month;
|
|
|
//$this->year = $record->year;
|
|
//$this->year = $record->year;
|
|
|
//$this->note = $record->note;
|
|
//$this->note = $record->note;
|
|
@@ -496,6 +523,13 @@ class RecordOUT extends Component
|
|
|
$this->emit('refresh');
|
|
$this->emit('refresh');
|
|
|
$this->validate();
|
|
$this->validate();
|
|
|
|
|
|
|
|
|
|
+ if (empty($this->data_pagamento) || $this->data_pagamento == '') {
|
|
|
|
|
+ $this->data_pagamento = null;
|
|
|
|
|
+ Log::info("Data pagamento vuota, imposto a NULL in update");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Log::info("Data pagamento in update: " . $this->data_pagamento);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
|
'member_id' => $this->member_id,
|
|
'member_id' => $this->member_id,
|