mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-08 23:58:42 +01:00
Fix creazione nota di credito
This commit is contained in:
parent
3de31bbec4
commit
4c30f237fd
@ -28,11 +28,11 @@ if (empty($righe)) {
|
|||||||
$link = !empty($documento_finale) ? ROOTDIR.'/editor.php?id_module='.$final_module['id'].'&id_record='.$documento_finale->id : ROOTDIR.'/controller.php?id_module='.$final_module['id'];
|
$link = !empty($documento_finale) ? ROOTDIR.'/editor.php?id_module='.$final_module['id'].'&id_record='.$documento_finale->id : ROOTDIR.'/controller.php?id_module='.$final_module['id'];
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
<form action="'.$link.'" method="post">
|
<form action="'.$link.'" method="post">
|
||||||
<input type="hidden" name="op" value="'.$options['op'].'">
|
<input type="hidden" name="op" value="'.$options['op'].'">
|
||||||
<input type="hidden" name="backto" value="record-edit">
|
<input type="hidden" name="backto" value="record-edit">
|
||||||
|
|
||||||
<input type="hidden" name="id_documento" value="'.$documento->id.'">
|
<input type="hidden" name="id_documento" value="'.$documento->id.'">
|
||||||
<input type="hidden" name="type" value="'.$options['type'].'">';
|
<input type="hidden" name="type" value="'.$options['type'].'">';
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ if (!empty($options['create_document'])) {
|
|||||||
<h3 class="box-title">'.tr('Nuovo documento').'</h3>
|
<h3 class="box-title">'.tr('Nuovo documento').'</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<input type="hidden" name="create_document" value="on" />
|
<input type="hidden" name="create_document" value="on" />
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "date", "label": "'.tr('Data del documento').'", "name": "data", "required": 1, "value": "-now-" ]}
|
{[ "type": "date", "label": "'.tr('Data del documento').'", "name": "data", "required": 1, "value": "-now-" ]}
|
||||||
</div>';
|
</div>';
|
||||||
@ -65,7 +65,7 @@ if (!empty($options['create_document'])) {
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{[ "type": "select", "label": "'.tr('Ritenuta contributi').'", "name": "id_ritenuta_contributi", "value": "$id_ritenuta_contributi$", "values": "query=SELECT * FROM co_ritenuta_contributi" ]}
|
{[ "type": "select", "label": "'.tr('Ritenuta contributi').'", "name": "id_ritenuta_contributi", "value": "$id_ritenuta_contributi$", "values": "query=SELECT * FROM co_ritenuta_contributi" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.prepare($final_module['id']).' ORDER BY name", "value": "'.$id_segment.'" ]}
|
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.prepare($final_module['id']).' ORDER BY name", "value": "'.$id_segment.'" ]}
|
||||||
</div>';
|
</div>';
|
||||||
@ -161,7 +161,7 @@ if (in_array($final_module['name'], ['Fatture di vendita', 'Fatture di acquisto'
|
|||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">'.tr('Righe da importare').'</h3>
|
<h3 class="box-title">'.tr('Righe da importare').'</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="box-body table table-striped table-hover table-condensed">
|
<table class="box-body table table-striped table-hover table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
@ -213,7 +213,7 @@ foreach ($righe as $i => $r) {
|
|||||||
echo '
|
echo '
|
||||||
<td>
|
<td>
|
||||||
<big id="subtotale_'.$i.'">'.moneyFormat($r->totale).'</big><br/>
|
<big id="subtotale_'.$i.'">'.moneyFormat($r->totale).'</big><br/>
|
||||||
|
|
||||||
<small style="color:#777;" id="subtotaledettagli_'.$i.'">'.Translator::numberToLocale($r->totale_imponibile).' + '.Translator::numberToLocale($r->iva).'</small>
|
<small style="color:#777;" id="subtotaledettagli_'.$i.'">'.Translator::numberToLocale($r->totale_imponibile).' + '.Translator::numberToLocale($r->iva).'</small>
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
|
@ -4,18 +4,21 @@ namespace Common\Components;
|
|||||||
|
|
||||||
trait MorphTrait
|
trait MorphTrait
|
||||||
{
|
{
|
||||||
|
protected $original_model = null;
|
||||||
|
|
||||||
public function hasOriginal()
|
public function hasOriginal()
|
||||||
{
|
{
|
||||||
return !empty($this->original_type) && !empty($this->getOriginal());
|
return !empty($this->original_type) && !empty($this->getOriginal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function original()
|
|
||||||
{
|
|
||||||
return $this->morphedByMany($this->original_type, 'original', $this->table, 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOriginal()
|
public function getOriginal()
|
||||||
{
|
{
|
||||||
return $this->original()->first();
|
if(!isset($this->original_model) && !empty($this->original_type)) {
|
||||||
|
$class = $this->original_type;
|
||||||
|
|
||||||
|
$this->original_model = $class::find($this->original_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->original_model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,6 +636,9 @@ switch (post('op')) {
|
|||||||
|
|
||||||
// Nota di credito
|
// Nota di credito
|
||||||
case 'nota_credito':
|
case 'nota_credito':
|
||||||
|
$id_documento = post('id_documento');
|
||||||
|
$fattura = Fattura::find($id_documento);
|
||||||
|
|
||||||
$id_segment = post('id_segment');
|
$id_segment = post('id_segment');
|
||||||
$data = post('data');
|
$data = post('data');
|
||||||
|
|
||||||
|
@ -2,31 +2,18 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
$module = Modules::get($id_module);
|
use Modules\Fatture\Fattura;
|
||||||
|
|
||||||
|
$documento = Fattura::find($id_record);
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
|
'type' => 'nota_credito',
|
||||||
'op' => 'nota_credito',
|
'op' => 'nota_credito',
|
||||||
'id_importazione' => 'id_documento',
|
'module' => 'Fatture di vendita',
|
||||||
'final_module' => $module['name'],
|
'documento' => $documento,
|
||||||
'original_module' => $module['name'],
|
|
||||||
'sql' => [
|
|
||||||
'table' => 'co_documenti',
|
|
||||||
'rows' => 'co_righe_documenti',
|
|
||||||
'id_rows' => 'iddocumento',
|
|
||||||
],
|
|
||||||
'serials' => [
|
|
||||||
'id_riga' => 'id_riga_documento',
|
|
||||||
'condition' => '(1 = 2)',
|
|
||||||
],
|
|
||||||
'button' => tr('Aggiungi'),
|
'button' => tr('Aggiungi'),
|
||||||
'dir' => $dir,
|
|
||||||
'create_document' => true,
|
'create_document' => true,
|
||||||
'allow-empty' => true,
|
'allow-empty' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = [
|
echo App::load('importa.php', [], $options, true);
|
||||||
'id_record' => $id_record,
|
|
||||||
'id_documento' => get('iddocumento'),
|
|
||||||
];
|
|
||||||
|
|
||||||
echo App::load('importa.php', $result, $options, true);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user