Money paidTotal = getPaidTotal();
try {
if(!paymentExpenditureAccountCombo.getText().equals("Selecione uma conta...")) {
if(paidDate.isToday()) {
Account accountDestiny = (Account) system.query(new GetAccountByName(paymentExpenditureAccountCombo.getText()));
if((system.getRegisterMachine() != null ? paymentExpenditureAccountCombo.getText().equals(system.getRegisterMachine().getName()) : false) || accountDestiny.isBankAccount()){
if(accountDestiny.isBankAccount()) {
if((accountDestiny.getLimit().getFloatValue() + accountDestiny.getAmount().getFloatValue()) >= paidTotal.getFloatValue()) {
new MoneyTransaction().expendituresPayment(getExpenditureId(), getAccountId(), paidDate, paidTotal.getValue(), paymentTypeCombo.getPaymentType(), extractBankItem);
GDWindowControl.getInstance().updateControlCenter();
close();
} else {
setErrorMessage("N�o existe saldo suficiente para efetuar a transa��o.");
}
} else {
new MoneyTransaction().expendituresPayment(getExpenditureId(), getAccountId(), paidDate, paidTotal.getValue(), paymentTypeCombo.getPaymentType(), extractBankItem);
GDWindowControl.getInstance().updateControlCenter();
close();
}
} else {
ConfirmUserAndPasswordDialog dialog = new ConfirmUserAndPasswordDialog(getShell(), ((User)accountDestiny.getPerson().getPersonType("user")));
dialog.open();
if(dialog.isCheckPassword()) {
new MoneyTransaction().expendituresPayment(getExpenditureId(), getAccountId(), paidDate, paidTotal.getValue(), paymentTypeCombo.getPaymentType(), extractBankItem);
GDWindowControl.getInstance().updateControlCenter();
close();
}
}
} else {
if(MessageDialog.openQuestion(getShell(), "Data invalida!", "A data '"+ paymentExpenditureDateText.getText() +"' � uma data diferente da atual, deseja efetuar a opera��o mesmo assim?")){
Account accountDestiny = (Account) system.query(new GetAccountByName(paymentExpenditureAccountCombo.getText()));
if((system.getRegisterMachine() != null ? paymentExpenditureAccountCombo.getText().equals(system.getRegisterMachine().getName()) : false) || accountDestiny.isBankAccount()){
new MoneyTransaction().expendituresPayment(getExpenditureId(), getAccountId(), paidDate, paidTotal.getValue(), paymentTypeCombo.getPaymentType(), extractBankItem);
close();
} else {
ConfirmUserAndPasswordDialog dialog = new ConfirmUserAndPasswordDialog(getShell(), ((User)accountDestiny.getPerson().getPersonType("user")));