import com.fasterxml.jackson.databind.ObjectMapper;
import hu.user.lis.db.Currency;
+import hu.user.lis.db.Invoice;
import hu.user.lis.db.Treasury;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.RandomStringUtils;
public List<Treasury> getAll() {
if (entities == null) {
try {
- entities = generate();
+ entities = generate2();
} catch (ParseException e) {
log.catching(e);
}
return result;
}
+ private List<Treasury> generate2() throws ParseException {
+
+ List<Treasury> result = new ArrayList<>();
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+
+ String id = RandomStringUtils.random(8, "0123456789abcdef");
+ String humanId = "001";
+ Date transactionDate = formatter.parse("2023-01-09");
+ Date valueDate = formatter.parse("2023-01-09");
+ Currency buyCurrency = Currency.EUR;
+ Currency sellCurrency = Currency.EUR;
+ double buyAmount = 12065.0;
+ double sellAmount = 0.0;
+ Treasury entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "002";
+ transactionDate = formatter.parse("2023-01-25");
+ valueDate = formatter.parse("2023-01-25");
+ buyCurrency = Currency.EUR;
+ sellCurrency = Currency.EUR;
+ buyAmount = 390.0;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "003";
+ transactionDate = formatter.parse("2023-01-27");
+ valueDate = formatter.parse("2023-01-27");
+ buyCurrency = Currency.EUR;
+ sellCurrency = Currency.EUR;
+ buyAmount = 66686.33;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "004";
+ transactionDate = formatter.parse("2023-01-27");
+ valueDate = formatter.parse("2023-01-27");
+ buyCurrency = Currency.EUR;
+ sellCurrency = Currency.EUR;
+ buyAmount = 3016.38;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "005";
+ transactionDate = formatter.parse("2023-01-30");
+ valueDate = formatter.parse("2023-01-30");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 20204.75;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "006";
+ transactionDate = formatter.parse("2023-01-30");
+ valueDate = formatter.parse("2023-01-30");
+ buyCurrency = Currency.EUR;
+ sellCurrency = Currency.EUR;
+ buyAmount = 56502.34;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "007";
+ transactionDate = formatter.parse("2023-02-06");
+ valueDate = formatter.parse("2023-02-06");
+ buyCurrency = Currency.HUF;
+ sellCurrency = Currency.HUF;
+ buyAmount = 2672749.00;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "008";
+ transactionDate = formatter.parse("2023-02-10");
+ valueDate = formatter.parse("2023-02-10");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 28573.73;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "009";
+ transactionDate = formatter.parse("2023-02-10");
+ valueDate = formatter.parse("2023-02-10");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 38.10;
+ sellAmount = 0.0;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "010";
+ transactionDate = formatter.parse("2023-03-29");
+ valueDate = formatter.parse("2023-03-29");
+ buyCurrency = Currency.EUR;
+ sellCurrency = Currency.EUR;
+ buyAmount = 0.0;
+ sellAmount = 199089.20;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "011";
+ transactionDate = formatter.parse("2023-03-31");
+ valueDate = formatter.parse("2023-03-31");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 0.0;
+ sellAmount = 85871.39;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "012";
+ transactionDate = formatter.parse("2023-05-17");
+ valueDate = formatter.parse("2023-05-17");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 0.0;
+ sellAmount = 18411.19;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ id = RandomStringUtils.random(8, "0123456789abcdef");
+ humanId = "013";
+ transactionDate = formatter.parse("2023-05-17");
+ valueDate = formatter.parse("2023-05-17");
+ buyCurrency = Currency.USD;
+ sellCurrency = Currency.USD;
+ buyAmount = 0.0;
+ sellAmount = 17928.59;
+ entity = Treasury.builder()
+ .id(id)
+ .humanId(humanId)
+ .buyCurrency(buyCurrency)
+ .sellCurrency(sellCurrency)
+ .transactionDate(transactionDate)
+ .valueDate(valueDate)
+ .buyAmount(buyAmount)
+ .sellAmount(sellAmount)
+ .build();
+ result.add(entity);
+
+ return result;
+ }
+
+
@Override
public List<Treasury> getRandom() {
int count = RandomUtils.nextInt(2, 5);
}
return result;
}
+
+ @Override
+ public Treasury getByHumanId(String id) {
+ return getAll().stream().filter(p -> p.getHumanId().equals(id)).findFirst().get();
+ }
+
+ @Override
+ public List<Treasury> getByHumanIds(String[] ids) {
+ List<Treasury> result = new ArrayList<>();
+
+ for (String i : ids) {
+ result.add(getByHumanId(i));
+ }
+
+ return result;
+ }
}