asd
This commit is contained in:
commit
3e4a056b14
67 files changed
+13926
No files matched your search
@@ -0,0 +1,71 @@
|
||||
# Recalculates the official branch workbook with Microsoft Excel for a grid of
|
||||
# nominal x tenor inputs and writes the results to tests/excel-fixtures.json.
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File tests\export-excel-fixtures.ps1 [-Workbook <path>]
|
||||
param(
|
||||
[string]$Workbook = "$env:USERPROFILE\Downloads\CALCULATOR CASHBACK SERUB KANTOR CABANG 22092026.xlsx",
|
||||
[string]$Out = (Join-Path $PSScriptRoot 'excel-fixtures.json')
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Work on a temp copy so the original file is never touched.
|
||||
$tmp = Join-Path $env:TEMP ("serubi-" + [guid]::NewGuid().ToString() + ".xlsx")
|
||||
Copy-Item -LiteralPath $Workbook -Destination $tmp
|
||||
|
||||
$nominals = @(100000, 500000, 999999, 1000000, 10000000, 49999999, 50000000, 55000000, 99999999,
|
||||
100000000, 100000001, 150000000, 250000000, 250000001, 300000000, 499999999, 500000000,
|
||||
500000001, 750000000, 999999999, 1000000000, 1000000001, 1500000000, 1999999999,
|
||||
2000000000, 2000000001, 5000000000, 10000000000, 50000000000, 50000000001, 100000000000)
|
||||
$tenors = @(1, 3, 6, 12, 24)
|
||||
|
||||
function V($cell) {
|
||||
$v = $cell.Value2
|
||||
if ($v -is [int] -and $v -lt -2000000000) { return $null } # COM error codes (#VALUE!, ...)
|
||||
if ($cell.Text -like '#*') { return $null }
|
||||
if ($v -is [string] -and $v -eq '') { return $null }
|
||||
return $v
|
||||
}
|
||||
|
||||
$xl = New-Object -ComObject Excel.Application
|
||||
$xl.Visible = $false
|
||||
$xl.DisplayAlerts = $false
|
||||
try {
|
||||
$wb = $xl.Workbooks.Open($tmp)
|
||||
$calc = $wb.Worksheets.Item('CALCULATOR CASHBACK SERUBI')
|
||||
$cob = $wb.Worksheets.Item('COB')
|
||||
$rows = @()
|
||||
foreach ($t in $tenors) {
|
||||
foreach ($n in $nominals) {
|
||||
$calc.Range('A6').Value2 = [double]$n
|
||||
$calc.Range('B6').Value2 = [double]$t
|
||||
$xl.Calculate()
|
||||
$rows += [ordered]@{
|
||||
nominal = $n; tenor = $t
|
||||
cashbackGross = V $calc.Range('C6'); cashbackNet = V $calc.Range('D6')
|
||||
giroNet = V $calc.Range('E6'); simanjaNet = V $calc.Range('F6'); simpedaNet = V $calc.Range('G6'); depositoNet = V $calc.Range('H6')
|
||||
totalGiro = V $calc.Range('B10'); totalSimanja = V $calc.Range('B11'); totalSimpeda = V $calc.Range('B12'); totalDeposito = V $calc.Range('B13')
|
||||
rateGiro = V $calc.Range('C10'); rateSimanja = V $calc.Range('C11'); rateSimpeda = V $calc.Range('C12')
|
||||
equiv = V $calc.Range('D10')
|
||||
totalRateGiro = V $calc.Range('E10'); totalRateSimanja = V $calc.Range('E11'); totalRateSimpeda = V $calc.Range('E12')
|
||||
rateDeposito = V $calc.Range('F10')
|
||||
penaltyRefund = V $calc.Range('B19'); penaltyTax = V $calc.Range('B20'); penaltyFee = V $calc.Range('B21'); penaltyTotal = V $calc.Range('B22')
|
||||
shareNasabah = V $cob.Range('I35'); shareBank = V $cob.Range('I34')
|
||||
income = V $cob.Range('F38'); puabIncome = V $cob.Range('F31'); creditIncome = V $cob.Range('F36')
|
||||
spreadSimanja = V $cob.Range('J29'); spreadSimpeda = V $cob.Range('N28'); spreadGiro = V $cob.Range('R28')
|
||||
depositoGross = V $cob.Range('L14')
|
||||
}
|
||||
}
|
||||
}
|
||||
$wb.Close($false)
|
||||
} finally {
|
||||
$xl.Quit()
|
||||
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($xl) | Out-Null
|
||||
Remove-Item -LiteralPath $tmp -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
$payload = [ordered]@{
|
||||
source = (Split-Path $Workbook -Leaf)
|
||||
generatedAt = (Get-Date).ToString('s')
|
||||
cases = $rows
|
||||
}
|
||||
$payload | ConvertTo-Json -Depth 5 | Out-File -FilePath $Out -Encoding utf8
|
||||
Write-Host ("Wrote {0} cases to {1}" -f $rows.Count, $Out)
|
||||
Reference in new issue
Block a user