mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-01 16:36:45 +01:00
Miglioramenti gestione classi
This commit is contained in:
parent
40d1b95ca9
commit
9f46b0935d
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'modules/anagrafiche' => 'Modules\\Anagrafiche\\',
|
||||
'modules/articoli' => 'Modules\\Articoli\\',
|
||||
'modules/fatture' => 'Modules\\Fatture\\',
|
||||
'modules/interventi' => 'Modules\\Interventi\\',
|
||||
'plugins/exportPA' => 'Plugins\\ExportPA\\',
|
||||
'plugins/importPA' => 'Plugins\\ImportPA\\',
|
||||
'modules/anagrafiche' => 'Modules\Anagrafiche',
|
||||
'modules/articoli' => 'Modules\Articoli',
|
||||
'modules/fatture' => 'Modules\Fatture',
|
||||
'modules/interventi' => 'Modules\Interventi',
|
||||
'plugins/exportPA' => 'Plugins\ExportPA',
|
||||
'plugins/importPA' => 'Plugins\ImportPA',
|
||||
];
|
||||
|
4
core.php
4
core.php
@ -26,8 +26,8 @@ $loader = require_once __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$namespaces = require_once __DIR__.'/config/namespaces.php';
|
||||
foreach ($namespaces as $path => $namespace) {
|
||||
$loader->addPsr4($namespace, $path.'/custom/src');
|
||||
$loader->addPsr4($namespace, $path.'/src');
|
||||
$loader->addPsr4($namespace.'\\', $path.'/custom/src');
|
||||
$loader->addPsr4($namespace.'\\', $path.'/src');
|
||||
}
|
||||
|
||||
// Individuazione dei percorsi di base
|
||||
|
@ -1,123 +1,71 @@
|
||||
<?php
|
||||
|
||||
$show_idrivalsainps = 0;
|
||||
$show_idritenutaacconto = 0;
|
||||
$show_calcolo_ritenutaacconto = 0;
|
||||
$idrivalsainps = 0;
|
||||
$idritenutaacconto = 0;
|
||||
$calcolo_ritenutaacconto = 0;
|
||||
|
||||
// Informazioni aggiuntive per Fatture
|
||||
if ($module['name'] == 'Fatture di acquisto' || $module['name'] == 'Fatture di vendita') {
|
||||
// Percentuale rivalsa INPS e Percentuale ritenuta d'acconto
|
||||
if ($options['action'] == 'edit') {
|
||||
if ($options['dir'] == 'uscita') {
|
||||
//Luca S. questi campi non dovrebbero essere impostati a 1 di default, ma solo se il fornitore ha effettivamente rivalsa inps o ritenuta
|
||||
$show_idrivalsainps = 1;
|
||||
$show_idritenutaacconto = 1;
|
||||
$show_calcolo_ritenutaacconto = 1;
|
||||
} elseif (($options['dir'] == 'entrata' && (setting('Percentuale rivalsa INPS') != '' || setting("Percentuale ritenuta d'acconto") != ''))) {
|
||||
if (setting('Percentuale rivalsa INPS') != '') {
|
||||
$show_idrivalsainps = 1;
|
||||
} else {
|
||||
$show_idrivalsainps = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_idritenutaacconto = 1;
|
||||
} else {
|
||||
$show_idritenutaacconto = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_calcolo_ritenutaacconto = 1;
|
||||
} else {
|
||||
$show_calcolo_ritenutaacconto = 0;
|
||||
}
|
||||
}
|
||||
if ($module['name'] != 'Fatture di acquisto' && $module['name'] != 'Fatture di vendita') {
|
||||
return;
|
||||
}
|
||||
|
||||
$idrivalsainps = $result['idrivalsainps'];
|
||||
$idritenutaacconto = $result['idritenutaacconto'];
|
||||
$calcolo_ritenutaacconto = $result['calcolo_ritenutaacconto'];
|
||||
} elseif ($options['action'] == 'add') {
|
||||
if ($options['dir'] == 'uscita') {
|
||||
$show_idrivalsainps = 1;
|
||||
$show_idritenutaacconto = 1;
|
||||
$show_calcolo_ritenutaacconto = 1;
|
||||
if ($options['dir'] == 'entrata') {
|
||||
$show_rivalsa_inps = (setting('Percentuale rivalsa INPS') != '');
|
||||
$show_ritenuta_acconto = (setting("Percentuale ritenuta d'acconto") != '');
|
||||
|
||||
// Luca S. questi campi non dovrebbero essere definiti all'interno della scheda fornitore?
|
||||
$idrivalsainps = '';
|
||||
$idritenutaacconto = '';
|
||||
// questo campo non andrebbe letto da impostazioni
|
||||
$calcolo_ritenutaacconto = setting("Metodologia calcolo ritenuta d'acconto predefinito");
|
||||
} elseif ($options['dir'] == 'entrata' && $options['op'] == 'addriga' && (setting('Percentuale rivalsa INPS') != '' || setting("Percentuale ritenuta d'acconto") != '')) {
|
||||
if (setting('Percentuale rivalsa INPS') != '') {
|
||||
$show_idrivalsainps = 1;
|
||||
} else {
|
||||
$show_idrivalsainps = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_idritenutaacconto = 1;
|
||||
} else {
|
||||
$show_idritenutaacconto = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_calcolo_ritenutaacconto = 1;
|
||||
} else {
|
||||
$show_calcolo_ritenutaacconto = 0;
|
||||
}
|
||||
$show_ritenuta_acconto |= !empty($result['id_ritenuta_acconto_predefined']);
|
||||
} else {
|
||||
$show_rivalsa_inps = 1;
|
||||
$show_ritenuta_acconto = 1;
|
||||
}
|
||||
|
||||
$idrivalsainps = setting('Percentuale rivalsa INPS');
|
||||
$idritenutaacconto = $result['id_ritenuta_acconto'] ?: setting("Percentuale ritenuta d'acconto");
|
||||
$calcolo_ritenutaacconto = setting("Metodologia calcolo ritenuta d'acconto predefinito");
|
||||
}
|
||||
// Caso particolare per aggiunta articolo in fatture di vendita
|
||||
elseif ($options['dir'] == 'entrata' && $options['op'] == 'addarticolo' && (setting('Percentuale rivalsa INPS') != '' || setting("Percentuale ritenuta d'acconto") != '')) {
|
||||
if (setting('Percentuale rivalsa INPS') != '') {
|
||||
$show_idrivalsainps = 1;
|
||||
} else {
|
||||
$show_idrivalsainps = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_idritenutaacconto = 1;
|
||||
} else {
|
||||
$show_idritenutaacconto = 0;
|
||||
}
|
||||
if (setting("Percentuale ritenuta d'acconto") != '') {
|
||||
$show_calcolo_ritenutaacconto = 1;
|
||||
} else {
|
||||
$show_calcolo_ritenutaacconto = 0;
|
||||
}
|
||||
$show_calcolo_ritenuta_acconto = $show_ritenuta_acconto;
|
||||
|
||||
$idrivalsainps = '';
|
||||
$idritenutaacconto = setting("Percentuale ritenuta d'acconto");
|
||||
$calcolo_ritenutaacconto = setting("Metodologia calcolo ritenuta d'acconto predefinito");
|
||||
}
|
||||
// Percentuale rivalsa INPS e Percentuale ritenuta d'acconto
|
||||
if ($options['action'] == 'edit') {
|
||||
$id_rivalsa_inps = $result['idrivalsainps'];
|
||||
$id_ritenuta_acconto = $result['idritenutaacconto'];
|
||||
$calcolo_ritenuta_acconto = $result['calcolo_ritenutaacconto'];
|
||||
} elseif ($options['action'] == 'add') {
|
||||
// Fattura di acquisto
|
||||
if ($options['dir'] == 'uscita') {
|
||||
// TODO: Luca S. questi campi non dovrebbero essere definiti all'interno della scheda fornitore?
|
||||
$id_rivalsa_inps = '';
|
||||
$id_ritenuta_acconto = '';
|
||||
// questo campo non andrebbe letto da impostazioni
|
||||
$calcolo_ritenuta_acconto = setting("Metodologia calcolo ritenuta d'acconto predefinito");
|
||||
}
|
||||
// Fattura di vendita
|
||||
elseif ($options['dir'] == 'entrata') {
|
||||
// Caso particolare per aggiunta articolo
|
||||
$id_rivalsa_inps = ($options['op'] == 'addarticolo') ? '':setting('Percentuale rivalsa INPS');
|
||||
|
||||
if ($show_idrivalsainps == 1 || $show_idritenutaacconto == 1) {
|
||||
$id_ritenuta_acconto = $result['id_ritenuta_acconto_predefined'] ?: setting("Percentuale ritenuta d'acconto");
|
||||
$calcolo_ritenuta_acconto = setting("Metodologia calcolo ritenuta d'acconto predefinito");
|
||||
}
|
||||
}
|
||||
|
||||
if ($show_rivalsa_inps == 1 || $show_ritenuta_acconto == 1) {
|
||||
echo '
|
||||
<div class="row">';
|
||||
|
||||
// Rivalsa INPS
|
||||
if ($show_idrivalsainps == 1) {
|
||||
if ($show_rivalsa_inps == 1) {
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Rivalsa INPS').'", "name": "idrivalsainps", "value": "'.$idrivalsainps.'", "values": "query=SELECT * FROM co_rivalsainps" ]}
|
||||
{[ "type": "select", "label": "'.tr('Rivalsa INPS').'", "name": "idrivalsainps", "value": "'.$id_rivalsa_inps.'", "values": "query=SELECT * FROM co_rivalsainps" ]}
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Ritenuta d'acconto
|
||||
if ($show_idritenutaacconto == 1) {
|
||||
if ($show_ritenuta_acconto == 1) {
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr("Ritenuta d'acconto").'", "name": "idritenutaacconto", "value": "'.$idritenutaacconto.'", "values": "query=SELECT * FROM co_ritenutaacconto" ]}
|
||||
{[ "type": "select", "label": "'.tr("Ritenuta d'acconto").'", "name": "idritenutaacconto", "value": "'.$id_ritenuta_acconto.'", "values": "query=SELECT * FROM co_ritenutaacconto" ]}
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Calcola ritenuta d'acconto su
|
||||
if ($show_calcolo_ritenutaacconto == 1) {
|
||||
if ($show_calcolo_ritenuta_acconto == 1) {
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr("Calcola ritenuta d'acconto su").'", "name": "calcolo_ritenutaacconto", "value": "'.((empty($calcolo_ritenutaacconto)) ? 'Imponibile' : $calcolo_ritenutaacconto).'", "values": "list=\"Imponibile\":\"Imponibile\", \"Imponibile + rivalsa inps\":\"Imponibile + rivalsa inps\"", "required": "1" ]}
|
||||
{[ "type": "select", "label": "'.tr("Calcola ritenuta d'acconto su").'", "name": "calcolo_ritenutaacconto", "value": "'.((empty($calcolo_ritenuta_acconto)) ? 'Imponibile' : $calcolo_ritenuta_acconto).'", "values": "list=\"Imponibile\":\"Imponibile\", \"Imponibile + rivalsa inps\":\"Imponibile + rivalsa inps\"", "required": "1" ]}
|
||||
</div>';
|
||||
}
|
||||
|
||||
@ -132,4 +80,3 @@ if ($module['name'] == 'Fatture di acquisto' || $module['name'] == 'Fatture di v
|
||||
{[ "type": "select", "label": "'.tr('Conto').'", "name": "idconto", "required": 1, "value": "'.$result['idconto'].'", "ajax-source": "'.$options['conti'].'" ]}
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ $iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendit
|
||||
$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
||||
|
||||
// Leggo la ritenuta d'acconto predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$ritenuta_acconto = $dbo->fetchArray('SELECT id_ritenuta_acconto_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS id_ritenuta_acconto FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$result['id_ritenuta_acconto'] = $ritenuta_acconto[0]['id_ritenuta_acconto'] ?: setting("Percentuale ritenuta d'acconto");
|
||||
$ritenuta_acconto = $dbo->fetchOne('SELECT id_ritenuta_acconto_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS id_ritenuta_acconto FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$result['id_ritenuta_acconto_predefined'] = $ritenuta_acconto['id_ritenuta_acconto'];
|
||||
|
||||
// Sconto unitario
|
||||
$rss = $dbo->fetchArray('SELECT prc_guadagno FROM mg_listini WHERE id=(SELECT idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).')');
|
||||
|
@ -42,10 +42,10 @@ class Articolo extends Article
|
||||
$data = $fattura->data;
|
||||
|
||||
$carico = ($tipo->dir == 'entrata') ? tr('Ripristino articolo da _TYPE_ _NUM_') : tr('Carico magazzino da _TYPE_ numero _NUM_');
|
||||
$scarico = ($tipo->dir == 'uscita') ? tr('Rimozione articolo da _TYPE_ _NUM_') : tr('Scarico magazzino per _TYPE_ numero _NUM_');
|
||||
$scarico = ($tipo->dir == 'entrata') ? tr('Scarico magazzino per _TYPE_ numero _NUM_') : tr('Rimozione articolo da _TYPE_ _NUM_') ;
|
||||
|
||||
$movimento = ($qta > 0) ? $carico : $scarico;
|
||||
$qta = ($tipo->dir == 'uscita') ? -$qta : $qta;
|
||||
$movimento = ($qta < 0) ? $carico : $scarico;
|
||||
|
||||
$movimento = replace($movimento, [
|
||||
'_TYPE_' => $tipo->descrizione,
|
||||
|
@ -49,4 +49,9 @@ switch (filter('op')) {
|
||||
|
||||
redirect(ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$id_record);
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
include __DIR__.'/rows.php';
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ echo '
|
||||
data = JSON.parse(data);
|
||||
|
||||
if (!data.already) {
|
||||
launch_modal("'.tr('Righe fattura').'", globals.rootdir + "/plugins/importPA/rows.php?id_module=" + globals.id_module + "&id_plugin=" + '.$id_plugin.' + "&id=" + data.id + "&filename=" + data.filename + "&id_segment=" + data.id_segment)
|
||||
launch_modal("'.tr('Righe fattura').'", globals.rootdir + "/actions.php?id_module=" + globals.id_module + "&id_plugin=" + '.$id_plugin.' + "&op=list&id=" + data.id + "&filename=" + data.filename + "&id_segment=" + data.id_segment);
|
||||
} else {
|
||||
swal({
|
||||
title: "'.tr('Fattura già importata!').'",
|
||||
|
@ -6,12 +6,14 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
abstract class Description extends Model
|
||||
{
|
||||
protected static function boot()
|
||||
protected static function boot($bypass)
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::addGlobalScope('descriptions', function (Builder $builder) {
|
||||
$builder->where('is_descrizione', '=', 0);
|
||||
});
|
||||
if (!$bypass) {
|
||||
static::addGlobalScope('descriptions', function (Builder $builder) {
|
||||
$builder->where('is_descrizione', '=', 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ abstract class Article extends Row
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
parent::boot(true);
|
||||
|
||||
static::addGlobalScope('articles', function (Builder $builder) {
|
||||
$builder->whereNotNull('idarticolo')->where('idarticolo', '<>', 0);
|
||||
|
@ -4,15 +4,17 @@ namespace Base;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
abstract class Row extends Model
|
||||
abstract class Row extends Description
|
||||
{
|
||||
protected static function boot()
|
||||
protected static function boot($bypass)
|
||||
{
|
||||
parent::boot();
|
||||
parent::boot($bypass);
|
||||
|
||||
static::addGlobalScope('rows', function (Builder $builder) {
|
||||
$builder->whereNull('idarticolo')->where('idarticolo', '=', 0);
|
||||
});
|
||||
if (!$bypass) {
|
||||
static::addGlobalScope('rows', function (Builder $builder) {
|
||||
$builder->whereNull('idarticolo')->where('idarticolo', '=', 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -96,12 +98,10 @@ abstract class Row extends Model
|
||||
$this->attributes['sconto'] = $this->sconto;
|
||||
}
|
||||
|
||||
public function setIdIvaAttribute($value)
|
||||
protected function fixIva()
|
||||
{
|
||||
$this->attributes['idiva'] = $value;
|
||||
|
||||
$iva = database()->fetchOne('SELECT * FROM co_iva WHERE id = :id_iva', [
|
||||
':id_iva' => $value,
|
||||
':id_iva' => $this->idiva,
|
||||
]);
|
||||
$descrizione = $iva['descrizione'];
|
||||
|
||||
@ -114,6 +114,15 @@ abstract class Row extends Model
|
||||
if (!isset($this->prezzo_vendita)) {
|
||||
$this->iva_indetraibile = $valore / 100 * $iva['indetraibile'];
|
||||
}
|
||||
|
||||
$this->attributes['sconto'] = $this->sconto;
|
||||
}
|
||||
|
||||
public function setIdIvaAttribute($value)
|
||||
{
|
||||
$this->attributes['idiva'] = $value;
|
||||
|
||||
$this->fixIva();
|
||||
}
|
||||
|
||||
public function getPrezzoAttribute()
|
||||
@ -126,5 +135,7 @@ abstract class Row extends Model
|
||||
$this->qta = $qta;
|
||||
|
||||
$this->subtotale = $prezzo * $qta;
|
||||
|
||||
$this->fixIva();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user