use of model.banking.Transaction in project amos-ss17-alexa by c-i-ber.
the class TransactionTest method getTransactions.
@Test
public void getTransactions() {
Collection<Transaction> transactions = TransactionAPI.getTransactionsForAccount(ACCOUNT_NUMBER1);
System.out.println(AccountAPI.getAccount(ACCOUNT_NUMBER1).getIban());
List<Transaction> txs = new ArrayList<>(transactions);
Collections.reverse(txs);
for (Transaction transaction : txs) {
System.out.println("ID: " + transaction.getTransactionId());
System.out.println("Source: " + transaction.getSourceAccount());
System.out.println("Destination: " + transaction.getDestinationAccount());
System.out.println("Date: " + transaction.getValueDate());
}
}
use of model.banking.Transaction in project amos-ss17-alexa by c-i-ber.
the class TransactionTest method testAndGetTransaction.
@Test
public void testAndGetTransaction() {
Transaction newTransaction = TransactionAPI.createTransaction(1, ACCOUNT_IBAN1, ACCOUNT_IBAN2, VALUE_DATE, "TestDescription", "Hans", "Helga");
assertEquals(1, newTransaction.getValue());
assertEquals(ACCOUNT_IBAN1, newTransaction.getSourceAccount());
assertEquals(ACCOUNT_IBAN2, newTransaction.getDestinationAccount());
assertEquals(VALUE_DATE, newTransaction.getValueDate());
assertEquals("TestDescription", newTransaction.getDescription());
Collection<Transaction> transactions = TransactionAPI.getTransactionsForAccount(ACCOUNT_NUMBER1);
boolean foundTransaction = false;
log.info("Found transactions: " + transactions.size());
for (Transaction transaction : transactions) {
if (transaction.getTransactionId().equals(newTransaction.getTransactionId())) {
foundTransaction = true;
break;
}
}
assertTrue(foundTransaction);
}
use of model.banking.Transaction in project amos-ss17-alexa by c-i-ber.
the class TransactionTest method createPeriodicTransactionTest.
@Ignore
public void createPeriodicTransactionTest() {
DynamoDbMapper dynamoDbMapper = DynamoDbMapper.getInstance();
String source = AccountAPI.getAccount(AccountData.ACCOUNT_DEFAULT).getIban();
String destination = AccountAPI.getAccount(AccountData.ACCOUNT_DEFAULT_2).getIban();
// create sample transactions
String date = new DateTime(2017, 8, 14, 12, 0).toLocalDate().toString();
Transaction transaction = TransactionAPI.createTransaction(10, source, destination, date, "Netflix", "Netflix", "Peter Müller");
TransactionDB tDB1 = new TransactionDB(transaction.getTransactionId().toString(), "", AccountData.ACCOUNT_DEFAULT);
tDB1.setPeriodic(true);
dynamoDbMapper.save(tDB1);
}
use of model.banking.Transaction in project amos-ss17-alexa by c-i-ber.
the class ContactService method askForNewContactConfirmation.
private SpeechletResponse askForNewContactConfirmation(Intent intent, Session session) {
Map<String, Slot> slots = intent.getSlots();
Slot transactionNumberSlot = slots.get("TransactionNumber");
if (transactionNumberSlot.getValue() == null || StringUtils.isBlank(transactionNumberSlot.getValue())) {
String speechText = "Das habe ich nicht ganz verstanden. Bitte wiederhole deine Eingabe.";
session.getAttributes().clear();
return getAskResponse(CONTACTS, speechText);
}
LOGGER.info("TransactionNumber: " + transactionNumberSlot.getValue());
String speechText = "";
List<Transaction> allTransactions = TransactionAPI.getTransactionsForAccount(AmosAlexaSpeechlet.ACCOUNT_ID);
Number transactionNumber = Integer.valueOf(transactionNumberSlot.getValue());
Transaction transaction = null;
for (Transaction t : allTransactions) {
if (transactionNumber.equals(t.getTransactionId())) {
transaction = t;
}
}
LOGGER.info("Found transaction: " + transaction);
if (transaction == null) {
speechText = "Ich habe keine Transaktion mit dieser Nummer gefunden. Bitte wiederhole deine Eingabe.";
session.getAttributes().clear();
return getAskResponse(CONTACTS, speechText);
}
LOGGER.info("Payee: " + transaction.getPayee());
LOGGER.info("Remitter: " + transaction.getRemitter());
String payee = transaction.getPayee();
String remitter = transaction.getRemitter();
String ibanRegex = ".*\\d+.*";
if ((payee == null && remitter == null) || (transaction.isOutgoing() && payee.matches(ibanRegex)) || (!transaction.isOutgoing() && remitter.matches(ibanRegex))) {
speechText = "Ich kann fuer diese Transaktion keine Kontaktdaten speichern, weil der Name des";
speechText = speechText.concat(transaction.isOutgoing() ? " Zahlungsempfaengers" : " Auftraggebers");
speechText = speechText.concat(" nicht bekannt ist. Bitte wiederhole deine Eingabe oder breche ab, indem du \"Alexa, Stop!\" sagst.");
session.getAttributes().clear();
return getAskResponse(CONTACTS, speechText);
} else {
// TODO improve
// Actually asking for confirmation
session.setAttribute("ContactName", transaction.isOutgoing() ? payee : remitter);
speechText = "Moechtest du ";
speechText = speechText.concat(transaction.isOutgoing() ? payee : remitter);
speechText = speechText.concat(" als Kontakt speichern?");
}
return getAskResponse(CONTACTS, speechText);
}
use of model.banking.Transaction in project amos-ss17-alexa by c-i-ber.
the class PeriodicTransactionService method markPeriodicTransactions.
private int markPeriodicTransactions() {
List<Transaction> transactions = new ArrayList(TransactionAPI.getTransactionsForAccount(ACCOUNT_NUMBER));
LOGGER.info("Size: " + transactions.size());
Map<Number, Set<Transaction>> candidates = new HashMap<>();
for (Transaction t : transactions) {
LOGGER.info("Transaction: " + t);
if (!candidates.containsKey(t.getAmount())) {
LOGGER.info("Not contains");
Set<Transaction> tList = new HashSet<>();
tList.add(t);
candidates.put(t.getAmount(), tList);
} else {
candidates.get(t.getAmount()).add(t);
}
}
Iterator<Number> iter = candidates.keySet().iterator();
while (iter.hasNext()) {
Number key = iter.next();
if (candidates.get(key).size() <= 1) {
iter.remove();
}
}
LOGGER.info("Candidates: " + candidates);
return candidates.size();
}
Aggregations