forge/build-arma.ps1
Jacob Schmidt ff7ff0c4e5 Implement org credit line debt and bank repayment flow (#2)
## Summary

This finishes the org credit line workflow so it behaves like reserved treasury-backed credit instead of a simple member allowance.

## What changed

- reserve org funds immediately when a credit line is assigned
- track credit lines with:
  - approved amount
  - available amount
  - outstanding principal
  - interest rate
  - amount due
- consume reserved credit during store checkout without charging org funds a second time
- add credit line repayment through the bank app
- sync richer credit line state into org and bank payloads/UI
- keep legacy `amount` compatibility mapped to available credit for older consumers

## User-facing behavior

- assigning a credit line now reduces available org funds immediately
- spending on `credit_line` reduces available credit and creates debt with interest
- the bank app now shows outstanding credit debt and allows repayment from personal bank funds
- the org treasury view now shows reserved credit and outstanding due totals

## Validation

- `cargo fmt`
- `npm run build:webui`
- `cargo test -p forge-services --quiet`
- `cargo test -p forge-server --quiet`

## Follow-up checks

- validate in-game that assigning a credit line reduces org funds immediately
- validate store checkout with `credit_line` updates available credit and debt correctly
- validate bank repayment decreases player bank balance, increases org funds, and reduces amount due

Co-authored-by: Jacob Schmidt <innovativestudios@outlook.com>
Reviewed-on: #2
2026-04-02 16:50:38 -05:00

99 lines
2.4 KiB
PowerShell

#!/usr/bin/env pwsh
<#
.SYNOPSIS
Build both arma/client and arma/server using hemtt
.DESCRIPTION
This script runs hemtt build for both the client and server Arma mods.
It changes to each directory and runs the build command.
.PARAMETER Target
Specify which target to build: 'client', 'server', or 'both' (default)
.PARAMETER BuildUI
Rebuild the web UI bundles before running the client build.
.EXAMPLE
.\build-arma.ps1
Builds both client and server
.EXAMPLE
.\build-arma.ps1 -Target client
Builds only the client
.EXAMPLE
.\build-arma.ps1 -Target client -BuildUI
Rebuilds web UI bundles and then builds the client
#>
param(
[Parameter(Mandatory=$false)]
[ValidateSet('client', 'server', 'both')]
[string]$Target = 'both',
[Parameter(Mandatory=$false)]
[switch]$BuildUI
)
$ErrorActionPreference = "Stop"
$scriptDir = $PSScriptRoot
function Build-WebUIAssets {
Write-Host "`n=== Building Web UI Bundles ===" -ForegroundColor Cyan
Push-Location $scriptDir
try {
& npm run build:webui
if ($LASTEXITCODE -ne 0) {
throw "Web UI bundle build failed with exit code $LASTEXITCODE"
}
Write-Host "✓ Web UI bundles built successfully" -ForegroundColor Green
}
finally {
Pop-Location
}
}
function Build-HemttProject {
param(
[string]$ProjectPath,
[string]$ProjectName
)
Write-Host "`n=== Building $ProjectName ===" -ForegroundColor Cyan
Push-Location $ProjectPath
try {
& hemtt utils fnl && hemtt build
if ($LASTEXITCODE -ne 0) {
throw "hemtt build failed for $ProjectName with exit code $LASTEXITCODE"
}
Write-Host "$ProjectName build successful" -ForegroundColor Green
}
finally {
Pop-Location
}
}
$clientPath = Join-Path $scriptDir "arma\client"
$serverPath = Join-Path $scriptDir "arma\server"
try {
if ($Target -eq 'client' -or $Target -eq 'both') {
if ($BuildUI) {
Build-WebUIAssets
}
Build-HemttProject -ProjectPath $clientPath -ProjectName "Client"
}
if ($Target -eq 'server' -or $Target -eq 'both') {
Build-HemttProject -ProjectPath $serverPath -ProjectName "Server"
}
Write-Host "`n=== Build Complete ===" -ForegroundColor Green
}
catch {
Write-Host "`n✗ Build failed: $_" -ForegroundColor Red
exit 1
}