From e232a6d4196e9503ec0fd69fe7ead99d49094778 Mon Sep 17 00:00:00 2001 From: pavlov346346-source Date: Fri, 11 Sep 2026 10:51:27 +0300 Subject: [PATCH] chore: add one-time order total repair --- .github/workflows/fix-order-total-v1774.yml | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/fix-order-total-v1774.yml diff --git a/.github/workflows/fix-order-total-v1774.yml b/.github/workflows/fix-order-total-v1774.yml new file mode 100644 index 0000000..9232746 --- /dev/null +++ b/.github/workflows/fix-order-total-v1774.yml @@ -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