1
0
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:
Thomas Zilio 2019-12-13 15:56:52 +01:00
parent 3de31bbec4
commit 4c30f237fd
4 changed files with 26 additions and 33 deletions

View File

@ -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;
} }
} }

View File

@ -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');

View File

@ -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);