Files
Facilitor/APPL/API2/model_fin_factuur.inc
Erik Groener 1dba0db7d0 FSN#40235 Mislukt toevoegen van een fin-kenmerk wordt niet goed gemeld
svn path=/Website/trunk/; revision=33547
2017-04-20 07:40:14 +00:00

147 lines
4.3 KiB
PHP

<% /*
$Revision$
$Id$
File: model_fin_factuur.inc
Description: Model voor fin_factuur
Context:
Notes:
*/
%>
<!-- #include file="../api2/model_fin_factuurregel.inc" -->
<%
function model_fin_factuur()
{
this.records_name = "invoices";
this.record_name = "invoice";
this.table = "fin_factuur";
this.primary = "fin_factuur_key";
this.autfunction = "WEB_BGTUSE"; // "WEB_FINUSE"
this.record_title = L("fin_invoice");
this.records_title = L("lcl_fin_invoices");
this.fields = {
"id": {
"dbs": "fin_factuur_key",
"label": L("lcl_key"),
"typ": "key",
"hidden_fld": true,
"required": true,
"filter": "exact",
"seq": "fin_s_fin_factuur_key"
},
"invoice": {
"dbs": "fin_factuur_nr",
"label": L("lcl_fin_invoice_number"),
"typ": "varchar"
},
"month": {
"dbs": "fin_factuur_boekmaand",
"label": "boekmaand",
"typ": "varchar"
},
"date": {
"dbs": "fin_factuur_datum",
"label": L("lcl_fin_findate"),
"typ": "date"
},
"costtype": {
"dbs": "prs_kostensoort_key",
"label": L("prs_kostensoort_key"),
"typ": "key",
"foreign": bgt_costtype_foreign(),
"hidden_fld": true
},
"order": {
"dbs": "mld_opdr_key",
"label": "opdracht",
"typ": "key",
"foreign": {
"tbl": "mld_opdr",
"key": "mld_opdr_key",
"desc": "mld_opdr_omschrijving"
}
},
"remark": {
"dbs": "fin_factuur_opmerking",
"label": L("lcl_fin_remark"),
"typ": "varchar"
},
"status": {
"dbs": "fin_factuur_statuses_key",
"label": L("lcl_fin_fin_status"),
"typ": "key",
"foreign": {
"tbl": "fin_factuur_statuses",
"key": "fin_factuur_statuses_key",
"desc": "fin_factuur_statuses_omschr"
},
"defaultvalue": "2"
},
"total": {
"dbs": "fin_factuur_totaal",
"label": L("lcl_fin_CO_sum"),
"typ": "float",
"iscurrency": true,
"total": true,
"hidden_fld": true,
"defaultvalue": "0"
},
"totalvat": {
"dbs": "fin_factuur_totaal_btw",
"label": L("lcl_fin_btwsum"),
"typ": "float",
"iscurrency": true,
"total": true,
"hidden_fld": true,
"defaultvalue": "0"
}
};
this.includes = {
"invoicerows": {
"model": new model_fin_factuurregel(),
"joinfield": "invoice",
"enable_update": true
}
};
this.list = {
"columns": [
"invoice",
"date",
"remark",
"total",
"totalvat"
]
};
this.hook_pre_post = function(params, obj)
{
// Wordt alleen gebruikt bij toevoegen.
}
this.hook_pre_put = function(params, obj, key)
{ //wijzigen factuur: bepaal ook opnieuw de som van de factuurregels.
var sql = "UPDATE fin_factuur ff"
+ " SET ff.fin_factuur_totaal = (SELECT SUM(fin_factuurregel_totaal)"
+ " FROM fin_factuurregel fr"
+ " WHERE fr.fin_factuur_key = ff.fin_factuur_key)"
+ " , ff.fin_factuur_totaal_btw = (SELECT SUM(fin_factuurregel_btw)"
+ " FROM fin_factuurregel fr"
+ " WHERE fr.fin_factuur_key = ff.fin_factuur_key)"
+ " WHERE ff.fin_factuur_key = " + key;
Oracle.Execute(sql);
}
this.REST_GET = generic_REST_GET(this);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this);
}
%>