From: karolykele Date: Fri, 12 May 2023 13:21:49 +0000 (+0200) Subject: Treasury manual test data implemented X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=d02c79b0bf07f0c96643b6d8af94be0d3def7089;p=sly-crm.git Treasury manual test data implemented --- diff --git a/lis-db/src/main/java/hu/user/lis/db/Treasury.java b/lis-db/src/main/java/hu/user/lis/db/Treasury.java index 9572229..7e59c59 100644 --- a/lis-db/src/main/java/hu/user/lis/db/Treasury.java +++ b/lis-db/src/main/java/hu/user/lis/db/Treasury.java @@ -11,6 +11,7 @@ import java.util.Date; @NoArgsConstructor public class Treasury { String id; + String humanId; double buyAmount; Currency buyCurrency; double sellAmount; diff --git a/lis-services/src/main/java/hu/user/lis/services/data/ProjectServiceImpl.java b/lis-services/src/main/java/hu/user/lis/services/data/ProjectServiceImpl.java index 49e337a..ea59bd3 100644 --- a/lis-services/src/main/java/hu/user/lis/services/data/ProjectServiceImpl.java +++ b/lis-services/src/main/java/hu/user/lis/services/data/ProjectServiceImpl.java @@ -2,6 +2,7 @@ package hu.user.lis.services.data; import hu.user.lis.db.Partner; import hu.user.lis.db.Project; +import hu.user.lis.db.Treasury; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -150,6 +151,7 @@ public class ProjectServiceImpl extends DataServiceImpl implements Proj .partner(partner) .incomingInvoices(invoiceService.getByHumanIds(new String[]{"EURSZLA0177/2022","19044","9171058452","9171058628","2022-SOV/000495","2022-SOV/000496","E-SYMPR-2022-105"})) // EURSZLA0177/2022, 19044, 9171058452, 9171058628, V-SZ3-2022/00001, 2022-SOV/000495, 2022-SOV/000496, E-SYMPR-2022-105 .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-12","E-USER-2023-13"})) // E-USER-2023-12, E-USER-2023-13 + .treasuries(treasuryService.getByHumanIds(new String[]{"001","002","003","004","005","006","007","008","009","010","011"})) .build(); result.add(entity); @@ -184,6 +186,7 @@ public class ProjectServiceImpl extends DataServiceImpl implements Proj .partner(partner) .incomingInvoices(invoiceService.getByHumanIds(new String[]{"2023-SOV/000123"})) // 2023-SOV/000123 .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-95"})) // E-USER-2023-95 + .treasuries(treasuryService.getByHumanIds(new String[]{"012","013"})) .build(); result.add(entity); diff --git a/lis-services/src/main/java/hu/user/lis/services/data/TreasuryService.java b/lis-services/src/main/java/hu/user/lis/services/data/TreasuryService.java index 7b0d08c..97a2a2e 100644 --- a/lis-services/src/main/java/hu/user/lis/services/data/TreasuryService.java +++ b/lis-services/src/main/java/hu/user/lis/services/data/TreasuryService.java @@ -16,4 +16,7 @@ public interface TreasuryService { Treasury copy(Treasury sourceEntity, String property, Object value); List getRandom(); + Treasury getByHumanId(String id); + + List getByHumanIds(String[] ids); } diff --git a/lis-services/src/main/java/hu/user/lis/services/data/TreasuryServiceImpl.java b/lis-services/src/main/java/hu/user/lis/services/data/TreasuryServiceImpl.java index 57402bb..221a6bc 100644 --- a/lis-services/src/main/java/hu/user/lis/services/data/TreasuryServiceImpl.java +++ b/lis-services/src/main/java/hu/user/lis/services/data/TreasuryServiceImpl.java @@ -2,6 +2,7 @@ package hu.user.lis.services.data; 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; @@ -31,7 +32,7 @@ public class TreasuryServiceImpl extends DataServiceImpl implements Tr public List getAll() { if (entities == null) { try { - entities = generate(); + entities = generate2(); } catch (ParseException e) { log.catching(e); } @@ -78,6 +79,275 @@ public class TreasuryServiceImpl extends DataServiceImpl implements Tr return result; } + private List generate2() throws ParseException { + + List 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 getRandom() { int count = RandomUtils.nextInt(2, 5); @@ -89,4 +359,20 @@ public class TreasuryServiceImpl extends DataServiceImpl implements Tr } return result; } + + @Override + public Treasury getByHumanId(String id) { + return getAll().stream().filter(p -> p.getHumanId().equals(id)).findFirst().get(); + } + + @Override + public List getByHumanIds(String[] ids) { + List result = new ArrayList<>(); + + for (String i : ids) { + result.add(getByHumanId(i)); + } + + return result; + } }