throw new IllegalStateException("Invoice was already created for academic course booking");
if (isNull(DB.gu_contact))
throw new IllegalStateException("AcademicCourseBooking.getContact() gu_contact not set");
Contact oCntc = new Contact(oConn, getString(DB.gu_contact));
if (oCntc.isNull(DB.gu_company))
throw new SQLException("Company not set for given Contact");
Company oComp = new Company(oConn, getString(DB.gu_contact));
if (oComp.isNull(DB.id_legal))
throw new SQLException("Legal document number not set for given Company");
Product oProd = new Product();
if (!oProd.load(oConn, new Object[]{getString(DB.gu_acourse)})) {
throw new SQLException("No product found for given academic course");
} else {
if (oProd.isNull(DB.id_currency)) {
throw new SQLException("Currency for product is not set");
}
if (oProd.isNull(DB.pr_list)) {
throw new SQLException("List price for product is not set");
}
}
DBSubset oAddrs = oComp.getAddresses(oConn);
DBSubset oBanks = oComp.getActiveBankAccounts(oConn);
Invoice oInvc = new Invoice();
oInvc.put(DB.bo_active, (short) 1);
oInvc.put(DB.gu_shop, sGuShop);
oInvc.put(DB.id_currency, oProd.get(DB.id_currency));
oInvc.put(DB.id_legal, oComp.getString(DB.id_legal));
oInvc.put(DB.de_order, Gadgets.left(getStringNull(DB.nm_course,"")+"/"+oCntc.getStringNull(DB.tx_name,"")+" "+oCntc.getStringNull(DB.tx_surname,""),100));
oInvc.put(DB.gu_company, oComp.getString(DB.gu_company));
oInvc.put(DB.nm_client, oComp.getString(DB.nm_legal));
if (oAddrs.getRowCount()>0) {
oInvc.put(DB.gu_bill_addr, oAddrs.getString(DB.gu_address,0));
if (!oAddrs.isNull(DB.tx_email,0)) {