import{b as f}from"./chunk-CPFCOPJN.js";import{b as r}from"./chunk-6JHOZEVK.js";import{a as u}from"./chunk-75MTL6QM.js";import{a,b as I}from"./chunk-LI2NM675.js";import{c as O,d as g}from"./chunk-YADAVUVK.js";import{F as m,k as v,la as h}from"./chunk-HEIW4SFT.js";var y=function(t){return t.NotSerial="N",t.E="E",t.S="S",t.P="P",t}(y||{}),d=function(t){return t.K="K",t}(d||{}),l=function(t){return t.Move="M",t.Receive="P",t.Order="O",t}(l||{});I();g();h();var P=class{static documentTypeLabel(n){switch(n){case r.POS:case r.Wholesale:case r.ReceivedBills:return"ConnectionTypeTrafic";case r.IssuedAdvancePayment:case r.ReceivingAdvancePayment:case r.AdvancePayment:return"ConnectionTypeAdvPay";case r.BuyerOrder:case r.SupplierOrder:case r.Orders:return"ConnectionTypeOrder";case r.Documents:case r.Archive:return"ConnectionTypeDocument";case r.InventoryExcess:return"ConnectionTypeExcess";case r.InventoryShortage:return"ConnectionTypeShortage"}return""}static documentTypeColor(n){switch(n){case r.POS:case r.Wholesale:case r.ReceivedBills:return"yellow";case r.IssuedAdvancePayment:case r.ReceivingAdvancePayment:case r.AdvancePayment:return"orange";case r.BuyerOrder:case r.SupplierOrder:case r.Orders:return"red";case r.Documents:case r.Archive:return"green";case r.InventoryExcess:return"cyan";case r.InventoryShortage:return"dark-pink"}return"no-fill"}static documentTypeLink(n,e){switch(n){case r.POS:return`${a.backofficeUrl}CashRegister/Index?acKey=`+e;case r.Wholesale:return`${a.backofficeUrl}Wholesale/Edit?id=`+e;case r.ReceivedBills:return`${a.backofficeUrl}ReceivedBills/Edit?id=`+e;case r.IssuedAdvancePayment:return`${a.backofficeUrl}AdvancePayment/EditIssuedAdvancePayment?id=`+e;case r.ReceivingAdvancePayment:case r.AdvancePayment:return`${a.backofficeUrl}AdvancePayment/EditReceivingAdvancePayment?id=`+e;case r.Orders:case r.BuyerOrder:return`${a.backofficeUrl}Order/EditBuyerOrder?id=`+e;case r.SupplierOrder:return`${a.backofficeUrl}Order/EditSupplierOrder?id=`+e;case r.Documents:case r.Archive:return`${a.backofficeUrl}Documents/Edit?qId=`+e;case r.InventoryExcess:return`${a.backofficeUrl}Inventory/ExcessOrMissing?inventoryType=E&id=`+e;case r.InventoryShortage:return`${a.backofficeUrl}Inventory/ExcessOrMissing?inventoryType=S&id=`+e}return""}static checkForZeros(n,e,c,o){(n.quantity===0||n[e]===0)&&c.openTyped({id:u.DialogMoveUtilsError,type:"error",text:o.instant("InoicePositionQuantityOrPrice0Warning",{0:n.anNo+" - "+n.name}),confirmButtonLabel:"Ok",denyButtonLabel:null})}static openSerialNumbersDialog(n,e,c,o,i=()=>{},s=!0){!c||e.serialNo===y.NotSerial||e.serialNo===""||(o?n.serialNumbersAutoEdition({acKey:e.acKey,docType:c.docType,date:c.invoiceDate??new Date,anNo:e.anNo,ident:e.ident,issuer:c.issuerId||"",receiver:c.receiverId||"",quantityOld:0,quantityNew:e.quantity,type:d.K,invoiceType:l.Move},e,i):n.isDialogOpen()||n.openDialog(e,c.receiverId||"",d.K,l.Move,!1,c.date??new Date,c.issuerId,!0,null,i,s))}static getIdentRabate(n,e,c){return n>0?n:e>0?e:c}static displayUpdateErrors(n,e){e&&e&&O.isSet(e.error)&&e.error!==""&&n.openTyped({id:u.DialogMoveUtilsError,type:"error",text:e.error??"GeneralError",confirmButtonLabel:"Ok",denyButtonLabel:null})}static updateIdentDiscount(n,e,c,o){return v(this,null,function*(){let i=0;if(f.DiscountPercent===e.fieldId)i=e.discountPercent;else if(f.Discount===e.fieldId){let s=e.value+e.tax;i=e.discount/(s||1)*100}return yield m(o.updateIdentsDiscount({acKey:n,discount:Math.max(Math.min(i,100),0),author:c}))})}static getSpecPayments(){let n=[];return n.push({value:null,label:""},{value:p.TrafficFreeOfCharge,label:"TrafficFreeOfCharge"},{value:p.SinglePurposeVouchers,label:"SinglePurposeVouchers"}),n}static setSubjectLabel(n,e,c="Subject"){n&&(n.label=e&&e.trim()!==""?e:c)}static checkIdentDuplicate(n,e,c,o){let i=n.filter(s=>s.ident===e.ident);i.length>0&&c.openTyped({id:u.DialogIdentDuplicateAlert,type:"error",title:o.instant("Error!"),text:o.instant(i.length>1?"IdentAlreadyEnteredOnPositions":"IdentAlreadyEnteredOnPosition",{0:e.ident,1:i.map(s=>s.anNo).join(", ")}),confirmButtonLabel:"Ok",denyButtonLabel:null})}},E=function(t){return t.Confirmed="P",t.Unconfirmed="N",t.Recorded="R",t}(E||{}),p=function(t){return t.SinglePurposeVouchers="V",t.TrafficFreeOfCharge="N",t}(p||{});export{y as a,d as b,l as c,P as d,E as e};
