PageSourceSearch

https://app.pazaros.com/assets/supply-items-Bek3CkCa.js

js pazaros.com collected 2026-10-02 01:41:45 UTC 11,988 bytes, 1 lines download raw bytes

1import{o as Y}from"./rolldown-runtime-ifEikEFx.js";import{B as F,Bt as A,Dt as o,Et as K,It as S,On as H,P as z,Q as L,Rt as W,U as Q,Z,ft as D,gt as R,it as N,lt as I,mt as q,qt as b,st as c,z as J,zt as T}from"./antd-vendor-D7gwNWgM.js";import{m as X}from"./query-vendor-Cvd8942y.js";import{t as P}from"./errorHandler-CFfbz1t3.js";import{n as ee,t as te}from"./usePermissions-CL4A21Xo.js";import{D as B,a as ae,c as ie,d as re,f as ne,g as V,i as se,l as le,m as $,o as de,p as ce,r as _,s as ue,t as M,u as oe}from"./trNumberInput-DcCSpQfU.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"[email protected]+202610012304"};var t=new r.Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="902d91c0-b49c-4b28-adf5-8671d6e50fa8",r._sentryDebugIdIdentifier="sentry-dbid-902d91c0-b49c-4b28-adf5-8671d6e50fa8")}catch{}})();var h=Y(H(),1),C=Y(K(),1),e=X(),me=M(2,4);function pe({open:r,supplyItemId:t,currency:y,entry:l,onClose:g,onSaved:j,onEditEntry:u}){const{message:x}=T.useApp(),[d]=c.useForm(),[v,m]=(0,h.useState)(!1),[p,f]=(0,h.useState)(null),a=ne(),n=ce(),i=a.reset,s=l?"update":"create",w=s==="update"?a.data?.sameDayConflict:void 0;(0,h.useEffect)(()=>{r&&(d.setFieldsValue({price:l?.price??0,effectiveFrom:l?(0,C.default)(l.effectiveFrom):(0,C.default)(),note:l?.note??void 0}),i(),m(!1),f(null))},[l,d,r,i]);const G=async()=>{let k;try{k=await d.validateFields()}catch{return}const E={price:k.price,currency:y,effectiveFrom:k.effectiveFrom.format(V),...k.note?{note:k.note}:{}};f(E),m(!0);try{await a.mutateAsync({supplyItemId:t,operation:s,...l?{entryId:l.id}:{},draft:E})}catch{}},U=async()=>{if(!(!p||a.data?.affectedOrders==null||w))try{await n.mutateAsync({supplyItemId:t,operation:s,...l?{entryId:l.id}:{},draft:p,overwrite:s==="create"&&!!a.data.sameDayConflict}),x.success(l?"Fiyat geçmişi güncellendi":"Yeni fiyat eklendi"),m(!1),j()}catch(k){x.error(P(k))}};return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(D,{open:r,onClose:g,title:l?"Sarf fiyatını düzenle":"Yeni sarf fiyatı",size:480,destroyOnHidden:!0,footer:(0,e.jsxs)(I,{justify:"flex-end",gap:8,children:[(0,e.jsx)(o,{onClick:g,children:"Vazgeç"}),(0,e.jsx)(o,{"data-guide":"settings-supply-items-price-inspect",type:"primary",loading:a.isPending,onClick:()=>{G()},children:"Etkiyi incele"})]}),children:(0,e.jsxs)(c,{form:d,layout:"vertical",requiredMark:!1,children:[(0,e.jsx)(c.Item,{name:"price",label:`Birim fiyat (${y})`,rules:[{required:!0,message:"Birim fiyat zorunlu"},{type:"number",min:0,message:"Birim fiyat negatif olamaz"}],children:(0,e.jsx)(R,{"data-guide":"settings-supply-items-price-amount",min:0,precision:4,...me,style:{width:"100%"}})}),(0,e.jsx)(c.Item,{name:"effectiveFrom",label:"Geçerlilik başlangıcı",rules:[{required:!0,message:"Geçerlilik tarihi zorunlu"}],children:(0,e.jsx)(q,{format:"DD.MM.YYYY",allowClear:!1,style:{width:"100%"}})}),(0,e.jsx)(z.Text,{type:"secondary",children:"Fiyat seçilen gün 00:00'dan itibaren geçerlidir (İstanbul saati)."}),(0,e.jsx)(c.Item,{name:"note",label:"Not",style:{marginTop:16},rules:[{max:200}],children:(0,e.jsx)(N.TextArea,{rows:3,maxLength:200,showCount:!0})})]})}),(0,e.jsx)(L,{open:v,title:l?"Geçmiş fiyat değişikliğini onayla":"Yeni fiyatı onayla",okText:"Onayla ve kaydet",cancelText:"Geri dön",okButtonProps:{"data-guide":"settings-supply-items-price-confirm",disabled:a.isPending||a.isError||a.data?.affectedOrders==null||!!w,loading:n.isPending},onOk:()=>{U()},onCancel:()=>m(!1),children:a.isPending?(0,e.jsx)(z.Text,{children:"Etki hesaplanıyor…"}):a.isError?(0,e.jsx)(b,{type:"error",showIcon:!0,title:"Etki hesaplanamadı",description:P(a.error)}):a.data?(0,e.jsxs)(I,{vertical:!0,gap:8,children:[w?(0,e.jsx)(b,{type:"error",showIcon:!0,title:"Bu tarihte kayıt var; o kaydı düzenleyin",description:`Aynı güne kayıtlı fiyat: ${_(w.price,w.currency)}.`,action:u?(0,e.jsx)(o,{size:"small",onClick:()=>u(w.entryId),children:"Çakışan kaydı düzenle"}):void 0}):a.data.sameDayConflict?(0,e.jsx)(b,{type:"warning",showIcon:!0,title:"Bu tarihte zaten bir fiyat var",description:"Onayladığınızda aynı günün mevcut kaydı bu fiyatla güncellenir."}):null,(0,e.jsx)(b,{type:(a.data.affectedOrders??0)>0?"warning":"info",showIcon:!0,title:`${a.data.affectedOrders??"Bilinmeyen sayıda"} sipariş etkilenecek`,description:"Geçmişe dönük değişiklikte bu siparişlerin maliyeti yeniden hesaplanır."})]}):null})]})}var{Title:ye,Text:O}=z,fe=M(2,4),ge=ae.map(r=>({value:r,label:r})),he=["TRY","USD","EUR"].map(r=>({value:r,label:r}));function xe({open:r,item:t,onClose:y,onInitialPriceFailed:l}){const{message:g,modal:j}=T.useApp(),[u]=c.useForm(),[x,d]=(0,h.useState)(!1),v=le(),m=$(),p=c.useWatch("vatIncluded",u);h.useEffect(()=>{r&&u.setFieldsValue({name:t?.name??"",unit:t?.unit??"adet",currency:t?.currency??"TRY",vatIncluded:t?.vatIncluded??!1,vatRate:t?.vatRate??20,price:t?.currentPrice??0,effectiveFrom:(0,C.default)()})},[u,t,r]);const f=async()=>{let a;try{a=await u.validateFields()}catch{return}const n=u.getFieldValue("vatRate")??20;if(t&&se({vatIncluded:a.vatIncluded,vatRate:n},t)){d(!0);let i;try{const s=await ie(t.id);i=`${s.truncated?"En az ":""}${s.affectedOrders}`}catch(s){g.error(P(s));return}finally{d(!1)}if(!await new Promise(s=>{j.confirm({title:"KDV ayarı değişiyor",content:`${i} siparişin maliyeti yeniden hesaplanacak.`,okText:"Onayla ve kaydet",cancelText:"Geri dön",onOk:()=>s(!0),onCancel:()=>s(!1)})}))return}try{t?await m.mutateAsync({id:t.id,name:a.name.trim(),unit:a.unit,currency:t.currency,vatIncluded:a.vatIncluded,vatRate:n}):await v.mutateAsync({name:a.name.trim(),unit:a.unit,currency:a.currency,vatIncluded:a.vatIncluded,vatRate:n,price:a.price,effectiveFrom:a.effectiveFrom.format(V)}),g.success(t?"Sarf tanımı güncellendi":"Sarf tanımı oluşturuldu"),y()}catch(i){if(i instanceof ue){g.warning("Tanım oluşturuldu, fiyat kaydedilemedi — fiyatı ekleyin"),y(),l(i.item);return}g.error(P(i))}};return(0,e.jsx)(D,{open:r,onClose:y,title:t?"Sarf tanımını düzenle":"Sarf malzemesi oluştur",size:500,footer:(0,e.jsxs)(I,{justify:"flex-end",gap:8,children:[(0,e.jsx)(o,{onClick:y,children:"Vazgeç"}),(0,e.jsx)(o,{"data-guide":"settings-supply-items-save",type:"primary",loading:v.isPending||m.isPending||x,onClick:()=>{f()},children:"Kaydet"})]}),children:(0,e.jsxs)(c,{form:u,layout:"vertical",requiredMark:!1,children:[(0,e.jsx)(c.Item,{name:"name",label:"Ad",rules:[{required:!0,whitespace:!0,message:"Ad zorunlu"},{max:100,message:"En fazla 100 karakter"}],children:(0,e.jsx)(N,{"data-guide":"settings-supply-items-name",maxLength:100,autoFocus:!0})}),(0,e.jsx)(c.Item,{name:"unit",label:"Birim",rules:[{required:!0,message:"Birim seÃ
1§in"}],children:(0,e.jsx)(S,{"data-guide":"settings-supply-items-unit",options:ge})}),(0,e.jsx)(c.Item,{name:"currency",label:"Para birimi",rules:[{required:!0,message:"Para birimi seçin"}],extra:t?"Para birimi geçmiş tutarlılığı için değiştirilemez.":void 0,children:(0,e.jsx)(S,{"data-guide":"settings-supply-items-currency",options:he,disabled:!!t})}),(0,e.jsx)(c.Item,{name:"vatIncluded",label:"KDV",valuePropName:"checked",children:(0,e.jsx)(Q,{"data-guide":"settings-supply-items-vat",checkedChildren:"Dahil",unCheckedChildren:"Hariç"})}),p?(0,e.jsx)(c.Item,{name:"vatRate",label:"KDV oranı",rules:[{required:!0,message:"KDV oranı seçin"}],children:(0,e.jsx)(S,{options:de.map(a=>({value:a,label:`%${a}`}))})}):null,!t&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(c.Item,{name:"price",label:"Birim fiyat",rules:[{required:!0,message:"Birim fiyat zorunlu"},{type:"number",min:0,message:"Birim fiyat negatif olamaz"}],children:(0,e.jsx)(R,{"data-guide":"settings-supply-items-price",min:0,precision:4,...fe,style:{width:"100%"}})}),(0,e.jsx)(c.Item,{name:"effectiveFrom",label:"Geçerlilik başlangıcı",rules:[{required:!0,message:"Geçerlilik tarihi zorunlu"}],children:(0,e.jsx)(q,{"data-guide":"settings-supply-items-effective-from",format:"DD.MM.YYYY",allowClear:!1,style:{width:"100%"}})})]})]})})}function Pe(){const{message:r}=T.useApp(),{canWrite:t}=ee(),{data:y=[],isLoading:l,isError:g}=oe({includeArchived:!0}),j=$(),[u,x]=(0,h.useState)(null),[d,v]=(0,h.useState)(null),[m,p]=(0,h.useState)(null),f=re(d?.id,!!d),a=(0,h.useMemo)(()=>[{title:"Ad",dataIndex:"name",render:(n,i)=>(0,e.jsxs)(I,{gap:8,align:"center",children:[(0,e.jsx)(O,{strong:!0,children:n}),i.archived?(0,e.jsx)(J,{children:"Arşivde"}):null]})},{title:"Birim",dataIndex:"unit",width:100},{title:"Güncel fiyat",key:"price",render:(n,i)=>i.currentPrice==null?"—":`${_(i.currentPrice,i.currency)} ${i.currency}`},{title:"Geçerlilik",dataIndex:"currentPriceEffectiveFrom",render:n=>n?B(n):"—"},{title:"KDV",dataIndex:"vatIncluded",render:(n,i)=>n?`Dahil (%${i.vatRate})`:"Hariç"},{title:"İşlemler",key:"actions",render:(n,i)=>(0,e.jsxs)(I,{gap:4,wrap:"wrap",children:[(0,e.jsx)(o,{"data-guide":"settings-supply-items-row-history",size:"small",onClick:()=>v(i),children:"Fiyat geçmişi"}),(0,e.jsx)(o,{"data-guide":"settings-supply-items-row-edit",size:"small",disabled:!t,onClick:()=>x(i),children:"Düzenle"}),i.archived?(0,e.jsx)(o,{"data-guide":"settings-supply-items-row-unarchive",size:"small",disabled:!t,onClick:async()=>{try{await j.mutateAsync({id:i.id,archived:!1}),r.success("Sarf tanımı arşivden çıkarıldı")}catch(s){r.error(P(s))}},children:"Arşivden çıkar"}):(0,e.jsx)(Z,{title:`“${i.name}” arşivlensin mi?`,description:"Arşivlenen tanım yeni gider satırlarında seçilemez.",okText:"Arşivle",cancelText:"Vazgeç",onConfirm:async()=>{try{await j.mutateAsync({id:i.id,archived:!0}),r.success("Sarf tanımı arşivlendi")}catch(s){r.error(P(s))}},children:(0,e.jsx)(o,{"data-guide":"settings-supply-items-row-archive",size:"small",danger:!0,disabled:!t,children:"Arşivle"})})]})}],[t,r,j]);return l?(0,e.jsx)(A,{active:!0,paragraph:{rows:7}}):(0,e.jsxs)(I,{vertical:!0,gap:16,children:[(0,e.jsxs)(I,{justify:"space-between",align:"center",wrap:"wrap",gap:12,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(ye,{level:4,style:{margin:0},children:"Sarf Malzemeleri"}),(0,e.jsx)(O,{type:"secondary",children:"Koli, folyo ve streç gibi birim maliyetleri tarihli olarak yönetin."})]}),(0,e.jsx)(o,{"data-guide":"settings-supply-items-create",type:"primary",disabled:!t,title:t?void 0:te,onClick:()=>x("new"),children:"Sarf malzemesi ekle"})]}),g?(0,e.jsx)(b,{type:"error",showIcon:!0,title:"Sarf tanımları yüklenemedi"}):null,(0,e.jsx)(F,{"data-guide":"settings-supply-items-table",rowKey:"id",columns:a,dataSource:y,locale:{emptyText:(0,e.jsx)(W,{description:"Henüz sarf malzemesi yok"})},pagination:{pageSize:25,hideOnSinglePage:!0},scroll:{x:"max-content"}}),(0,e.jsx)(xe,{open:u!==null,item:u==="new"?null:u,onClose:()=>x(null),onInitialPriceFailed:n=>{v(n),p("new")}}),(0,e.jsx)(D,{open:!!d,onClose:()=>v(null),title:d?`${d.name} · fiyat geçmişi`:"Fiyat geçmişi",size:640,extra:(0,e.jsx)(o,{"data-guide":"settings-supply-items-new-price",type:"primary",disabled:!t,onClick:()=>p("new"),children:"Yeni fiyat"}),children:f.isLoading?(0,e.jsx)(A,{active:!0}):f.isError?(0,e.jsx)(b,{type:"error",showIcon:!0,title:"Fiyat geçmişi yüklenemedi"}):(0,e.jsx)(F,{rowKey:"id",size:"small",dataSource:f.data??[],pagination:!1,locale:{emptyText:"Fiyat kaydı yok"},columns:[{title:"Geçerlilik",dataIndex:"effectiveFrom",render:n=>B(n)},{title:"Birim fiyat",dataIndex:"price",render:n=>_(n,d?.currency)},{title:"Not",dataIndex:"note",render:n=>n||"—"},{title:"",key:"edit",width:100,render:(n,i)=>(0,e.jsx)(o,{size:"small",disabled:!t,onClick:()=>p(i),children:"Düzenle"})}]})}),d&&m?(0,e.jsx)(pe,{open:!0,supplyItemId:d.id,currency:d.currency,entry:m==="new"?null:m,onClose:()=>p(null),onEditEntry:n=>
1{const i=f.data?.find(s=>s.id===n);i&&p(i)},onSaved:()=>{p(null),f.refetch()}}):null]})}export{Pe as SupplyItemsPage};

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.