---
# System prepended metadata

title: Bulk Order Improvement

---

# Bulk Order Improvement

## Existing Flow

```plantuml
participant "frontend" as fe
participant "evm-asgard" as asgard
participant "AWS S3" as s3
participant "everpro-logistic-client" as elc

fe -> asgard : upload file from user
activate asgard
asgard -> s3 : put the file to S3 bucket
s3 ---> asgard : success
asgard -> fe : upload success
deactivate asgard
fe -> fe : parse excel file
fe -> elc : send the data to validate
activate elc
note right
see /v1/public/shipment/validate/excel flow
endnote
elc -> fe : return validated order
deactivate elc
```

## New Flow 1

```plantuml
participant "frontend" as fe
participant "everpro-logistic-client" as elc
database "popaket_logistic" as db
participant "everpro-user" as eu
participant "evm-gss" as gss
participant "everpro-rts-scoring" as rtsScoring
participant "AWS S3" as s3

fe -> elc : upload the excel file
activate elc
elc -> elc : parse the file
elc -> s3 : upload to S3 bucket
note left: in paralel
group existing process validate excel at handler layer
elc -> db : (settingUsecase) get logistic insurance setting from table insurance_settings
db ---> elc
elc -> db : (settingUsecase) get shipment setting from table shipment_settings
db --> elc
elc --> db : (settingUsecase) get package insurance markup from table package_insurance_markup_settings
db --> elc
end group
group existing method ValidateExcelCreateOrder
elc -> eu : call grpc method GetUserByUserId to get user data
eu --> elc
elc -> elc : KYC validation
elc -> db : bulk checking unique reference number is exist
db --> elc
    group loop
        elc -> gss : find origin location data for courier coverage
        gss --> elc
        elc -> gss : find destination location data for courier coverage
        gss --> elc
        elc -> elc : validate required field (nama pengirim wajib diisi, etc)
        elc -> rtsScoring : check RTS score for this route
        rtsScoring --> elc
        alt if data is valid
            elc -> elc : call method GetRateV6()
        end
    end group
end group
elc -> fe : return back the data
deactivate elc
```

## New Flow 2

```plantuml
participant "frontend" as fe
participant "everpro-utility" as utility
database "redis" as redis
participant "everpro-logistic-client" as elc
database "popaket_logistic" as db
participant "everpro-user" as eu
participant "evm-gss" as gss
participant "everpro-rts-scoring" as rtsScoring
participant "AWS S3" as s3

fe -> utility : upload excel file
activate utility
utility -> utility : parse the uploaded file
utility -> s3 : put the file to S3
utility -> utility : generate the upload ID
utility -> redis : set the parsed data from file to redis (upload ID as key)
utility -> fe : return the upload ID
deactivate utility
fe -> elc : hit /v2/public/shipment/validate/excel with upload id
activate elc
group existing process from validate excel at handler layer
elc -> db : (settingUsecase) get logistic insurance setting from table insurance_settings
db ---> elc
elc -> db : (settingUsecase) get shipment setting from table shipment_settings
db --> elc
elc --> db : (settingUsecase) get package insurance markup from table package_insurance_markup_settings
db --> elc
end group
elc -> elc : call ValidateExcelCreateOrder() with upload ID
elc -> redis : retrive the data from redis
redis --> elc
group existing method ValidateExcelCreateOrder
elc -> eu : call grpc method GetUserByUserId to get user data
eu --> elc
elc -> elc : KYC validation
elc -> db : bulk checking unique reference number is exist
db --> elc
    group loop
        elc -> gss : find origin location data for courier coverage
        gss --> elc
        elc -> gss : find destination location data for courier coverage
        gss --> elc
        elc -> elc : validate required field (nama pengirim wajib diisi, etc)
        elc -> rtsScoring : check RTS score for this route
        rtsScoring --> elc
        alt if data is valid
            elc -> elc : call method GetRateV6()
        end
    end group
end group
elc -> fe : return back the data
deactivate elc
```

## Flow in /v1/public/shipment/validate/excel

```plantuml
participant "frontend" as fe
participant "everpro-logistic-client" as elc
database "popaket_logistic" as db
participant "everpro-user" as eu
participant "evm-gss" as gss
participant "everpro-rts-scoring" as rtsScoring

fe -> elc : hit validate excel
activate elc
elc -> db : (settingUsecase) get logistic insurance setting from table insurance_settings
db ---> elc
elc -> db : (settingUsecase) get shipment setting from table shipment_settings
db --> elc
elc --> db : (settingUsecase) get package insurance markup from table package_insurance_markup_settings
db --> elc
group logisticUsecase ValidateExcelCreateOrder
elc -> eu : call grpc method GetUserByUserId to get user data
eu --> elc
elc -> elc : KYC validation
elc -> db : bulk checking unique reference number is exist
db --> elc
    group loop
        elc -> gss : find origin location data for courier coverage
        gss --> elc
        elc -> gss : find destination location data for courier coverage
        gss --> elc
        elc -> elc : validate required field (nama pengirim wajib diisi, etc)
        elc -> rtsScoring : check RTS score for this route
        rtsScoring --> elc
        alt if data is valid
            elc -> elc : call method GetRateV6()
        end
    end group
end group
elc -> fe : return back the data + rate
deactivate elc
```