PageSourceSearch

https://hudsonvalleycraft.com/cellarboard/_next/static/chunks/profit-loss-5pwBP8WK.js

js hudsonvalleycraft.com collected 2026-10-09 23:14:05 UTC 5,229 bytes, 1 lines download raw bytes

1import{i as e}from"./utils-DCILHpx1.js";import{c as t,l as n,u as r}from"./contract-DZ_G02Mm.js";import{Q as i,Y as a,et as o}from"./demo-notice-Dqfoe0YN.js";var s=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),c=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),l=e=>!!e&&[`owner`,`admin`].includes(e.role),u=e=>e===`Soda`||e===`Tea`?0:null,d=e=>24*e/3968;function f(e){let i=new Map(r(e).map(e=>[e.id,e]));for(let r of e.batches)if(r.status!==`Cancelled`&&r.beer.trim()&&!i.has(n(r))){let n=t(r,``,e.items);i.set(n.id,n)}return[...i.values()].sort((e,t)=>e.beer.localeCompare(t.beer)||e.customer.localeCompare(t.customer))}function p(e,t){let n=new Map;for(let r of t)(e.items.find(e=>e.id===r.itemId)?.category??r.category)!==`Packaging`&&n.set(r.itemId,(n.get(r.itemId)||0)+r.qty);let r=e.pos.map((e,t)=>({po:e,index:t})).filter(({po:e})=>e.status!==`Cancelled`&&!e.autoManaged&&!e.mergedInto).sort((e,t)=>(t.po.costUpdatedAt||``).localeCompare(e.po.costUpdatedAt||``)||t.index-e.index),i=[...n].map(([t,n])=>{let i=e.items.find(e=>e.id===t),a=r.find(({po:e})=>e.lines.some(e=>e.itemId===t)),o=a?.po.lines.find(e=>e.itemId===t)?.cost,s=!!i&&Number.isFinite(n)&&n>0&&o!==void 0&&Number.isFinite(o)&&o>0;return{id:t,name:i?.name||`Missing ingredient`,qty:n,unit:i?.unit||``,unitCost:s?o:null,cost:s?n*o:null,source:a?`${a.po.number} · ${a.po.status}`:`Purchase price needed`}}),a=i.filter(e=>e.cost===null).map(e=>e.name);return i.length||a.push(`No ingredients entered`),{lines:i,missing:a,total:a.length?null:i.reduce((e,t)=>e+(t.cost??0),0)}}function m(e,t){let r=[...e.batches].reverse().find(e=>e.status!==`Cancelled`&&n(e)===t.id&&e.brewSheet),i=r?.brewSheet?o(r.brewSheet).canSizeOz:16;return{recipeId:t.id,casePrice:null,sixthPrice:u(t.beverage),halfPrice:null,canSizeOz:i===12?12:i===19.2?19.2:16,updatedAt:``}}function h(e,t,n,r=0){let i=e===null?null:e*t,a=i===null||n===null?null:n-i-r;return{ingredient:i,canCost:r,totalCost:i===null?null:i+r,profit:a,margin:a===null||n===null||n===0?null:a/n*100}}function g(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number.isFinite(Date.parse(e+`T12:00:00Z`))&&new Date(e+`T12:00:00Z`).toISOString().slice(0,10)===e}function _(e,t){let r=t.status!==`Packaged`,{volume:o,factor:s,packages:c}=i(t),l=n(t),f=e.beveragePricing?.find(e=>e.recipeId===l),m=p(e,t.requirements),h=[],g=f?.sixthPrice??u(t.beverage),_=m.missing.length?[`Ingredient costs needed: `+m.missing.join(`, `)]:[];(!Number.isFinite(o)||o<=0)&&h.push(r?`Planned batch volume needed`:`Actual packaged volume needed`),c?c.kegMixValid||h.push(r?`Package counts exceed the planned batch volume`:`Package counts exceed the actual packaged volume`):h.push(`Case / keg packaging mix needed`);let v=c?c.cases+c.looseCans/24:0;v>0&&(f?.casePrice==null?h.push(`Selling price needed: case`):c.canSizeOz!==f.canSizeOz&&h.push(`Case price is for ${f.canSizeOz} oz cans; this batch uses ${c.canSizeOz} oz`)),(c?.sixthBblKegs??0)>0&&g===null&&h.push(`Selling price needed: 1/6 bbl keg`),(c?.halfBblKegs??0)>0&&f?.halfPrice==null&&h.push(`Selling price needed: 1/2 bbl keg`),c&&v+c.sixthBblKegs+c.halfBblKegs===0&&h.push(`No full packages recorded`);let y=h.length?null:v*(f?.casePrice??0)+(c?.sixthBblKegs??0)*(g??0)+(c?.halfBblKegs??0)*(f?.halfPrice??0),b=!!c&&c.kegMixValid,x=b?(c.canSizeOz===f?.canSizeOz?v*(f?.casePrice??0):0)+c.sixthBblKegs*(g??0)+c.halfBblKegs*(f?.halfPrice??0):null,S=b?a(c.cans):null,C=m.total===null||S===null?null:m.total+S,w=y===null||C===null?null:y-C,T=c?v*d(c.canSizeOz)+c.sixthBblKegs/6+c.halfBblKegs*.5:0;return{batch:t,projected:r,volume:o,yieldFactor:s,date:r?t.packageDate:t.actualPackage,recipeId:l,packages:c,ingredientCost:m.total,canCost:S,totalCost:C,revenue:y,knownRevenue:x,profit:w,margin:w===null||!y?null:w/y*100,issues:[..._,...h],unpricedVolume:Math.max(0,o-T)}}function v(e,t,n){if(!g(t)||!g(n)||t>n)throw Error(`Choose a valid start date on or before the end date.`);let r=e.batches.filter(e=>e.status!==`Cancelled`),i=e=>e.status===`Packaged`?e.actualPackage:e.packageDate,a=r.filter(e=>!g(i(e))).length,o=r.filter(e=>g(i(e))&&i(e)>=t&&i(e)<=n).map(t=>_(e,t)).sort((e,t)=>
1t.date.localeCompare(e.date)||e.batch.beer.localeCompare(t.batch.beer)),s=o.filter(e=>e.profit!==null),c=s.reduce((e,t)=>e+t.revenue,0),l=s.reduce((e,t)=>e+t.ingredientCost,0),u=s.reduce((e,t)=>e+t.canCost,0),d=l+u;return{rows:o,undated:a,included:s.length,excluded:o.length-s.length,revenue:c,ingredientCost:l,canCost:u,cost:d,profit:c-d,margin:c?(c-d)/c*100:null}}function y(e){let t=new Map;for(let n of e)t.set(n.recipeId,[...t.get(n.recipeId)||[],n]);return[...t].map(([e,t])=>{let n=t.every(e=>e.totalCost!==null)?t.reduce((e,t)=>e+t.totalCost,0):null,r=t.every(e=>e.revenue!==null),i=t.some(e=>e.knownRevenue!==null)?t.reduce((e,t)=>e+(t.knownRevenue??0),0):null,a=t.every(e=>e.profit!==null)?t.reduce((e,t)=>e+t.profit,0):null;return{recipeId:e,name:t[0].batch.beer,customer:t[0].batch.customer,batches:t.length,cost:n,revenue:i,revenueComplete:r,profit:a,margin:a===null||!i?null:a/i*100,issues:[...new Set(t.flatMap(e=>e.issues))]}}).sort((e,t)=>e.name.localeCompare(t.name))}export{p as a,f as c,c as d,s as f,u as i,y as l,l as n,g as o,m as r,h as s,d as t,v as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.