1/*! For license information please see 6774.a7c303e6.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkDigi_Bakery=self.webpackChunkDigi_Bakery||[]).push([[6774],{28(e,t,r){r.d(t,{hS:()=>g});var a=r(9379),s=r(5043),n=r(7819),i=r(2054),o=r(6955),d=r(7719),l=r(7856),c=r(614),x=r(579);function m(e){let{isOpen:t,onClose:r,onConfirm:a,title:s,message:m,type:g="info",confirmText:h,cancelText:u,language:p="en"}=e;if(!t)return null;const b="confirm"===g,f={alert:{icon:n.A,gradient:"from-terracotta to-terracotta-dark",iconBg:"bg-terracotta/20",iconColor:"text-terracotta",primaryBtn:"bg-[var(--btn-primary-bg)] text-[var(--btn-primary-text)] border border-[var(--btn-primary-border)] hover:bg-[var(--btn-primary-hover-bg)]"},confirm:{icon:o.A,gradient:"from-sage to-sage-dark",iconBg:"bg-sage/20",iconColor:"text-sage-dark",primaryBtn:"bg-[var(--btn-primary-bg)] text-[var(--btn-primary-text)] border border-[var(--btn-primary-border)] hover:bg-[var(--btn-primary-hover-bg)]"},warning:{icon:d.A,gradient:"from-amber-500 to-amber-600",iconBg:"bg-[var(--status-warning-soft)]",iconColor:"text-[var(--status-warning)]",primaryBtn:"bg-[var(--btn-ghost-bg)] text-[var(--btn-ghost-text)] border border-[var(--btn-ghost-border)] hover:bg-[var(--btn-ghost-hover-bg)]"},error:{icon:n.A,gradient:"from-red-500 to-red-600",iconBg:"bg-[var(--status-danger-soft)]",iconColor:"text-[var(--status-danger)]",primaryBtn:"bg-[var(--btn-danger-bg)] text-[var(--btn-danger-text)] border border-[var(--btn-danger-border)] hover:bg-[var(--btn-danger-hover-bg)]"},success:{icon:i.A,gradient:"from-sage to-sage-dark",iconBg:"bg-sage-light/30",iconColor:"text-sage-dark",primaryBtn:"bg-[var(--btn-secondary-bg)] text-[var(--btn-secondary-text)] border border-[var(--btn-secondary-border)] hover:bg-[var(--btn-secondary-hover-bg)]"},info:{icon:l.A,gradient:"from-terracotta to-terracotta-dark",iconBg:"bg-terracotta/10",iconColor:"text-terracotta",primaryBtn:"bg-[var(--btn-primary-bg)] text-[var(--btn-primary-text)] border border-[var(--btn-primary-border)] hover:bg-[var(--btn-primary-hover-bg)]"}},y=f[g]||f.info,v=y.icon,j="fr"===p?"Confirmer":"Confirm",N="fr"===p?"Annuler":"Cancel";return(0,x.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[(0,x.jsx)("div",{className:"absolute inset-0 bg-charcoal/60 backdrop-blur-sm",onClick:r,style:{animation:"fadeIn 0.2s ease-out"}}),(0,x.jsxs)("div",{className:"relative rounded-3xl shadow-lifted max-w-md w-full overflow-hidden",style:{background:"var(--surface-elevated)",animation:"modalSlideUp 0.3s ease-out"},children:[(0,x.jsx)("div",{className:"h-2 bg-gradient-to-r ".concat(y.gradient)}),(0,x.jsx)("button",{onClick:r,className:"absolute top-4 right-4 p-2 rounded-full hover:bg-[var(--action-ghost-hover)] transition-colors z-10","aria-label":"fr"===p?"Fermer":"Close",children:(0,x.jsx)(c.A,{size:20,className:"text-[var(--text-secondary)]"})}),(0,x.jsxs)("div",{className:"p-8",children:[(0,x.jsx)("div",{className:"w-16 h-16 rounded-2xl ".concat(y.iconBg," flex items-center justify-center mb-6 mx-auto"),children:(0,x.jsx)(v,{size:32,className:y.iconColor,strokeWidth:2})}),s&&(0,x.jsx)("h2",{className:"font-display text-2xl font-bold text-[var(--text-primary)] text-center mb-3 leading-tight",children:s}),(0,x.jsx)("p",{className:"font-body-serif text-base text-[var(--text-secondary)] text-center leading-relaxed mb-8",children:m}),(0,x.jsxs)("div",{className:"flex gap-3 ".concat(b?"flex-row":"flex-col"),children:[b&&(0,x.jsx)("button",{onClick:r,className:"flex-1 bg-[var(--btn-ghost-bg)] text-[var(--btn-ghost-text)] border border-[var(--btn-ghost-border)] hover:bg-[var(--btn-ghost-hover-bg)] py-3 px-6 rounded-full font-ui font-semibold transition-all hover:shadow-soft",children:u||N}),(0,x.jsx)("button",{onClick:()=>{a&&a(),r()},className:"".concat(b?"flex-1":"w-full"," ").concat(y.primaryBtn," py-3 px-6 rounded-full font-ui font-semibold transition-all"),children:b?h||j:h||"OK"})]})]})]}),(0,x.jsx)("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes modalSlideUp {\n from {\n opacity: 0;\n transform: translateY(20px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n "})]})}function g(){const[e,t]=s.useState({isOpen:!1,type:"info",title:"",message:"",onConfirm:null,confirmText:"",cancelText:""}),r=()=>{t(e=>(0,a.A)((0,a.A)({},e),{},{isOpen:!1}))};return{modalState:e,openModal:e=>{let{type:r="info",title:a="",message:s,onConfirm:n,confirmText:i,cancelText:o}=e;
2t({isOpen:!0,type:r,title:a,message:s,onConfirm:n,confirmText:i,cancelText:o})},closeModal:r,showModal:t=>(0,x.jsx)(m,(0,a.A)((0,a.A)((0,a.A)({},e),t),{},{isOpen:e.isOpen,onClose:r}))}}},6774(e,t,r){r.r(t),r.d(t,{default:()=>v});var a=r(9379),s=r(5043),n=r(5847),i=r(1608),o=r(5399),d=r(9463),l=r(9761),c=r(624),x=r(5850),m=r(883),g=r(4093),h=r(163),u=r(3781),p=r(28),b=r(579);const f=["Shrinkage","MeasurementError","ReceivingError","SpoilageNotLogged","Other"],y={Shrinkage:"adjustmentReasonShrinkage",MeasurementError:"adjustmentReasonMeasurementError",ReceivingError:"adjustmentReasonReceivingError",SpoilageNotLogged:"adjustmentReasonSpoilageNotLogged",Other:"adjustmentReasonOther"};function v(e){let{currentUser:t,bakeryId:r}=e;const{language:v}=(0,c.o)(),j=(0,n.Zp)(),{bakerySubdomain:N}=(0,n.g)(),{openModal:w,showModal:k}=(0,p.hS)(),[C,A]=(0,s.useState)("capture"),[S,B]=(0,s.useState)(!0),[E,T]=(0,s.useState)(!1),[M,Q]=(0,s.useState)([]),[F,R]=(0,s.useState)(new Map),[z,O]=(0,s.useState)("$"),[K,L]=(0,s.useState)({}),[D,I]=(0,s.useState)(()=>new Set),[_,H]=(0,s.useState)({}),[U,q]=(0,s.useState)({}),[V,Y]=(0,s.useState)({show:!1,type:"success",message:""}),[$,P]=(0,s.useState)(!1),W=r||(null===t||void 0===t?void 0:t.uid),Z=(0,s.useCallback)(e=>(0,g.qt)(e,F,v),[F,v]),G=(0,s.useCallback)(async()=>{if(W){B(!0);try{const e=(await(0,m.LB)(W)).filter(e=>e.remainingQuantity>0).sort((e,t)=>Z(e.ingredientKey||e.ingredientName).localeCompare(Z(t.ingredientKey||t.ingredientName),v));Q(e);const t={};e.forEach(e=>{t[e.id]=(e.remainingQuantity/1e3).toFixed(2)}),L(t),I(new Set),H({}),q({}),A("capture")}finally{B(!1)}}},[W,Z,v]);(0,s.useEffect)(()=>{if(!t)return;const e=(0,g.do)(W,e=>{R(e)});return(async()=>{try{const e=(0,i.H9)(o.db,"bakeries",W),t=await(0,i.x7)(e);t.exists()&&O(t.data().currencySymbol||"$")}catch(e){console.error("Error loading baker settings:",e)}})(),()=>e&&e()},[t,W]),(0,s.useEffect)(()=>{G()},[G]);const J=e=>{if(!D.has(e.id))return 0;const t=parseFloat(K[e.id]);return isNaN(t)?0:Math.round(1e3*t)-e.remainingQuantity},X=M.filter(e=>0!==J(e)),ee=(e,t)=>{const r=Math.abs(e)/1e3,a=Math.abs(e*t);return r>2||a>20},te=X.length>0;return!t||S?(0,b.jsx)("div",{className:"text-center py-12",children:(0,b.jsx)("div",{className:"text-xl text-[var(--text-secondary)]",children:(0,x.t)("loading",v)||"Loading..."})}):(0,b.jsxs)("div",{children:[(0,b.jsx)(u.A,{show:V.show,type:V.type,message:V.message}),k({language:v}),(0,b.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,b.jsxs)("h2",{className:"text-3xl font-bold text-[var(--text-primary)] flex items-center gap-2",children:[(0,b.jsx)(l.A,{size:32}),(0,x.t)("physicalInventory",v)]}),(0,b.jsxs)(h.A,{variant:"ghost",size:"sm",onClick:()=>j(-1),className:"flex items-center gap-1",children:[(0,b.jsx)(d.A,{size:16}),(0,x.t)("backToHome",v)||("fr"===v?"Retour":"Back")]})]}),"capture"===C&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"bg-[var(--surface-card)] rounded-lg shadow-md p-6 mb-6",children:(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full",children:[(0,b.jsx)("thead",{className:"bg-[var(--bg-secondary)]",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-3 py-2 text-left text-xs font-semibold",children:(0,x.t)("ingredient",v)}),(0,b.jsx)("th",{className:"px-3 py-2 text-left text-xs font-semibold",children:(0,x.t)("lotBatchNumber",v)}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("systemQuantity",v)," (kg)"]}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("actualQuantity",v)," (kg)"]})]})}),(0,b.jsxs)("tbody",{className:"divide-y divide-[var(--border-subtle)]",children:[M.map(e=>{var t;const r=0!==J(e);return(0,b.jsxs)("tr",{className:r?"bg-[var(--status-warning-soft)]":"",children:[(0,b.jsx)("td",{className:"px-3 py-2 text-sm font-medium",children:Z(e.ingredientKey||e.ingredientName)}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm",children:e.lotBatchNumber||"-"}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:(e.remainingQuantity/1e3).toFixed(2)}),(0,b.jsx)("td",{className:"px-3 py-2 text-right",children:(0,b.jsx)("input",{type:"number",min:"0",step:"0.01",value:null!==(t=K[e.id])&&void 0!==t?t:"",onChange:t=>{L((0,a.A)((0,a.A)({},K),{},{[e.id]:t.target.value})),I(t=>new Set(t).add(e.id))},className:"w-28 border border-[var(--border-strong)] rounded px-2 py-1 text-sm text-right"})})]},e.id)}),0===M.length&&(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:4,className:"px-3 py-6 text-center text-sm text-[var(--text-secondary)]",children:(0,x.t)("noStock",v)})})]})]})})}),(0,b.jsx)("div",{className:"flex justify-end",children:(0,b.jsx)(h.A,{variant:"primary",disabled:!te,onClick:()=>A("review"),className:"px-6 py-3 rounded-full font-semibold",children:(0,x.t)("reviewCount",v)})})]}),"review"===C&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"bg-[var(--surface-card)] rounded-lg shadow-md p-6 mb-6",children:(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full",children:[(0,b.jsx)("thead",{className:"bg-[var(--bg-secondary)]",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-3 py-2 text-left text-xs font-semibold",children:(0,x.t)("ingredient",v)}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("expectedQty",v)," (kg)"]}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("countedQty",v)," (kg)"]}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("variance",v)," (kg)"]}),(0,b.jsxs)("th",{className:"px-3 py-2 text-right text-xs font-semibold",children:[(0,x.t)("varianceValue",v)," (",z,")"]}),(0,b.jsx)("th",{className:"px-3 py-2 text-left text-xs font-semibold",children:(0,x.t)("adjustmentReason",v)}),(0,b.jsx)("th",{className:"px-3 py-2 text-left text-xs font-semibold",children:(0,x.t)("note",v)}
2)]})}),(0,b.jsx)("tbody",{className:"divide-y divide-[var(--border-subtle)]",children:M.map(e=>{const t=J(e);if(0===t)return(0,b.jsxs)("tr",{className:"text-[var(--text-muted)]",children:[(0,b.jsx)("td",{className:"px-3 py-2 text-sm",children:Z(e.ingredientKey||e.ingredientName)}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:(e.remainingQuantity/1e3).toFixed(2)}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:K[e.id]}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:"0.00"}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:"-"}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm",colSpan:2,children:"-"})]},e.id);const r=t*e.unitCost,s=ee(t,e.unitCost);return(0,b.jsxs)("tr",{className:"bg-[var(--status-warning-soft)]",children:[(0,b.jsx)("td",{className:"px-3 py-2 text-sm font-medium",children:Z(e.ingredientKey||e.ingredientName)}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:(e.remainingQuantity/1e3).toFixed(2)}),(0,b.jsx)("td",{className:"px-3 py-2 text-sm text-right",children:K[e.id]}),(0,b.jsxs)("td",{className:"px-3 py-2 text-sm text-right font-semibold ".concat(t>0?"text-green-600":"text-red-600"),children:[t>0?"+":"",(t/1e3).toFixed(2)]}),(0,b.jsxs)("td",{className:"px-3 py-2 text-sm text-right font-semibold ".concat(r>0?"text-green-600":"text-red-600"),children:[r>0?"+":"",r.toFixed(2)]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsxs)("select",{value:_[e.id]||"",onChange:t=>H((0,a.A)((0,a.A)({},_),{},{[e.id]:t.target.value})),className:"border border-[var(--border-strong)] rounded px-2 py-1 text-xs w-full",children:[(0,b.jsx)("option",{value:"",children:(0,x.t)("adjustmentReason",v)}),f.map(e=>(0,b.jsx)("option",{value:e,children:(0,x.t)(y[e],v)},e))]})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)("input",{type:"text",value:U[e.id]||"",onChange:t=>q((0,a.A)((0,a.A)({},U),{},{[e.id]:t.target.value})),placeholder:s?"".concat((0,x.t)("note",v)," *"):(0,x.t)("note",v),className:"border rounded px-2 py-1 text-xs w-full ".concat(s&&!(U[e.id]||"").trim()?"border-red-500":"border-[var(--border-strong)]")})})]},e.id)})})]})})}),(0,b.jsxs)("div",{className:"flex justify-between",children:[(0,b.jsxs)(h.A,{variant:"ghost",onClick:()=>A("capture"),className:"flex items-center gap-1",children:[(0,b.jsx)(d.A,{size:16})," ",(0,x.t)("startCount",v)]}),(0,b.jsx)(h.A,{variant:"primary",disabled:!(()=>{for(const e of X){if(!_[e.id])return!1;const t=J(e);if(ee(t,e.unitCost)&&!(U[e.id]||"").trim())return!1}return!0})()||E,onClick:()=>P(!0),className:"px-6 py-3 rounded-full font-semibold",children:E?(0,x.t)("loading",v)||"...":(0,x.t)("postCount",v)})]})]}),$&&(0,b.jsx)("div",{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[60] animate-slide-up",children:(0,b.jsxs)("div",{className:"bg-[var(--surface-card)] rounded-lg shadow-2xl p-6 w-full max-w-md mx-4 border-2 border-[var(--border-subtle)]",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,b.jsx)("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:(0,b.jsx)(l.A,{size:24,className:"text-[var(--action-primary)]"})}),(0,b.jsxs)("div",{className:"flex-1",children:[(0,b.jsx)("h3",{className:"text-lg font-bold text-[var(--text-primary)] mb-2",children:(0,x.t)("postCount",v)}),(0,b.jsxs)("p",{className:"text-sm text-[var(--text-secondary)]",children:[X.length," ",(0,x.t)("adjustedLines",v).toLowerCase(),"."," ","fr"===v?"Cette action est d\xe9finitive.":"This cannot be edited afterward."]})]})]}),(0,b.jsxs)("div",{className:"flex gap-3 justify-end",children:[(0,b.jsx)(h.A,{onClick:()=>P(!1),variant:"ghost",className:"px-6 py-2 rounded-full",children:(0,x.t)("cancel",v)}),(0,b.jsx)(h.A,{onClick:()=>{P(!1),(async()=>{T(!0);try{const e=[];for(const t of X)e.push({purchaseId:t.id,ingredientKey:t.ingredientKey||t.ingredientName,ingredientLabelSnapshot:Z(t.ingredientKey||t.ingredientName),lotBatchNumber:t.lotBatchNumber||"",expectedQtyAtCapture:t.remainingQuantity,countedQty:Math.round(1e3*parseFloat(K[t.id])),reason:_[t.id],note:U[t.id]||""});await(0,m.B_)(W,t.uid,e),Y({show:!0,type:"success",message:(0,x.t)("countPosted",v)}),setTimeout(()=>{j("/".concat(N||r||(null===t||void 0===t?void 0:t.uid),"/stock"))},1500)}catch(e){"DRIFT_DETECTED"===e.message?(w({type:"warning",title:(0,x.t)("refreshCount",v),message:(0,x.t)("driftDetected",v)}),await G()):w({type:"error",title:"fr"===v?"Erreur":"Error",message:e.message})}finally{T(!1)}})()},variant:"primary",className:"px-6 py-2 rounded-full",children:(0,x.t)("postCount",v)})]})]})})]})}},3781(e,t,r){r.d(t,{A:()=>n});var a=r(5043),s=r(7035);function n(e){let{show:t,type:r="success",message:n}=e;const{showToast:i}=(0,s.d)();return(0,a.useEffect)(()=>{t&&n&&i(n,r)},[t,n,r,i]),null}},9463(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},9761(e,t,r){r.d(t,{A:()=>a});
2const a=(0,r(7784).A)("clipboard-check",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]])}}]); 3//# sourceMappingURL=6774.a7c303e6.chunk.js.map
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.