Skip to content

ESM0135-RAMESH/esm-sample-shipping-app

Repository files navigation

How to Run (Local)

Open 2 terminals: one for the API and one for the Web app.

1) Run the API

cd src/ShippingRules.API
dotnet run

API base URL:

  • http://localhost:8080
  • Swagger UI: http://localhost:8080 (root)

Port config:

2) Run the Web App (Blazor)

cd src/ShippingRules.Web
dotnet run

Web URL:

  • http://localhost:5014

API base for Web:

3) Run the MAUI App (Optional)

Install workload (one time):

dotnet workload install maui

Run:

cd src/ShippingRules.MAUI
dotnet run

MAUI API base URL:

  • Android emulator: http://10.0.2.2:8080/api
  • Desktop: http://localhost:8080/api

Config:


How to Use (Business Flow)

Step A — Create a Rule

Web:

MAUI:

API used:

Important inputs:

  • Rule Type (string): must match exactly (example: PortCharge, FreightCharge)
  • Precedence Level: 1=Vessel, 2=Port, 3=Principal, 4=Country, 5=Global
  • Effective From/To: date window for when the rule applies

Step B — Validate (Find Applicable Rule)

Web:

Pick:

  • Country / Port / Principal / Vessel (optional, depending on rule)
  • Rule Type
  • Effective Date

API used:

Step C — Calculate Cost (from Validate page)

In the same Validate page:

  • Enter Base Amount
  • Click Calculate Cost

API used:


Core Business Logic (Precedence)

Rule selection is handled by:

The system filters rules by:

  • RuleType
  • Effective range: EffectiveFrom <= EffectiveDate <= EffectiveTo (if set)
  • IsActive == true

Then it picks the most specific match by precedence:

  1. Vessel-specific
  2. Port-specific
  3. Principal-specific
  4. Country-specific
  5. Global default

Precedence consistency validation:


Cost Calculation

Formula (as implemented): $$\text{TotalCost}=\text{BaseRate}+(\text{BaseAmount}\times\frac{\text{Surcharge%}}{100})$$

Calculation helper:


Approval Workflow

If RequiresApproval = true on creation:

  • The rule is created as Pending / Inactive
  • It will not be applied until approved

Approve a rule:

Entity fields:


Conflict Detection (Overlap)

On create, the system checks for overlapping rules (same criteria + same RuleType + overlapping effective dates).
If conflicts exist, the API returns 409 Conflict with conflict details.

Repository support:


Multi-currency (FX Conversion)

Exchange rates are stored in:

API:

  • GET /api/master/fx-rate?from=USD&to=INR&at=2025-12-20T00:00:00Z

Cost conversion (optional):

  • POST /api/ShippingRules/calculate-cost with TargetCurrency

Bulk Simulation / Batch Validation

Batch cost calculation:

  • POST /api/ShippingRules/batch-calculate-cost

Implementation:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published