Watch
1
0
Fork
You've already forked Seyyed_arc
0
forked from hesabix/arc
Seyyed_arc/extraScripts/migration/holoo2hesabix/scripts/clear-transient-invoice-fails.ps1
Babak Alizadeh a5875e7a3a Release Holoo2Hesabix 1.1.0 with production-ready accounting migration.
Harden Holoo-to-Hesabix document partition/mapping, sample E2E tooling, remove hardcoded SQL credentials from scripts, fix income AR account 10401, and publish Setup MSI 1.1.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 15:56:40 +03:30

25 lines
1.4 KiB
PowerShell

# Clear transient invoice failures from checkpoint (ASCII-safe).
param([int]$BusinessId = 6823, [string]$HolooDb = "Holoo1")
$ErrorActionPreference = "Stop"
$path = Join-Path $env:LOCALAPPDATA "Holoo2Hesabix\checkpoints\biz${BusinessId}_${HolooDb}.json"
if (-not (Test-Path $path)) { throw "checkpoint not found: $path" }
$cp = Get-Content $path -Raw -Encoding UTF8 | ConvertFrom-Json
$inv = $cp.Modules.Invoices; if (-not $inv) { $inv = $cp.modules.Invoices }
if (-not $inv) { throw "Invoices module missing" }
$failed = $inv.Failed; if (-not $failed) { $failed = $inv.failed }
$doneObj = $inv.Done; if (-not $doneObj) { $doneObj = $inv.done }
if (-not $failed) { Write-Host "No invoice failures."; exit 0 }
$removed = @()
foreach ($p in @($failed.PSObject.Properties)) {
$msg = [string]$p.Value
$isTransient = $msg -match "internal|timeout|502|503|504|\b500\b|Unavailable|canceled|cancelled|Task was canceled|A task was canceled"
if ($isTransient) { $removed += $p.Name }
}
foreach ($name in $removed) {
$failed.PSObject.Properties.Remove($name)
Write-Host "cleared: $name"
}
[IO.File]::WriteAllText($path, ($cp | ConvertTo-Json -Depth 100), [Text.UTF8Encoding]::new($false))
$remain = if ($failed) { @($failed.PSObject.Properties).Count } else { 0 }
$doneN = if ($doneObj) { @($doneObj.PSObject.Properties).Count } else { 0 }
Write-Host "Removed $($removed.Count); remaining=$remain; done=$doneN"