AAIT#30557: Toetsing dubbele factuur werkt niet naar behoren.
svn path=/Website/trunk/; revision=23611
This commit is contained in:
@@ -24,10 +24,10 @@ DOCTYPE_Disable = 1;
|
||||
<%
|
||||
|
||||
var fac_nr = getQParam("fac_nr");
|
||||
var deb_nr = getQParam("deb_nr", null);
|
||||
var lev_uit_key = getQParam("lev_uit_key", null);
|
||||
var fin_key = getQParamInt("fin_key", -1);
|
||||
|
||||
var result = fin.checkfactuurexist(fac_nr, deb_nr, fin_key);
|
||||
var result = fin.getfactuurexist(fac_nr, lev_uit_key, fin_key);
|
||||
|
||||
Response.Write(JSON.stringify(result));
|
||||
%>
|
||||
|
||||
110
APPL/FIN/fin.inc
110
APPL/FIN/fin.inc
@@ -975,45 +975,10 @@ fin = { func_enabled_factuur: // Wat mag ik zoal op deze specifieke factuur?
|
||||
|
||||
if (result.lev_uit_key)
|
||||
{
|
||||
var sql = "SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE(SUM(f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", mld_opdr o"
|
||||
+ " WHERE f.mld_opdr_key = o.mld_opdr_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fin_factuur_nr)
|
||||
+ " AND o.mld_uitvoerende_keys = " + result.lev_uit_key
|
||||
+ " UNION ALL"
|
||||
+ " SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE(SUM(f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", bes_bestelopdr bo"
|
||||
+ " WHERE f.bes_bestelopdr_key = bo.bes_bestelopdr_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fin_factuur_nr)
|
||||
+ " AND bo.prs_bedrijf_key = " + result.lev_uit_key
|
||||
+ " UNION ALL"
|
||||
+ " SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE(SUM(f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", cnt_contract c"
|
||||
+ " WHERE f.cnt_contract_key = c.cnt_contract_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fin_factuur_nr)
|
||||
+ " AND c.cnt_prs_bedrijf_key = " + result.lev_uit_key;
|
||||
sql = "SELECT SUM(aantal_facturen) aantal_facturen"
|
||||
+ ", SUM(totaal_bedrag) totaal_bedrag"
|
||||
+ ", SUM(totaal_bedrag_btw) totaal_btw_bedrag"
|
||||
+ " FROM (" + sql + ")";
|
||||
|
||||
var oRs = Oracle.Execute(sql);
|
||||
result.aantalfacturen = oRs("aantal_facturen").Value;
|
||||
result.totaalbedrag = oRs("totaal_bedrag").Value;
|
||||
result.totaalbtwbedrag = oRs("totaal_btw_bedrag").Value;
|
||||
oRs.close();
|
||||
var result_getfe = fin.getfactuurexist(fin_factuur_nr, result.lev_uit_key, -1);
|
||||
result.aantalfacturen = result_getfe.aantal;
|
||||
result.totaalbedrag = result_getfe.totaalbedrag;
|
||||
result.totaalbtwbedrag = result_getfe.totaalbtwbedrag;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1045,24 +1010,57 @@ fin = { func_enabled_factuur: // Wat mag ik zoal op deze specifieke factuur?
|
||||
return btwtabel;
|
||||
},
|
||||
|
||||
checkfactuurexist:
|
||||
function _checkfactuurexist(fac_nr, deb_nr, fin_key)
|
||||
{ // controle op het Factuurnr (van de leverancier) of dat dan van dezelfde leverancier(!) al bestaat
|
||||
sql = "SELECT COUNT(f.fin_factuur_key) aantal"
|
||||
+ ", SUM(f.fin_factuur_totaal) totaal"
|
||||
+ " FROM fin_factuur f"
|
||||
+ " WHERE f.fin_factuur_nr = " + safe.quoted_sql(fac_nr)
|
||||
+ (fin_key > 0
|
||||
? " AND f.fin_factuur_key != " + fin_key
|
||||
: "")
|
||||
+ (deb_nr
|
||||
? " AND f.fin_factuur_debiteur_nr = " + safe.quoted_sql(deb_nr)
|
||||
: " AND f.fin_factuur_debiteur_nr IS NULL")
|
||||
+ " AND f.fin_factuur_verwijder IS NULL";
|
||||
oRs = Oracle.Execute(sql);
|
||||
getfactuurexist:
|
||||
function _getfactuurexist(fac_nr, lev_uit_key, fin_key)
|
||||
{ // Controle op het Factuurnr (van de leverancier) en of dat dan van dezelfde leverancier(!) al bestaat.
|
||||
var sql = "SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", mld_opdr o"
|
||||
+ " WHERE f.mld_opdr_key = o.mld_opdr_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fac_nr)
|
||||
+ " AND o.mld_uitvoerende_keys = " + lev_uit_key
|
||||
+ (fin_key > 0
|
||||
? " AND f.fin_factuur_key != " + fin_key
|
||||
: "")
|
||||
+ " UNION ALL"
|
||||
+ " SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", bes_bestelopdr bo"
|
||||
+ " WHERE f.bes_bestelopdr_key = bo.bes_bestelopdr_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fac_nr)
|
||||
+ " AND bo.prs_bedrijf_key = " + lev_uit_key
|
||||
+ (fin_key > 0
|
||||
? " AND f.fin_factuur_key != " + fin_key
|
||||
: "")
|
||||
+ " UNION ALL"
|
||||
+ " SELECT COUNT(f.fin_factuur_key) aantal_facturen"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal), 0) totaal_bedrag"
|
||||
+ ", COALESCE (SUM (f.fin_factuur_totaal_btw), 0) totaal_bedrag_btw"
|
||||
+ " FROM fin_factuur f"
|
||||
+ ", cnt_contract c"
|
||||
+ " WHERE f.cnt_contract_key = c.cnt_contract_key"
|
||||
+ " AND f.fin_factuur_verwijder IS NULL"
|
||||
+ " AND f.fin_factuur_nr = " + safe.quoted_sql(fac_nr)
|
||||
+ " AND c.cnt_prs_bedrijf_key = " + lev_uit_key
|
||||
+ (fin_key > 0
|
||||
? " AND f.fin_factuur_key != " + fin_key
|
||||
: "");
|
||||
sql = "SELECT SUM(aantal_facturen) aantal_facturen"
|
||||
+ ", SUM(totaal_bedrag) totaal_bedrag"
|
||||
+ ", SUM(totaal_bedrag_btw) totaal_btw_bedrag"
|
||||
+ " FROM (" + sql + ")";
|
||||
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var result = { fac_nr: fac_nr,
|
||||
aantal: oRs("aantal").Value? oRs("aantal").Value : 0,
|
||||
totaal: oRs("totaal").Value? safe.curr(oRs("totaal").Value) : 0
|
||||
aantal: oRs("aantal_facturen").Value? oRs("aantal_facturen").Value : 0,
|
||||
totaalbedrag: oRs("totaal_bedrag").Value? oRs("totaal_bedrag").Value : 0,
|
||||
totaalbtwbedrag: oRs("totaal_btw_bedrag").Value
|
||||
};
|
||||
oRs.close();
|
||||
return result;
|
||||
|
||||
@@ -351,6 +351,7 @@ var fin_btwtabel_key = oRs("fin_btwtabel_key").value; // Standaard btw tabel key
|
||||
</td>
|
||||
</tr>
|
||||
<% RWFIELDTR("lev_uit", "fld", L("lcl_cnt_contractant"), (ref_info.lev_uit? ref_info.lev_uit : ""), { readonly: true }); // Leverancier/Uitvoerder
|
||||
%> <input type="hidden" name="lev_uit_key" id="lev_uit_key" value="<%=ref_info.lev_uit_key? ref_info.lev_uit_key : ""%>"><%
|
||||
|
||||
// Return waarde fin.getnomatchreasoncontract():
|
||||
// 00 (0): No match
|
||||
@@ -408,7 +409,6 @@ var fin_btwtabel_key = oRs("fin_btwtabel_key").value; // Standaard btw tabel key
|
||||
RWFIELDTR("fincnt", "fldfincnt", L("lcl_fin_aantal_facturen"), (ref_info.aantalfacturen? ref_info.aantalfacturen : "0"), { readonly: true }); // Aantal facturen met dezelfde factuurnummer
|
||||
// Totaal bedrag van het aantal facturen met dezelfde factuurnummer
|
||||
RWFIELDTR("finsom", "fldfinsom", L("lcl_fin_totaal_bedrag"), S("currency_pref") + safe.curr(ref_info.totaalbedrag? ref_info.totaalbedrag : "0") + S("currency_suff"), { readonly: true }); // Totaal bedrag van het aantal facturen met dezelfde factuurnummer
|
||||
// Twee velden met hetzelfde id?? TODO!
|
||||
RWFIELDTR("finsominc", "fldfinsom", L("lcl_fin_totaal_bedrag_btw"), S("currency_pref") + safe.curr(ref_info.totaalbedrag? (ref_info.totaalbedrag + ref_info.totaalbtwbedrag) : "0") + S("currency_suff"), {readonly:true}); // Totaal bedrag van het aantal facturen met dezelfde factuurnummer
|
||||
BLOCK_END();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ var dateInputs = new Object();
|
||||
function checkFactuurExistCallback(json, textStatus)
|
||||
{
|
||||
if (json.aantal > 0)
|
||||
if (confirm(L("lcl_fin_invoice_number") + " " + json.fac_nr + L("lcl_fin_is_al") + json.aantal + L("lcl_fin_register_total") + json.totaal + ". " + L("lcl_fin_toch_doorgaan")))
|
||||
if (confirm(L("lcl_fin_invoice_number") + " " + json.fac_nr + L("lcl_fin_is_al") + json.aantal + L("lcl_fin_register_total") + currency_pref + num2currEditable(parseFloat(json.totaalbedrag)) + ". " + L("lcl_fin_toch_doorgaan")))
|
||||
document.forms.u2.submit();
|
||||
else
|
||||
return false;
|
||||
@@ -43,7 +43,7 @@ function checkInput()
|
||||
// Melding: "Factuurnr 1234 is al N keer geregistreerd met een totaalbedrag van 99999. Toch doorgaan?", bij Cancel keer je terug in het scherm
|
||||
$.getJSON("check_factuur_exist.asp",
|
||||
{ fac_nr: $("#finnr").val(),
|
||||
deb_nr: $("#findebtor").val(),
|
||||
lev_uit_key: $("#lev_uit_key").val(), // Via de referentie bepaald en opgeslagen. Afdeling, Persoon of Bedrijf.
|
||||
fin_key: $("#fin_key").val() },
|
||||
checkFactuurExistCallback);
|
||||
}
|
||||
@@ -125,6 +125,7 @@ function clearRefDetails()
|
||||
$("#tr_refopdrtype").hide();
|
||||
$("#fincnt").val("");
|
||||
$("#finsom").val("");
|
||||
$("#finsominc").val("");
|
||||
FcltMgr.resized(window);
|
||||
}
|
||||
|
||||
@@ -168,6 +169,7 @@ function FcltGetRefInfoCallback(json)
|
||||
|
||||
$("#fin_type").val(json.ref_type);
|
||||
$("#lev_uit").val(json.lev_uit);
|
||||
$("#lev_uit_key").val(json.lev_uit_key);
|
||||
if (canReqRelDetails)
|
||||
{
|
||||
$('#lev_uit').click(function()
|
||||
@@ -300,7 +302,8 @@ function FcltGetRefInfoCallback(json)
|
||||
}
|
||||
|
||||
$("#fincnt").val(json.aantalfacturen);
|
||||
$("#finsom").val(currency_pref + json.totaalbedrag + currency_suff);
|
||||
$("#finsom").val(currency_pref + num2currEditable(parseFloat(json.totaalbedrag)) + currency_suff);
|
||||
$("#finsominc").val(currency_pref + num2currEditable(parseFloat(json.totaalbedrag + json.totaalbtwbedrag)) + currency_suff);
|
||||
|
||||
window.btwtabel_key = json.btwtabel_key;
|
||||
window.btwtabel = json.btwtabel;
|
||||
@@ -328,7 +331,7 @@ function referenceChanged(refchanged)
|
||||
fin_factuur_nr: $("#finnr").val(),
|
||||
ascontactpers: asContactpersoon? 1 : 0
|
||||
});
|
||||
FcltGetRefInfoCallback(returndata)
|
||||
FcltGetRefInfoCallback(returndata);
|
||||
}
|
||||
else
|
||||
// T.b.v. de mogelijkheid om oude waarde weer terug te zetten bij ongeldige referentie
|
||||
|
||||
Reference in New Issue
Block a user