diff --git a/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/CostCenterConversionTaskItemTest.java b/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/CostCenterConversionTaskItemTest.java index 2bdf041f..d84a7bfb 100644 --- a/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/CostCenterConversionTaskItemTest.java +++ b/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/CostCenterConversionTaskItemTest.java @@ -69,7 +69,7 @@ void testNoCostCenterConversionSuccess() { @Test void testCostCenterConversionSuccess() { val txId = Transaction.id("1", "1"); - when(organisationPublicApiIF.findCostCenter("1", "1")).thenReturn(Optional.of(new OrganisationCostCenter(new OrganisationCostCenter.Id("1", "1"), "Cost Center 1", "2", null, null))); + when(organisationPublicApiIF.findCostCenter("1", "1")).thenReturn(Optional.of(new OrganisationCostCenter(new OrganisationCostCenter.Id("1", "1"), "Cost Center 1", "2", null, null, true))); val txItem1 = new TransactionItemEntity(); txItem1.setId(TransactionItem.id(txId, "0")); diff --git a/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/DocumentConversionTaskItemTest.java b/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/DocumentConversionTaskItemTest.java index 9ebb8151..c80ad10d 100644 --- a/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/DocumentConversionTaskItemTest.java +++ b/accounting_reporting_core/src/test/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/business_rules/items/DocumentConversionTaskItemTest.java @@ -219,14 +219,13 @@ void testDocumentConversionWithMultipleViolations() { } @Test - public void testDocumentConversionWithNoCurrenciInDocument() { - val txId = "1"; - val txInternalNumber = "txn123"; - val organisationId = "org1"; - val customerCurrencyCode = "UNKNOWN_CURRENCY"; - val customerVatCode = "UNKNOWN_VAT"; - - val document = Document.builder() + void testDocumentConversionWithNoCurrencyInDocument() { + String txId = "1"; + String txInternalNumber = "txn123"; + String organisationId = "org1"; + String customerVatCode = "UNKNOWN_VAT"; + + Document document = Document.builder() .vat(Vat.builder() .customerCode(customerVatCode) .build()) @@ -235,13 +234,13 @@ public void testDocumentConversionWithNoCurrenciInDocument() { .build()) .build(); - val txItem = new TransactionItemEntity(); + TransactionItemEntity txItem = new TransactionItemEntity(); txItem.setDocument(Optional.of(document)); - val items = new LinkedHashSet(); + LinkedHashSet items = new LinkedHashSet(); items.add(txItem); - val transaction = new TransactionEntity(); + TransactionEntity transaction = new TransactionEntity(); transaction.setId(txId); transaction.setTransactionInternalNumber(txInternalNumber); transaction.setOrganisation(Organisation.builder() diff --git a/docs/examples/cost_center_csv_example.csv b/docs/examples/cost_center_csv_example.csv index 701220a0..da7ee93e 100644 --- a/docs/examples/cost_center_csv_example.csv +++ b/docs/examples/cost_center_csv_example.csv @@ -1,2 +1,2 @@ -customer code,external customer code,name,parent customer code -12323,456,CostCenter,99 \ No newline at end of file +customer code,external customer code,name,parent customer code,active +12323,456,CostCenter,99,True \ No newline at end of file diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/csv/CostCenterUpdate.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/csv/CostCenterUpdate.java index bb6b095f..e2194ba0 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/csv/CostCenterUpdate.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/csv/CostCenterUpdate.java @@ -19,5 +19,7 @@ public class CostCenterUpdate { private String name; @CsvBindByName(column = "parent customer code") private String parentCustomerCode; + @CsvBindByName(column = "active") + private boolean active = true; } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/entity/OrganisationCostCenter.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/entity/OrganisationCostCenter.java index 2fa961a6..41d5299a 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/entity/OrganisationCostCenter.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/entity/OrganisationCostCenter.java @@ -49,6 +49,10 @@ public class OrganisationCostCenter extends CommonEntity implements Persistable< @Column(name = "parent_customer_code") private String parentCustomerCode; + @Column(name = "active") + @Builder.Default + private boolean active = true; + public Optional getParent() { return Optional.ofNullable(parent); } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java index 4d0d825a..7952d899 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java @@ -22,13 +22,16 @@ public class OrganisationCostCenterView { private OrganisationCostCenterView parentCustomerCode; + private boolean active; + private Problem error; public static OrganisationCostCenterView fromEntity(OrganisationCostCenter costCenter) { OrganisationCostCenterViewBuilder builder = OrganisationCostCenterView.builder() .customerCode(costCenter.getId() == null ? null : costCenter.getId().getCustomerCode()) .externalCustomerCode(costCenter.getExternalCustomerCode()) - .name(costCenter.getName()); + .name(costCenter.getName()) + .active(costCenter.isActive()); if (costCenter.getParent().isPresent()) { builder.parentCustomerCode(OrganisationCostCenterView.fromEntity(costCenter.getParent().get())); } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java index 80495da4..91bc3021 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java @@ -45,6 +45,7 @@ public OrganisationCostCenterView updateCostCenter(String orgId, CostCenterUpdat OrganisationCostCenter costCenter = costCenterFound.get(); costCenter.setExternalCustomerCode(costCenterUpdate.getExternalCustomerCode()); costCenter.setName(costCenterUpdate.getName()); + costCenter.setActive(costCenterUpdate.isActive()); // check if parent exists if (costCenterUpdate.getParentCustomerCode() != null) { Optional project = getCostCenter(orgId, costCenterUpdate.getParentCustomerCode()); @@ -87,7 +88,8 @@ public OrganisationCostCenterView insertCostCenter(String orgId, CostCenterUpdat OrganisationCostCenter.OrganisationCostCenterBuilder builder = OrganisationCostCenter.builder() .id(new OrganisationCostCenter.Id(orgId, costCenterUpdate.getCustomerCode())) .externalCustomerCode(costCenterUpdate.getExternalCustomerCode()) - .name(costCenterUpdate.getName()); + .name(costCenterUpdate.getName()) + .active(costCenterUpdate.isActive()); // check if parent exists if (costCenterUpdate.getParentCustomerCode() != null) { diff --git a/organisation/src/main/resources/db/migration/postgresql/common/V1.0_100_3_1__add_active_to_costcenter.sql b/organisation/src/main/resources/db/migration/postgresql/common/V1.0_100_3_1__add_active_to_costcenter.sql new file mode 100644 index 00000000..b0b8df91 --- /dev/null +++ b/organisation/src/main/resources/db/migration/postgresql/common/V1.0_100_3_1__add_active_to_costcenter.sql @@ -0,0 +1,4 @@ +ALTER TABLE organisation_cost_center +ADD COLUMN active BOOLEAN DEFAULT TRUE; +ALTER TABLE organisation_cost_center_aud + ADD COLUMN active BOOLEAN DEFAULT TRUE; \ No newline at end of file