}
DBSubset oAddrs = oCntc.getAddresses(oConn);
DBSubset oBanks = oCntc.getActiveBankAccounts(oConn);
Invoice oInvc = new Invoice();
oInvc.put(DB.gu_shop, sGuShop);
oInvc.put(DB.id_currency, oProd.get(DB.id_currency));
oInvc.put(DB.id_legal, oCntc.getString(DB.sn_passport));
oInvc.put(DB.de_order, Gadgets.left(getStringNull(DB.nm_acourse,"")+"/"+oCntc.getStringNull(DB.tx_name,"")+" "+oCntc.getStringNull(DB.tx_surname,""),100));
oInvc.put(DB.gu_contact, oCntc.getString(DB.gu_contact));
oInvc.put(DB.nm_client, Gadgets.left(oCntc.getStringNull(DB.tx_name,"")+" "+oCntc.getStringNull(DB.tx_surname,""),200));
if (oAddrs.getRowCount()>0) {
oInvc.put(DB.gu_bill_addr, oAddrs.getString(DB.gu_address,0));
if (!oAddrs.isNull(DB.tx_email,0)) {
oInvc.put(DB.tx_email_to, oAddrs.getString(DB.tx_email,0));
}
} // fi
if (oBanks.getRowCount()>0) {
oInvc.put(DB.nu_bank, oBanks.getString(DB.nu_bank_acc,0));
} // fi
oInvc.store(oConn);
oInvc.addProduct(oConn, oProd.getString(DB.gu_product), 1f);
oInvc.put(DB.im_subtotal, oInvc.computeSubtotal(oConn));
oInvc.put(DB.im_taxes, oInvc.computeTaxes(oConn));
oInvc.put(DB.im_total, oInvc.computeTotal(oConn));
oInvc.put(DB.im_paid, new BigDecimal(0d));
oInvc.store(oConn);
DBCommand.executeUpdate(oConn, "UPDATE "+DB.k_x_course_bookings+" SET "+DB.gu_invoice+"='"+oInvc.getString(DB.gu_invoice)+"' WHERE "+DB.gu_acourse+"='"+getString(DB.gu_acourse)+"' AND "+DB.gu_contact+"='"+getString(DB.gu_contact)+"'");
return oInvc;
} // createInvoiceForContact