Finish Gramm_ResiConsegna_CampoRiferimentiDocumento
This commit is contained in:
@@ -257,6 +257,7 @@ if (!is_null($ordineLav["note"])) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($scarichiOrdine as $k => $scar) {
|
||||
if (trim($scar["cod_mart"]) === trim($codMart)) {
|
||||
$scarichiOrdine[$k]["rendered"] = true;
|
||||
|
||||
@@ -85,9 +85,11 @@ class ResiConsegna {
|
||||
|
||||
public static function explode_note($note) {
|
||||
$ret = array(null, null);
|
||||
|
||||
if (!is_null($note)) {
|
||||
$sep1 = self::get_sepNumPratVett1() . self::get_sepNumPratVett2();
|
||||
$sep2 = self::get_sepNumPratVett2();
|
||||
|
||||
if (Utility\Str::contains($note, $sep1)) { // contiene entrambi i campi
|
||||
$ret = explode($sep1, $note);
|
||||
} else if (Utility\Str::startsWith($note, $sep2)) { // contiene solo num pratica
|
||||
@@ -96,14 +98,16 @@ class ResiConsegna {
|
||||
$ret = array($note, null);
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function get_docRows($key) {
|
||||
$Ret = self::isValid_document($key);
|
||||
if ($Ret->is_OK()) {
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile("list-docRows")
|
||||
$ret = self::isValid_document($key);
|
||||
|
||||
if ($ret->is_OK()) {
|
||||
$query = new Query;
|
||||
$query->importSqlFile("list-docRows")
|
||||
->setDateVar("data_doc", $key["data_doc"])
|
||||
->setVar("num_doc", $key["num_doc"])
|
||||
->setVar("ser_doc", $key["ser_doc"])
|
||||
@@ -111,30 +115,30 @@ class ResiConsegna {
|
||||
->setVar("cod_dtip", $key["cod_dtip"]);
|
||||
|
||||
$arr_causali = self::get_causali();
|
||||
|
||||
foreach ($arr_causali as $causale) {
|
||||
$Query->setVar(strtoupper("TIPODOC_{$causale}"), self::get_tipoDoc($causale));
|
||||
$query->setVar(strtoupper("TIPODOC_{$causale}"), self::get_tipoDoc($causale));
|
||||
}
|
||||
$Ret = $Query->toRet()->date2ts()->execute(); //echo $Query;exit;
|
||||
|
||||
$ret = $query->toRet()->date2ts()->execute();;
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function check_addebitoVettore($documento) {
|
||||
$is_enabled = true;
|
||||
$message = null;
|
||||
|
||||
if (is_null($documento["cod_anag_vvet"])) {
|
||||
$is_enabled = false;
|
||||
$message = "Il vettore non risulta associato ad alcuna anagrafica";
|
||||
} else {
|
||||
$tipoAnagDocAddForn = self::get_tipoAnagDocAddForn();
|
||||
|
||||
if (!(($tipoAnagDocAddForn == "C" && $documento["is_clie"]) || ($tipoAnagDocAddForn == "F" && $documento["is_forn"]))) {
|
||||
$is_enabled = false;
|
||||
$message = "Il documento di addebito al vettore <b>" . self::get_tipoDocAddebitoVettore() . "</b> non è compatibile con il vettore";
|
||||
}
|
||||
}
|
||||
|
||||
$Ret = new Ret;
|
||||
return $Ret->set_boolean($is_enabled)->set_string($message);
|
||||
}
|
||||
@@ -223,10 +227,14 @@ class ResiConsegna {
|
||||
$keyReso = array_pick($documento, "data_doc", "num_doc");
|
||||
$keyReso["cod_dtip"] = self::get_tipoDoc($causale);
|
||||
$keyReso["cod_anag"] = !self::is_causaleAddebitoVettore($causale) ? $documento["cod_anag"] : $documento["cod_anag_vvet"];
|
||||
|
||||
$Query = new Query;
|
||||
$Query->select("serie")->from("dtb_tipi")->where("cod_dtip", $keyReso["cod_dtip"]);
|
||||
|
||||
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
||||
|
||||
$keyReso["ser_doc"] = $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
|
||||
return $keyReso;
|
||||
}
|
||||
|
||||
@@ -243,6 +251,7 @@ class ResiConsegna {
|
||||
if ($Ret->is_OK()) {
|
||||
$noteRaw = $data["note"];
|
||||
$noteNumPratVettRaw = $data["noteNumPratVett"];
|
||||
$rifDocClie = $data["rifDocClie"];
|
||||
$rifFatt = $documento["rif_fatt"];
|
||||
$arr_rows = $Ret->get_data();
|
||||
|
||||
@@ -263,16 +272,18 @@ class ResiConsegna {
|
||||
$codVage2 = null;
|
||||
$noteDoc[$causale] = $noteRaw;
|
||||
$codVage = $documento["cod_vage"];
|
||||
|
||||
if ($causale == "addebitoVettore" && !is_null($noteNumPratVettRaw)) {
|
||||
$noteDoc[$causale] = self::implode_note($noteRaw, $noteNumPratVettRaw);
|
||||
}
|
||||
|
||||
if ($causale != "addebitoVettore" && $causale != "addebitoVettoreMerceRient") {
|
||||
$codVage2 = $documento["cod_vage2"];
|
||||
} else {
|
||||
$codVage = "[NULL]";
|
||||
}
|
||||
$codVlis = $documento["listino"];
|
||||
|
||||
$codVlis = $documento["listino"];
|
||||
$keyDocReso = self::calc_keyDocReso($causale, $documento);
|
||||
|
||||
//Controllo se il documento esiste
|
||||
@@ -284,6 +295,7 @@ class ResiConsegna {
|
||||
->where("ser_doc", $keyDocReso["ser_doc"])
|
||||
->where("cod_anag", $keyDocReso["cod_anag"])
|
||||
->where("cod_dtip", $keyDocReso["cod_dtip"]);
|
||||
|
||||
$Ret = $queryEx->toRet()->countRows();
|
||||
//se esiste lo elimino
|
||||
|
||||
@@ -297,6 +309,7 @@ class ResiConsegna {
|
||||
->set("numDoc", $keyDocReso["num_doc"])
|
||||
->set("codAnag", $keyDocReso["cod_anag"])
|
||||
->set("serDoc", $keyDocReso["ser_doc"]);
|
||||
|
||||
$EntityList->push($deleteDtbDoct);
|
||||
}
|
||||
}
|
||||
@@ -313,19 +326,20 @@ class ResiConsegna {
|
||||
->set("annotazioni", $noteDoc[$causale], true)
|
||||
->set("codVage2", $codVage2)
|
||||
->set("codVage", $codVage)
|
||||
// ->set("listino", $codVlis)
|
||||
->set("sconto1", 0)
|
||||
->set("sconto2", 0)
|
||||
->set("sconto3", 0)
|
||||
->set("sconto4", 0)
|
||||
->setDate("dataOrd", $documento["data_ord"])
|
||||
->set("numOrd", $documento["num_ord"])
|
||||
->set("rifOrd", $documento["rif_ord"]);
|
||||
->set("rifOrd", $documento["rif_ord"])
|
||||
->set("numDocForn", $rifDocClie);
|
||||
|
||||
if (!self::is_causaleAddebitoVettore($causale)) {
|
||||
$arrDtbDoct[$causale]->set("codVdes", $documento["cod_vdes"]);
|
||||
$arrDtbDoct[$causale]->set("listino", $codVlis);
|
||||
}
|
||||
|
||||
if (self::is_causaleResoConRientro($causale) && isset($data["codMdep"]) && !empty($data["codMdep"])) {
|
||||
$arrDtbDoct[$causale]->set("codMdep", $data["codMdep"]);
|
||||
}
|
||||
@@ -337,6 +351,7 @@ class ResiConsegna {
|
||||
$codMart = $row["codMart"];
|
||||
$partitaMag = $row["partitaMag"];
|
||||
$qtaDocReso = $row["qta_{$causale}"];
|
||||
|
||||
$causaleReso = $causale;
|
||||
|
||||
if ($causale == "addebitoVettore") {
|
||||
@@ -345,6 +360,7 @@ class ResiConsegna {
|
||||
return $x["codMart"] == $codMart && $x["partitaMag"] == $partitaMag;
|
||||
})
|
||||
->toArray());
|
||||
|
||||
if (count($result) > 0 && $result[0]["qta_resoConRientro"] > 0) {
|
||||
$causaleReso = "addebitoVettoreMerceRient";
|
||||
}
|
||||
@@ -356,6 +372,7 @@ class ResiConsegna {
|
||||
return $x["codMart"] == $codMart && $x["partitaMag"] == $partitaMag;
|
||||
})
|
||||
->toArray());
|
||||
|
||||
if (count($result) > 0 && $result[0]["qta_addebitoVettore"] > 0) {
|
||||
$causaleReso = "resoConRientro";
|
||||
}
|
||||
@@ -448,7 +465,7 @@ class ResiConsegna {
|
||||
$Ret = $EntityList->send();
|
||||
}
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
if ($Ret->is_OK() && $Ret->get_data()) {
|
||||
$Ret->set_number(count($Ret->get_data()));
|
||||
}
|
||||
}
|
||||
@@ -456,7 +473,7 @@ class ResiConsegna {
|
||||
$Ret->set_error("Documento non valido");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
$ragSocClieFlt = null;
|
||||
if (isset($_GET["anag"])) { // VALIDAZIONE
|
||||
$codAnag = Utility::sanitize($_GET["anag"]);
|
||||
@@ -8,8 +8,10 @@ if (isset($_GET["anag"])) { // VALIDAZIONE
|
||||
$ragSocClieFlt = $clieData["rag_soc"];
|
||||
$filter["codAnag"] = $codAnag;
|
||||
unset($clieData);
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("anag");</script><?
|
||||
} else {
|
||||
?>
|
||||
<script>unset_urlParameter("anag");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +20,10 @@ if (isset($_GET["tipo"])) { // VALIDAZIONE
|
||||
$Ret = ResiConsegna::valid_codDtip($codDtip);
|
||||
if ($Ret->is_OK()) {
|
||||
$filter["tipoDoc"] = $codDtip;
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("tipo");</script><?
|
||||
} else {
|
||||
?>
|
||||
<script>unset_urlParameter("tipo");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +32,10 @@ if (isset($_GET["d"])) { // VALIDAZIONE
|
||||
$Ret = ResiConsegna::valid_dataDoc($dataDoc);
|
||||
if ($Ret->is_OK()) {
|
||||
$filter["dataDoc"] = $dataDoc;
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("d");</script><?
|
||||
} else {
|
||||
?>
|
||||
<script>unset_urlParameter("d");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +44,10 @@ if (isset($_GET["n"])) { // VALIDAZIONE
|
||||
$Ret = ResiConsegna::valid_numDoc($numDoc);
|
||||
if ($Ret->is_OK()) {
|
||||
$filter["numDoc"] = $numDoc;
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("n");</script><?
|
||||
} else {
|
||||
?>
|
||||
<script>unset_urlParameter("n");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +57,8 @@ if (isset($_GET["s"])) { // VALIDAZIONE
|
||||
if ($Ret->is_OK()) {
|
||||
$filter["serDoc"] = $serDoc;
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("s");</script><?
|
||||
<script>unset_urlParameter("s");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,71 +71,80 @@ if (isset($_GET["vett"])) { // VALIDAZIONE
|
||||
$ragSocVettFlt = $vettData["rag_soc"];
|
||||
$filter["codVvet"] = $codVvet;
|
||||
unset($vettData);
|
||||
} else { ?>
|
||||
<script>unset_urlParameter("vett");</script><?
|
||||
} else {
|
||||
?>
|
||||
<script>unset_urlParameter("vett");</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<form id="frm_flt" class="mb-20">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mb-8">
|
||||
<div class="col-sm-4">
|
||||
<label>Cliente</label><br/>
|
||||
<input id="flt-clie" value="<?= $ragSocClieFlt ?>" type="text" class="form-control" autocomplete="off"/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 mb-8">
|
||||
<label>Cliente</label><br/>
|
||||
<input id="flt-clie" value="<?= $ragSocClieFlt ?>" type="text" class="form-control" autocomplete="off"/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 mb-8">
|
||||
<label>Tipo Doc.</label><br/><?
|
||||
$Ret = ResiConsegna::get_listCodDtip();
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_tipoDoc = $Ret->get_data(); ?>
|
||||
<select id="flt-tipoDoc" class="form-control" autocomplete="off">
|
||||
<option></option><?
|
||||
foreach ($arr_tipoDoc as $codDtip) {
|
||||
<div class="col-sm-2">
|
||||
<label>Tipo Doc.</label><br/>
|
||||
<?php
|
||||
$Ret = ResiConsegna::get_listCodDtip();
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_tipoDoc = $Ret->get_data();
|
||||
?>
|
||||
<option
|
||||
value="<?= $codDtip ?>" <?= isset($filter["tipoDoc"]) && $filter["tipoDoc"] == $codDtip ? "selected" : "" ?>><?= $codDtip ?></option><?
|
||||
} ?>
|
||||
</select><?
|
||||
} else {
|
||||
$Ret->showErrorAlert();
|
||||
} ?>
|
||||
</div>
|
||||
<select id="flt-tipoDoc" class="form-control" autocomplete="off">
|
||||
<option></option>
|
||||
<?php foreach ($arr_tipoDoc as $codDtip) { ?>
|
||||
<option
|
||||
value="<?= $codDtip ?>" <?= isset($filter["tipoDoc"]) && $filter["tipoDoc"] == $codDtip ? "selected" : "" ?>><?= $codDtip ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<?php
|
||||
} else {
|
||||
$Ret->showErrorAlert();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 mb-8">
|
||||
<label>Data doc.</label><br/>
|
||||
<div class="input-group">
|
||||
<input id="flt-dataDoc"
|
||||
value="<?= isset($filter["dataDoc"]) ? strftime(Format::strftimeDMY, $filter["dataDoc"]) : "" ?>"
|
||||
type="text" class="form-control" autocomplete="off" readonly/>
|
||||
<span class="input-group-addon dpicker">
|
||||
<div class="col-sm-2">
|
||||
<label>Data doc.</label><br/>
|
||||
<div class="input-group">
|
||||
<input id="flt-dataDoc"
|
||||
value="<?= isset($filter["dataDoc"]) ? strftime(Format::strftimeDMY, $filter["dataDoc"]) : "" ?>"
|
||||
type="text" class="form-control" autocomplete="off" readonly/>
|
||||
<span class="input-group-addon dpicker">
|
||||
<i class="fa fa-calendar"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<label>Num. doc.</label><br/>
|
||||
<input id="flt-numDoc" value="<?= isset($filter["numDoc"]) ? $filter["numDoc"] : "" ?>" type="text"
|
||||
class="form-control text-right" autocomplete="off" maxlength="5"/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<label>Serie doc.</label><br/>
|
||||
<input id="flt-serDoc" value="<?= isset($filter["serDoc"]) ? $filter["serDoc"] : "" ?>" type="text"
|
||||
class="form-control" autocomplete="off" maxlength="2"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1 mb-8">
|
||||
<label>Num. doc.</label><br/>
|
||||
<input id="flt-numDoc" value="<?= isset($filter["numDoc"]) ? $filter["numDoc"] : "" ?>" type="text"
|
||||
class="form-control text-right" autocomplete="off" maxlength="5"/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1 mb-8">
|
||||
<label>Serie doc.</label><br/>
|
||||
<input id="flt-serDoc" value="<?= isset($filter["serDoc"]) ? $filter["serDoc"] : "" ?>" type="text"
|
||||
class="form-control" autocomplete="off" maxlength="2"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4 mb-8">
|
||||
<label>Vettore</label><br/>
|
||||
<input id="flt-vett" value="<?= $ragSocVettFlt ?>" type="text" class="form-control" autocomplete="off"/>
|
||||
</div>
|
||||
<div class="col-sm-2 col-sm-offset-4 mb-8">
|
||||
<label> </label><br/>
|
||||
<button class="btn btn-default btn-block" type="button" id="bt_fltCancel">
|
||||
<i class="fa fa-times-circle text-muted"></i> Reset filtro
|
||||
</button>
|
||||
<div class="col-sm-12 mb-8">
|
||||
<div class="col-sm-4">
|
||||
<label>Vettore</label><br/>
|
||||
<input id="flt-vett" value="<?= $ragSocVettFlt ?>" type="text" class="form-control" autocomplete="off"/>
|
||||
</div>
|
||||
<div class="col-sm-2 col-sm-offset-6">
|
||||
<label> </label><br/>
|
||||
<button class="btn btn-default btn-block" type="button" id="bt_fltCancel">
|
||||
<i class="fa fa-times-circle text-muted"></i> Reset filtro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -11,8 +11,9 @@ if ($ret->is_OK()) {
|
||||
|
||||
if (count($arr_rows) > 0) {
|
||||
ob_start();
|
||||
$firstRow = $arr_rows[0];
|
||||
$ret = ResiConsegna::check_addebitoVettore($documento);
|
||||
$flag_existDocFat = boolValue($arr_rows[0]["flag_existDocFat"]);
|
||||
$flag_existDocFat = boolValue($firstRow["flag_existDocFat"]);
|
||||
$is_enabledAddebitoVettore = $ret->get_boolean();
|
||||
$alert = new BC\Alert;
|
||||
|
||||
@@ -21,7 +22,6 @@ if ($ret->is_OK()) {
|
||||
} else if (!$is_enabledAddebitoVettore) {
|
||||
$alert->warning()->text($ret->get_string())->title("Addebito al vettore non consentito")->show();
|
||||
}
|
||||
|
||||
list($noteRaw, $noteNumPratVettRaw) = ResiConsegna::explode_note($documento["note"]);
|
||||
?>
|
||||
<div class="row">
|
||||
@@ -34,13 +34,19 @@ if ($ret->is_OK()) {
|
||||
$ddtrc = array_filter($arr_rows, function ($row) {
|
||||
return !empty($row["cod_mdep_ddtrc"]);
|
||||
});
|
||||
|
||||
$codMdepDdtrc = array_shift($ddtrc);
|
||||
$rifDocClie = $firstRow["rif_doc_clie"];
|
||||
?>
|
||||
<div class="form-group col-sm-8">
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Causale reso</label>
|
||||
<input value="<?= $noteRaw ?>" id="m_note" class="form-control" type="text"
|
||||
maxlength="<?= $maxLenCausale ?>"/>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Riferimenti documento</label>
|
||||
<input value="<?= $rifDocClie ?>" id="rifDocClie" class="form-control" type="text"/>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Num. pratica vettore</label>
|
||||
<input value="<?= $noteNumPratVettRaw ?>" id="m_noteNumPratVett" class="form-control" type="text"
|
||||
@@ -52,7 +58,7 @@ if ($ret->is_OK()) {
|
||||
</label>
|
||||
<select name="cod_mdep" id="cod_mdep"
|
||||
class="form-control" <?= empty($codMdepDdtrc["cod_mdep_ddtrc"]) ? "readonly" : "" ?>>
|
||||
<option value="">-</option>
|
||||
<option value=""></option>
|
||||
<?php foreach ($depositiResi as $deposito) { ?>
|
||||
<option value="<?= $deposito["cod_mdep"] ?>" <?= ($deposito["cod_mdep"] === $codMdepDdtrc["cod_mdep_ddtrc"]) ? "selected" : "" ?>>
|
||||
<?= $deposito["cod_mdep"] ?> - <?= $deposito["descrizione"] ?>
|
||||
@@ -101,6 +107,7 @@ if ($ret->is_OK()) {
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
$html = Utility\Str::remove_multiple_spaces(@ob_get_clean());
|
||||
|
||||
if ($ret->is_OK()) {
|
||||
|
||||
@@ -4,7 +4,7 @@ $(function () {
|
||||
const key = $tr.getAttr("data-key");
|
||||
|
||||
_resiConsegna.open_detail(key, $(this)).then(function (ret) {
|
||||
if (ret.returnId === 1 && ret?.returnNumber) {
|
||||
if (ret.returnId === 1 && ret?.returnNumber && ret?.returnData) {
|
||||
const c = ret.returnNumber;
|
||||
$tr.toggleClass("warning", c > 0);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ $(function () {
|
||||
_resiConsegna.init();
|
||||
});
|
||||
|
||||
var _resiConsegna = {
|
||||
const _resiConsegna = {
|
||||
filter: null,
|
||||
|
||||
init: function () {
|
||||
@@ -159,6 +159,7 @@ var _resiConsegna = {
|
||||
const data = {
|
||||
key: key,
|
||||
note: $("#m_note").getValue(),
|
||||
rifDocClie: $("#rifDocClie").getValue(),
|
||||
noteNumPratVett: $("#m_noteNumPratVett").getValue(),
|
||||
codMdep: $("select[name=cod_mdep]").val(),
|
||||
rows: []
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
Select cod_mdep, descrizione
|
||||
from mtb_depo
|
||||
where cod_mdep in (SELECT value_string
|
||||
from dbo.parseStringIntoArray(
|
||||
(select value
|
||||
from stb_gest_setup
|
||||
where gest_name = 'PVM'
|
||||
and section = 'RESI_CONSEGNA'
|
||||
and key_section = 'DEPOSITI_RESI'),
|
||||
'|')
|
||||
)
|
||||
SELECT cod_mdep, descrizione
|
||||
FROM mtb_depo
|
||||
WHERE cod_mdep IN (SELECT value_string
|
||||
FROM dbo.parseStringIntoArray(
|
||||
(SELECT value
|
||||
FROM stb_gest_setup
|
||||
WHERE gest_name = 'PVM'
|
||||
AND section = 'RESI_CONSEGNA'
|
||||
AND key_section = 'DEPOSITI_RESI'),
|
||||
'|'))
|
||||
@@ -1,6 +1,4 @@
|
||||
SELECT dtb_docr.*,
|
||||
/*SUM(dtb_docr_resoConRientro.qta_doc) AS qta_doc_resoConRientro,
|
||||
SUM(dtb_docr_resoSenzaRientro.qta_doc) AS qta_doc_resoSenzaRientro,*/
|
||||
SUM(CASE
|
||||
WHEN dtb_docr_addebitoVettore.cod_dtip IS NOT NULL THEN NULL
|
||||
ELSE dtb_docr_resoConRientro.qta_doc END) AS qta_doc_resoConRientro,
|
||||
@@ -12,11 +10,11 @@ SELECT dtb_docr.*,
|
||||
SUM(CASE
|
||||
WHEN dtb_doct_resoConRientro.data_doc_val IS NOT NULL OR
|
||||
dtb_doct_resosenzaRientro.data_doc_val IS NOT NULL OR
|
||||
dtb_doct_addebitoVettore.data_doc_val IS NOT NULL OR
|
||||
dtb_doct_resoConRientroFatt.cod_dtip_val IS NOT NULL THEN 1
|
||||
dtb_doct_addebitoVettore.data_doc_val IS NOT NULL THEN 1
|
||||
ELSE 0 END)
|
||||
OVER (PARTITION BY dtb_docr.num_doc) AS flag_existDocFat,
|
||||
dtb_doct_resoConRientro.cod_mdep as cod_mdep_ddtrc
|
||||
dtb_doct_resoConRientro.cod_mdep AS cod_mdep_ddtrc,
|
||||
dtb_doct_resoConRientro.num_doc_forn AS rif_doc_clie
|
||||
FROM (SELECT dtb_docr.cod_mart,
|
||||
dtb_docr.partita_mag,
|
||||
dtb_docr.descrizione,
|
||||
@@ -27,7 +25,7 @@ FROM (SELECT dtb_docr.cod_mart,
|
||||
dtb_docr.cod_anag,
|
||||
dtb_docr.cod_dtip,
|
||||
mtb_aart.peso_kg,
|
||||
max(dtb_docr.perc_prov2) as perc_prov2 /*necessario perchè sulle rigche con omaggio viene impostata provvigione a zero e quindi duplicava le righe (La percentuale del secondo agente è sempre fissa per documento*/,
|
||||
MAX(dtb_docr.perc_prov2) AS perc_prov2, /* necessario perchè sulle righe con omaggio viene impostata provvigione a zero e quindi duplicava le righe (La percentuale del secondo agente è sempre fissa per documento */
|
||||
SUM(dtb_docr.qta_doc) AS qta_doc,
|
||||
SUM(dtb_docr.importo_riga) AS importo_riga
|
||||
FROM dtb_docr,
|
||||
@@ -37,13 +35,11 @@ FROM (SELECT dtb_docr.cod_mart,
|
||||
AND dtb_docr.num_doc = [num_doc]
|
||||
AND dtb_docr.cod_anag = '[cod_anag]'
|
||||
AND dtb_docr.cod_dtip = '[cod_dtip]'
|
||||
AND
|
||||
--dtb_docr.cod_mart IS NOT NULL AND
|
||||
dtb_docr.qta_doc > 0
|
||||
AND dtb_docr.qta_doc > 0
|
||||
AND dtb_docr.cod_mart = mtb_aart.cod_mart
|
||||
GROUP BY dtb_docr.cod_mart, dtb_docr.data_doc, dtb_docr.ser_doc, dtb_docr.num_doc, dtb_docr.cod_anag,
|
||||
dtb_docr.cod_dtip, dtb_docr.partita_mag, dtb_docr.descrizione, dtb_docr.unt_doc, mtb_aart.peso_kg
|
||||
) dtb_docr
|
||||
dtb_docr.cod_dtip, dtb_docr.partita_mag, dtb_docr.descrizione, dtb_docr.unt_doc,
|
||||
mtb_aart.peso_kg) dtb_docr
|
||||
LEFT OUTER JOIN dtb_docr dtb_docr_resoConRientro ON
|
||||
dtb_docr_resoConRientro.cod_dtip = '[TIPODOC_RESOCONRIENTRO]' AND
|
||||
dtb_docr.data_doc = dtb_docr_resoConRientro.data_doc_comp AND
|
||||
@@ -59,11 +55,6 @@ FROM (SELECT dtb_docr.cod_mart,
|
||||
dtb_doct_resoConRientro.num_doc = dtb_docr_resoConRientro.num_doc AND
|
||||
dtb_doct_resoConRientro.cod_anag = dtb_docr_resoConRientro.cod_anag AND
|
||||
dtb_doct_resoConRientro.cod_dtip = dtb_docr_resoConRientro.cod_dtip
|
||||
LEFT OUTER JOIN dtb_doct dtb_doct_resoConRientroFatt ON
|
||||
dtb_doct_resoConRientroFatt.data_doc = dtb_docr.data_doc AND
|
||||
dtb_doct_resoConRientroFatt.num_doc = dtb_docr.num_doc AND
|
||||
dtb_doct_resoConRientroFatt.cod_anag = dtb_docr.cod_anag AND
|
||||
dtb_doct_resoConRientroFatt.cod_dtip = '[TIPODOC_RESOCONRIENTRO]'
|
||||
LEFT OUTER JOIN dtb_docr dtb_docr_resoSenzaRientro ON
|
||||
dtb_docr_resoSenzaRientro.cod_dtip = '[TIPODOC_RESOSENZARIENTRO]' AND
|
||||
dtb_docr.data_doc = dtb_docr_resoSenzaRientro.data_doc_comp AND
|
||||
@@ -112,5 +103,6 @@ FROM (SELECT dtb_docr.cod_mart,
|
||||
GROUP BY dtb_docr.importo_riga, dtb_docr.qta_doc, dtb_docr.cod_dtip, dtb_docr.cod_anag, dtb_docr.num_doc,
|
||||
dtb_docr.ser_doc, dtb_docr.data_doc, dtb_docr.unt_doc, dtb_docr.cod_mart, dtb_docr.partita_mag,
|
||||
dtb_docr.descrizione, dtb_doct_resoConRientro.data_doc_val, dtb_doct_resosenzaRientro.data_doc_val,
|
||||
dtb_doct_addebitoVettore.data_doc_val, dtb_docr.perc_prov2, dtb_docr.peso_kg, dtb_doct_resoConRientro.cod_mdep, dtb_doct_resoConRientroFatt.cod_dtip_val
|
||||
dtb_doct_addebitoVettore.data_doc_val, dtb_docr.perc_prov2, dtb_docr.peso_kg, dtb_doct_resoConRientro.cod_mdep,
|
||||
dtb_doct_resoConRientro.num_doc_forn
|
||||
ORDER BY dtb_docr.cod_mart, dtb_docr.partita_mag
|
||||
Reference in New Issue
Block a user