Fix incorrect order totals from hidden orphan lines
* chore: add one-time order total repair * fix: exclude hidden orphan lines from totals [order-total-fix] --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
d5265a1c11
commit
dbbc416676
42
.github/workflows/fix-order-total-v1774.yml
vendored
Normal file
42
.github/workflows/fix-order-total-v1774.yml
vendored
Normal 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
|
||||||
@ -7149,8 +7149,8 @@ body.sun-splitting *{cursor:col-resize!important}
|
|||||||
pane?.classList.add('sun-order-pane');
|
pane?.classList.add('sun-order-pane');
|
||||||
|
|
||||||
// Correct calculations: custom per-order item price is preferred over catalog price.
|
// Correct calculations: custom per-order item price is preferred over catalog price.
|
||||||
calcOrderTotal=function(){return (draft.lines||[]).reduce((sum,line)=>sum+unitPrice(line)*Math.max(0,Number(line.qty||0)),0)};
|
calcOrderTotal=function(){return (draft.lines||[]).reduce((sum,line)=>itemById(line.id)?sum+unitPrice(line)*Math.max(0,Number(line.qty||0)):sum,0)};
|
||||||
orderTotalValue=function(order){return (order?.lines||[]).reduce((sum,line)=>sum+unitPrice(line)*Math.max(0,Number(line.qty||0)),0)};
|
orderTotalValue=function(order){return (order?.lines||[]).reduce((sum,line)=>itemById(line.id)?sum+unitPrice(line)*Math.max(0,Number(line.qty||0)):sum,0)};
|
||||||
updateOrderSummary=function(){
|
updateOrderSummary=function(){
|
||||||
const total=calcOrderTotal(),paid=Math.max(0,Number(prepayment.value||0)),rest=Math.max(0,total-paid);
|
const total=calcOrderTotal(),paid=Math.max(0,Number(prepayment.value||0)),rest=Math.max(0,total-paid);
|
||||||
orderTotal.value=Math.round(total);balance.value=Math.round(rest);
|
orderTotal.value=Math.round(total);balance.value=Math.round(rest);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user