blob: 625261fed924c850997fd7fdae9bacf6804454a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beans.auftragsAbwicklung;
import beans.bestell.BestellRemote;
import beans.lieferant.LieferantRemote;
import beans.lager.LagerRemote;
import beans.*;
import beans.artikelManager.ArtikelManagerRemote;
import entities.Artikel;
import exceptions.AuftragsAbwicklungException;
import javax.ejb.EJB;
import javax.ejb.Stateless;
/**
* Eine Klasse für das abwickeln von Aufträgen
* @author jmueller
*/
@Stateless(mappedName="AuftragsAbwicklungBean")
public class AuftragsAbwicklungBean implements AuftragsAbwicklungRemote {
@EJB
private BestellRemote bestellBean;
@EJB
private ArtikelManagerRemote artikelManagerBean;
@EJB
private LieferantRemote lieferantBean;
@EJB
private LagerRemote lagerBean;
/**
* simuliert die Bestellung eines Artikels durch einen Kunden
*
* @param kundenId Id des Kunden
* @param artikelId Id des Artikels
* @param artikelAnzahl Anzahl des Artikels
*
* @return String Bericht
* @throws java.lang.Exception
*/
public String bestelleArtikel(long kundenId, long artikelId, long artikelAnzahl ) throws Exception{
if( bestellBean.validiereBestellung(artikelId, artikelAnzahl, kundenId) != true){
throw new AuftragsAbwicklungException("Bestellung nicht valide!");
}
Artikel artikel = artikelManagerBean.readArtikel(artikelId);
// falls nicht verfuegbar -> nachbestellen
if (lagerBean.pruefeVerfuegbarkeit(artikelId, artikelAnzahl) != true) {
long mindestMenge = 10L;
long imLager = artikel.getAnzahl();
long anzahlNachbestellen = artikelAnzahl - imLager + mindestMenge;
lieferantBean.bestelleNach(artikelId, anzahlNachbestellen);
}
lagerBean.bucheArtikelAus(artikelId, artikelAnzahl);
double preisOhneMwSt = bestellBean.berechneGesamtpreis(artikelAnzahl, artikel.getPreis());
double MwSt = bestellBean.berechneMehrwertSteuer(preisOhneMwSt);
return "";
}
}
|