|
@@ -9,7 +9,7 @@ use SimpleXMLElement;
|
|
|
use Livewire\WithFileUploads;
|
|
use Livewire\WithFileUploads;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
-
|
|
|
|
|
|
|
+use App\Services\RecordFileService;
|
|
|
|
|
|
|
|
class RecordOUT extends Component
|
|
class RecordOUT extends Component
|
|
|
{
|
|
{
|
|
@@ -63,6 +63,7 @@ class RecordOUT extends Component
|
|
|
$add = false,
|
|
$add = false,
|
|
|
$is_paid = false;
|
|
$is_paid = false;
|
|
|
public $attachment;
|
|
public $attachment;
|
|
|
|
|
+ public $attachment_old;
|
|
|
|
|
|
|
|
public $filterSupplier = 0, $filterPaymentMethod = 0, $filterCausals = [], $filterFrom = '', $filterTo = '', $filterCommercial = 0;
|
|
public $filterSupplier = 0, $filterPaymentMethod = 0, $filterCausals = [], $filterFrom = '', $filterTo = '', $filterCommercial = 0;
|
|
|
|
|
|
|
@@ -105,6 +106,13 @@ class RecordOUT extends Component
|
|
|
'rows.*.causal_id.required' => 'La causale è obbligatoria'
|
|
'rows.*.causal_id.required' => 'La causale è obbligatoria'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ protected $recordFileService;
|
|
|
|
|
+
|
|
|
|
|
+ public function boot()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->recordFileService = app(RecordFileService::class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getSupplierProperty()
|
|
public function getSupplierProperty()
|
|
|
{
|
|
{
|
|
|
$ret = null;
|
|
$ret = null;
|
|
@@ -130,7 +138,8 @@ class RecordOUT extends Component
|
|
|
$this->payment_method_id = null;
|
|
$this->payment_method_id = null;
|
|
|
$this->date = date("Y-m-d");
|
|
$this->date = date("Y-m-d");
|
|
|
$this->data_pagamento = date("Y-m-d");
|
|
$this->data_pagamento = date("Y-m-d");
|
|
|
- //$this->attachment = null;
|
|
|
|
|
|
|
+ $this->attachment = null;
|
|
|
|
|
+ $this->attachment_old = null;
|
|
|
$this->numero_fattura = null;
|
|
$this->numero_fattura = null;
|
|
|
$this->type = 'OUT';
|
|
$this->type = 'OUT';
|
|
|
$this->commercial = 1;
|
|
$this->commercial = 1;
|
|
@@ -180,7 +189,6 @@ class RecordOUT extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
|
|
$this->vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function mount()
|
|
public function mount()
|
|
@@ -286,7 +294,7 @@ class RecordOUT extends Component
|
|
|
if (false) {
|
|
if (false) {
|
|
|
if ($this->hasFilter) {
|
|
if ($this->hasFilter) {
|
|
|
|
|
|
|
|
- $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method','is_paid');
|
|
|
|
|
|
|
+ $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method', 'is_paid');
|
|
|
if ($this->filterSupplier > 0) {
|
|
if ($this->filterSupplier > 0) {
|
|
|
$datas = $datas->where('supplier_id', $this->filterSupplier);
|
|
$datas = $datas->where('supplier_id', $this->filterSupplier);
|
|
|
}
|
|
}
|
|
@@ -366,14 +374,8 @@ class RecordOUT extends Component
|
|
|
public function store()
|
|
public function store()
|
|
|
{
|
|
{
|
|
|
$this->emit('refresh');
|
|
$this->emit('refresh');
|
|
|
- /*
|
|
|
|
|
- if ($this->attachment) {
|
|
|
|
|
- Log::info("Attachment: " . json_encode($this->attachment));
|
|
|
|
|
- $name = md5($this->attachment . microtime()) . '.' . $this->attachment->extension();
|
|
|
|
|
- $this->attachment->storeAs('public', $name);
|
|
|
|
|
- } */
|
|
|
|
|
-
|
|
|
|
|
- if($this->numero_fattura == null || $this->numero_fattura == '') {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ($this->numero_fattura == null || $this->numero_fattura == '') {
|
|
|
$this->numero_fattura = 'USC-' . date('Ymd');
|
|
$this->numero_fattura = 'USC-' . date('Ymd');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -394,8 +396,8 @@ class RecordOUT extends Component
|
|
|
'supplier_id' => $this->supplier_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
|
'date' => $this->date,
|
|
'date' => $this->date,
|
|
|
- 'data_pagamento' =>$this->data_pagamento,
|
|
|
|
|
- //'attachment' => $this->attachment,
|
|
|
|
|
|
|
+ 'data_pagamento' => $this->data_pagamento,
|
|
|
|
|
+ 'attachment' => '',
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
'amount' => $this->currencyToDouble($this->amount),
|
|
'amount' => $this->currencyToDouble($this->amount),
|
|
|
'commercial' => $this->commercial,
|
|
'commercial' => $this->commercial,
|
|
@@ -405,6 +407,19 @@ class RecordOUT extends Component
|
|
|
Log::info("Record data being inserted: " . json_encode($record));
|
|
Log::info("Record data being inserted: " . json_encode($record));
|
|
|
|
|
|
|
|
$this->dataId = $record->id;
|
|
$this->dataId = $record->id;
|
|
|
|
|
+ $this->recordFileService->createRecordFolders($record->id, 'OUT');
|
|
|
|
|
+ if ($this->attachment) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $attachmentPath = $this->recordFileService->uploadAttachment($this->attachment, $record->id, 'OUT');
|
|
|
|
|
+
|
|
|
|
|
+ $record->update(['attachment' => $attachmentPath]);
|
|
|
|
|
+
|
|
|
|
|
+ Log::info("Attachment uploaded and record updated: " . $attachmentPath);
|
|
|
|
|
+ } catch (\Exception $ex) {
|
|
|
|
|
+ Log::error("Error uploading attachment: " . $ex->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$tot = 0;
|
|
$tot = 0;
|
|
|
foreach ($this->rows as $row) {
|
|
foreach ($this->rows as $row) {
|
|
|
foreach ($row["when"] as $x => $y) {
|
|
foreach ($row["when"] as $x => $y) {
|
|
@@ -474,13 +489,14 @@ class RecordOUT extends Component
|
|
|
$this->data_pagamento = $record->data_pagamento;
|
|
$this->data_pagamento = $record->data_pagamento;
|
|
|
$this->type = $record->type;
|
|
$this->type = $record->type;
|
|
|
$this->numero_fattura = $record->numero_fattura;
|
|
$this->numero_fattura = $record->numero_fattura;
|
|
|
- //$attachment = $record->attachment;
|
|
|
|
|
|
|
+ $this->attachment_old = $record->attachment;
|
|
|
$this->commercial = $record->commercial;
|
|
$this->commercial = $record->commercial;
|
|
|
$this->dataId = $record->id;
|
|
$this->dataId = $record->id;
|
|
|
$this->update = true;
|
|
$this->update = true;
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
|
|
|
|
|
|
$this->rows = [];
|
|
$this->rows = [];
|
|
|
|
|
+ $this->recordFileService->createRecordFolders($record->id, 'OUT');
|
|
|
|
|
|
|
|
$recordRows = \App\Models\RecordRow::where('record_id', $this->dataId)->get();
|
|
$recordRows = \App\Models\RecordRow::where('record_id', $this->dataId)->get();
|
|
|
|
|
|
|
@@ -549,6 +565,21 @@ class RecordOUT extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+
|
|
|
|
|
+ $attachmentPath = $this->attachment_old;
|
|
|
|
|
+
|
|
|
|
|
+ if ($this->attachment) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if ($this->attachment_old) {
|
|
|
|
|
+ $this->recordFileService->deleteAttachment($this->attachment_old);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $attachmentPath = $this->recordFileService->uploadAttachment($this->attachment, $this->dataId, 'OUT');
|
|
|
|
|
+ } catch (\Exception $ex) {
|
|
|
|
|
+ session()->flash('error', 'Errore caricamento allegato: ' . $ex->getMessage());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
|
'member_id' => $this->member_id,
|
|
'member_id' => $this->member_id,
|
|
|
'supplier_id' => $this->supplier_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
@@ -559,7 +590,7 @@ class RecordOUT extends Component
|
|
|
'commercial' => $this->commercial,
|
|
'commercial' => $this->commercial,
|
|
|
'is_paid' => $is_paid,
|
|
'is_paid' => $is_paid,
|
|
|
'numero_fattura' => $this->numero_fattura,
|
|
'numero_fattura' => $this->numero_fattura,
|
|
|
- //'attachment' => $this->attachment,
|
|
|
|
|
|
|
+ 'attachment' => $attachmentPath,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
$tot = 0;
|
|
$tot = 0;
|
|
@@ -645,7 +676,12 @@ class RecordOUT extends Component
|
|
|
public function delete($id)
|
|
public function delete($id)
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
- \App\Models\Record::find($id)->delete();
|
|
|
|
|
|
|
+ $record = \App\Models\Record::find($id);
|
|
|
|
|
+ if ($record->attachment) {
|
|
|
|
|
+ $this->recordFileService->deleteAttachment($record->attachment);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $record->delete();
|
|
|
session()->flash('success', "Movimento eliminato");
|
|
session()->flash('success', "Movimento eliminato");
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
$this->emit('flash-error', 'Errore (' . $e->getMessage() . ')');
|
|
$this->emit('flash-error', 'Errore (' . $e->getMessage() . ')');
|
|
@@ -656,7 +692,13 @@ class RecordOUT extends Component
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
foreach ($this->multipleIds as $id) {
|
|
foreach ($this->multipleIds as $id) {
|
|
|
- \App\Models\Record::find($id)->delete();
|
|
|
|
|
|
|
+ $record = \App\Models\Record::find($id);
|
|
|
|
|
+
|
|
|
|
|
+ if ($record->attachment) {
|
|
|
|
|
+ $this->recordFileService->deleteAttachment($record->attachment);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $record->delete();
|
|
|
}
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
$this->emit('flash-error', 'Errore (' . $e->getMessage() . ')');
|
|
$this->emit('flash-error', 'Errore (' . $e->getMessage() . ')');
|
|
@@ -664,6 +706,25 @@ class RecordOUT extends Component
|
|
|
$this->multipleAction = '';
|
|
$this->multipleAction = '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getAttachmentUrl($filePath)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$filePath) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->recordFileService->getAttachmentUrl($filePath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Remove attachment file
|
|
|
|
|
+ */
|
|
|
|
|
+ public function removeAttachment()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->attachment_old) {
|
|
|
|
|
+ $this->recordFileService->deleteAttachment($this->attachment_old);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->attachment_old = '';
|
|
|
|
|
+ }
|
|
|
function currencyToDouble($val)
|
|
function currencyToDouble($val)
|
|
|
{
|
|
{
|
|
|
$x = str_replace("€", "", $val);
|
|
$x = str_replace("€", "", $val);
|
|
@@ -749,10 +810,10 @@ class RecordOUT extends Component
|
|
|
public function importReceipts()
|
|
public function importReceipts()
|
|
|
{
|
|
{
|
|
|
$this->validate([
|
|
$this->validate([
|
|
|
- //'receiptFiles.*' => 'required|mimes:xml|max:2048',
|
|
|
|
|
'selectedCausal' => 'required|exists:causals,id',
|
|
'selectedCausal' => 'required|exists:causals,id',
|
|
|
]);
|
|
]);
|
|
|
Log::info("Importazione ricevute: " . json_encode($this->receiptFiles));
|
|
Log::info("Importazione ricevute: " . json_encode($this->receiptFiles));
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
$importCount = 0;
|
|
$importCount = 0;
|
|
|
$updateCount = 0;
|
|
$updateCount = 0;
|
|
@@ -771,6 +832,7 @@ class RecordOUT extends Component
|
|
|
try {
|
|
try {
|
|
|
$fileName = $receiptFile->getClientOriginalName();
|
|
$fileName = $receiptFile->getClientOriginalName();
|
|
|
Log::info("Elaborazione file: " . $fileName);
|
|
Log::info("Elaborazione file: " . $fileName);
|
|
|
|
|
+
|
|
|
// Carica e analizza il file XML
|
|
// Carica e analizza il file XML
|
|
|
$xmlString = file_get_contents($receiptFile->getRealPath());
|
|
$xmlString = file_get_contents($receiptFile->getRealPath());
|
|
|
$xml = simplexml_load_string($xmlString);
|
|
$xml = simplexml_load_string($xmlString);
|
|
@@ -792,7 +854,7 @@ class RecordOUT extends Component
|
|
|
// Estrai i dati dalla fattura elettronica
|
|
// Estrai i dati dalla fattura elettronica
|
|
|
$fatturaData = $this->extractFatturaData($xml);
|
|
$fatturaData = $this->extractFatturaData($xml);
|
|
|
|
|
|
|
|
- // Trova o crea il fornitorez
|
|
|
|
|
|
|
+ // Trova o crea il fornitore
|
|
|
$supplier = $this->findOrCreateSupplier($fatturaData);
|
|
$supplier = $this->findOrCreateSupplier($fatturaData);
|
|
|
|
|
|
|
|
// Trova il metodo di pagamento
|
|
// Trova il metodo di pagamento
|
|
@@ -808,16 +870,33 @@ class RecordOUT extends Component
|
|
|
$record = $this->updateRecord($existingRecord, $paymentMethodId, $fatturaData);
|
|
$record = $this->updateRecord($existingRecord, $paymentMethodId, $fatturaData);
|
|
|
$isUpdate = true;
|
|
$isUpdate = true;
|
|
|
$updateCount++;
|
|
$updateCount++;
|
|
|
- $updatedFiles[] = $fileName; // Aggiungiamo il nome del file alla lista degli aggiornati
|
|
|
|
|
|
|
+ $updatedFiles[] = $fileName;
|
|
|
Log::info("Fattura aggiornata con successo: {$fatturaData['numeroFattura']}, Fornitore: {$supplier->name}");
|
|
Log::info("Fattura aggiornata con successo: {$fatturaData['numeroFattura']}, Fornitore: {$supplier->name}");
|
|
|
} else {
|
|
} else {
|
|
|
// Crea un nuovo record
|
|
// Crea un nuovo record
|
|
|
$record = $this->createRecord($supplier->id, $paymentMethodId, $fatturaData);
|
|
$record = $this->createRecord($supplier->id, $paymentMethodId, $fatturaData);
|
|
|
$importCount++;
|
|
$importCount++;
|
|
|
- $importedFiles[] = $fileName; // Aggiungiamo il nome del file alla lista degli importati
|
|
|
|
|
|
|
+ $importedFiles[] = $fileName;
|
|
|
Log::info("Fattura importata con successo: {$fatturaData['numeroFattura']}, Fornitore: {$supplier->name}");
|
|
Log::info("Fattura importata con successo: {$fatturaData['numeroFattura']}, Fornitore: {$supplier->name}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // ← NOW $record exists! Create folder structure for the record
|
|
|
|
|
+ $this->recordFileService->createRecordFolders($record->id, 'OUT');
|
|
|
|
|
+
|
|
|
|
|
+ // ← Store the XML file as an attachment to the record
|
|
|
|
|
+ try {
|
|
|
|
|
+ $xmlAttachmentPath = $this->recordFileService->uploadXmlReceipt($receiptFile, $record->id, 'OUT');
|
|
|
|
|
+
|
|
|
|
|
+ // ← Update the record with the XML attachment path (if you have a field for it)
|
|
|
|
|
+ // If you want to store XML separately from regular attachments, you could add a xml_attachment field
|
|
|
|
|
+ // Or if you want to overwrite the attachment field:
|
|
|
|
|
+ $record->update(['attachment' => $xmlAttachmentPath]);
|
|
|
|
|
+
|
|
|
|
|
+ Log::info("XML receipt stored as attachment: " . $xmlAttachmentPath);
|
|
|
|
|
+ } catch (\Exception $ex) {
|
|
|
|
|
+ Log::warning("Could not store XML as attachment: " . $ex->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Crea il record row
|
|
// Crea il record row
|
|
|
$this->createRecordRow($record->id, $fatturaData);
|
|
$this->createRecordRow($record->id, $fatturaData);
|
|
|
|
|
|
|
@@ -1104,7 +1183,7 @@ class RecordOUT extends Component
|
|
|
|
|
|
|
|
if ($record->data_pagamento != null) {
|
|
if ($record->data_pagamento != null) {
|
|
|
$record->is_paid = true;
|
|
$record->is_paid = true;
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
$record->is_paid = false;
|
|
$record->is_paid = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1439,7 +1518,8 @@ class RecordOUT extends Component
|
|
|
$this->reset(['receiptFiles']);
|
|
$this->reset(['receiptFiles']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getFriendlyErrorMessage($errorMessage) {
|
|
|
|
|
|
|
+ private function getFriendlyErrorMessage($errorMessage)
|
|
|
|
|
+ {
|
|
|
// Errore di parsing XML iniziale
|
|
// Errore di parsing XML iniziale
|
|
|
if (strpos($errorMessage, "simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found") !== false) {
|
|
if (strpos($errorMessage, "simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found") !== false) {
|
|
|
return "Il file non è in formato valido. Potrebbe essere danneggiato o in un formato diverso.";
|
|
return "Il file non è in formato valido. Potrebbe essere danneggiato o in un formato diverso.";
|
|
@@ -1456,8 +1536,10 @@ class RecordOUT extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Errori di struttura interna
|
|
// Errori di struttura interna
|
|
|
- if (strpos($errorMessage, "Undefined index") !== false ||
|
|
|
|
|
- strpos($errorMessage, "Trying to get property") !== false) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ strpos($errorMessage, "Undefined index") !== false ||
|
|
|
|
|
+ strpos($errorMessage, "Trying to get property") !== false
|
|
|
|
|
+ ) {
|
|
|
return "La fattura è incompleta o non contiene tutti i dati necessari.";
|
|
return "La fattura è incompleta o non contiene tutti i dati necessari.";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1468,14 +1550,11 @@ class RecordOUT extends Component
|
|
|
public function getVats()
|
|
public function getVats()
|
|
|
{
|
|
{
|
|
|
$vats = array();
|
|
$vats = array();
|
|
|
- foreach($this->rows as $r)
|
|
|
|
|
- {
|
|
|
|
|
- if ($r["amount"] != null && $r["amount"] != "" && $r["vat_id"] > 0)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->rows as $r) {
|
|
|
|
|
+ if ($r["amount"] != null && $r["amount"] != "" && $r["vat_id"] > 0) {
|
|
|
$vat = getVatValue($this->currencyToDouble($r["amount"]), $r["vat_id"]);
|
|
$vat = getVatValue($this->currencyToDouble($r["amount"]), $r["vat_id"]);
|
|
|
$vatName = "";
|
|
$vatName = "";
|
|
|
- foreach($this->vats as $v)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($this->vats as $v) {
|
|
|
if ($v->id == $r["vat_id"])
|
|
if ($v->id == $r["vat_id"])
|
|
|
$vatName = $v->name;
|
|
$vatName = $v->name;
|
|
|
}
|
|
}
|
|
@@ -1519,39 +1598,41 @@ class RecordOUT extends Component
|
|
|
return $newVat->id;
|
|
return $newVat->id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-public function viewData($id)
|
|
|
|
|
-{
|
|
|
|
|
- Log::info("Visualizzazione dati per ID: " . $id);
|
|
|
|
|
- try {
|
|
|
|
|
- $record = \App\Models\Record::with(['supplier', 'payment_method', 'rows.causal'])->findOrFail($id);
|
|
|
|
|
|
|
+ public function viewData($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log::info("Visualizzazione dati per ID: " . $id);
|
|
|
|
|
+ try {
|
|
|
|
|
+ $record = \App\Models\Record::with(['supplier', 'payment_method', 'rows.causal'])->findOrFail($id);
|
|
|
|
|
|
|
|
- if (!$record) {
|
|
|
|
|
- $this->emit('flash-error', 'Movimento non trovato');
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!$record) {
|
|
|
|
|
+ $this->emit('flash-error', 'Movimento non trovato');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $record->formatted_date = date("d/m/Y", strtotime($record->date));
|
|
|
|
|
- $record->formatted_data_pagamento = $record->data_pagamento ? date("d/m/Y", strtotime($record->data_pagamento)) : 'Non impostata';
|
|
|
|
|
- $record->supplier_name = $record->supplier ? $record->supplier->name : 'N/A';
|
|
|
|
|
- $record->payment_method_name = $record->payment_method ? $record->payment_method->name : 'N/A';
|
|
|
|
|
- $record->formatted_amount = formatPrice($record->amount);
|
|
|
|
|
- $record->payment_status = $record->is_paid ? 'Pagato' : 'Da Pagare';
|
|
|
|
|
-
|
|
|
|
|
- foreach ($record->rows as $row) {
|
|
|
|
|
- $row->causal_name = $row->causal ? $row->causal->getTree() : 'N/A';
|
|
|
|
|
- $row->formatted_imponibile = $row->imponibile ? formatPrice($row->imponibile) : 'N/A';
|
|
|
|
|
- $row->iva = $row->aliquota_iva ? formatPrice($row->aliquota_iva) : 'N/A';
|
|
|
|
|
- $row->formatted_imposta = $row->imposta ? formatPrice($row->imposta) : 'N/A';
|
|
|
|
|
- $row->formatted_amount = formatPrice($row->amount);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $record->formatted_date = date("d/m/Y", strtotime($record->date));
|
|
|
|
|
+ $record->formatted_data_pagamento = $record->data_pagamento ? date("d/m/Y", strtotime($record->data_pagamento)) : 'Non impostata';
|
|
|
|
|
+ $record->supplier_name = $record->supplier ? $record->supplier->name : 'N/A';
|
|
|
|
|
+ $record->payment_method_name = $record->payment_method ? $record->payment_method->name : 'N/A';
|
|
|
|
|
+ $record->formatted_amount = formatPrice($record->amount);
|
|
|
|
|
+ $record->payment_status = $record->is_paid ? 'Pagato' : 'Da Pagare';
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($record->rows as $row) {
|
|
|
|
|
+ $row->causal_name = $row->causal ? $row->causal->getTree() : 'N/A';
|
|
|
|
|
+ $row->formatted_imponibile = $row->imponibile ? formatPrice($row->imponibile) : 'N/A';
|
|
|
|
|
+ $row->iva = $row->aliquota_iva ? formatPrice($row->aliquota_iva) : 'N/A';
|
|
|
|
|
+ $row->formatted_imposta = $row->imposta ? formatPrice($row->imposta) : 'N/A';
|
|
|
|
|
+ $row->formatted_amount = formatPrice($row->amount);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Log::info("Emitting show-record-details event");
|
|
|
|
|
- $this->dispatchBrowserEvent('show-record-details', ['record' => $record]);
|
|
|
|
|
|
|
+ if ($record->attachment) {
|
|
|
|
|
+ $record->attachment_url = $this->getAttachmentUrl($record->attachment);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- Log::error("Errore nel caricamento dei dettagli: " . $e->getMessage());
|
|
|
|
|
- $this->emit('flash-error', 'Errore nel caricamento dei dettagli: ' . $e->getMessage());
|
|
|
|
|
|
|
+ Log::info("Emitting show-record-details event");
|
|
|
|
|
+ $this->dispatchBrowserEvent('show-record-details', ['record' => $record]);
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ Log::error("Errore nel caricamento dei dettagli: " . $e->getMessage());
|
|
|
|
|
+ $this->emit('flash-error', 'Errore nel caricamento dei dettagli: ' . $e->getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-}
|
|
|