<?php
namespace App\AI\Contexts\ReportsData; class SupplierInvoiceRows extends \App\AI\Contexts\ReportsData\ReportsDataAbstract { public function getColumns($dbTable=null): array { $columns['rd_supplierInvoiceRows'] = [ ['name'=>'suppInvRow.id', 'type'=>'integer', 'sort_by'=>true, 'minimum'=> 1000000000, 'maximum'=> 9999999999, ], ['name'=>'suppInvRow.idInvoice', 'type'=>'integer', 'description'=>'Reference to the related invoice', 'minimum'=> 1000000000, 'maximum'=> 9999999999, ], ['name'=>'suppInvRow.serviceCode', 'type'=>'string', 'enum'=>array_keys(\App\Config\Services_Basic::getInstance()->getListLinearSimple()), 'description'=>'Service code'], ['name'=>'suppInvRow.description', 'type'=>'string', 'description'=>'Description of the supplier invoice row'], ['name'=>'suppInvRow.rowType', 'type'=>'string', 'enum'=>['price', 'advance', 'discount', 'tax', 'penalty'], 'operators'=>['eq', 'neq'], 'description'=>'Supplier invoice row type'], ['name'=>'suppInvRow.externalReservationId', 'type'=>'string'], ['name'=>'suppInvRow.externalReservationDate', 'type'=>'string'], ['name'=>'suppInvRow.confirmationNumber', 'type'=>'string'], ['name'=>'suppInvRow.idPassenger', 'type'=>'integer', 'description'=>'Reference to the related passenger'], ['name'=>'suppInvRow.checkIn', 'type'=>'string', 'format'=>'date' ], ['name'=>'suppInvRow.checkOut', 'type'=>'string', 'format'=>'date' ], ['name'=>'suppInvRow.contractNumber', 'type'=>'string'], ['name'=>'suppInvRow.ticketNo', 'type'=>'string'], ['name'=>'suppInvRow.idSupplierProduct', 'type'=>'integer', 'description'=>'Reference to the related supplier product'], ['name'=>'suppInvRow.countryCode', 'type'=>'string'], ['name'=>'suppInvRow.cityId', 'type'=>'integer'], ['name'=>'suppInvRow.orderCode', 'type'=>'string'], ['name'=>'suppInvRow.orderNumber', 'type'=>'string'], ['name'=>'suppInvRow.idOrder', 'type'=>'integer', 'description'=>'Reference to the related order', 'minimum'=> 1000000000, 'maximum'=> 9999999999, ], ['name'=>'suppInvRow.idService', 'type'=>'integer', 'description'=>'Reference to the related service', 'minimum'=> 1000000000, 'maximum'=> 9999999999, ], ['name'=>'suppInvRow.measureUnit', 'type'=>'string'], ['name'=>'suppInvRow.quantity', 'type'=>'number'], ['name'=>'suppInvRow.rowUnitValue', 'type'=>'number'], ['name'=>'suppInvRow.rowValue', 'type'=>'number'], ['name'=>'suppInvRow.rowVat', 'type'=>'number'], ['name'=>'suppInvRow.vatPercent', 'type'=>'number'], ['name'=>'suppInvRow.vatText', 'type'=>'string'], ['name'=>'suppInvRow.idBalance', 'type'=>'integer', 'description'=>'Reference to the related balance ID', 'minimum'=> 1000000000, 'maximum'=> 9999999999, ], ]; return $dbTable ? $columns[$dbTable] : $columns; } protected function getLinkedColumns($dbTable=null): array { $linkedColumns['rd_supplierInvoiceRows'] = [ ['suppInvRow.id', 'suppInvRow.rowType', 'suppInvRow.confirmationNumber', 'suppInvRow.ticketNo', ], ['suppInvRow.idInvoice', 'suppInv.invoiceNumber', 'suppInv.invoiceDate', ], ['suppInvRow.idService', 'suppInvRow.serviceCode', 'serv.serviceName', 'suppInvRow.idOrder', 'suppInvRow.orderCode', 'suppInvRow.orderNumber', ], ]; return $dbTable ? $linkedColumns[$dbTable] : $linkedColumns; } protected function checkPermission_run_rd_supplierInvoiceRows_analytics() : bool { return true; } protected function generateFunctionObject_run_rd_supplierInvoiceRows_analytics() : \App\AI\Api\ChatGpt\Responses\ToolFunction { return parent::generateAnalyticsFunctionObject('rd_supplierInvoiceRows'); } protected function executeFunction_run_rd_supplierInvoiceRows_analytics(string $arguments) : array { $args = json_decode($arguments, 1); $listObj = new \App\ReportsData\EntityList\SupplierInvoiceRows(); $this->prepareReportsDataEntitylist('rd_supplierInvoiceRows', $listObj, $args); $results = $listObj->exportRecords(); return $results; } protected function developerMessage_run_rd_supplierInvoiceRows_analytics(string $arguments) : string { return "Allow the user to see the `Supplier invoices` section by giving him a clickable link to the section: " . \Engine\Mvc\Dispatcher::getInstance()->getAppUrl('Modules/Invoices/SupplierInvoices', 'index'); } } 