1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
CREATE OR REPLACE PROCEDURE NVFACTURE
(resid IN INTEGER) IS
CURSOR cr IS SELECT res_id,clit_nom_societe,clit_nom,clit_prenom,clit_adresse,hot_nom,hot_adresse,hot_tel,hot_site_web,res_date_arr,res_date_dep,res_nb_nuits,cha_num,pr_prix,ser_fac_prix_total_ht from client,reservation,prix,chambre,hotels,services_fact,service_proposer
where resid=res_id and res_clit=clit_code and res_cha=cha_id and cha_prix=pr_id and cha_hot=hot_id and ser_fac_fac_id=res_id and ser_fac_ser_id=ser_prop_id;
montantht NUMBER(5,2);
totalserv NUMBER(5,2);
tva NUMBER(5,2);
montantttc NUMBER(5,2);
BEGIN
select sum(ser_fac_prix_total_ht) into totalserv from services_fact where ser_fac_fac_id=resid;
montantht:= x.res_nb_nuits*x.pr_prix+totalserv;
tva:=montantht*0.196;
montantttc:=montantht+tva;
FOR X IN CR LOOP
INSERT INTO FACTURE VALUES (sq_facture.NEXTVAL,sysdate,x.res_id,x.clit_nom_societe,x.clit_nom,x.clit_prenom,x.clit_adresse,x.hot_nom,x.hot_adresse,x.hot_tel,x.hot_site_web,x.res_date_arr,x.res_date_dep,x.res_nb_nuits,x.cha_num,x.pr_prix,totalserv,montantht,tva,montantttc);
dbms_output.put_line('facture creer');
END LOOP;
END; |
Partager