super.validateBillNoteVsEmployee(errors);
}
public Resolution upload() throws Exception {
String sFwd;
Ticket tckt = null;
BillNote bill = null;
setCapturedCount(0);
final int nItems = (getItems()==null ? 0 : getItems().size());
if (nItems>0) {
Log.out.debug("UploadBillNote "+String.valueOf(nItems)+" items found");
try {
connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
TaxPayer txpy = new TaxPayer(getSession().getDms(), getRecipientTaxPayer());
bill = txpy.billnotes(getSession()).forConcept(getSession(), getConcept(), getEmployee());
setCapturedPage1("");
for (FileBean attachment : getItems()) {
if (attachment != null) {
if (attachment.getSize() > 0) {
if (tckt==null) {
tckt = bill.createTicket(getSession(), getAccount());
setId(tckt.id());
FlashScope oFscope = FlashScope.getCurrent(getContext().getRequest(), true);
oFscope.put("ticket_docid", tckt.id());
}
TicketNote note = tckt.createNote(getSession(), attachment.getInputStream(), incCapturedCount(), attachment.getFileName());
if (getCapturedPage1().length()==0) setCapturedPage1(note.id());
attachment.delete();
} else {
ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
getContext().getValidationErrors().add("items" , error);
}
}
} // next
disconnect();
if (getCapturedCount()>0)
ThumbnailCreator.createThumbnailFor(getId(), getCapturedPage1());
sFwd = "EditBillNote.action?id="+tckt.id();
} catch (IllegalStateException e) {
Log.out.error("BillNoteUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));
sFwd = "error.jsp?e=couldnotloadticket";
} finally { close(); }