chore: add one-time order total repair

This commit is contained in:
pavlov346346-source 2026-09-11 10:51:27 +03:00
parent d5265a1c11
commit e232a6d419

View File

@ -0,0 +1,42 @@
name: Caterium One-Time Order Total Fix
on:
push:
branches: ["fix/order-total-orphan-lines-v1774"]
permissions:
contents: write
jobs:
repair:
if: ${{ !contains(github.event.head_commit.message, '[order-total-fix]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: fix/order-total-orphan-lines-v1774
fetch-depth: 0
- name: Exclude hidden orphan order lines from totals
shell: bash
run: |
node <<'NODE'
const fs=require('fs');
const path='public/index.html';
let src=fs.readFileSync(path,'utf8');
const from1="calcOrderTotal=function(){return (draft.lines||[]).reduce((sum,line)=>sum+unitPrice(line)*Math.max(0,Number(line.qty||0)),0)};";
const to1="calcOrderTotal=function(){return (draft.lines||[]).reduce((sum,line)=>itemById(line.id)?sum+unitPrice(line)*Math.max(0,Number(line.qty||0)):sum,0)};";
const from2="orderTotalValue=function(order){return (order?.lines||[]).reduce((sum,line)=>sum+unitPrice(line)*Math.max(0,Number(line.qty||0)),0)};";
const to2="orderTotalValue=function(order){return (order?.lines||[]).reduce((sum,line)=>itemById(line.id)?sum+unitPrice(line)*Math.max(0,Number(line.qty||0)):sum,0)};";
for(const [from,to] of [[from1,to1],[from2,to2]]){
const count=src.split(from).length-1;
if(count!==1) throw new Error(`Expected exactly one target occurrence, found ${count}`);
src=src.replace(from,to);
}
fs.writeFileSync(path,src);
NODE
- name: Commit total fix
shell: bash
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add public/index.html
git commit -m "fix: exclude hidden orphan lines from totals [order-total-fix]"
git push origin HEAD:fix/order-total-orphan-lines-v1774