Table of Contents |
---|
Prerequisites
- GitHub account created and account part of a FOLIO organization and ThunderJet team.
- Clone ThunderJet modules and set workspace in the IDEA
- Create branch from "onboarding_<release_name>" with name "onboarding/<EPAM_login>" for acq-models, mod-invoice and mod-invoice-storage. Example : "onboarding_morning_glory" → "Andrei_Makaranka"
- You able to replace instances of the mod-invoice and mod-invoice-storage modules by your instance which run from IDEA.
...
The purpose of practical tasks in the implementation of CRUD API to insert/updating/obtaining the order line number with which the invoice line is associated.
Useful links and information
Full flow - Onboarding.postman_collection.json - Download this collection that allows you to create an order with an order line as well as an invoice and an invoice line based on the order line.
Apply last update from sub-module.PNG - How to set your sub module on specific commit or branch
Tasks
1.
...
Create/Update schema → mod-invoice-storage
First of all we need to define JSON schema "po_line_vs_invoice_line.json" for model which should contain next fields :
Name | Type | Mandatory | Description | Note |
---|---|---|---|---|
id | UUID | Y | Unique identifier. | This field is mandatory for RMB |
poLineId | UUID | Y | Reference on order line | |
poLineNumber | Pattern | Y | Number of the order line | The same pattern as in the po_line.json |
invoiceLineId | UUID | Y | Reference on invoice line | |
invoiceLineNumber | String | Y | Number of the invoice line |
On the FOLIO project JSON schema is used to define models which will be used as REST request/response and also save in the PostgreSQL : https://json-schema.org/
https://github.com/folio-org/acq-models → This is the central repository for the models of the various acquisition modules.
1.1 Please create schema "po_line_vs_invoice_line.json" in the mod-invoice-storage/schemas of theacq-models. Also add examplemod-invoice-storage/examples.
...
Note : Don't merge your PR and just provide for review
2. Define storage CRUD API → mod-invoice-storage
Storage modules in the FOLIO should contain logic for working only with the database.
2.1 Check out on branch "onboarding/<EPAM_login>" in the GIT sub-module : mod-invoice-storage\ramls\acq-models. Use Apply last update from sub-module.PNG replace branch "master" with your branch "<EPAM_login>"
2.2 Create new RAML file "mod-invoice-storage\ramls\po-line-invoice-line-connection.raml", where you should define new CRUD API.
...
Note : Don't merge your PR and just provide for review
! Important (issue with module upgrade and load sample and reference)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{{okapiprotocol}}://{{okapiurl}}:{{okapiport}}/_/proxy/tenants/{{xokapitenant}}/install?tenantParameters=loadSample=false,loadReference=false
12:49
@Override
public Future<Integer> loadData(TenantAttributes attributes, String tenantId, Map<String, String> headers, Context vertxContext) {
// log.info("postTenant");
// Vertx vertx = vertxContext.owner();
// Parameter parameter = new Parameter().withKey(PARAMETER_LOAD_SYSTEM).withValue("true");
// attributes.getParameters().add(parameter);
//
// TenantLoading tl = new TenantLoading();
// buildDataLoadingParameters(attributes, tl);
//
// DBClient client = new DBClient(vertxContext, headers);
//
// return Future.succeededFuture()
// .compose(v -> migration(attributes, "mod-invoice-storage-5.2.0",
// () -> migrationService.syncOrderPoNumbersWithInvoicePoNumbers(headers, vertxContext)))
// .compose(v -> {
//
// Promise<Integer> promise = Promise.promise();
//
// tl.perform(attributes, headers, vertx, res -> {
// if (res.failed()) {
// promise.fail(res.cause());
// } else {
// promise.complete(res.result());
// }
// });
// return promise.future();
// })
// .onFailure(throwable -> Future.failedFuture(throwable.getCause()));
return Future.succeededFuture(0);
} |
3. Define business GET APIs → mod-invoice
Business modules in the FOLIO should contain business logic, calls to his storage module (mod-invoice → mod-invoice-storage) and should call third modules by using business APIs of this module.
...
Note : Don't merge your PR and just provide for review
4. Add business logic to connect invoice line and order line → mod-invoice
Connection should be stored in the DB if invoice line created based on order line.
4.1 Business API for creating invoice line → POST /invoice/invoice-lines}. Please find controller and service method which responsible for creating invoice line.
4.2 Add logic to the method founded in 4.1, which should create connection between order line and invoice line in the DB. Please use Storage API from Task 2
4.3 Deploy module mod-invoice with your updates. Check that connection is created using Postman collection.
4.4 Commit and push new schema in the branch "onboarding/<EPAM_login>" and create PR in the "onboarding_<release_name>". In the PR attach screen that API works
Note : Don't merge your PR and just provide for review
5. Add DB transaction support → mod-invoice-storage
If we delete the invoice line, then we need to delete the links between the order line and the invoice line (delete record of "po_line_vs_invoice_line").
To ensure data consistency, this operation must be atomic and performed within a single database transaction.
45.1 Business API for deleting invoice line → DELETE /invoices/invoice-lines/{id} and finally Storage API will be invoked → DELETE /invoices-storage/invoice-lines/{id}.
45.2 Go to mod-invoice-storage and find method which responsible for deleting invoice line from database.
45.3 Update logic of the method which you found in 45.2 by adding method, which should delete record of "po_line_vs_invoice_line". Learn org.folio.rest.persist.DBClient implementation.
45.4 Deploy module mod-invoice-storage with your updates. Check that invoice line will be deleted with "po_line_vs_invoice_line" using Postman collection.
45.5 Commit and push new schema in the branch "onboarding/<EPAM_login>" and create PR in the "onboarding_<release_name>". In the PR attach screen that API works
Note : Don't merge your PR and just provide for review
...
6. Add validation business logic → mod-orders
Should not be possible delete order line (DELETED /orders/order-line/{id}) if there is connection between order line and invoice line.
56.1 Business API for deleting order line → DELETE /orders/order-line/{id}. Please find controller and service method which responsible for deleting order line.
5.2
...
6.2 Add logic to the method founded in 6.1, which should block deletion order line and return error to user.
6.3 Deploy module mod-invoice-storage with your updates. Check that is not possible delete order line if there is connection to invoice line using Postman collection.
6.4 Commit and push new schema in the branch "onboarding/<EPAM_login>" and create PR in the "onboarding_<release_name>". In the PR attach screen that API works
Note : Don't merge your PR and just provide for review