Skip to content

Commit

Permalink
[MODORDERS-892] Using the new transaction batch endpoint (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-git authored Feb 5, 2024
1 parent abe2ecf commit 5f4a125
Show file tree
Hide file tree
Showing 34 changed files with 349 additions and 870 deletions.
77 changes: 13 additions & 64 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@
"orders.item.delete"
],
"modulePermissions": [
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance.encumbrances.item.delete",
"finance.encumbrances.item.post",
"finance.encumbrances.item.put",
"finance.release-encumbrance.item.post",
"finance.order-transaction-summaries.item.put",
"orders-storage.purchase-orders.item.get",
"orders-storage.purchase-orders.item.delete",
"orders-storage.po-lines.collection.get",
Expand Down Expand Up @@ -220,22 +216,14 @@
"orders-storage.pieces.item.post",
"orders-storage.po-lines.collection.get",
"finance.funds.collection.get",
"finance.transactions.collection.get",
"finance.budgets.collection.get",
"finance.funds.budget.item.get",
"finance.encumbrances.item.delete",
"finance.encumbrances.item.post",
"finance.encumbrances.item.put",
"finance.pending-payments.item.put",
"finance.ledgers.current-fiscal-year.item.get",
"finance.fiscal-years.item.get",
"finance-storage.order-transaction-summaries.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance.invoice-transaction-summaries.item.put",
"finance.release-encumbrance.item.post",
"finance.expense-classes.collection.get",
"finance-storage.transactions.item.put",
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance-storage.ledgers.collection.get",
"finance-storage.budget-expense-classes.collection.get",
"inventory.instances.collection.get",
Expand Down Expand Up @@ -277,12 +265,8 @@
"orders.po-lines.item.delete"
],
"modulePermissions": [
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance.encumbrances.item.post",
"finance.release-encumbrance.item.post",
"finance.encumbrances.item.put",
"finance.order-transaction-summaries.item.put",
"finance.encumbrances.item.delete",
"orders-storage.purchase-orders.item.get",
"orders-storage.po-lines.item.get",
"orders-storage.po-lines.item.delete",
Expand Down Expand Up @@ -391,8 +375,7 @@
"acquisitions-units-storage.units.collection.get",
"acquisitions-units-storage.memberships.collection.get",
"orders-storage.purchase-orders.collection.get",
"finance.encumbrances.item.put",
"finance.order-transaction-summaries.item.put",
"finance.transactions.batch",
"finance.transactions.collection.get"
]
},
Expand All @@ -419,8 +402,7 @@
"inventory-storage.holdings.item.get",
"inventory-storage.items.item.post",
"inventory-storage.loan-types.collection.get",
"finance.encumbrances.item.put",
"finance.order-transaction-summaries.item.put",
"finance.transactions.batch",
"finance.transactions.collection.get",
"orders-storage.pieces.collection.get",
"orders-storage.pieces.item.put",
Expand Down Expand Up @@ -503,10 +485,7 @@
"inventory-storage.instance-statuses.collection.get",
"finance.funds.budget.item.get",
"finance.fiscal-years.item.get",
"finance.order-transaction-summaries.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance.encumbrances.item.put",
"finance.transactions.batch",
"finance-storage.ledgers.collection.get",
"orders-storage.pieces.item.post",
"orders-storage.pieces.collection.get",
Expand Down Expand Up @@ -553,10 +532,7 @@
"inventory-storage.holdings-sources.collection.get",
"inventory-storage.items.item.post",
"inventory-storage.instance-statuses.collection.get",
"finance.order-transaction-summaries.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance.encumbrances.item.put",
"finance.transactions.batch",
"finance-storage.ledgers.collection.get",
"orders-storage.pieces.item.get",
"orders-storage.pieces.item.post",
Expand Down Expand Up @@ -587,18 +563,12 @@
"inventory.items.collection.get",
"inventory-storage.holdings.item.get",
"inventory-storage.holdings.item.delete",
"finance.encumbrances.item.put",
"finance.encumbrances.item.post",
"finance.encumbrances.item.delete",
"finance.order-transaction-summaries.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance.funds.collection.get",
"finance.funds.budget.item.get",
"finance.fiscal-years.item.get",
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance-storage.ledgers.collection.get",
"finance-storage.order-transaction-summaries.item.get",
"orders-storage.pieces.item.delete",
"orders-storage.pieces.item.get",
"orders-storage.pieces.collection.get",
Expand Down Expand Up @@ -961,8 +931,8 @@
"modulePermissions": [
"configuration.entries.collection.get",
"finance-storage.funds.collection.get",
"finance.encumbrances.item.delete",
"finance.exchange-rate.item.get",
"finance.transactions.batch",
"finance.transactions.collection.get",
"orders-storage.purchase-orders.collection.get",
"orders-storage.po-lines.collection.get",
Expand Down Expand Up @@ -1126,11 +1096,7 @@
},
{
"id": "finance.transactions",
"version": "5.0"
},
{
"id": "finance.order-transaction-summaries",
"version": "1.2"
"version": "5.1"
},
{
"id": "finance.ledgers",
Expand Down Expand Up @@ -1164,10 +1130,6 @@
"id": "finance-storage.budget-expense-classes",
"version": "2.0"
},
{
"id": "finance-storage.transactions",
"version": "4.0"
},
{
"id": "finance.exchange-rate",
"version": "1.0"
Expand Down Expand Up @@ -1770,22 +1732,15 @@
"finance.funds.budget.item.get",
"finance.funds.collection.get",
"finance.budgets.collection.get",
"finance.encumbrances.item.delete",
"finance.encumbrances.item.post",
"finance.encumbrances.item.put",
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance.transactions.item.get",
"finance.ledgers.current-fiscal-year.item.get",
"finance.fiscal-years.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance-storage.ledgers.collection.get",
"finance-storage.order-transaction-summaries.item.get",
"finance.exchange-rate.item.get",
"finance.release-encumbrance.item.post",
"finance-storage.budget-expense-classes.collection.get",
"finance.expense-classes.collection.get",
"finance-storage.transactions.item.put",
"inventory.instances.collection.get",
"inventory.instances.item.post",
"inventory.items.collection.get",
Expand Down Expand Up @@ -1841,23 +1796,17 @@
"orders-storage.alerts.item.get",
"orders-storage.reporting-codes.item.get",
"configuration.entries.collection.get",
"finance.encumbrances.item.post",
"finance.encumbrances.item.put",
"finance.funds.budget.item.get",
"finance.funds.collection.get",
"finance.budgets.collection.get",
"finance.fiscal-years.item.get",
"finance.ledgers.current-fiscal-year.item.get",
"finance.transactions.batch",
"finance.transactions.collection.get",
"finance.transactions.item.get",
"finance.exchange-rate.item.get",
"finance.order-transaction-summaries.item.post",
"finance.order-transaction-summaries.item.put",
"finance-storage.order-transaction-summaries.item.get",
"finance.release-encumbrance.item.post",
"finance.expense-classes.collection.get",
"finance-storage.budget-expense-classes.collection.get",
"finance-storage.transactions.item.put",
"finance-storage.ledgers.collection.get",
"inventory.instances.collection.get",
"inventory.instances.item.post",
Expand Down
36 changes: 10 additions & 26 deletions src/main/java/org/folio/config/ApplicationConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
import org.folio.service.finance.transaction.PendingToPendingEncumbranceStrategy;
import org.folio.service.finance.transaction.ReceivingEncumbranceStrategy;
import org.folio.service.finance.transaction.TransactionService;
import org.folio.service.finance.transaction.summary.InvoiceTransactionSummariesService;
import org.folio.service.finance.transaction.summary.OrderTransactionSummariesService;
import org.folio.service.inventory.InventoryManager;
import org.folio.service.inventory.InventoryService;
import org.folio.service.invoice.InvoiceLineService;
Expand Down Expand Up @@ -235,11 +233,10 @@ BudgetRestrictionService budgetRestrictionService() {

@Bean
EncumbranceService encumbranceService(TransactionService transactionService,
OrderTransactionSummariesService orderTransactionSummariesService,
InvoiceLineService invoiceLineService,
OrderInvoiceRelationService orderInvoiceRelationService,
FiscalYearService fiscalYearService) {
return new EncumbranceService(transactionService, orderTransactionSummariesService, invoiceLineService, orderInvoiceRelationService, fiscalYearService);
return new EncumbranceService(transactionService, invoiceLineService, orderInvoiceRelationService, fiscalYearService);
}

@Bean
Expand Down Expand Up @@ -271,22 +268,10 @@ TransactionService transactionService(RestClient restClient) {
return new TransactionService(restClient);
}

@Bean
OrderTransactionSummariesService transactionSummariesService(RestClient restClient) {
return new OrderTransactionSummariesService(restClient);
}

@Bean
InvoiceTransactionSummariesService invoiceTransactionSummariesService(RestClient restClient) {
return new InvoiceTransactionSummariesService(restClient);
}

@Bean
EncumbranceWorkflowStrategy openToPendingEncumbranceStrategy(EncumbranceService encumbranceService,
OrderTransactionSummariesService orderTransactionSummariesService,
EncumbranceRelationsHoldersBuilder encumbranceRelationsHoldersBuilder) {
return new OpenToPendingEncumbranceStrategy(encumbranceService, orderTransactionSummariesService,
encumbranceRelationsHoldersBuilder);
return new OpenToPendingEncumbranceStrategy(encumbranceService, encumbranceRelationsHoldersBuilder);
}

@Bean
Expand Down Expand Up @@ -326,10 +311,8 @@ EncumbranceWorkflowStrategy pendingToOpenEncumbranceStrategy(EncumbranceService

@Bean
EncumbranceWorkflowStrategy openToClosedEncumbranceStrategy(EncumbranceService encumbranceService,
EncumbranceRelationsHoldersBuilder encumbranceRelationsHoldersBuilder,
OrderTransactionSummariesService orderTransactionSummariesService) {
return new OpenToClosedEncumbranceStrategy(encumbranceService, encumbranceRelationsHoldersBuilder,
orderTransactionSummariesService);
EncumbranceRelationsHoldersBuilder encumbranceRelationsHoldersBuilder) {
return new OpenToClosedEncumbranceStrategy(encumbranceService, encumbranceRelationsHoldersBuilder);
}

@Bean
Expand Down Expand Up @@ -372,11 +355,9 @@ OrderReEncumberService orderReEncumberService(PurchaseOrderStorageService purcha
LedgerRolloverProgressService ledgerRolloverProgressService,
PurchaseOrderLineService purchaseOrderLineService,
TransactionService transactionService,
OrderTransactionSummariesService orderTransactionSummariesService,
BudgetRestrictionService budgetRestrictionService) {
return new OrderReEncumberService(purchaseOrderStorageService, reEncumbranceHoldersBuilder, ledgerRolloverErrorService,
ledgerRolloverProgressService, purchaseOrderLineService, transactionService,
orderTransactionSummariesService, budgetRestrictionService);
ledgerRolloverProgressService, purchaseOrderLineService, transactionService, budgetRestrictionService);
}

@Bean
Expand Down Expand Up @@ -739,8 +720,11 @@ OrderTemplatesService orderTemplatesService() {
return new PoLineInvoiceLineHolderBuilder(invoiceLineService);
}

@Bean POLInvoiceLineRelationService polInvoiceLineRelationService(InvoiceLineService invoiceLineService, PendingPaymentService pendingPaymentService, InvoiceTransactionSummariesService invoiceTransactionSummariesService, PoLineInvoiceLineHolderBuilder poLineInvoiceLineHolderBuilder) {
return new POLInvoiceLineRelationService(invoiceLineService, pendingPaymentService, invoiceTransactionSummariesService, poLineInvoiceLineHolderBuilder);
@Bean POLInvoiceLineRelationService polInvoiceLineRelationService(InvoiceLineService invoiceLineService,
PendingPaymentService pendingPaymentService, PoLineInvoiceLineHolderBuilder poLineInvoiceLineHolderBuilder,
TransactionService transactionService) {
return new POLInvoiceLineRelationService(invoiceLineService, pendingPaymentService, poLineInvoiceLineHolderBuilder,
transactionService);
}

@Bean
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/folio/helper/PurchaseOrderLineHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,14 @@ public Future<Void> updateOrderLine(CompositePoLine compOrderLine, RequestContex
private Future<Void> updateEncumbranceStatus(CompositePoLine compOrderLine, JsonObject lineFromStorage,
RequestContext requestContext) {
PoLine poLine = lineFromStorage.mapTo(PoLine.class);
if(isReleaseEncumbrances(compOrderLine, poLine)) {
if (isReleaseEncumbrances(compOrderLine, poLine)) {
logger.info("Encumbrances releasing for poLineId={} where paymentStatus={}", compOrderLine.getId(), compOrderLine.getPaymentStatus());
return encumbranceService.getPoLineUnreleasedEncumbrances(compOrderLine.getId(), requestContext)
.compose(transactionList -> encumbranceService.updateOrderTransactionSummary(compOrderLine, transactionList, requestContext)
.compose(v -> encumbranceService.releaseEncumbrances(transactionList, requestContext)));
.compose(transactionList -> encumbranceService.releaseEncumbrances(transactionList, requestContext));
} else if (isUnreleasedEncumbrances(compOrderLine, poLine)) {
logger.info("Encumbrances unreleasing for poLineId={} where paymentStatus={}", compOrderLine.getId(), compOrderLine.getPaymentStatus());
return encumbranceService.getPoLineReleasedEncumbrances(compOrderLine, requestContext)
.compose(transactionList -> encumbranceService.updateOrderTransactionSummary(compOrderLine, transactionList, requestContext)
.compose(v -> encumbranceService.unreleaseEncumbrances(transactionList, requestContext)));
.compose(transactionList -> encumbranceService.unreleaseEncumbrances(transactionList, requestContext));
}
return Future.succeededFuture();
}
Expand Down
16 changes: 2 additions & 14 deletions src/main/java/org/folio/models/EncumbrancesProcessingHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import org.folio.rest.acq.model.finance.Transaction;

import com.google.common.collect.ImmutableList;

public class EncumbrancesProcessingHolder {
private List<Transaction> encumbrancesFromStorage;
private List<Transaction> encumbrancesForRelease;
private List<EncumbranceRelationsHolder> encumbrancesForCreate;
private List<EncumbranceRelationsHolder> encumbrancesForDelete;
Expand All @@ -18,7 +15,6 @@ public class EncumbrancesProcessingHolder {
private List<Transaction> encumbrancesToReleaseAfter;

public EncumbrancesProcessingHolder() {
this.encumbrancesFromStorage = new ArrayList<>();
this.encumbrancesForCreate = new ArrayList<>();
this.encumbrancesForDelete = new ArrayList<>();
this.encumbrancesForUpdate = new ArrayList<>();
Expand Down Expand Up @@ -63,11 +59,6 @@ public EncumbrancesProcessingHolder withEncumbrancesForRelease(List<Transaction>
return this;
}

public EncumbrancesProcessingHolder withEncumbrancesFromStorage(List<Transaction> encumbrancesFromStorage) {
this.encumbrancesFromStorage = new ArrayList<>(encumbrancesFromStorage);
return this;
}

public EncumbrancesProcessingHolder withEncumbrancesForUnrelease(List<Transaction> encumbrancesForUnrelease) {
this.encumbrancesForUnrelease = new ArrayList<>(encumbrancesForUnrelease);
return this;
Expand Down Expand Up @@ -113,10 +104,7 @@ public List<Transaction> getEncumbrancesToUnreleaseAfter() {

public int getAllEncumbrancesQuantity() {
return encumbrancesForCreate.size() + encumbrancesForUpdate.size()
+ encumbrancesForRelease.size() + encumbrancesForUnrelease.size();
}

public List<Transaction> getEncumbrancesFromStorage() {
return ImmutableList.copyOf(encumbrancesFromStorage);
+ encumbrancesForRelease.size() + encumbrancesForUnrelease.size()
+ encumbrancesForDelete.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ private ResourcePathResolver() {
public static final String PAYMENT_STATUS = "paymentStatus";
public static final String ORDER_TEMPLATES = "orderTemplates";
public static final String TITLES = "titles";
public static final String ENCUMBRANCES = "finance.encumbrances";
public static final String FUNDS = "finance.funds";
public static final String BUDGETS = "finance.budgets";
public static final String LEDGERS = "finance.ledgers";
public static final String ORDER_TRANSACTION_SUMMARIES = "finance.order-summaries";
public static final String REASONS_FOR_CLOSURE = "configuration.reasons-for-closure";
public static final String PREFIXES = "configuration.prefixes";
public static final String SUFFIXES = "configuration.suffixes";
public static final String TRANSACTIONS_ENDPOINT = "finance.transactions";
public static final String USER_TENANTS_ENDPOINT = "user.tenants";
public static final String FINANCE_RELEASE_ENCUMBRANCE = "finance.release-encumbrance";
public static final String FINANCE_BATCH_TRANSACTIONS = "finance.batch-all-or-nothing";
public static final String BUDGET_EXPENSE_CLASSES = "finance-storage.budget-expense-classes";
public static final String CURRENT_BUDGET = "finance.current-budgets";
public static final String FINANCE_EXCHANGE_RATE = "finance/exchange-rate";
Expand Down Expand Up @@ -68,18 +66,16 @@ private ResourcePathResolver() {
apis.put(RECEIVING_HISTORY, "/orders-storage/receiving-history");
apis.put(PO_LINE_NUMBER, "/orders-storage/po-line-number");
apis.put(ORDER_TEMPLATES, "/orders-storage/order-templates");
apis.put(ENCUMBRANCES, "/finance/encumbrances");
apis.put(FUNDS, "/finance/funds");
apis.put(BUDGETS, "/finance/budgets");
apis.put(LEDGERS, "/finance-storage/ledgers");
apis.put(ORDER_TRANSACTION_SUMMARIES, "/finance/order-transaction-summaries");
apis.put(TITLES, "/orders-storage/titles");
apis.put(REASONS_FOR_CLOSURE, "/orders-storage/configuration/reasons-for-closure");
apis.put(PREFIXES, "/orders-storage/configuration/prefixes");
apis.put(SUFFIXES, "/orders-storage/configuration/suffixes");
apis.put(TRANSACTIONS_ENDPOINT, "/finance/transactions");
apis.put(USER_TENANTS_ENDPOINT, "/user-tenants");
apis.put(FINANCE_RELEASE_ENCUMBRANCE, "/finance/release-encumbrance");
apis.put(FINANCE_BATCH_TRANSACTIONS, "/finance/transactions/batch-all-or-nothing");
apis.put(BUDGET_EXPENSE_CLASSES, "/finance-storage/budget-expense-classes");
apis.put(CURRENT_BUDGET, "/finance/funds/%s/budget");
apis.put(FINANCE_EXCHANGE_RATE, "/finance/exchange-rate");
Expand Down
Loading

0 comments on commit 5f4a125

Please sign in to comment.