Fix codice aliquota iva e validazione

This commit is contained in:
MatteoPistorello 2022-02-09 14:32:03 +01:00
parent c06e8f725e
commit 6aba52df8d
4 changed files with 52 additions and 3 deletions

View File

@ -19,6 +19,10 @@
include_once __DIR__.'/../../core.php'; include_once __DIR__.'/../../core.php';
use Modules\Iva\Aliquota;
$codice = Aliquota::max('id')+1;
?><form action="" method="post" id="add-form"> ?><form action="" method="post" id="add-form">
<input type="hidden" name="op" value="add"> <input type="hidden" name="op" value="add">
<input type="hidden" name="backto" value="record-edit"> <input type="hidden" name="backto" value="record-edit">
@ -29,7 +33,7 @@ include_once __DIR__.'/../../core.php';
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
{[ "type": "number", "label": "<?php echo tr('Codice'); ?>", "name": "codice", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3 ]} {[ "type": "number", "label": "<?php echo tr('Codice'); ?>", "name": "codice", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3, "value": "<?php echo $codice; ?>", "validation": "codice" ]}
</div> </div>
</div> </div>

View File

@ -79,7 +79,7 @@ if ($res) {
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
{[ "type": "number", "label": "<?php echo tr('Codice'); ?>", "name": "codice", "value": "$codice$", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3, "extra": "<?php echo $attr; ?>" ]} {[ "type": "number", "label": "<?php echo tr('Codice'); ?>", "name": "codice", "value": "$codice$", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3, "extra": "<?php echo $attr; ?>", "validation": "codice" ]}
</div> </div>
<div class="col-md-4"> <div class="col-md-4">

View File

@ -0,0 +1,42 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
use Modules\Iva\Aliquota;
$name = filter('name');
$value = filter('value');
switch ($name) {
case 'codice':
$disponibile = Aliquota::where([
['codice', $value],
['id', '<>', $id_record],
])->count() == 0;
$message = $disponibile ? tr('Il codice è disponbile') : tr('Il codice è già utilizzato in un altra aliquota');
$response = [
'result' => $disponibile,
'message' => $message,
];
break;
}

View File

@ -1,2 +1,5 @@
-- Aggiunta dicitura fissa nei segmenti fiscali -- Aggiunta dicitura fissa nei segmenti fiscali
ALTER TABLE `zz_segments` ADD `dicitura_fissa` TEXT NOT NULL AFTER `note`; ALTER TABLE `zz_segments` ADD `dicitura_fissa` TEXT NOT NULL AFTER `note`;
-- Fix codice iva
UPDATE `co_iva` SET `codice`=`id` WHERE `codice` IS NULL;