private void jTakeAwayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTakeAwayActionPerformed
List<TicketLineInfo> tLines;
// TicketLineInfo currentLine;
TicketTaxInfo[] taxes;
TaxInfo taxline;
Double marge;
/*
* Mettre le client à Emporter à "invisible"
* remplacer les données ci-dessous par les bonnes
*
*
*
*/
Double taxTakeAway = 1.06; //taxe à emporter = 6%
String takeAwayID = "8ba8e7e2-197f-4296-9531-ed27ad875ad8"; // ID du client "A Emporter"
String taxTakeAwayName = "Sur Place"; // Nom de la taxe "Sur Place"
double total = m_oTicket.getTotal();
if (total <= 0.0) {
java.awt.Toolkit.getDefaultToolkit().beep();
return;
}
tLines = m_oTicket.getLines();
try {
m_oTicket.setCustomer(dlSales.loadCustomerExt(takeAwayID));
} catch (BasicException e) {
MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e);
msg.show(this);
}
// refreshTicket();
for (int i = 0; i < tLines.size(); i++) {
TicketLineInfo currentLine = tLines.get(i);
taxline = currentLine.getTaxInfo();
if (taxline.getName().contains(taxTakeAwayName)) {
marge = (currentLine.getPriceTax() / taxTakeAway);
currentLine.setPrice(marge);
m_oTicket.setLine(i, currentLine);
}
}
refreshTicket();
if (closeTicket(m_oTicket, m_oTicketExt)) {
m_ticketsbag.deleteTicket();
} else {
m_oTicket.setCustomer(null);
refreshTicket();
for (int i = 0; i < tLines.size(); i++) {
// taxline = taxes[i];
TicketLineInfo currentLine = tLines.get(i);
taxline = currentLine.getTaxInfo();
if (taxline.getName().contains(taxTakeAwayName)) {
Double tax = (taxline.getRate())+1.0;
marge = ((currentLine.getPrice()*taxTakeAway) / tax);
currentLine.setPrice(marge);
m_oTicket.setLine(i, currentLine);