-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3697.2abeae7687de9285.js
467 lines (427 loc) · 106 KB
/
3697.2abeae7687de9285.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
"use strict";(self.webpackChunkfuse=self.webpackChunkfuse||[]).push([[3697],{47413:(B,S,a)=>{a.d(S,{Dz:()=>I,Lx:()=>m});var v=a(59640);const e=s=>s.pagination,I=(0,v.Mz)(e,s=>s.pagination),m=(0,v.Mz)(e,s=>s.secondaryPagination)},23301:(B,S,a)=>{a.d(S,{I:()=>m,p:()=>I});var v=a(54438),e=a(92581);const I=(s,k)=>(0,v.WQX)(e.v).getCurrencies(),m=(s,k)=>(0,v.WQX)(e.v).getActiveCurrency()},91401:(B,S,a)=>{a.d(S,{y$:()=>m});var v=a(59640);const e=s=>s.currencies,m=((0,v.Mz)(e,s=>s.currency),(0,v.Mz)(e,s=>s.currencies))},92581:(B,S,a)=>{a.d(S,{v:()=>V});var v=a(54438),e=a(96697),I=a(25558),m=a(88141),s=a(53473),k=a(59640),P=a(98216),E=a(54588),x=a(91401);const $=s.J1`
mutation CreateCurrency($createCurrencyInput: CreateCurrencyInput!) {
createCurrency(createCurrencyInput: $createCurrencyInput) {
ok
message
currency {
id
active
name
iso
symbol
}
}
}
`,A=s.J1`
mutation UpdateCurrency($updateCurrencyInput: UpdateCurrencyInput!) {
updateCurrency(updateCurrencyInput: $updateCurrencyInput) {
ok
message
currency {
id
active
name
iso
symbol
}
}
}
`,Y=s.J1`
mutation Mutation($updateEntityStatusInput: UpdateEntityStatusInput!) {
updateCurrencyStatus(updateEntityStatusInput: $updateEntityStatusInput) {
ok
message
}
}
`,G=s.J1`
mutation RemoveCurrency($removeCurrencyId: String!) {
removeCurrency(id: $removeCurrencyId) {
ok,
message
}
}
`,T=s.J1`
query FindAllCurrencies($offset: Int, $limit: Int, $sort: String, $order: Order, $search: String) {
findAllCurrencies(offset: $offset, limit: $limit, sort: $sort, order: $order, search: $search) {
ok
message
pagination {
length
size
page
}
currencies {
id
active
name
iso
symbol
}
}
}
`,M=s.J1`
query FindAllActiveCurrencies {
findAllActiveCurrencies {
ok
message
currencies {
id
name
iso
}
}
}
`,D=s.J1`
query FindCurrencyById($findCurrencyByIdId: String!) {
findCurrencyById(id: $findCurrencyByIdId) {
ok
message
currency {
id
active
name
iso
symbol
}
}
}
`;let V=(()=>{class f{constructor(){this.apolloProvider=(0,v.WQX)(s.Ic),this.store=(0,v.WQX)(k.il),this._apollo=this.apolloProvider.use("BALANC")}createCurrency(y){return this.store.select(x.y$).pipe((0,e.s)(1),(0,I.n)(h=>this._apollo.mutate({mutation:$,variables:{createCurrencyInput:y},errorPolicy:"all"}).pipe((0,m.M)(({data:p})=>{const d=structuredClone(h);d.push(p.createCurrency.currency),this.store.dispatch((0,E.Ih)({currencies:d}))}))))}getCurrencies(y=1,h=20,p="name",d="asc",g=""){return this._apollo.query({query:T,variables:{offset:h*(y-1),limit:h,sort:p,order:d,search:g},errorPolicy:"all"}).pipe((0,m.M)(({data:_})=>{this.store.dispatch((0,P.Bp)({pagination:_.findAllCurrencies.pagination})),this.store.dispatch((0,E.Ih)({currencies:_.findAllCurrencies.currencies}))}))}getActiveCurrency(){return this._apollo.query({query:M,errorPolicy:"all"}).pipe((0,m.M)(({data:y})=>{y&&this.store.dispatch((0,E.Ih)({currencies:y.findAllActiveCurrencies.currencies}))}))}getCurrencyById(y){return this._apollo.query({query:D,variables:{findCurrencyByIdId:y},errorPolicy:"all"}).pipe((0,m.M)(({data:h})=>{this.store.dispatch((0,E.MN)({currency:h.findCurrencyById.currency}))}))}updateCurrency(y){return this.store.select(x.y$).pipe((0,e.s)(1),(0,I.n)(h=>this._apollo.mutate({mutation:A,variables:{updateCurrencyInput:y},errorPolicy:"all"}).pipe((0,m.M)(({data:p})=>{const d=structuredClone(h);d[h.findIndex(_=>_.id===y.id)]=p.updateCurrency.currency,this.store.dispatch((0,E.Ih)({currencies:d}))}))))}updateCurrencyStatus(y){return this.store.select(x.y$).pipe((0,e.s)(1),(0,I.n)(h=>this._apollo.mutate({mutation:Y,variables:{updateEntityStatusInput:y},errorPolicy:"all"}).pipe((0,m.M)(({})=>{const d=structuredClone(h);d[h.findIndex(_=>_.id===y.id)].active=y.active,this.store.dispatch((0,E.Ih)({currencies:d}))}))))}removeCurrency(y){return this.store.select(x.y$).pipe((0,e.s)(1),(0,I.n)(h=>this._apollo.mutate({mutation:G,variables:{removeCurrencyId:y},errorPolicy:"all"}).pipe((0,m.M)(({})=>{const d=structuredClone(h),g=h.findIndex(_=>_.id===y);d.splice(g,1),this.store.dispatch((0,E.Ih)({currencies:d}))}))))}static#e=this.\u0275fac=function(h){return new(h||f)};static#t=this.\u0275prov=v.jDH({token:f,factory:f.\u0275fac,providedIn:"root"})}return f})()},59013:(B,S,a)=>{a.d(S,{v:()=>I});var v=a(54438),e=a(78693);const I=(m,s)=>(0,v.WQX)(e.q).getPaymentMethods()},84713:(B,S,a)=>{a.d(S,{xi:()=>m});var v=a(59640);const e=s=>s.paymentMethods,m=((0,v.Mz)(e,s=>s.paymentMethod),(0,v.Mz)(e,s=>s.paymentMethods))},78693:(B,S,a)=>{a.d(S,{q:()=>f});var v=a(54438),e=a(96697),I=a(25558),m=a(88141),s=a(53473),k=a(59640),P=a(98216),E=a(20604),x=a(84713),$=a(94794);const A=s.J1`
query FindAllPaymentMethods($page: Int, $size: Int, $sort: String, $order: Order, $search: String) {
findAllPaymentMethods(page: $page, size: $size, sort: $sort, order: $order, search: $search) {
ok
message
pagination {
length
size
page
}
paymentMethods {
id
active
name
useGateway
}
}
}
`,Y=s.J1`
query FindPaymentMethodById($findPaymentMethodById: String!) {
findPaymentMethodById(id: $findPaymentMethodById) {
ok
message
paymentMethod {
id
active
name
useGateway
}
}
}
`,G=s.J1`
mutation CreatePaymentMethod($createPaymentMethodInput: CreatePaymentMethodInput!) {
createPaymentMethod(createPaymentMethodInput: $createPaymentMethodInput) {
ok
message
paymentMethod {
id
active
name
useGateway
}
}
}
`,T=s.J1`
mutation UpdatePaymentMethod($updatePaymentMethodInput: UpdatePaymentMethodInput!) {
updatePaymentMethod(updatePaymentMethodInput: $updatePaymentMethodInput) {
ok
message
paymentMethod {
id
active
name
useGateway
}
}
}
`,M=s.J1`
mutation RemovePaymentMethod($removePaymentMethodId: String!) {
removePaymentMethod(id: $removePaymentMethodId) {
ok
message
}
}
`,D=s.J1`
mutation Mutation($updateEntityStatusInput: UpdateEntityStatusInput!) {
updatePaymentMethodStatus(updateEntityStatusInput: $updateEntityStatusInput) {
ok
message
}
}
`;var V=a(95416);let f=(()=>{class j{constructor(h){this._snackBar=h,this.apolloProvider=(0,v.WQX)(s.Ic),this.store=(0,v.WQX)(k.il),this._apollo=this.apolloProvider.use("BALANC")}createPaymentMethod(h){return this.store.select(x.xi).pipe((0,e.s)(1),(0,I.n)(p=>this._apollo.mutate({mutation:G,variables:{createPaymentMethodInput:h},errorPolicy:"all"}).pipe((0,m.M)(({errors:d,data:g})=>{if(d){let b="";d.forEach(R=>b+=`\n ${R.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:b,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}const _=structuredClone(p);_.push(g.createPaymentMethod.paymentMethod),this.store.dispatch((0,E.f)({paymentMethods:_}))}))))}getPaymentMethods(h=0,p=25,d="name",g="asc",_=""){return this._apollo.query({query:A,errorPolicy:"all",variables:{page:h,size:p,sort:d,order:g,search:_}}).pipe((0,m.M)(({errors:b,data:R})=>{if(b){let w="";b.forEach(ne=>w+=`\n ${ne.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:w,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}this.store.dispatch((0,E.f)({paymentMethods:R.findAllPaymentMethods.paymentMethods})),this.store.dispatch((0,P.Bp)({pagination:R.findAllPaymentMethods.pagination}))}))}getPaymentMethodById(h){return this._apollo.query({query:Y,variables:{findPaymentMethodByIdId:h},errorPolicy:"all"}).pipe((0,m.M)(({errors:p,data:d})=>{if(p){let g="";p.forEach(_=>g+=`\n ${_.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:g,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}this.store.dispatch((0,E.Ye)({paymentMethod:d.findPaymentMethodById.paymentMethod}))}))}updatePaymentMethod(h){return this.store.select(x.xi).pipe((0,e.s)(1),(0,I.n)(p=>this._apollo.mutate({mutation:T,variables:{updatePaymentMethodInput:h},errorPolicy:"all"}).pipe((0,m.M)(({errors:d,data:g})=>{if(d){let R="";d.forEach(w=>R+=`\n ${w.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:R,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}const _=structuredClone(p);_[p.findIndex(R=>R.id===h.id)]=g.updatePaymentMethod.paymentMethod,this.store.dispatch((0,E.f)({paymentMethods:_}))}))))}updatePaymentMethodStatus(h){return this.store.select(x.xi).pipe((0,e.s)(1),(0,I.n)(p=>this._apollo.mutate({mutation:D,variables:{updateEntityStatusInput:h},errorPolicy:"all"}).pipe((0,m.M)(({errors:d})=>{if(d){let b="";d.forEach(R=>b+=`\n ${R.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:b,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}const g=structuredClone(p);g[p.findIndex(b=>b.id===h.id)].active=h.active,this.store.dispatch((0,E.f)({paymentMethods:g}))}))))}removePaymentMethod(h){return this.store.select(x.xi).pipe((0,e.s)(1),(0,I.n)(p=>this._apollo.mutate({mutation:M,variables:{removePaymentMethodId:h},errorPolicy:"all"}).pipe((0,m.M)(({errors:d})=>{if(d){let b="";d.forEach(R=>b+=`\n ${R.message}.`),this._snackBar.openFromComponent($.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:1e4,data:{message:b,title:"Error",type:"error",svgIcon:"mat_solid:error"}})}const g=structuredClone(p),_=p.findIndex(b=>b.id===h);g.splice(_,1),this.store.dispatch((0,E.f)({paymentMethods:g}))}))))}static#e=this.\u0275fac=function(p){return new(p||j)(v.KVO(V.UG))};static#t=this.\u0275prov=v.jDH({token:j,factory:j.\u0275fac,providedIn:"root"})}return j})()},3899:(B,S,a)=>{a.d(S,{o:()=>I});const I=(0,a(59640).Mz)(m=>m.rates,m=>m.rates)},25910:(B,S,a)=>{a.d(S,{f:()=>j});var v=a(54438),e=a(96697),I=a(25558),m=a(88141),s=a(96354),k=a(53473),P=a(59640),E=a(98216),x=a(28610),$=a(3899);const A=k.J1`
mutation CreateRate($createRateInput: CreateRateInput!) {
createRate(createRateInput: $createRateInput) {
ok
message
rate {
id
active
userId
date
name
value
currencyRefId
currencyRef {
id
name
iso
}
currencyBaseId
currencyBase {
id
name
iso
}
}
}
}
`,Y=k.J1`
mutation UpdateRate($updateRateInput: UpdateRateInput!) {
updateRate(updateRateInput: $updateRateInput) {
ok
message
rate {
id
active
userId
date
name
value
currencyRefId
currencyRef {
id
name
iso
}
currencyBaseId
currencyBase {
id
name
iso
}
}
}
}
`,G=k.J1`
mutation Mutation($updateEntityStatusInput: UpdateEntityStatusInput!) {
updateRateStatus(updateEntityStatusInput: $updateEntityStatusInput) {
ok
message
}
}
`,T=k.J1`
mutation RemoveRate($removeRateId: String!) {
removeRate(id: $removeRateId) {
ok
message
}
}
`,M=k.J1`
query FindAllRates($page: Int, $size: Int, $sort: String, $order: Order, $search: String) {
findAllRates(page: $page, size: $size, sort: $sort, order: $order, search: $search) {
ok
message
pagination {
length,
size,
page,
lastPage,
startIndex,
endIndex
}
rates {
id
active
userId
date
name
value
currencyRefId
currencyRef {
id
name
iso
}
currencyBaseId
currencyBase {
id
name
iso
}
}
}
}
`,D=k.J1`
query FindActiveByBaseId($currencyBaseId: String!) {
findActiveByBaseId(currencyBaseId: $currencyBaseId) {
id
active
date
name
value
currencyRefId
currencyRef {
id
iso
}
currencyBaseId
currencyBase {
id
iso
}
}
}
`,V=k.J1`
query FindActiveRateByBaseIdForAthendatPlatform($currencyBaseId: String!) {
getActiveRateByBaseIdForAthendatPlatform(currencyBaseId: $currencyBaseId) {
id
active
date
name
value
currencyRefId
currencyRef {
id
iso
}
currencyBaseId
currencyBase {
id
iso
}
}
}
`,f=k.J1`
query FindRateById($findRateByIdId: String!) {
findRateById(id: $findRateByIdId) {
ok
message
rate {
id
active
userId
date
name
value
currencyRefId
currencyRef {
id
name
iso
}
currencyBaseId
currencyBase {
id
name
iso
}
}
}
}
`;let j=(()=>{class y{constructor(){this.apolloProvider=(0,v.WQX)(k.Ic),this.store=(0,v.WQX)(P.il),this._apollo=this.apolloProvider.use("BALANC")}createRate(p){return this.store.select($.o).pipe((0,e.s)(1),(0,I.n)(d=>this._apollo.mutate({mutation:A,variables:{createRateInput:p},errorPolicy:"all"}).pipe((0,m.M)(({data:g})=>{const _=structuredClone(d);_.push(g.createRate.rate),this.store.dispatch((0,x.CD)({rates:_}))}))))}getRates(p=0,d=10,g="name",_="asc",b=""){return this._apollo.query({query:M,errorPolicy:"all",variables:{page:p,size:d,sort:g,order:_,search:b}}).pipe((0,m.M)(({data:R})=>{this.store.dispatch((0,E.Bp)({pagination:R.findAllRates.pagination})),this.store.dispatch((0,x.CD)({rates:R.findAllRates.rates}))}))}findActiveByBaseId(p){return this._apollo.query({query:D,variables:{currencyBaseId:p},errorPolicy:"all"}).pipe((0,s.T)(({data:d})=>d?d.findActiveByBaseId:[]),(0,m.M)(d=>{d&&this.store.dispatch((0,x.CD)({rates:d}))}))}getActiveRateByBaseIdForAthendatPlatform(p){return this._apollo.query({query:V,variables:{currencyBaseId:p},errorPolicy:"all"}).pipe((0,s.T)(({data:d})=>d?d.getActiveRateByBaseIdForAthendatPlatform:null),(0,m.M)(d=>{d&&this.store.dispatch((0,x.r$)({rate:d}))}))}getRateById(p){return this._apollo.query({query:f,variables:{findRateByIdId:p},errorPolicy:"all"}).pipe((0,m.M)(({data:d})=>{this.store.dispatch((0,x.r$)({rate:d.findRateById.rate}))}))}updateRate(p){return this.store.select($.o).pipe((0,e.s)(1),(0,I.n)(d=>this._apollo.mutate({mutation:Y,variables:{updateRateInput:p},errorPolicy:"all"}).pipe((0,m.M)(({data:g})=>{const _=structuredClone(d);_[d.findIndex(R=>R.id===p.id)]=g.updateRate.rate,this.store.dispatch((0,x.CD)({rates:_}))}))))}updateRateStatus(p){return this.store.select($.o).pipe((0,e.s)(1),(0,I.n)(d=>this._apollo.mutate({mutation:G,variables:{updateEntityStatusInput:p},errorPolicy:"all"}).pipe((0,m.M)(({})=>{const _=structuredClone(d);_[d.findIndex(R=>R.id===p.id)].active=p.active,this.store.dispatch((0,x.CD)({rates:_}))}))))}removeRate(p){return this.store.select($.o).pipe((0,e.s)(1),(0,I.n)(d=>this._apollo.mutate({mutation:T,variables:{removeRateId:p},errorPolicy:"all"}).pipe((0,m.M)(({data:g})=>{if(g){const _=structuredClone(d),b=d.findIndex(R=>R.id===p);_.splice(b,1),this.store.dispatch((0,x.CD)({rates:_}))}}))))}static#e=this.\u0275fac=function(d){return new(d||y)};static#t=this.\u0275prov=v.jDH({token:y,factory:y.\u0275fac,providedIn:"root"})}return y})()},33697:(B,S,a)=>{a.r(S),a.d(S,{default:()=>ro});var v=a(51188),e=a(54438);let I=(()=>{class r{static#e=this.\u0275fac=function(i){return new(i||r)};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["trade-purchases"]],standalone:!0,features:[e.aNF],decls:1,vars:0,template:function(i,o){1&i&&e.nrm(0,"router-outlet")},dependencies:[v.n3],encapsulation:2})}return r})();var m=a(60177),s=a(89417),k=a(88834),P=a(32102),E=a(99213),x=a(59042),$=a(96695),A=a(9183),Y=a(30450),G=a(95416),T=a(2042),M=a(7673),D=a(21413),V=a(57786),f=a(56977),j=a(70152),y=a(99172),h=a(70980),p=a(31397),d=a(25558),g=a(96354),_=a(47413),b=a(21781),R=a(84713),w=a(70819),ne=a(63729),ve=a(35526),Fe=a(56730),Z=a(33446),K=a(96697),U=a(88141),Ce=a(98216),L=a(59640);const pe=r=>r.suppliers,O=((0,L.Mz)(pe,r=>r.supplier),(0,L.Mz)(pe,r=>r.suppliers));var X=a(51451),z=a(53473);const ye=z.J1`
mutation CreateSupplier($createSupplierInput: CreateSupplierInput!) {
createSupplier(createSupplierInput: $createSupplierInput) {
ok
message
supplier {
id
active
code
email
name
nit
phone
}
}
}
`,be=z.J1`
mutation UpdateSupplier($updateSupplierInput: UpdateSupplierInput!) {
updateSupplier(updateSupplierInput: $updateSupplierInput) {
ok
message
supplier {
id
active
code
email
name
nit
phone
}
}
}
`,xe=z.J1`
mutation Mutation($updateEntityStatusInput: UpdateEntityStatusInput!) {
updateSupplierStatus(updateEntityStatusInput: $updateEntityStatusInput) {
ok
message
}
}
`,Ie=z.J1`
mutation RemoveSupplier($removeSupplierId: String!) {
removeSupplier(id: $removeSupplierId) {
ok
message
}
}
`,ke=z.J1`
query FindAllSuppliers($page: Int, $size: Int, $sort: String, $order: Order, $search: String) {
findAllSuppliers(page: $page, size: $size, sort: $sort, order: $order, search: $search) {
ok
message
pagination {
length,
size,
page,
lastPage,
startIndex,
endIndex
}
suppliers {
id
active
code
email
name
nit
phone
}
}
}
`,Re=z.J1`
query FindActiveSuppliers($search: String!, $size: Int!) {
findActiveSuppliers(search: $search, size: $size) {
id
active
code
email
name
nit
phone
}
}
`,Pe=z.J1`
query FindSupplierById($findSupplierById: String!) {
findSupplierById(id: $findSupplierById) {
ok
message
supplier {
id
active
code
email
name
nit
phone
}
}
}
`;let Q=(()=>{class r{constructor(t,i){this.apolloProvider=t,this.store=i,this._apollo=this.apolloProvider.use("BALANC")}createSupplier(t){return this.store.select(O).pipe((0,K.s)(1),(0,d.n)(i=>this._apollo.mutate({mutation:ye,variables:{createSupplierInput:t},errorPolicy:"all"}).pipe((0,U.M)(({data:o})=>{if(o){const n=(0,Z.A)(i);n.push(o.createSupplier.supplier),this.store.dispatch((0,X.as)({suppliers:n}))}}))))}getSuppliers(t=0,i=25,o="name",n="asc",l=""){return this._apollo.query({query:ke,errorPolicy:"all",variables:{page:t,size:i,sort:o,order:n,search:l}}).pipe((0,U.M)(({data:u})=>{u&&(this.store.dispatch((0,X.as)({suppliers:u.findAllSuppliers.suppliers})),this.store.dispatch((0,Ce.Bp)({pagination:u.findAllSuppliers.pagination})))}))}findActiveSuppliers(t="",i=10){return this._apollo.query({query:Re,variables:{search:t,size:i},errorPolicy:"all"}).pipe((0,g.T)(({data:o})=>o?o.findActiveSuppliers:[]),(0,U.M)(o=>{o&&this.store.dispatch((0,X.as)({suppliers:o}))}))}getSupplierById(t){return this._apollo.query({query:Pe,variables:{findSupplierByIdId:t},errorPolicy:"all"}).pipe((0,U.M)(({data:i})=>{i&&this.store.dispatch((0,X.hP)({supplier:i.findSupplierById.supplier}))}))}updateSupplier(t){return this.store.select(O).pipe((0,K.s)(1),(0,d.n)(i=>this._apollo.mutate({mutation:be,variables:{updateSupplierInput:t},errorPolicy:"all"}).pipe((0,U.M)(({data:o})=>{if(o){const n=(0,Z.A)(i);n[i.findIndex(u=>u.id===t.id)]=o.updateSupplier.supplier,this.store.dispatch((0,X.as)({suppliers:n}))}}))))}updatesSupplierStatus(t){return this.store.select(O).pipe((0,K.s)(1),(0,d.n)(i=>this._apollo.mutate({mutation:xe,variables:{updateEntityStatusInput:t},errorPolicy:"all"}).pipe((0,U.M)(({data:o})=>{if(o){const n=(0,Z.A)(i);n[i.findIndex(u=>u.id===t.id)].active=t.active,this.store.dispatch((0,X.as)({suppliers:n}))}}))))}removeSupplier(t){return this.store.select(O).pipe((0,K.s)(1),(0,d.n)(i=>this._apollo.mutate({mutation:Ie,variables:{removeSupplierId:t},errorPolicy:"all"}).pipe((0,U.M)(({data:o})=>{if(o){const n=(0,Z.A)(i),l=i.findIndex(u=>u.id===t);n.splice(l,1),this.store.dispatch((0,X.as)({suppliers:n}))}}))))}static#e=this.\u0275fac=function(i){return new(i||r)(e.KVO(z.Ic),e.KVO(L.il))};static#t=this.\u0275prov=e.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var q=a(94794),Ee=a(78357),ae=a(82765),ee=a(59115),ce=a(64193),te=a(14823),re=a(46601),me=a(32488);const Se=["voucherFilter"],$e=["voucherDateFilter"],Me=["supplierFilter"],je=["paymentMethodFilter"],Te=["statusFilter"],Ge=["paymentStatusFilter"],De=()=>({wheelPropagation:!1}),Ne=()=>["nueva","recibida","cancelada","rechazada"],Be=()=>["pendiente","pagada"],Ae=(r,c)=>({"pointer-events-none":r,hidden:c}),Ye=()=>[10,25,50,100],Ve=(r,c,t,i)=>({"bg-amber-50 text-amber-700":r,"text-blue-700 bg-blue-50":c,"text-red-700 bg-red-50":t,"text-orange-700 bg-orange-50":i}),we=(r,c)=>({"text-primary-700 bg-primary-50":r,"text-green-700 bg-green-50":c});function ze(r,c){1&r&&e.nrm(0,"mat-icon",57),2&r&&e.Y8G("svgIcon","mat_solid:done")}function Ue(r,c){1&r&&e.nrm(0,"mat-icon",57),2&r&&e.Y8G("svgIcon","mat_solid:done")}function Xe(r,c){1&r&&e.nrm(0,"mat-icon",57),2&r&&e.Y8G("svgIcon","mat_solid:done")}function Je(r,c){if(1&r){const t=e.RV6();e.j41(0,"div",46)(1,"div",47),e.EFF(2),e.k0s(),e.j41(3,"div",48),e.EFF(4),e.k0s(),e.j41(5,"div",48),e.EFF(6),e.k0s(),e.j41(7,"div",49),e.EFF(8),e.nI1(9,"date"),e.k0s(),e.j41(10,"div",50),e.EFF(11),e.k0s(),e.j41(12,"div",48),e.EFF(13),e.k0s(),e.j41(14,"div",51)(15,"span"),e.EFF(16),e.nI1(17,"number"),e.k0s(),e.j41(18,"span",52),e.EFF(19),e.k0s()(),e.j41(20,"div",53)(21,"span",54),e.EFF(22),e.nI1(23,"uppercase"),e.k0s()(),e.j41(24,"div",53)(25,"span",54),e.EFF(26),e.nI1(27,"uppercase"),e.k0s()(),e.j41(28,"div",55)(29,"button",56),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(3);return e.Njj(n.viewPurchaseReport(o))}),e.nrm(30,"mat-icon",57),e.k0s(),e.j41(31,"div")(32,"button",58),e.nrm(33,"mat-icon",57),e.k0s(),e.j41(34,"mat-menu",null,6)(36,"div",59),e.EFF(37," Actualizar Estado "),e.k0s(),e.j41(38,"button",60),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(3);return e.Njj(n.updatePurchaseStatus(o.id,null,"pagada"))}),e.j41(39,"div",61),e.DNE(40,ze,1,1,"mat-icon",57),e.k0s(),e.j41(41,"span",62),e.EFF(42,"Pagada"),e.k0s()(),e.j41(43,"button",60),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(3);return e.Njj(n.updatePurchaseStatus(o.id,"cancelada"))}),e.j41(44,"div",61),e.DNE(45,Ue,1,1,"mat-icon",57),e.k0s(),e.j41(46,"span",62),e.EFF(47,"Cancelada"),e.k0s()(),e.j41(48,"button",60),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(3);return e.Njj(n.updatePurchaseStatus(o.id,"rechazada"))}),e.j41(49,"div",61),e.DNE(50,Xe,1,1,"mat-icon",57),e.k0s(),e.j41(51,"span",62),e.EFF(52,"Rechazada"),e.k0s()()()()()()}if(2&r){const t=c.$implicit,i=e.sdS(35);e.R7$(2),e.SpI(" ",t.code," "),e.R7$(2),e.SpI(" ",t.voucher.name," "),e.R7$(2),e.SpI(" ",t.voucherNo," "),e.R7$(2),e.SpI(" ",e.i5U(9,22,t.voucherDate,"dd/MM/yyyy")," "),e.R7$(3),e.SpI(" ",t.supplier.name," "),e.R7$(2),e.SpI(" ",t.paymentMethod.name," "),e.R7$(3),e.JRh(e.i5U(17,25,t.total,"1.2-2")),e.R7$(3),e.JRh(t.currency.iso),e.R7$(),e.Y8G("ngClass",e.ziG(32,Ve,"nueva"===t.status,"recibida"===t.status,"cancelada"===t.status,"rechazada"===t.status)),e.R7$(2),e.SpI(" ",e.bMT(23,28,t.status)," "),e.R7$(2),e.Y8G("ngClass",e.l_i(37,we,"pendiente"===t.paymentStatus,"pagada"===t.paymentStatus)),e.R7$(2),e.SpI(" ",e.bMT(27,30,t.paymentStatus)," "),e.R7$(4),e.Y8G("svgIcon","mat_solid:print"),e.R7$(2),e.Y8G("matMenuTriggerFor",i)("disabled",t.status.includes("cancelada")||t.status.includes("rechazada")),e.R7$(),e.Y8G("svgIcon","mat_solid:update"),e.R7$(5),e.Y8G("disabled",t.paymentStatus.includes("pagada")||t.status.includes("cancelada")||t.status.includes("rechazada")),e.R7$(2),e.vxM(40,t.paymentStatus.includes("pagada")?40:-1),e.R7$(3),e.Y8G("disabled",t.paymentStatus.includes("pagada")||t.status.includes("rechazada")||t.status.includes("cancelada")),e.R7$(2),e.vxM(45,t.status.includes("cancelada")?45:-1),e.R7$(3),e.Y8G("disabled",t.paymentStatus.includes("pagada")||t.status.includes("cancelada")||t.status.includes("rechazada")),e.R7$(2),e.vxM(50,t.status.includes("rechazada")?50:-1)}}function Le(r,c){if(1&r&&e.Z7z(0,Je,53,40,"div",46,e.BUC().trackByFn,!0),2&r){const t=e.XpG();e.Dyx(t)}}function Oe(r,c){1&r&&(e.j41(0,"div",63),e.EFF(1," \xa1No se ha registrado ninguna compra! "),e.k0s())}function Qe(r,c){if(1&r){const t=e.RV6();e.j41(0,"div",26)(1,"div",27)(2,"div",28)(3,"span"),e.EFF(4,"No"),e.k0s()(),e.j41(5,"div",29)(6,"span",30),e.EFF(7,"T.Comprob..."),e.k0s(),e.j41(8,"table-filter",31,0),e.nI1(10,"async"),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addVoucher(o))}),e.k0s()(),e.j41(11,"div",32)(12,"span"),e.EFF(13,"No.Comprob..."),e.k0s()(),e.j41(14,"div",33)(15,"span",34),e.EFF(16,"F.Comprob..."),e.k0s(),e.j41(17,"table-filter",35,1),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addDate(o))}),e.k0s()(),e.j41(19,"div",36)(20,"span"),e.EFF(21,"Proveedor"),e.k0s(),e.j41(22,"table-filter",37,2),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addSupplier(o))}),e.k0s()(),e.j41(24,"div",29)(25,"span",38),e.EFF(26,"M.Pago"),e.k0s(),e.j41(27,"table-filter",31,3),e.nI1(29,"async"),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addPaymentMethod(o))}),e.k0s()(),e.j41(30,"div",39)(31,"span"),e.EFF(32,"Importe"),e.k0s()(),e.j41(33,"div",29)(34,"span",34),e.EFF(35,"Estado"),e.k0s(),e.j41(36,"table-filter",40,4),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addStatus(o))}),e.k0s()(),e.j41(38,"div",29)(39,"span",41),e.EFF(40,"E.Pago"),e.k0s(),e.j41(41,"table-filter",40,5),e.bIt("dataChange",function(o){e.eBV(t);const n=e.XpG();return e.Njj(n.addPaymentStatus(o))}),e.k0s()(),e.j41(43,"div",42)(44,"span"),e.EFF(45,"Acciones"),e.k0s(),e.j41(46,"button",43),e.bIt("click",function(){e.eBV(t);const o=e.XpG();return e.Njj(o.clearTableFilters())}),e.nrm(47,"mat-icon",44),e.k0s()()(),e.DNE(48,Le,2,0)(49,Oe,2,0),e.nrm(50,"mat-paginator",45),e.k0s()}if(2&r){const t=e.XpG();e.R7$(2),e.Y8G("mat-sort-header","code"),e.R7$(6),e.Y8G("filterType","multiSelectEntity")("entityPropertyName","name")("useUpperCase",!1)("data",e.bMT(10,31,t.vouchers$)),e.R7$(3),e.Y8G("mat-sort-header","voucherNo"),e.R7$(4),e.Y8G("mat-sort-header","voucherDate"),e.R7$(2),e.Y8G("filterType","date"),e.R7$(5),e.Y8G("filterType","filterEntity")("searchEntityControl",t.searchSuppliersControl)("entitiesFiltered",t.suppliersFiltered),e.R7$(5),e.Y8G("filterType","multiSelectEntity")("entityPropertyName","name")("useUpperCase",!1)("data",e.bMT(29,33,t.paymentMethods$)),e.R7$(3),e.Y8G("mat-sort-header","total"),e.R7$(4),e.Y8G("mat-sort-header","status"),e.R7$(2),e.Y8G("filterType","multiSelect")("data",e.lJ4(35,Ne)),e.R7$(3),e.Y8G("mat-sort-header","paymentStatus"),e.R7$(2),e.Y8G("filterType","multiSelect")("data",e.lJ4(36,Be)),e.R7$(5),e.Y8G("disabled",!t.existTableFilter()),e.R7$(),e.Y8G("svgIcon","mat_solid:filter_list_off"),e.R7$(),e.vxM(48,c.length>0?48:49),e.R7$(2),e.Y8G("ngClass",e.l_i(37,Ae,t.isLoading,t.pagination.length<10&&t.pagination.page<1))("length",t.pagination.length)("pageIndex",t.pagination.page)("pageSize",t.pagination.size)("pageSizeOptions",e.lJ4(40,Ye))("showFirstLastButtons",!0)}}let qe=(()=>{class r{constructor(t,i,o,n){this._changeDetectorRef=t,this._fuseConfirmationService=i,this._purchasesService=o,this.store=n,this.isLoading=!1,this.purchases$=(0,M.of)([]),this.searchInputControl=new s.MJ(null),this.selectedSupplier=null,this.searchSuppliersControl=new s.MJ(null),this.filterInputControl=new s.MJ,this.selectedVouchersId=[],this.selectedPaymentMethodsId=[],this.selectedDate=null,this.selectedStatus=[],this.selectedPaymentStatus=[],this.vouchers$=(0,M.of)([]),this.paymentMethods$=(0,M.of)([]),this.merchant=null,this.user=null,this._snackBar=(0,e.WQX)(G.UG),this._suppliersService=(0,e.WQX)(Q),this._unsubscribeAll=new D.B,this._documentsService=(0,e.WQX)(Fe.Q)}ngOnInit(){this.store.select(ne.SW).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.user=t,this._changeDetectorRef.markForCheck()}),this.store.select(w.Xb).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.merchant=t,this._changeDetectorRef.markForCheck()}),this.store.select(_.Dz).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.pagination=t,this._changeDetectorRef.markForCheck()}),this.vouchers$=this.store.select(b.gQ),this.paymentMethods$=this.store.select(R.xi),this.purchases$=this.store.select(ve.vY),this.suppliersFiltered=this.searchSuppliersControl.valueChanges.pipe((0,j.B)(200),(0,y.Z)(null),(0,h.j)(()=>{this.isLoading=!1}),(0,p.Z)(t=>null!==t&&"string"==typeof t&&(this.selectedSupplier&&t!==this.selectedSupplier.name||!this.selectedSupplier)?(this.isLoading=!0,this._suppliersService.findActiveSuppliers(t.trim())):(0,M.of)())),this.searchInputControl.valueChanges.pipe((0,f.Q)(this._unsubscribeAll),(0,h.j)(()=>{this.isLoading=!1}),(0,j.B)(300),(0,d.n)(t=>{if(null!==t)return this.isLoading=!0,this._purchasesService.getPurchases(0,25,"code","desc",t,this.selectedSupplier?this.selectedSupplier.id:null,this.selectedVouchersId,this.selectedPaymentMethodsId,this.selectedStatus,this.selectedPaymentStatus,this.selectedDate)}),(0,g.T)(()=>{this.isLoading=!1})).subscribe(),this.filterInputControl.valueChanges.pipe((0,f.Q)(this._unsubscribeAll),(0,j.B)(300),(0,d.n)(t=>(this.isLoading=!0,this._purchasesService.getPurchases(0,25,"code","desc",this.searchInputControl.value,this.selectedSupplier?this.selectedSupplier.id:null,this.selectedVouchersId,this.selectedPaymentMethodsId,this.selectedStatus,this.selectedPaymentStatus,this.selectedDate))),(0,g.T)(()=>{this.isLoading=!1})).subscribe(),this.suppliersFiltered=this.searchSuppliersControl.valueChanges.pipe((0,j.B)(200),(0,y.Z)(null),(0,h.j)(()=>{this.isLoading=!1}),(0,p.Z)(t=>null!==t&&"string"==typeof t&&(this.selectedSupplier&&t!==this.selectedSupplier.name||!this.selectedSupplier)?(this.isLoading=!0,this._suppliersService.findActiveSuppliers(t.trim())):(0,M.of)()))}ngAfterViewInit(){this._sort&&this._paginator&&(this._sort.sort({id:"code",start:"desc",disableClear:!0}),this._changeDetectorRef.markForCheck(),this._sort.sortChange.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(()=>{this._paginator.pageIndex=0}),(0,V.h)(this._sort.sortChange,this._paginator.page).pipe((0,d.n)(()=>(this.isLoading=!0,this._purchasesService.getPurchases(this._paginator.pageIndex,this._paginator.pageSize,this._sort.active,this._sort.direction,this.searchInputControl.value))),(0,g.T)(()=>{this.isLoading=!1})).subscribe())}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}resetSupplier(){this.selectedSupplier=null,this.searchInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addSupplier(t){this.selectedSupplier=t,this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addVoucher(t){this.selectedVouchersId=t.map(i=>i.id),this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addPaymentMethod(t){this.selectedPaymentMethodsId=t.map(i=>i.id),this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addDate(t){this.selectedDate=t,this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addStatus(t){this.selectedStatus=t,this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}addPaymentStatus(t){this.selectedPaymentStatus=t,this.filterInputControl.setValue(""),this._changeDetectorRef.markForCheck()}updatePurchaseStatus(t,i,o){this._fuseConfirmationService.open({title:"Actualizar Estado de la Compra",message:"\xbfEsta seguro que toda la informaci\xf3n es correcta?",icon:{show:!0,name:"mat_solid:question_mark",color:"info"},actions:{confirm:{label:"Aceptar",color:"primary"}}}).afterClosed().subscribe(l=>{"confirmed"===l&&this._purchasesService.updatePurchaseStatus(t,i,o).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(({data:u})=>{this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:u.updatePurchaseStatus.message,title:"Confirmaci\xf3n",type:"success",svgIcon:"mat_solid:done"}})}),this._changeDetectorRef.markForCheck()})}trackByFn(t,i){return i.id||t}viewPurchaseReport(t){this._documentsService.generatePurchaseDocument(t,this.merchant,this.user)}existTableFilter(){return this.voucherFilter?.hasFilter||this.voucherDateFilter?.hasFilter||this.supplierFilter?.hasFilter||this.paymentMethodDateFilter?.hasFilter||this.statusFilter?.hasFilter||this.paymentStatusFilter?.hasFilter}clearTableFilters(){this.voucherFilter?.hasFilter&&this.voucherFilter.clearFilter(),this.voucherDateFilter?.hasFilter&&this.voucherDateFilter.clearFilter(),this.supplierFilter?.hasFilter&&this.supplierFilter.clearFilter(),this.paymentMethodDateFilter?.hasFilter&&this.paymentMethodDateFilter.clearFilter(),this.statusFilter?.hasFilter&&this.statusFilter.clearFilter(),this.paymentStatusFilter?.hasFilter&&this.paymentStatusFilter.clearFilter()}static#e=this.\u0275fac=function(i){return new(i||r)(e.rXU(e.gRc),e.rXU(re.G),e.rXU(me.W),e.rXU(L.il))};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["purchases-list"]],viewQuery:function(i,o){if(1&i&&(e.GBs($.iy,5),e.GBs(T.B4,5),e.GBs(Se,5),e.GBs($e,5),e.GBs(Me,5),e.GBs(je,5),e.GBs(Te,5),e.GBs(Ge,5)),2&i){let n;e.mGM(n=e.lsd())&&(o._paginator=n.first),e.mGM(n=e.lsd())&&(o._sort=n.first),e.mGM(n=e.lsd())&&(o.voucherFilter=n.first),e.mGM(n=e.lsd())&&(o.voucherDateFilter=n.first),e.mGM(n=e.lsd())&&(o.supplierFilter=n.first),e.mGM(n=e.lsd())&&(o.paymentMethodDateFilter=n.first),e.mGM(n=e.lsd())&&(o.statusFilter=n.first),e.mGM(n=e.lsd())&&(o.paymentStatusFilter=n.first)}},standalone:!0,features:[e.aNF],decls:26,vars:12,consts:[["voucherFilter",""],["voucherDateFilter",""],["supplierFilter",""],["paymentMethodFilter",""],["statusFilter",""],["paymentStatusFilter",""],["listStatusMenu","matMenu"],["fuseScrollbar","",1,"absolute","inset-0","flex","flex-col","flex-auto","min-w-0","bg-card","dark:bg-transparent",3,"fuseScrollbarOptions"],[1,"relative","flex","flex-col","px-6","py-8","lg:flex-row","flex-0","lg:items-center","lg:justify-between","md:px-8"],[1,"flex-1","min-w-0"],[1,"flex","flex-wrap","items-center","font-medium"],["routerLink","/desktop",1,"whitespace-nowrap","text-primary-500"],[1,"flex","items-center","ml-1","whitespace-nowrap"],[1,"icon-size-5","text-secondary",3,"svgIcon"],[1,"ml-1","text-primary-500"],[1,"mt-2"],[1,"text-3xl","font-extrabold","leading-7","tracking-tight","truncate","sm:leading-10"],[1,"flex","flex-wrap","items-center","w-full","gap-2","mt-6","md:fixed","right-8","shrink-0","lg:mt-0","lg:ml-4","lg:w-auto","sm:w-1/2"],[1,"fuse-mat-dense","fuse-mat-rounded","min-w-64",3,"subscriptSizing"],["matPrefix","",1,"icon-size-5",3,"svgIcon"],["matInput","",3,"formControl","autocomplete","placeholder"],["mat-raised-button","","routerLink","/modules/trade/purchases/form",1,"text-white","bg-gradient-to-r","from-primary-500","to-primary-700"],[3,"svgIcon"],[1,"hidden","ml-2","mr-1","text-white","sm:block"],[1,"flex","flex-auto"],[1,"z-10","flex","flex-col","flex-auto","bg-white","dark:bg-default"],[1,"relative","grid","border-t"],["matSort","","matSortDisableClear","",1,"sticky","top-0","z-10","grid","gap-4","px-6","py-4","font-semibold","shadow","purchase-grid","md:px-8","text-md","text-secondary","bg-gray-50","dark:bg-slate-900"],[1,"flex","items-center","justify-center",3,"mat-sort-header"],[1,"flex","items-center","justify-center"],["matTooltip","Tipo de Comprobante"],[3,"dataChange","filterType","entityPropertyName","useUpperCase","data"],["matTooltip","N\xfamero de Comprobante",1,"flex","items-center","justify-center",3,"mat-sort-header"],["matTooltip","Fecha de Comprobante",1,"flex","justify-center"],[3,"mat-sort-header"],[3,"dataChange","filterType"],[1,"flex","items-center","justify-start"],[3,"dataChange","filterType","searchEntityControl","entitiesFiltered"],["matTooltip","M\xe9todo de pago"],[1,"flex","items-center","justify-end",3,"mat-sort-header"],[3,"dataChange","filterType","data"],["matTooltip","Estado del pago",3,"mat-sort-header"],[1,"flex","items-center","justify-end","mr-1"],["color","warn","mat-icon-button","","matTooltip","Limpiar filtros",1,"w-6","h-6","min-h-6","min-w-6",3,"click","disabled"],[1,"icon-size-4",3,"svgIcon"],[1,"border-b","first-letter:z-10","sm:inset-x-0","sm:sticky","sm:bottom-0","sm:border-t","sm:border-b-0","bg-gray-50","dark:bg-gray-900",3,"ngClass","length","pageIndex","pageSize","pageSizeOptions","showFirstLastButtons"],[1,"z-0","grid","items-center","gap-4","px-6","py-3","border-b","purchase-grid","md:px-8"],[1,"font-mono"],[1,"text-center"],[1,"font-mono","text-center"],[1,"truncate"],[1,"flex","flex-row","justify-center","space-x-1","font-mono"],[1,"text-xs","text-secondary"],[1,"flex","items-center","justify-center","mr-4","text-center","truncate","delay-100","rounded-full","h-7","lock","dark:bg-white","dark:bg-opacity-5",3,"ngClass"],[1,"w-full","px-2","text-sm","font-medium","text-center"],[1,"flex","flex-row","justify-end","gap-2","mr-2"],["mat-stroked-button","",1,"px-2","leading-6","min-w-10","min-h-7","h-7",3,"click"],[1,"icon-size-5",3,"svgIcon"],["mat-stroked-button","","matTooltip","Actualizar estado de la compra",1,"px-2","leading-6","min-w-10","min-h-7","h-7",3,"matMenuTriggerFor","disabled"],[1,"w-full","p-2","text-lg","font-semibold","text-center","text-secondary"],["mat-menu-item","",1,"grid","w-full","grid-cols-4",3,"click","disabled"],[1,"col-span-1"],[1,"col-span-3","text-center"],[1,"p-8","text-4xl","font-semibold","tracking-tight","text-center","border-t","sm:p-16"]],template:function(i,o){if(1&i&&(e.j41(0,"div",7)(1,"div",8)(2,"div",9)(3,"div",10)(4,"div")(5,"a",11),e.EFF(6,"Inicio"),e.k0s()(),e.j41(7,"div",12),e.nrm(8,"mat-icon",13),e.j41(9,"a",14),e.EFF(10,"Compras"),e.k0s()()(),e.j41(11,"div",15)(12,"h2",16),e.EFF(13," Facturas de Compras "),e.k0s()()(),e.j41(14,"div",17)(15,"mat-form-field",18),e.nrm(16,"mat-icon",19)(17,"input",20),e.k0s(),e.j41(18,"button",21),e.nrm(19,"mat-icon",22),e.j41(20,"span",23),e.EFF(21,"Registrar"),e.k0s()()()(),e.j41(22,"div",24)(23,"div",25),e.DNE(24,Qe,51,41,"div",26),e.nI1(25,"async"),e.k0s()()()),2&i){let n;e.Y8G("fuseScrollbarOptions",e.lJ4(11,De)),e.R7$(8),e.Y8G("svgIcon","mat_solid:chevron_right"),e.R7$(7),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("svgIcon","mat_solid:search"),e.R7$(),e.Y8G("formControl",o.searchInputControl)("autocomplete","off")("placeholder","Escriba para buscar"),e.R7$(2),e.Y8G("svgIcon","mat_solid:add"),e.R7$(5),e.vxM(24,(n=e.bMT(25,9,o.purchases$))?24:-1,n)}},dependencies:[m.Jj,m.vh,m.QX,ce.p,k.Hl,k.$z,k.iY,ae.g7,P.RG,P.rl,P.JW,E.m_,E.An,x.fS,x.fg,ee.Cn,ee.kk,ee.fb,ee.Cp,$.Ou,$.iy,A.D6,Y.mV,T.NQ,T.B4,T.aE,m.YU,s.X1,s.me,s.BC,s.l_,v.Wk,Ee.i,m.Pc,te.uc,te.oV],styles:[".purchase-grid{grid-template-columns:130px 150px 110px 130px 150px 100px 130px 100px 100px auto}@media (min-width: 1280px){.purchase-grid{grid-template-columns:120px 150px 110px 130px 150px 100px 100px 100px 100px auto}}\n"],encapsulation:2,changeDetection:0})}return r})(),We=(()=>{class r{static#e=this.\u0275fac=function(i){return new(i||r)};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["app-purchase-details"]],standalone:!0,features:[e.aNF],decls:2,vars:0,template:function(i,o){1&i&&(e.j41(0,"p"),e.EFF(1,"purchase-details works!"),e.k0s())},encapsulation:2})}return r})();var le=a(82798),ue=a(60850),oe=a(25084),ie=a(75351),He=a(91401),he=a(13189),Ze=a(39928),Ke=a(17085),et=a(99184),tt=a(25910),rt=a(36296),ot=a(68824),it=a(77005),de=a(55364),N=a(5864),st=a(86600);const nt=["stockTemplateFile"],at=(r,c)=>c.id,ct=()=>({suppressScrollX:!0}),lt=()=>({suppressScrollY:!0}),ut=r=>({"cursor-pointer shadow":r}),dt=(r,c)=>({"bg-gray-50 dark:bg-primary dark:bg-opacity-5":r,"bg-white dark:bg-transparent":c}),pt=r=>({"text-warn":r}),mt=()=>["$"],ht=(r,c)=>({"animate-pulse":r,"animate-none":c}),ft=r=>({$implicit:r});function gt(r,c){if(1&r){const t=e.RV6();e.j41(0,"mat-option",60),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG();return e.Njj(n.selectSupplier(o))}),e.EFF(1),e.k0s()}if(2&r){const t=c.$implicit;e.Y8G("value",t),e.R7$(),e.SpI(" ",t.name," ")}}function _t(r,c){if(1&r&&(e.j41(0,"mat-option",28),e.EFF(1),e.k0s()),2&r){const t=c.$implicit;e.Y8G("value",t.id),e.R7$(),e.SpI(" ",t.name," ")}}function vt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El tipo de comprobante es obligatorio "),e.k0s())}function Ft(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El n\xfamero del comprobante es obligatorio "),e.k0s())}function Ct(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La fecha del comprobante es obligatoria "),e.k0s())}function yt(r,c){if(1&r&&(e.j41(0,"mat-option",28),e.EFF(1),e.k0s()),2&r){const t=c.$implicit;e.Y8G("value",t.id),e.R7$(),e.SpI(" ",t.name," ")}}function bt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El tipo de comprobante es obligatorio "),e.k0s())}function xt(r,c){if(1&r){const t=e.RV6();e.j41(0,"mat-option",60),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG();return e.Njj(n.selectedCurrencyIso=o.iso)}),e.EFF(1),e.k0s()}if(2&r){const t=c.$implicit;e.Y8G("value",t.id),e.R7$(),e.SpI(" ",t.iso," ")}}function It(r,c){if(1&r&&(e.j41(0,"span",36),e.EFF(1),e.k0s()),2&r){let t;const i=e.XpG();e.R7$(),e.Lme(" (+ ",2===(null==(t=i.purchaseForm.get("rates").value)?null:t.length)?"otro":"otros"," ",i.purchaseForm.get("rates").value.length>2?i.purchaseForm.get("rates").value.length-1:"",") ")}}function kt(r,c){if(1&r&&(e.j41(0,"mat-option",28)(1,"span",61),e.EFF(2),e.nI1(3,"number"),e.k0s(),e.j41(4,"span"),e.EFF(5),e.k0s()()),2&r){const t=c.$implicit;e.Y8G("value",t),e.R7$(2),e.JRh(e.i5U(3,3,t.value,"1.4-4")),e.R7$(3),e.SpI(" ",t.name,"")}}function Rt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Las tasas de cambio son requeridas "),e.k0s())}function Pt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El costo de FOB es obligatorio "),e.k0s())}function Et(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El costo de FOB debe ser mayor que 0 "),e.k0s())}function St(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Costos FOB"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Pt,2,0,"mat-error")(6,Et,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","fobCosts"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("fobCosts").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("fobCosts").hasError("min")?6:-1)}}function $t(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El flete es obligatorio "),e.k0s())}function Mt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El flete debe ser mayor que 0 "),e.k0s())}function jt(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Flete"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,$t,2,0,"mat-error")(6,Mt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","freight"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("freight").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("freight").hasError("min")?6:-1)}}function Tt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Los aranceles son obligatorios "),e.k0s())}function Gt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Los aranceles deben ser mayores que 0 "),e.k0s())}function Dt(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Aranceles"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Tt,2,0,"mat-error")(6,Gt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","customsDuties"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("customsDuties").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("customsDuties").hasError("min")?6:-1)}}function Nt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Los servicios aduanales son obligatorios "),e.k0s())}function Bt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Los servicios aduanales deben ser mayores que 0 "),e.k0s())}function At(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Servicios Aduanales"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Nt,2,0,"mat-error")(6,Bt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","customsServices"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("customsServices").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("customsServices").hasError("min")?6:-1)}}function Yt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El seguro es obligatorio "),e.k0s())}function Vt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El seguro debe ser mayor que 0 "),e.k0s())}function wt(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Seguro"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Yt,2,0,"mat-error")(6,Vt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","insurance"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("insurance").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("insurance").hasError("min")?6:-1)}}function zt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La transportaci\xf3n es obligatoria "),e.k0s())}function Ut(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La transportaci\xf3n debe ser mayor que 0 "),e.k0s())}function Xt(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Transportaci\xf3n"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,zt,2,0,"mat-error")(6,Ut,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","transportation"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("transportation").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("transportation").hasError("min")?6:-1)}}function Jt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La descarga es obligatoria "),e.k0s())}function Lt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La descarga debe ser mayor que 0 "),e.k0s())}function Ot(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Descarga"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Jt,2,0,"mat-error")(6,Lt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","unloading"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("unloading").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("unloading").hasError("min")?6:-1)}}function Qt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Otros Gastos son obligatorios "),e.k0s())}function qt(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Otros Gastos deben ser mayores que 0 "),e.k0s())}function Wt(r,c){if(1&r&&(e.j41(0,"div",39)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Otros Gastos"),e.k0s(),e.nrm(4,"input",63),e.DNE(5,Qt,2,0,"mat-error")(6,qt,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","otherCosts"),e.R7$(),e.vxM(5,t.purchaseForm.get("indirectCost").get("otherCosts").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.purchaseForm.get("indirectCost").get("otherCosts").hasError("min")?6:-1)}}function Ht(r,c){if(1&r){const t=e.RV6();e.j41(0,"mat-option",64),e.bIt("click",function(o){const n=e.eBV(t).$implicit;return e.XpG().addProductToPurchase(n),e.Njj(o.stopPropagation())}),e.j41(1,"div",65),e.bIt("click",function(o){const n=e.eBV(t).$implicit;return e.XpG().addProductToPurchase(n),e.Njj(o.stopPropagation())}),e.j41(2,"span",66),e.nrm(3,"mat-checkbox",67),e.EFF(4),e.k0s(),e.j41(5,"span",68),e.EFF(6),e.k0s(),e.j41(7,"span",68),e.EFF(8),e.k0s()()()}if(2&r){const t=c.$implicit;e.Y8G("value",t),e.R7$(3),e.Y8G("checked",t.checked),e.R7$(),e.SpI(" ",t.name," "),e.R7$(2),e.JRh(t.currency.iso),e.R7$(2),e.JRh(t.uom.abbr)}}function Zt(r,c){1&r&&(e.j41(0,"span",78),e.EFF(1,"Sin nombre"),e.k0s())}function Kt(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor m\xednimo 0.1 "),e.k0s())}function er(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor requerido "),e.k0s())}function tr(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Patr\xf3n no v\xe1lido "),e.k0s())}function rr(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor m\xednimo 0 "),e.k0s())}function or(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor requerido "),e.k0s())}function ir(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor m\xednimo 0 "),e.k0s())}function sr(r,c){1&r&&(e.j41(0,"mat-error",85),e.EFF(1," Valor requerido "),e.k0s())}function nr(r,c){1&r&&e.eu8(0)}function ar(r,c){if(1&r&&e.DNE(0,nr,1,0,"ng-container",92),2&r){const t=e.XpG().$implicit;e.XpG(2);const i=e.sdS(128);e.Y8G("ngTemplateOutlet",i)("ngTemplateOutletContext",e.eq3(2,ft,t))}}function cr(r,c){if(1&r){const t=e.RV6();e.j41(0,"div",76)(1,"div"),e.EFF(2),e.k0s(),e.j41(3,"div",77),e.EFF(4),e.DNE(5,Zt,2,0,"span",78),e.k0s(),e.j41(6,"div",79),e.EFF(7),e.k0s(),e.j41(8,"div",71),e.EFF(9),e.k0s(),e.j41(10,"div",80)(11,"div",81)(12,"button",82),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(2);return e.Njj(n.decrementProductQty(o))}),e.nrm(13,"mat-icon",49),e.k0s(),e.j41(14,"mat-form-field",83),e.nrm(15,"input",84),e.k0s(),e.j41(16,"button",82),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(2);return e.Njj(n.incrementProductQty(o))}),e.nrm(17,"mat-icon",49),e.k0s()(),e.DNE(18,Kt,2,0,"mat-error",85)(19,er,2,0,"mat-error",85)(20,tr,2,0,"mat-error",85),e.k0s(),e.j41(21,"div",86)(22,"mat-form-field",83),e.nrm(23,"input",87),e.k0s(),e.DNE(24,rr,2,0,"mat-error",85)(25,or,2,0,"mat-error",85),e.k0s(),e.j41(26,"div",71),e.EFF(27),e.nI1(28,"number"),e.k0s(),e.j41(29,"div",88),e.EFF(30),e.nI1(31,"currency"),e.k0s(),e.j41(32,"div",86)(33,"mat-form-field",83),e.nrm(34,"input",87),e.k0s(),e.DNE(35,ir,2,0,"mat-error",85)(36,sr,2,0,"mat-error",85),e.k0s(),e.j41(37,"div",89)(38,"button",90),e.bIt("click",function(){const o=e.eBV(t),n=o.$implicit,l=o.$index,u=e.XpG(2);return e.Njj(u.toggleProductDetail(n,l))}),e.nrm(39,"mat-icon",49),e.k0s(),e.j41(40,"button",91),e.bIt("click",function(){const o=e.eBV(t).$index,n=e.XpG(2);return e.Njj(n.removeProductToPurchase(o))}),e.nrm(41,"mat-icon",49),e.k0s()()(),e.j41(42,"div",58),e.DNE(43,ar,1,4,"ng-container"),e.k0s()}if(2&r){const t=c.$implicit,i=c.$index,o=e.XpG(2);e.Y8G("ngClass",e.l_i(43,dt,o.selectedProductIndex===i,o.selectedProductIndex!==i)),e.R7$(2),e.SpI(" ",i+1," "),e.R7$(),e.Y8G("matTooltip",t.get("name").value),e.R7$(),e.SpI(" ",t.get("name").value," "),e.R7$(),e.vxM(5,t.get("name").value?-1:5),e.R7$(),e.Y8G("ngClass",e.eq3(46,pt,!t.get("rate").value)),e.R7$(),e.SpI(" ",t.get("rate").value?o.selectedCurrencyIso:t.get("currency").value," "),e.R7$(2),e.SpI(" ",t.get("uom").value," "),e.R7$(3),e.Y8G("disabled",t.get("quantity").value<=.1||t.get("quantity").hasError("pattern")),e.R7$(),e.Y8G("svgIcon","mat_solid:remove"),e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("min",.1)("formControl",t.get("quantity")),e.R7$(),e.Y8G("disabled",t.get("quantity").hasError("pattern")),e.R7$(),e.Y8G("svgIcon","mat_solid:add"),e.R7$(),e.vxM(18,t.get("quantity").hasError("min")?18:-1),e.R7$(),e.vxM(19,t.get("quantity").hasError("required")?19:-1),e.R7$(),e.vxM(20,t.get("quantity").hasError("pattern")&&!t.get("quantity").hasError("min")?20:-1),e.R7$(2),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("min",0)("max",99999)("formControl",t.get("cost")),e.R7$(),e.vxM(24,t.get("cost").hasError("min")?24:-1),e.R7$(),e.vxM(25,t.get("cost").hasError("required")?25:-1),e.R7$(2),e.SpI(" ",e.i5U(28,37,t.get("cui").value,"1.2-2")," "),e.R7$(3),e.SpI(" ",e.i5U(31,40,t.get("ct").value,e.lJ4(48,mt))," "),e.R7$(3),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("min",0)("max",9999999)("formControl",t.get("price")),e.R7$(),e.vxM(35,t.get("price").hasError("min")?35:-1),e.R7$(),e.vxM(36,t.get("price").hasError("required")?36:-1),e.R7$(2),e.Y8G("color",t.invalid?"warn":"")("ngClass",e.l_i(49,ht,t.invalid||!t.get("productId").value||t.get("isPerishable").value,t.valid)),e.R7$(),e.Y8G("svgIcon",o.selectedProductIndex===i?"mat_solid:expand_more":"mat_solid:expand_less"),e.R7$(2),e.Y8G("svgIcon","mat_solid:close"),e.R7$(2),e.vxM(43,o.selectedProductIndex===i?43:-1)}}function lr(r,c){if(1&r&&(e.j41(0,"div",58)(1,"div",69),e.nrm(2,"div"),e.j41(3,"div",70),e.EFF(4," Producto "),e.k0s(),e.j41(5,"div",71),e.EFF(6," Moneda "),e.k0s(),e.j41(7,"div",71),e.EFF(8," UM "),e.k0s(),e.j41(9,"div",71),e.EFF(10," Cantidad "),e.k0s(),e.j41(11,"div",72),e.EFF(12," Costo "),e.k0s(),e.j41(13,"div",73),e.EFF(14," Costo Indirecto "),e.k0s(),e.j41(15,"div",74),e.EFF(16," Costo Total "),e.k0s(),e.j41(17,"div",71),e.EFF(18," Precio "),e.k0s(),e.j41(19,"div",75),e.EFF(20," Acciones "),e.k0s()(),e.Z7z(21,cr,44,52,null,null,at),e.k0s()),2&r){const t=e.XpG();e.R7$(21),e.Dyx(t.purchaseForm.get("products").controls)}}function ur(r,c){1&r&&(e.j41(0,"div",93),e.EFF(1," \xa1No ha seleccionado ning\xfan producto a\xfan! "),e.k0s())}function dr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El c\xf3digo de barras es obligatorio "),e.k0s())}function pr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor entre 3 y 255 caracteres. "),e.k0s())}function mr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El nombre es obligatorio "),e.k0s())}function hr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor entre 3 y 255 caracteres. "),e.k0s())}function fr(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",97)(2,"mat-label"),e.EFF(3,"UPC"),e.k0s(),e.nrm(4,"input",98),e.DNE(5,dr,2,0,"mat-error")(6,pr,2,0,"mat-error"),e.k0s()(),e.j41(7,"div",96)(8,"mat-form-field",62)(9,"mat-label"),e.EFF(10,"Nombre"),e.k0s(),e.nrm(11,"input",98),e.DNE(12,mr,2,0,"mat-error")(13,hr,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","upc"),e.R7$(),e.vxM(5,t.selectedProductForm.get("upc").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.selectedProductForm.get("upc").hasError("minlength")||t.selectedProductForm.get("upc").hasError("maxlength")?6:-1),e.R7$(2),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","name"),e.R7$(),e.vxM(12,t.selectedProductForm.get("name").hasError("required")?12:-1),e.R7$(),e.vxM(13,t.selectedProductForm.get("name").hasError("minlength")||t.selectedProductForm.get("name").hasError("maxlength")?13:-1)}}function gr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," El n\xfamero de lote es obligatorio "),e.k0s())}function _r(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor entre 1 y 100 caracteres. "),e.k0s())}function vr(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"N\xfamero de Lote"),e.k0s(),e.nrm(4,"input",99),e.DNE(5,gr,2,0,"mat-error")(6,_r,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","lotNumber")("required",t.selectedProductForm.get("isPerishable").value),e.R7$(),e.vxM(5,t.selectedProductForm.get("lotNumber").hasError("required")?5:-1),e.R7$(),e.vxM(6,t.selectedProductForm.get("lotNumber").hasError("minlength")||t.selectedProductForm.get("lotNumber").hasError("maxlength")?6:-1)}}function Fr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor m\xe1ximo de 100 caracteres. "),e.k0s())}function Cr(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"N\xfamero de Lote"),e.k0s(),e.nrm(4,"input",100),e.k0s()(),e.DNE(5,Fr,2,0,"mat-error")),2&r){const t=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","lotNumber"),e.R7$(),e.vxM(5,t.selectedProductForm.get("lotNumber").hasError("maxlength")?5:-1)}}function yr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," La fecha de vencimiento es obligatoria "),e.k0s())}function br(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Fecha de Vencimiento"),e.k0s(),e.nrm(4,"input",101)(5,"mat-datepicker-toggle",102)(6,"mat-datepicker",null,7),e.DNE(8,yr,2,0,"mat-error"),e.k0s()()),2&r){const t=e.sdS(7),i=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("matDatepicker",t)("formControlName","dueDate")("min",i.maxDate),e.R7$(),e.Y8G("for",t),e.R7$(3),e.vxM(8,i.selectedProductForm.get("dueDate").hasError("required")?8:-1)}}function xr(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor entre 3 y 255 caracteres. "),e.k0s())}function Ir(r,c){1&r&&(e.j41(0,"mat-error"),e.EFF(1," Valor entre 3 y 255 caracteres. "),e.k0s())}function kr(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"SKU"),e.k0s(),e.nrm(4,"input",103),e.DNE(5,xr,2,0,"mat-error"),e.k0s()(),e.j41(6,"div",96)(7,"mat-form-field",62)(8,"mat-label"),e.EFF(9,"C\xf3digo"),e.k0s(),e.nrm(10,"input",103),e.DNE(11,Ir,2,0,"mat-error"),e.k0s()()),2&r){const t=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","sku"),e.R7$(),e.vxM(5,t.selectedProductForm.get("sku").hasError("minlength")||t.selectedProductForm.get("sku").hasError("maxlength")?5:-1),e.R7$(2),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","bCode"),e.R7$(),e.vxM(11,t.selectedProductForm.get("bCode").hasError("minlength")||t.selectedProductForm.get("bCode").hasError("maxlength")?11:-1)}}function Rr(r,c){if(1&r&&(e.j41(0,"mat-option",28),e.EFF(1),e.k0s()),2&r){const t=c.$implicit;e.Y8G("value",t.abbr),e.R7$(),e.SpI(" ",t.name," ")}}function Pr(r,c){if(1&r&&(e.j41(0,"div",96)(1,"mat-form-field",62)(2,"mat-label"),e.EFF(3,"Unidad de Medida"),e.k0s(),e.j41(4,"mat-select",104),e.Z7z(5,Rr,2,2,"mat-option",28,e.fX1),e.nI1(7,"async"),e.k0s()()(),e.j41(8,"div",96)(9,"mat-form-field",62)(10,"mat-label"),e.EFF(11,"Marca"),e.k0s(),e.nrm(12,"input",105),e.k0s()()),2&r){const t=e.XpG(2);e.R7$(),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","uom"),e.R7$(),e.Dyx(e.bMT(7,4,t.uoms$)),e.R7$(4),e.Y8G("subscriptSizing","dynamic"),e.R7$(3),e.Y8G("formControlName","brand")}}function Er(r,c){if(1&r&&(e.j41(0,"div",94)(1,"form",95),e.DNE(2,fr,14,8)(3,vr,7,5,"div",96)(4,Cr,6,3)(5,br,9,6,"div",96)(6,kr,12,6)(7,Pr,13,6),e.k0s()()),2&r){const t=e.XpG();e.R7$(),e.Y8G("formGroup",t.selectedProductForm),e.R7$(),e.vxM(2,t.selectedProductForm.get("productId").value?-1:2),e.R7$(),e.vxM(3,t.selectedProductForm.get("productId").value?3:-1),e.R7$(),e.vxM(4,t.selectedProductForm.get("productId").value?-1:4),e.R7$(),e.vxM(5,t.selectedProductForm.get("lotNumber").value?5:-1),e.R7$(),e.vxM(6,t.selectedProductForm.get("productId").value?-1:6),e.R7$(),e.vxM(7,t.selectedProductForm.get("productId").value?-1:7)}}let Sr=(()=>{class r{constructor(){this.currencies=[],this.currencies$=(0,M.of)([]),this.maxDate=new Date,this.merchant=null,this.paymentMethods$=(0,M.of)([]),this.previewsProductsFormData=[],this.rates=[],this.searchProductControl=new s.MJ(null),this.searchSupplierControl=new s.MJ(null),this.selectedCurrencyIso="",this.selectedProductForm=null,this.selectedProductIndex=-1,this.selectedSupplierName="",this.stayHere=!1,this.total=0,this.uoms$=(0,M.of)([]),this.vouchers=[],this.vouchers$=(0,M.of)([]),this._changeDetectorRef=(0,e.WQX)(e.gRc),this._dialog=(0,e.WQX)(ie.bZ),this._fileSaverService=(0,e.WQX)(ot.f),this._formBuilder=(0,e.WQX)(s.ok),this._fuseConfirmationService=(0,e.WQX)(re.G),this._productsService=(0,e.WQX)(rt.g),this._purchasesService=(0,e.WQX)(me.W),this._ratesService=(0,e.WQX)(tt.f),this._router=(0,e.WQX)(v.Ix),this._snackBar=(0,e.WQX)(G.UG),this._suppliersService=(0,e.WQX)(Q),this._unsubscribeAll=new D.B,this.store=(0,e.WQX)(L.il)}ngOnInit(){this.purchaseForm=this._formBuilder.group({currencyId:new s.MJ(null,[s.k0.required]),supplierId:new s.MJ(null,[s.k0.required]),voucherTypeId:new s.MJ(null,[s.k0.required]),voucherNo:new s.MJ(null,[s.k0.required]),voucherDate:new s.MJ(new Date,[s.k0.required]),paymentMethodId:new s.MJ(null,[s.k0.required]),rates:new s.MJ([],[s.k0.required]),products:new s.Yp([]),indirectCost:this._formBuilder.group({fobCosts:new s.MJ(0,[s.k0.required,s.k0.min(0)]),freight:new s.MJ(0,[s.k0.required,s.k0.min(0)]),insurance:new s.MJ(0,[s.k0.required,s.k0.min(0)]),customsDuties:new s.MJ(0,[s.k0.required,s.k0.min(0)]),customsServices:new s.MJ(0,[s.k0.required,s.k0.min(0)]),transportation:new s.MJ(0,[s.k0.required,s.k0.min(0)]),unloading:new s.MJ(0,[s.k0.required,s.k0.min(0)]),otherCosts:new s.MJ(0,[s.k0.required,s.k0.min(0)])})}),this.store.select(w.Xb).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.merchant=t,this._changeDetectorRef.markForCheck()}),this.purchaseForm.get("voucherTypeId").valueChanges.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{const i=this.vouchers.find(o=>o.id===t);i&&"6e82b91b-a2a7-40e2-8ee1-e31ae3db4826"===i.id?this.purchaseForm.get("voucherNo").clearValidators():this.purchaseForm.get("voucherNo").addValidators([s.k0.required]),this.purchaseForm.get("voucherNo").reset()}),this.purchaseForm.get("indirectCost").valueChanges.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.calcAllIndirectCost()}),this.purchaseForm.get("products").valueChanges.pipe((0,f.Q)(this._unsubscribeAll),(0,j.B)(100)).subscribe(t=>{const i=this.verifyUpcChanges(t,this.previewsProductsFormData);i&&i.upc&&this.findProductsByUpcSAndRefreshForm([i.upc.toString()]),this.verificarCambios(t,this.previewsProductsFormData)&&this.calcAllIndirectCost(),this.previewsProductsFormData=[...t],this._calculatePurchaseTotal(),this._changeDetectorRef.markForCheck()}),this.currencies$=this.store.select(He.y$),this.currencies$.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.currencies=t,N.H.IsNullOrEmpty(t)||setTimeout(()=>{const i=t.find(o=>o.id===this.merchant.currencyId);this.purchaseForm.get("currencyId").setValue(i.id)},500),this._changeDetectorRef.markForCheck()}),this.store.select(he.MW).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{if(t&&t.length>0&&this.currencies.length>0){this.closeFormDetail();const i=[],o=this.purchaseForm.get("products").getRawValue();for(const l of t)o.some(u=>u.upc===l.upc)||i.push(l);i.map(l=>this.createProductFormGroup(l)).filter(l=>null!==l).forEach(l=>{this.purchaseForm.get("products").push(l)}),this._changeDetectorRef.markForCheck(),this.findProductsByUpcSAndRefreshForm(i.filter(l=>l.upc).map(l=>l.upc.toString()))}}),this.suppliers$=this.store.select(O),this.paymentMethods$=this.store.select(R.xi),this.paymentMethods$.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{if(!N.H.IsNullOrEmpty(t)){const i=t.find(o=>"Efectivo"===o.name);this.purchaseForm.get("paymentMethodId").setValue(i?i.id:t[0].id)}this._changeDetectorRef.markForCheck()}),this.vouchers$=this.store.select(b.gQ),this.vouchers$.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{if(this.vouchers=t,!N.H.IsNullOrEmpty(t)){const i=t.find(o=>"Factura"===o.name);this.purchaseForm.get("voucherTypeId").setValue(i?i.id:t[0].id)}this._changeDetectorRef.markForCheck()}),this.products$=this.store.select(he.VW),this.uoms$=this.store.select(Ke.Ns),this.ratesFiltered=this.purchaseForm.get("currencyId").valueChanges.pipe((0,y.Z)(null),(0,p.Z)(t=>{if(t){const i=this.currencies.find(o=>o.id===t);return this.selectedCurrencyIso=i.iso,this._ratesService.findActiveByBaseId(t)}return(0,M.of)([])})),this.ratesFiltered.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.rates=t,this.resetSelectedProductsRates(),this.updateSelectedRates()}),this.purchaseForm.get("rates").valueChanges.pipe((0,f.Q)(this._unsubscribeAll),(0,j.B)(500)).subscribe(t=>{this.resetSelectedProductsRates()}),this.productsFiltered=this.searchProductControl.valueChanges.pipe((0,j.B)(200),(0,y.Z)(null),(0,p.Z)(t=>this._mapChecked(null!==t&&"string"==typeof t?this._productsService.findActiveProducts(t.trim(),10):this.products$))),this.suppliersFiltered=this.searchSupplierControl.valueChanges.pipe((0,j.B)(200),(0,y.Z)(null),(0,p.Z)(t=>null!==t&&"string"==typeof t&&t!==this.selectedSupplierName?this._suppliersService.findActiveSuppliers(t.trim()):this.suppliers$))}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete(),this.store.dispatch((0,Ze.R4)())}voucherNoHasValidator(){return this.purchaseForm.get("voucherNo").hasValidator(s.k0.required)}displayFn(t){return t&&t.name?t.name:""}selectSupplier(t){this.purchaseForm.get("supplierId").setValue(t.id),this.selectedSupplierName=t.name}addPurchaseProduct(t){const i=this.getProductFrom(t);this.purchaseForm.get("products").push(i),this.updateSelectedRates(),this._changeDetectorRef.markForCheck()}removePurchaseProduct(t){this.purchaseForm.get("products").removeAt(t),t===this.selectedProductIndex&&this.closeFormDetail(),this.updateSelectedRates(),this._changeDetectorRef.markForCheck()}addProductToPurchase(t){const i=this.purchaseForm.get("products").getRawValue().findIndex(o=>o.productId===t.id);t.checked?(this.removePurchaseProduct(i),t.checked=!1):t.checked=!0,!(i>-1)&&this.addPurchaseProduct(t)}addNewProduct(){this.purchaseForm.get("products").push(this.createEmptyProductFormGroup())}incrementProductQty(t){const i=t.get("quantity").value;t.get("quantity").setValue(Number(i)+1)}decrementProductQty(t){const i=t.get("quantity").value;t.get("quantity").setValue(Number(i)-1)}removeProductToPurchase(t){this.removePurchaseProduct(t),this.searchProductControl.reset()}selectDepot(){this.openDialog().afterClosed().pipe((0,f.Q)(this._unsubscribeAll)).subscribe(i=>{i&&!N.H.IsNullOrEmpty(i.depot)&&this.createPurchase(i.depot.id)})}createPurchase(t=""){if(this.purchaseForm.invalid||0===this.purchaseForm.get("products").controls.length)return;const i=this.purchaseForm.getRawValue();i.ratesId=i.products.map(n=>n.rateId).filter((n,l,u)=>u.indexOf(n)===l),i.products=i.products.map(n=>new it.vf(n)),i.total=this._calculatePurchaseTotal(),delete i.rates,this._fuseConfirmationService.open({title:"Registrar compra",message:"\xbfEst\xe1 seguro que toda la informaci\xf3n es correcta?",icon:{show:!0,name:"mat_solid:question_mark",color:"info"},actions:{confirm:{label:"Aceptar",color:"primary"}}}).afterClosed().pipe((0,f.Q)(this._unsubscribeAll)).subscribe(n=>{"confirmed"===n&&this._purchasesService.createPurchase(i).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(({data:l})=>{l&&(this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:"Factura de compra creada correctamente",title:"Confirmaci\xf3n",type:"success",appearance:"fill"}}),this.stayHere?this.restoreForm():this._router.navigateByUrl("/modules/trade/purchases/list")),this._changeDetectorRef.markForCheck()})})}toggleProductDetail(t,i){if(this.selectedProductIndex===i)return this.closeFormDetail(),void this._changeDetectorRef.markForCheck();this.selectedProductIndex=i,this.selectedProductForm=t,this._changeDetectorRef.markForCheck()}importStockFormTemplateFile(t){const i=t.target;this.isExcelFile=!!i.files[0].name.match(/(.xls|.xlsx)/),i.files.length>1&&(this.stockTemplateFile.nativeElement.value=""),this.isExcelFile?this._productsService.importStockFormTemplateFile(t):this.stockTemplateFile.nativeElement.value=""}exportProductsTemplate(t){const o=t.getRawValue().map(u=>({upc:u.upc,sku:u.sku,bCode:u.bCode,name:u.name,uom:u.uom,quantity:u.quantity,cost:u.cost,price:u.price,lotNumber:u.lotNumber,dueDate:N.H.isValidDate(u.dueDate)?new Date(u.dueDate):u.dueDate?new Date(u.dueDate.toISODate()):"",brand:u.brand}));this._fileSaverService.exportAsExcelFile(o,"Plantilla de productos",[["UPC","SKU","C\xf3digo","Nombre","Unidad de Medida","Cantidad","Costo","Precio","N\xfamero de Lote","Fecha de Vencimiento","Marca"]],[{wch:20},{wch:20},{wch:20},{wch:30},{wch:16},{wch:10},{wch:10},{wch:10},{wch:20},{wch:20},{wch:10}])}restoreForm(){const t=this.purchaseForm.get("paymentMethodId").value,i=this.purchaseForm.get("voucherTypeId").value;if(this.purchaseForm.get("products").clear(),this.searchSupplierControl.reset(),this.purchaseForm.reset(),this.total=0,this.selectedSupplierName="",this.searchProductControl.setValue(""),this.purchaseForm.get("paymentMethodId").setValue(t),this.purchaseForm.get("voucherTypeId").setValue(i),this.purchaseForm.get("voucherDate").setValue(new Date),this.purchaseForm.get("indirectCost").get("fobCosts").setValue(0),this.purchaseForm.get("indirectCost").get("freight").setValue(0),this.purchaseForm.get("indirectCost").get("insurance").setValue(0),this.purchaseForm.get("indirectCost").get("customsDuties").setValue(0),this.purchaseForm.get("indirectCost").get("customsServices").setValue(0),this.purchaseForm.get("indirectCost").get("transportation").setValue(0),this.purchaseForm.get("indirectCost").get("unloading").setValue(0),this.purchaseForm.get("indirectCost").get("otherCosts").setValue(0),!N.H.IsNullOrEmpty(this.currencies)){const o=this.currencies.find(n=>n.id===this.merchant.currencyId);this.purchaseForm.get("currencyId").setValue(o.id)}}_calculatePurchaseTotal(){const t=this.total=this.purchaseForm.get("products").getRawValue().map(i=>i.ct).reduce((i,o)=>i+o,0);return this.total=Number(t.toFixed(2)),this.total}_mapChecked(t){return t.pipe((0,g.T)(i=>i.map(o=>this.purchaseForm.get("products").getRawValue().some(l=>l.productId===o.id)?{...structuredClone(o),checked:!0}:{...structuredClone(o),checked:!1})))}resetSelectedProductsRates(){const t=this.purchaseForm.get("currencyId").value,o=this.purchaseForm.get("products").getRawValue().reduce((n,l)=>n+Number(l.quantity)*l.cost,0);for(const n of this.purchaseForm.get("products").controls){const l=n.getRawValue(),u=structuredClone(this.purchaseForm.get("rates").value);let F=u.find(W=>W.currencyBaseId===t&&W.currencyRefId===l.currencyId);!F&&t!==l.currencyId&&(F=u.find(W=>W.currencyRefId===t&&W.currencyRefId!==W.currencyBaseId),F&&(F.value=1/F.value));let C=F?F.value:null;const J=n.get("cost").value,se=n.get("price").value;let H=n.get("rate").value?n.get("rate").value:1;H&&C===H&&(H=1,C=1),n.patchValue({...l,cost:C?J*C:1*J/H,price:C?se*C:1*se/H,rate:F?F.value:null,rateId:F?F.id:null}),this.calcIndirectCost(n,o)}this._changeDetectorRef.markForCheck()}calcAllIndirectCost(){const t=this.purchaseForm.get("products").getRawValue();this.previewsProductsFormData=[...t];const i=t.reduce((o,n)=>o+Number(n.quantity)*n.cost,0);for(const o of this.purchaseForm.get("products").controls)this.calcIndirectCost(o,i)}calcIndirectCost(t,i){const o=this.purchaseForm.get("indirectCost").getRawValue(),n=o.fobCosts+o.freight+o.insurance+o.customsDuties+o.customsServices+o.transportation+o.unloading+o.otherCosts,l=t.getRawValue(),F=Number(l.quantity)*l.cost/i*n,C=Number((F/Number(l.quantity)).toFixed(2)),J=l.cost+C,se=Number((l.quantity*J).toFixed(2));t.patchValue({...l,cui:C,cut:J,ct:se})}createProductFormGroup(t){if(this.currencies.length>0){const i=this.currencies.find(F=>F.id===this.merchant.currencyId),o=this.purchaseForm.get("currencyId").value,l=structuredClone(this.purchaseForm.get("rates").value).find(F=>F.currencyBaseId===o&&F.currencyRefId===i.id),u=this._formBuilder.group({upc:[t.upc,[s.k0.required]],sku:[t.sku],bCode:[t.bCode],name:[t.name,[s.k0.required]],description:[t.description,[s.k0.maxLength(1e4)]],uom:[t.uom?t.uom:"U",[s.k0.required]],quantity:[Number(t.quantity),[de.t.onlyNumbersPattern(),s.k0.required,s.k0.min(.1)]],cost:new s.MJ((l?l.value:1)*t.cost,[s.k0.required,s.k0.min(0),s.k0.max(99999999)]),cui:new s.MJ(0),cut:new s.MJ(0),ct:new s.MJ(0),isPerishable:[t?.isPerishable],lotNumber:[t?.lotNumber,[s.k0.maxLength(100)]],dueDate:[t?.dueDate],price:[t.price,[s.k0.required,s.k0.min(0),s.k0.max(9999999)]],brand:[t.brand],currencyId:new s.MJ(i.id,[s.k0.required]),currency:new s.MJ(i.iso,[s.k0.required]),rate:new s.MJ(l?l.value:null,[s.k0.required]),rateId:new s.MJ(l?l.id:null),productId:[null]});return!N.H.IsNullOrEmpty(t.isPerishable)&&!0===t.isPerishable&&(u.get("lotNumber").addValidators([s.k0.required]),u.get("dueDate").addValidators([s.k0.required])),u}return null}createEmptyProductFormGroup(){if(this.currencies.length>0){const t=this.currencies.find(l=>l.id===this.merchant.currencyId),i=this.purchaseForm.get("currencyId").value,n=structuredClone(this.purchaseForm.get("rates").value).find(l=>l.currencyBaseId===i&&l.currencyRefId===t.id);return this._formBuilder.group({upc:[null,[s.k0.required]],sku:[null],bCode:[null],name:[null,[s.k0.required]],description:[null,[s.k0.maxLength(1e4)]],uom:["U",[s.k0.required]],quantity:[1,[de.t.onlyNumbersPattern(),s.k0.required,s.k0.min(.1)]],cost:new s.MJ(0,[s.k0.required,s.k0.min(0),s.k0.max(99999999)]),cui:new s.MJ(0),cut:new s.MJ(0),ct:new s.MJ(0),isPerishable:[!1],lotNumber:[null,[s.k0.maxLength(100)]],dueDate:[null],price:[0,[s.k0.required,s.k0.min(0),s.k0.max(9999999)]],brand:[""],currencyId:new s.MJ(t.id,[s.k0.required]),currency:new s.MJ(t.iso,[s.k0.required]),rate:new s.MJ(n?n.value:null,[s.k0.required]),rateId:new s.MJ(n?n.id:null),productId:[null]})}return null}verificarCambios(t,i){for(let o=0;o<t.length;o++)if(t.length!==i.length||t[o].cost!==i[o].cost||Number(t[o].quantity)!==Number(i[o].quantity))return!0;return!1}verifyUpcChanges(t,i){for(let o=0;o<t.length;o++){const n=i[o]?structuredClone(i[o]):null;if(n&&t[o].upc!==n.upc&&N.H.IsNullOrEmpty(t[o].productId))return t[o];if(t.length!==i.length&&t.length>0&&N.H.IsNullOrEmpty(t[o].productId))return t[t.length-1]}return null}findProductsByUpcSAndRefreshForm(t){this._productsService.findProductsByUpcS(t).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(i=>{const o=this.purchaseForm.get("products").getRawValue();for(const n of this.purchaseForm.get("products").controls){const l=n.getRawValue(),u=i.findIndex(F=>F.upc===l.upc);-1!==u&&(!l.productId&&o.some(F=>F.upc===l.upc&&F.productId===i[u].id)?n.get("upc").reset():(n.patchValue({...this.getProductFrom({...i[u]}).getRawValue(),quantity:Number(l.quantity),price:l.price,cost:l.cost,lotNumber:l?.lotNumber,dueDate:new Date(l?.dueDate)}),this.closeFormDetail()))}this.updateSelectedRates()})}getProductFrom(t){const i=this.purchaseForm.get("currencyId").value,o=structuredClone(this.purchaseForm.get("rates").value);let n=o.find(u=>u.currencyBaseId===i&&u.currencyRefId===t.currencyId);n||(n=o.find(u=>u.currencyRefId===i&&u.currencyRefId!==u.currencyBaseId),n&&(n.value=1/n.value));const l=this._formBuilder.group({productId:new s.MJ(t.id,[s.k0.required]),currencyId:new s.MJ(t.currencyId,[s.k0.required]),name:new s.MJ(t.name,[s.k0.required]),cost:new s.MJ((n?n.value:1)*t.cost,[s.k0.required,s.k0.min(0),s.k0.max(99999999)]),cui:new s.MJ(0),cut:new s.MJ(0),ct:new s.MJ(0),price:new s.MJ((n?n.value:1)*t.price,[s.k0.required,s.k0.min(0),s.k0.max(99999999)]),uom:new s.MJ(t.uom.abbr,[s.k0.required]),currency:new s.MJ(t.currency.iso,[s.k0.required]),rateId:new s.MJ(n?n.id:null,[s.k0.required]),rate:new s.MJ(n?n.value:null,[s.k0.required]),quantity:new s.MJ(1,[de.t.onlyNumbersPattern(),s.k0.required,s.k0.min(.1)]),isPerishable:[t?.isPerishable],lotNumber:[null,[s.k0.maxLength(100)]],dueDate:[null],upc:[t.upc,[s.k0.required]],sku:[t.sku],bCode:[t.bCode],description:[t.description,[s.k0.maxLength(1e4)]],brand:[t.brand.name]});return!N.H.IsNullOrEmpty(t.isPerishable)&&!0===t.isPerishable&&(l.get("lotNumber").addValidators([s.k0.required]),l.get("dueDate").addValidators([s.k0.required])),l}updateSelectedRates(){const t=this.purchaseForm.get("currencyId").value,i=this.purchaseForm.get("products").getRawValue();let o=[];for(const l of i)o=[...this.rates.filter(C=>C.currencyBaseId===t&&C.currencyRefId===l.currencyId),...this.rates.filter(C=>C.currencyBaseId===l.currencyId&&C.currencyRefId===t&&C.currencyRefId!==C.currencyBaseId),...o];const n=o.reduce((l,u)=>(l.find(C=>C.id===u.id&&C.name===u.name)||l.push(u),l),[]);this.purchaseForm.get("rates").setValue(n)}closeFormDetail(){this.selectedProductIndex=-1,this.selectedProductForm=null}openDialog(){return this._dialog.open(et._,{data:{},panelClass:"ath-dialog-panel",disableClose:!0})}static#e=this.\u0275fac=function(i){return new(i||r)};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["purchase-form"]],viewQuery:function(i,o){if(1&i&&e.GBs(nt,5),2&i){let n;e.mGM(n=e.lsd())&&(o.stockTemplateFile=n.first)}},standalone:!0,features:[e.aNF],decls:132,vars:77,consts:[["purchaseNgForm","ngForm"],["supplierAutocomplete","matAutocomplete"],["voucherDate",""],["indirectCost",""],["productsAutocomplete","matAutocomplete"],["templateFile",""],["rowDetailsTemplate",""],["dueDate",""],["fuseScrollbar","",1,"absolute","inset-0","flex","flex-col","flex-auto","min-w-0",3,"fuseScrollbarOptions"],[1,"relative","flex","flex-col","px-6","py-8","lg:flex-row","flex-0","lg:items-center","lg:justify-between","md:px-8"],[1,"flex-1","min-w-0"],[1,"flex","flex-wrap","items-center","font-medium"],["routerLink","/desktop",1,"whitespace-nowrap","text-primary-500"],[1,"flex","items-center","ml-1","whitespace-nowrap"],[1,"icon-size-5","text-secondary",3,"svgIcon"],[1,"ml-1","text-primary-500"],[1,"mt-2"],[1,"text-3xl","font-extrabold","leading-7","tracking-tight","truncate","sm:leading-10"],[1,"flex","items-center","gap-2","mt-6","shrink-0","lg:mt-0","lg:ml-4"],["color","primary",3,"ngModelChange","ngModel"],["mat-flat-button","",1,"text-white","bg-gradient-to-r","from-primary-500","to-primary-700",3,"click","disabled"],[1,"flex","flex-col","px-4","mt-4","mb-12","gap-y-8","sm:px-8"],[1,"col-span-2","shadow","rounded-2xl","bg-card"],[1,"grid","gap-4","p-10","sm:grid-cols-4","lg:grid-cols-5",3,"formGroup"],["appearance","fill",1,"w-full","md:col-span-2","fuse-mat-dense"],["matPrefix","",3,"svgIcon"],["type","text","matInput","",3,"formControl","matAutocomplete","placeholder","required"],[1,"ath-autocomplete",3,"displayWith"],[3,"value"],[1,"w-full","fuse-mat-dense"],[3,"formControlName","required"],["matInput","","maxlength","50",3,"type","formControlName","required"],["matInput","",3,"matDatepicker","formControlName","max","required"],["matIconSuffix","",3,"for"],[3,"formControlName","required","placeholder"],["multiple","",3,"formControlName","required","placeholder"],[1,"text-sm","opacity-75"],["value","importation"],["value","national"],["formGroupName","indirectCost"],[1,"col-span-4","shadow","rounded-2xl","bg-card"],[1,"p-6","pb-0"],[1,"flex","flex-col-reverse","justify-between","sm:flex-row"],["appearance","fill",1,"w-full","md:mr-8","fuse-mat-dense",3,"subscriptSizing"],["type","text","matInput","",3,"formControl","matAutocomplete","placeholder"],[1,"ath-autocomplete",3,"closed","displayWith"],[1,"w-full","bg-default",3,"click"],[1,"flex","items-center","justify-center","w-full",3,"click"],[1,"inline-flex","items-center","rounded","cursor-pointer"],[1,"icon-size-5",3,"svgIcon"],[1,"ml-2","font-medium","text-secondary","group-hover:underline"],[1,"w-full",3,"value"],[1,"flex","items-center","self-end","sm:w-20","sm:space-x-2","sm:justify-evenly"],["mat-icon-button","","matTooltip","Importar Plantilla",1,"rounded-full","cursor-pointer","hover:bg-hover"],["for","template-file-input",1,"flex","items-center","cursor-pointer","p-2.5"],["id","template-file-input","type","file","accept",".xls, .xlsx",1,"absolute","invisible","w-0","h-0","opacity-0","pointer-events-none",3,"change"],["mat-icon-button","","matTooltip","Descargar Plantilla",3,"click"],["fuseScrollbar","",1,"flex","flex-col","flex-auto","pb-3","mt-2","min-h-72",3,"fuseScrollbarOptions"],[1,"grid"],[1,"flex","items-center","justify-center","w-full","gap-2","p-2","font-mono","text-3xl","font-semibold","leading-7","text-white","rounded-b-2xl","bg-gradient-to-r","from-primary-500","to-primary-700",3,"click","ngClass"],[3,"click","value"],[1,"w-18"],[1,"w-full","fuse-mat-dense",3,"subscriptSizing"],["matInput","","type","number","min","0",3,"formControlName"],[1,"w-full",3,"click","value"],[1,"grid","w-full","grid-cols-6",3,"click"],[1,"flex","flex-row","items-center","col-span-5","truncate","md:col-span-3"],["color","primary",3,"checked"],[1,"flex","items-center","text-center"],[1,"sticky","top-0","z-10","grid","gap-4","px-6","py-4","font-semibold","purchase-products-grid","md:px-8","text-md","text-secondary","bg-gray-50","dark:bg-primary","dark:bg-opacity-5"],[1,"text-left"],[1,"text-center"],["matTooltip","Costo Unitario Directo",1,"text-center"],["matTooltip","Costo Unitario Indirecto",1,"text-center"],["matTooltip","Costo Total = (Costo + CUI) x Cantidad",1,"text-right"],[1,"mr-2","text-right"],[1,"grid","items-center","gap-4","px-6","py-3","border-b","purchase-products-grid","md:px-8",3,"ngClass"],[1,"truncate",3,"matTooltip"],[1,"text-warn"],[1,"text-center",3,"ngClass"],[1,"flex","flex-col","justify-center"],[1,"flex","flex-row","items-center","justify-center","gap-2"],["mat-stroked-button","",1,"p-2","leading-6","min-w-7","min-h-7","h-7",3,"click","disabled"],[1,"fuse-mat-dense","fuse-mat-rounded",3,"subscriptSizing"],["matInput","","type","text","name","quantity",1,"font-mono","font-semibold","text-center",3,"min","formControl"],[1,"w-full","text-sm","text-center"],[1,"flex","flex-col","items-center","justify-center"],["matInput","","type","number",1,"font-mono","font-semibold","text-center",3,"min","max","formControl"],[1,"font-mono","text-right"],[1,"flex","justify-end","gap-2"],["mat-stroked-button","",1,"px-2","leading-6","min-w-10","min-h-7","h-7",3,"click","color","ngClass"],["mat-stroked-button","",1,"px-2","leading-6","min-w-10","min-h-7","h-7",3,"click"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"p-8","text-4xl","font-semibold","tracking-tight","text-center","border-t","sm:p-30"],[1,"p-6","mb-4","overflow-hidden","shadow-lg"],[1,"grid","grid-cols-8","gap-4",3,"formGroup"],[1,"col-span-2"],["matTooltip","C\xf3digo de barras",1,"w-full","fuse-mat-dense",3,"subscriptSizing"],["matInput","","type","text","minlength","3","maxlength","255","required","",3,"formControlName"],["matInput","","type","text","minlength","1","maxlength","100",3,"formControlName","required"],["matInput","","type","text","maxlength","100",3,"formControlName"],["matInput","","required","",3,"matDatepicker","formControlName","min"],["matSuffix","",3,"for"],["matInput","","type","text","minlength","3","maxlength","255",3,"formControlName"],["required","",3,"formControlName"],["matInput","","type","text","minlength","1","maxlength","255",3,"formControlName"]],template:function(i,o){if(1&i){const n=e.RV6();e.j41(0,"div",8)(1,"div",9)(2,"div",10)(3,"div",11)(4,"div")(5,"a",12),e.EFF(6,"Inicio"),e.k0s()(),e.j41(7,"div",13),e.nrm(8,"mat-icon",14),e.j41(9,"a",15),e.EFF(10,"Compras"),e.k0s()()(),e.j41(11,"div",16)(12,"h2",17),e.EFF(13," Registrar Factura de Compra "),e.k0s()()(),e.j41(14,"div",18)(15,"mat-checkbox",19),e.mxI("ngModelChange",function(u){return e.eBV(n),e.DH7(o.stayHere,u)||(o.stayHere=u),e.Njj(u)}),e.EFF(16,"Permanecer aqu\xed"),e.k0s(),e.j41(17,"button",20),e.bIt("click",function(){return e.eBV(n),e.Njj(o.createPurchase())}),e.EFF(18," Registrar "),e.k0s()()(),e.j41(19,"div",21)(20,"div",22)(21,"form",23,0)(23,"mat-form-field",24)(24,"mat-label"),e.EFF(25,"Proveedor"),e.k0s(),e.nrm(26,"mat-icon",25)(27,"input",26),e.j41(28,"mat-autocomplete",27,1),e.Z7z(30,gt,2,2,"mat-option",28,e.fX1),e.nI1(32,"async"),e.k0s()(),e.j41(33,"mat-form-field",29)(34,"mat-label"),e.EFF(35,"Tipo de comprobante"),e.k0s(),e.j41(36,"mat-select",30),e.Z7z(37,_t,2,2,"mat-option",28,e.fX1),e.nI1(39,"async"),e.k0s(),e.DNE(40,vt,2,0,"mat-error"),e.k0s(),e.j41(41,"mat-form-field",29)(42,"mat-label"),e.EFF(43,"N\xfamero del comprobante"),e.k0s(),e.nrm(44,"input",31),e.DNE(45,Ft,2,0,"mat-error"),e.k0s(),e.j41(46,"mat-form-field",29)(47,"mat-label"),e.EFF(48,"Fecha del comprobante"),e.k0s(),e.nrm(49,"input",32),e.j41(50,"mat-hint"),e.EFF(51,"DD/MM/YYYY"),e.k0s(),e.nrm(52,"mat-datepicker-toggle",33)(53,"mat-datepicker",null,2),e.DNE(55,Ct,2,0,"mat-error"),e.k0s(),e.j41(56,"mat-form-field",29)(57,"mat-label"),e.EFF(58,"M\xe9todo de pago"),e.k0s(),e.j41(59,"mat-select",30),e.Z7z(60,yt,2,2,"mat-option",28,e.fX1),e.nI1(62,"async"),e.k0s(),e.DNE(63,bt,2,0,"mat-error"),e.k0s(),e.j41(64,"mat-form-field",29)(65,"mat-label"),e.EFF(66,"Moneda"),e.k0s(),e.j41(67,"mat-select",34),e.Z7z(68,xt,2,2,"mat-option",28,e.fX1),e.nI1(70,"async"),e.k0s()(),e.j41(71,"mat-form-field",29)(72,"mat-label"),e.EFF(73,"Tasa de Cambio"),e.k0s(),e.j41(74,"mat-select",35)(75,"mat-select-trigger"),e.EFF(76),e.DNE(77,It,2,2,"span",36),e.k0s(),e.Z7z(78,kt,6,6,"mat-option",28,e.fX1),e.nI1(80,"async"),e.k0s(),e.DNE(81,Rt,2,0,"mat-error"),e.k0s(),e.j41(82,"mat-form-field",29)(83,"mat-label"),e.EFF(84,"Tipo de Compra"),e.k0s(),e.j41(85,"mat-select",null,3)(87,"mat-option",37),e.EFF(88,"Importaci\xf3n"),e.k0s(),e.j41(89,"mat-option",38),e.EFF(90,"En Plaza"),e.k0s()()(),e.DNE(91,St,7,4,"div",39)(92,jt,7,4,"div",39)(93,Dt,7,4,"div",39)(94,At,7,4,"div",39)(95,wt,7,4,"div",39)(96,Xt,7,4,"div",39)(97,Ot,7,4,"div",39)(98,Wt,7,4,"div",39),e.k0s()(),e.j41(99,"div",40)(100,"div",41)(101,"div",42)(102,"mat-form-field",43),e.nrm(103,"mat-icon",25)(104,"input",44),e.j41(105,"mat-autocomplete",45,4),e.bIt("closed",function(){return e.eBV(n),e.Njj(o.searchProductControl.reset())}),e.j41(107,"mat-option",46),e.bIt("click",function(u){return e.eBV(n),o.addNewProduct(),e.Njj(u.stopPropagation())}),e.j41(108,"div",47),e.bIt("click",function(u){return e.eBV(n),o.addNewProduct(),e.Njj(u.stopPropagation())}),e.j41(109,"div",48),e.nrm(110,"mat-icon",49),e.j41(111,"span",50),e.EFF(112," Agregar Producto "),e.k0s()()()(),e.Z7z(113,Ht,9,5,"mat-option",51,e.fX1),e.nI1(115,"async"),e.k0s()(),e.j41(116,"div",52)(117,"div",53)(118,"label",54),e.nrm(119,"mat-icon",49),e.k0s(),e.j41(120,"input",55,5),e.bIt("change",function(u){return e.eBV(n),e.Njj(o.importStockFormTemplateFile(u))}),e.k0s()(),e.j41(122,"button",56),e.bIt("click",function(){return e.eBV(n),e.Njj(o.exportProductsTemplate(o.purchaseForm.get("products")))}),e.nrm(123,"mat-icon",49),e.k0s()()(),e.j41(124,"div",57),e.DNE(125,lr,23,0,"div",58)(126,ur,2,0)(127,Er,8,7,"ng-template",null,6,e.C5r),e.k0s()(),e.j41(129,"div",59),e.bIt("click",function(){return e.eBV(n),e.Njj(o.createPurchase())}),e.EFF(130),e.nI1(131,"number"),e.k0s()()()()}if(2&i){let n,l;const u=e.sdS(29),F=e.sdS(54),C=e.sdS(86),J=e.sdS(106);e.Y8G("fuseScrollbarOptions",e.lJ4(73,ct)),e.R7$(8),e.Y8G("svgIcon","mat_solid:chevron_right"),e.R7$(7),e.R50("ngModel",o.stayHere),e.R7$(2),e.Y8G("disabled",o.purchaseForm.invalid||0===o.purchaseForm.get("products").controls.length),e.R7$(4),e.Y8G("formGroup",o.purchaseForm),e.R7$(5),e.Y8G("svgIcon","mat_solid:search"),e.R7$(),e.Y8G("formControl",o.searchSupplierControl)("matAutocomplete",u)("placeholder","Buscar proveedor")("required",!0),e.R7$(),e.Y8G("displayWith",o.displayFn),e.R7$(2),e.Dyx(e.bMT(32,58,o.suppliersFiltered)),e.R7$(6),e.Y8G("formControlName","voucherTypeId")("required",!0),e.R7$(),e.Dyx(e.bMT(39,60,o.vouchers$)),e.R7$(3),e.vxM(40,o.purchaseForm.get("voucherTypeId").hasError("required")?40:-1),e.R7$(4),e.Y8G("type","text")("formControlName","voucherNo")("required",o.voucherNoHasValidator()),e.R7$(),e.vxM(45,o.purchaseForm.get("voucherNo").hasError("required")?45:-1),e.R7$(4),e.Y8G("matDatepicker",F)("formControlName","voucherDate")("max",o.maxDate)("required",!0),e.R7$(3),e.Y8G("for",F),e.R7$(3),e.vxM(55,o.purchaseForm.get("voucherDate").hasError("required")?55:-1),e.R7$(4),e.Y8G("formControlName","paymentMethodId")("required",!0),e.R7$(),e.Dyx(e.bMT(62,62,o.paymentMethods$)),e.R7$(3),e.vxM(63,o.purchaseForm.get("paymentMethodId").hasError("required")?63:-1),e.R7$(4),e.Y8G("formControlName","currencyId")("required",!0)("placeholder","Moneda"),e.R7$(),e.Dyx(e.bMT(70,64,o.currencies$)),e.R7$(6),e.Y8G("formControlName","rates")("required",!0)("placeholder","Tasa de cambio"),e.R7$(2),e.SpI(" ",(null==(n=o.purchaseForm.get("rates").value)||null==n[0]?null:n[0].name)||""," "),e.R7$(),e.vxM(77,((null==(l=o.purchaseForm.get("rates").value)?null:l.length)||0)>1?77:-1),e.R7$(),e.Dyx(e.bMT(80,66,o.ratesFiltered)),e.R7$(3),e.vxM(81,o.purchaseForm.get("rates").hasError("required")?81:-1),e.R7$(10),e.vxM(91,"importation"===C.value?91:-1),e.R7$(),e.vxM(92,"importation"===C.value?92:-1),e.R7$(),e.vxM(93,"importation"===C.value?93:-1),e.R7$(),e.vxM(94,"importation"===C.value?94:-1),e.R7$(),e.vxM(95,"importation"===C.value||"national"===C.value?95:-1),e.R7$(),e.vxM(96,"importation"===C.value||"national"===C.value?96:-1),e.R7$(),e.vxM(97,"importation"===C.value||"national"===C.value?97:-1),e.R7$(),e.vxM(98,"importation"===C.value||"national"===C.value?98:-1),e.R7$(4),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("svgIcon","mat_solid:search"),e.R7$(),e.Y8G("formControl",o.searchProductControl)("matAutocomplete",J)("placeholder","Buscar productos"),e.R7$(),e.Y8G("displayWith",o.displayFn),e.R7$(5),e.Y8G("svgIcon","mat_solid:add_circle"),e.R7$(3),e.Dyx(e.bMT(115,68,o.productsFiltered)),e.R7$(6),e.Y8G("svgIcon","mat_solid:upload"),e.R7$(4),e.Y8G("svgIcon","mat_solid:download"),e.R7$(),e.Y8G("fuseScrollbarOptions",e.lJ4(74,lt)),e.R7$(),e.vxM(125,o.purchaseForm.get("products").controls.length>0?125:126),e.R7$(4),e.Y8G("ngClass",e.eq3(75,ut,o.purchaseForm.valid&&o.purchaseForm.get("products").controls.length>0)),e.R7$(),e.Lme(" ",e.i5U(131,70,o.total,"1.2-2")," ",o.selectedCurrencyIso," ")}},dependencies:[m.Jj,m.oe,m.QX,s.YN,s.qT,s.me,s.Q0,s.BC,s.cb,s.YS,s.xh,s.tU,s.VZ,s.zX,s.vS,ce.p,ue.jL,ue.$3,st.wT,ue.pN,k.Hl,k.$z,k.iY,ae.g7,ae.So,oe.X6,oe.Vh,oe.bZ,oe.bU,P.RG,P.rl,P.nJ,P.MV,P.TL,P.JW,P.yw,E.m_,E.An,x.fS,x.fg,le.Ve,le.VO,le.$2,te.uc,te.oV,m.YU,s.X1,s.l_,s.j4,s.JD,s.$R,m.T3],encapsulation:2,changeDetection:0})}return r})();var $r=a(87122);class Mr{}var jr=a(67376);const fe=r=>({"cursor-not-allowed":r});function Tr(r,c){1&r&&(e.j41(0,"h2",2),e.EFF(1,"Agregar Proveedor"),e.k0s())}function Gr(r,c){1&r&&(e.j41(0,"h2",2),e.EFF(1,"Editar Proveedor"),e.k0s())}function Dr(r,c){if(1&r){const t=e.RV6();e.j41(0,"button",15),e.bIt("click",function(){e.eBV(t);const o=e.XpG();return e.Njj(o.updateSupplier())}),e.EFF(1,"Actualizar"),e.k0s()}if(2&r){const t=e.XpG();e.Y8G("disabled",t.supplierForm.invalid)("ngClass",e.eq3(3,fe,t.supplierForm.invalid))("color","primary")}}function Nr(r,c){if(1&r){const t=e.RV6();e.j41(0,"button",15),e.bIt("click",function(){e.eBV(t);const o=e.XpG();return e.Njj(o.createSupplier())}),e.EFF(1,"Agregar"),e.k0s()}if(2&r){const t=e.XpG();e.Y8G("disabled",t.supplierForm.invalid)("ngClass",e.eq3(3,fe,t.supplierForm.invalid))("color","primary")}}let Br=(()=>{class r{constructor(t,i,o,n,l,u,F){this.data=t,this._suppliersService=i,this._changeDetectorRef=o,this._dialogRef=n,this._formBuilder=l,this._fuseConfirmationService=u,this._snackBar=F,this._unsubscribeAll=new D.B,this.dialogMode=t.dialogMode,this.supplier=this.data.supplier}ngOnInit(){this.supplierForm=this._formBuilder.group({id:new s.MJ,name:new s.MJ(null,[s.k0.required,s.k0.minLength(3),s.k0.maxLength(150)]),nit:new s.MJ(null,[s.k0.maxLength(20)]),email:new s.MJ(null,[s.k0.email]),phone:new s.MJ(null,[s.k0.maxLength(15),s.k0.pattern("^((\\+53)?\\d{8})?$")])}),null!==this.supplier.name&&this.supplierForm.patchValue(this.supplier)}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}closeDialog(){this._dialogRef.close()}createSupplier(){let t=this.supplierForm.getRawValue();t=(0,jr.omit)(t,["id"]),this._fuseConfirmationService.open({title:"Crear categor\xeda",message:"\xbfEst\xe1 seguro que toda la informaci\xf3n es correcta?",icon:{show:!0,name:"mat_solid:question_mark",color:"info"},actions:{confirm:{label:"Aceptar",color:"primary"}}}).afterClosed().pipe((0,f.Q)(this._unsubscribeAll)).subscribe(o=>{"confirmed"===o&&this._suppliersService.createSupplier(t).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(({data:n})=>{this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:n.createSupplier.message,title:"Confirmaci\xf3n",type:"success",svgIcon:"mat_solid:done"}}),this._changeDetectorRef.markForCheck(),this.closeDialog()})})}updateSupplier(){const t=this.supplierForm.getRawValue();this._fuseConfirmationService.open({title:"Categor\xeda",message:"\xbfEst\xe1 seguro que toda la informaci\xf3n es correcta?",icon:{show:!0,name:"mat_solid:question_mark",color:"info"},actions:{confirm:{label:"Aceptar",color:"primary"}}}).afterClosed().pipe((0,f.Q)(this._unsubscribeAll)).subscribe(o=>{"confirmed"===o&&this._suppliersService.updateSupplier(t).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(({data:n})=>{this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:n.updateSupplier.message,title:"Confirmaci\xf3n",type:"success",svgIcon:"mat_solid:done"}}),this.closeDialog(),this._changeDetectorRef.markForCheck()})})}static#e=this.\u0275fac=function(i){return new(i||r)(e.rXU(ie.Vh),e.rXU(Q),e.rXU(e.gRc),e.rXU(ie.CP),e.rXU(s.ok),e.rXU(re.G),e.rXU(G.UG))};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["supplier-dialog"]],standalone:!0,features:[e.aNF],decls:32,vars:11,consts:[[1,"relative","flex","flex-col","w-full","max-h-screen"],[1,"flex","flex-col","items-center","px-8","pt-4","space-y-1","text-center","sm:items-start","sm:mt-0","sm:pr-8","sm:text-left"],["mat-dialog-title",""],[1,"flex","flex-col","items-center","flex-auto","w-full","px-8","pb-6"],[1,"w-full","overflow-hidden"],[1,"flex","border-t"],[1,"flex","flex-col","w-full","pt-8",3,"formGroup","autocomplete"],[1,"flex","flex-col","flex-auto","gap-2"],[1,"w-full","fuse-mat-dense"],["matInput","","type","text",3,"formControlName"],["matInput","","type","email",3,"formControlName"],["matInput","","type","tel",3,"formControlName"],[1,"flex","items-center","justify-center","px-6","py-4","space-x-3","sm:justify-end","bg-gray-50","dark:bg-black/10"],["mat-button","",1,"-ml-4",3,"click","color"],["mat-flat-button","",3,"disabled","ngClass","color"],["mat-flat-button","",3,"click","disabled","ngClass","color"]],template:function(i,o){1&i&&(e.j41(0,"div",0)(1,"div",1),e.DNE(2,Tr,2,0,"h2",2)(3,Gr,2,0,"h2",2),e.k0s(),e.j41(4,"div",3)(5,"div",4)(6,"div",5)(7,"form",6)(8,"div",7)(9,"mat-form-field",8)(10,"mat-label"),e.EFF(11,"Nombre"),e.k0s(),e.nrm(12,"input",9),e.k0s(),e.j41(13,"mat-form-field",8)(14,"mat-label"),e.EFF(15,"N\xfamero de identificaci\xf3n tributaria"),e.k0s(),e.nrm(16,"input",9),e.k0s(),e.j41(17,"mat-form-field",8)(18,"mat-label"),e.EFF(19,"Correo electr\xf3nico"),e.k0s(),e.nrm(20,"input",10),e.k0s(),e.j41(21,"mat-form-field",8)(22,"mat-label"),e.EFF(23,"Tel\xe9fono"),e.k0s(),e.nrm(24,"input",11),e.j41(25,"mat-hint"),e.EFF(26,"Si es cubano debe incluir +53 al inicio del tel\xe9fono"),e.k0s()()()()()()(),e.j41(27,"div",12)(28,"button",13),e.bIt("click",function(){return o.closeDialog()}),e.EFF(29,"Cancelar"),e.k0s(),e.DNE(30,Dr,2,5,"button",14)(31,Nr,2,5,"button",14),e.k0s()()),2&i&&(e.R7$(2),e.vxM(2,o.data.supplier.id||"add"!==o.dialogMode?-1:2),e.R7$(),e.vxM(3,o.data.supplier.id&&"edit"===o.dialogMode?3:-1),e.R7$(4),e.Y8G("formGroup",o.supplierForm)("autocomplete","off"),e.R7$(5),e.Y8G("formControlName","name"),e.R7$(4),e.Y8G("formControlName","nit"),e.R7$(4),e.Y8G("formControlName","email"),e.R7$(4),e.Y8G("formControlName","phone"),e.R7$(4),e.Y8G("color","warn"),e.R7$(2),e.vxM(30,"edit"===o.data.dialogMode?30:-1),e.R7$(),e.vxM(31,"add"===o.data.dialogMode?31:-1))},dependencies:[k.Hl,k.$z,P.RG,P.rl,P.nJ,P.MV,x.fS,x.fg,m.YU,s.X1,s.qT,s.me,s.BC,s.cb,s.j4,s.JD],encapsulation:2})}return r})();const Ar=()=>({wheelPropagation:!1}),Yr=(r,c)=>({"pointer-events-none":r,hidden:c}),Vr=()=>[10,25,50,100];function wr(r,c){if(1&r){const t=e.RV6();e.j41(0,"mat-slide-toggle",34),e.bIt("change",function(o){e.eBV(t);const n=e.XpG(),l=n.$implicit,u=n.$index,F=e.XpG(4);return e.Njj(F.updateSupplierStatus(o,l,u))}),e.k0s()}if(2&r){const t=e.XpG().$implicit;e.Y8G("checked",t.active)("color","primary")}}function zr(r,c){1&r&&e.nrm(0,"mat-spinner",30),2&r&&e.Y8G("diameter",20)("color","primary")}function Ur(r,c){if(1&r){const t=e.RV6();e.j41(0,"div",26)(1,"div",27),e.EFF(2),e.k0s(),e.j41(3,"div",22),e.EFF(4),e.k0s(),e.j41(5,"div",22),e.EFF(6),e.k0s(),e.j41(7,"div",22),e.EFF(8),e.k0s(),e.j41(9,"div",28),e.DNE(10,wr,1,2,"mat-slide-toggle",29)(11,zr,1,2,"mat-spinner",30),e.k0s(),e.j41(12,"div",31)(13,"button",32),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(4);return e.Njj(n.openDialog(o,"edit"))}),e.nrm(14,"mat-icon",33),e.k0s(),e.j41(15,"button",32),e.bIt("click",function(){const o=e.eBV(t).$implicit,n=e.XpG(4);return e.Njj(n.deleteSupplier(o.id))}),e.nrm(16,"mat-icon",33),e.k0s()()()}if(2&r){const t=c.$implicit,i=c.$index,o=e.XpG(4);e.R7$(2),e.SpI(" ",t.name," "),e.R7$(2),e.SpI(" ",t.nit," "),e.R7$(2),e.SpI(" ",t.phone," "),e.R7$(2),e.SpI(" ",t.email," "),e.R7$(2),e.vxM(10,o.isSlideLoading&&o.selectedSlide===i?-1:10),e.R7$(),e.vxM(11,o.isSlideLoading&&o.selectedSlide===i?11:-1),e.R7$(3),e.Y8G("svgIcon","mat_solid:edit"),e.R7$(2),e.Y8G("svgIcon","mat_solid:delete")}}function Xr(r,c){1&r&&e.Z7z(0,Ur,17,8,"div",26,e.BUC().trackByFn,!0),2&r&&e.Dyx(c)}function Jr(r,c){if(1&r&&(e.j41(0,"div",19)(1,"div",20)(2,"div",21),e.EFF(3," Nombre "),e.k0s(),e.j41(4,"div",22),e.EFF(5," NIT "),e.k0s(),e.j41(6,"div",22),e.EFF(7," Tel\xe9fono "),e.k0s(),e.j41(8,"div",22),e.EFF(9," Correo "),e.k0s(),e.j41(10,"div",23)(11,"span"),e.EFF(12,"Activo"),e.k0s()(),e.j41(13,"div",24),e.EFF(14,"Detalles"),e.k0s()(),e.DNE(15,Xr,2,0),e.nI1(16,"async"),e.nrm(17,"mat-paginator",25),e.k0s()),2&r){let t;const i=e.XpG(2);e.R7$(2),e.Y8G("mat-sort-header","name"),e.R7$(8),e.Y8G("mat-sort-header","active"),e.R7$(5),e.vxM(15,(t=e.bMT(16,9,i.suppliers$))?15:-1,t),e.R7$(2),e.Y8G("ngClass",e.l_i(11,Yr,i.isLoading,i.pagination.length<10&&i.pagination.page<1))("length",i.pagination.length)("pageIndex",i.pagination.page)("pageSize",i.pagination.size)("pageSizeOptions",e.lJ4(14,Vr))("showFirstLastButtons",!0)}}function Lr(r,c){1&r&&(e.j41(0,"div",35),e.EFF(1," \xa1No se ha creado ning\xfan proveedor! "),e.k0s())}function Or(r,c){1&r&&e.DNE(0,Jr,18,15,"div",19)(1,Lr,2,0),2&r&&e.vxM(0,c.length>0?0:1)}let Qr=(()=>{class r{constructor(t,i,o,n,l,u){this._changeDetectorRef=t,this._dialog=i,this._fuseConfirmationService=o,this._snackBar=n,this._suppliersService=l,this.store=u,this.isLoading=!1,this.suppliers$=(0,M.of)([]),this.searchInputControl=new s.MJ(null),this.isSlideLoading=!1,this.selectedSlide=null,this.supplier=new Mr,this._unsubscribeAll=new D.B}ngOnInit(){this.store.select(_.Dz).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(t=>{this.pagination=t,this._changeDetectorRef.markForCheck()}),this.suppliers$=this.store.select(O),this.searchInputControl.valueChanges.pipe((0,f.Q)(this._unsubscribeAll),(0,h.j)(()=>{this.isLoading=!1}),(0,j.B)(300),(0,d.n)(t=>{if(null!==t)return this.isLoading=!0,this._suppliersService.getSuppliers(0,25,"name","desc",t)})).subscribe()}ngAfterViewInit(){this._sort&&this._paginator&&(this._sort.sort({id:"name",start:"desc",disableClear:!0}),this._changeDetectorRef.markForCheck(),this._sort.sortChange.pipe((0,f.Q)(this._unsubscribeAll)).subscribe(()=>{this._paginator.pageIndex=0}),(0,V.h)(this._sort.sortChange,this._paginator.page).pipe((0,d.n)(()=>(this.isLoading=!0,this._suppliersService.getSuppliers(this._paginator.pageIndex,this._paginator.pageSize,this._sort.active,this._sort.direction,this.searchInputControl.value))),(0,g.T)(()=>{this.isLoading=!1})).subscribe())}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}updateSupplierStatus(t,i,o){this.isSlideLoading=!0,this.selectedSlide=o,this._suppliersService.updatesSupplierStatus({id:i.id,active:t.checked}).subscribe(({data:n})=>{this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:n.updateSupplierStatus.message,title:"Confirmaci\xf3n",type:"success",svgIcon:"mat_solid:done"}}),this.isSlideLoading=!1,this.selectedSlide=null,this._changeDetectorRef.markForCheck()})}deleteSupplier(t){this._fuseConfirmationService.open({title:"Eliminar proveedor",message:"\xbfEsta seguro que desea eliminar el proveedor?",icon:{show:!0,name:"mat_solid:question_mark",color:"info"},actions:{confirm:{label:"Aceptar",color:"primary"}}}).afterClosed().subscribe(o=>{"confirmed"===o&&this._suppliersService.removeSupplier(t).pipe((0,f.Q)(this._unsubscribeAll)).subscribe(({data:n})=>{this._snackBar.openFromComponent(q.p,{panelClass:["p-0","bg-transparent"],horizontalPosition:"end",verticalPosition:"bottom",duration:5e3,data:{message:n.removeSupplier.message,title:"Confirmaci\xf3n",type:"success",svgIcon:"mat_solid:done"}})}),this._changeDetectorRef.markForCheck()})}openDialog(t,i){this._dialog.open(Br,{data:{supplier:t,dialogMode:i},panelClass:"ath-dialog-panel",disableClose:!0})}trackByFn(t,i){return i.id||t}static#e=this.\u0275fac=function(i){return new(i||r)(e.rXU(e.gRc),e.rXU(ie.bZ),e.rXU(re.G),e.rXU(G.UG),e.rXU(Q),e.rXU(L.il))};static#t=this.\u0275cmp=e.VBU({type:r,selectors:[["suppliers"]],viewQuery:function(i,o){if(1&i&&(e.GBs($.iy,5),e.GBs(T.B4,5)),2&i){let n;e.mGM(n=e.lsd())&&(o._paginator=n.first),e.mGM(n=e.lsd())&&(o._sort=n.first)}},standalone:!0,features:[e.aNF],decls:26,vars:12,consts:[["fuseScrollbar","",1,"absolute","inset-0","flex","flex-col","flex-auto","min-w-0","bg-card","dark:bg-transparent",3,"fuseScrollbarOptions"],[1,"relative","flex","flex-col","px-6","py-8","border-b","lg:flex-row","flex-0","lg:items-center","lg:justify-between","md:px-8"],[1,"flex-1","min-w-0"],[1,"flex","flex-wrap","items-center","font-medium"],["routerLink","/desktop",1,"whitespace-nowrap","text-primary-500"],[1,"flex","items-center","ml-1","whitespace-nowrap"],[1,"icon-size-5","text-secondary",3,"svgIcon"],[1,"ml-1","text-primary-500"],[1,"mt-2"],[1,"text-3xl","font-extrabold","leading-7","tracking-tight","truncate","sm:leading-10"],[1,"flex","flex-wrap","items-center","w-full","gap-2","mt-6","md:fixed","right-8","shrink-0","lg:mt-0","lg:ml-4","lg:w-auto","sm:w-1/2"],[1,"fuse-mat-dense","fuse-mat-rounded","min-w-64",3,"subscriptSizing"],["matPrefix","",1,"icon-size-5",3,"svgIcon"],["matInput","",3,"formControl","autocomplete","placeholder"],["mat-raised-button","",1,"text-white","bg-gradient-to-r","from-primary-500","to-primary-700",3,"click"],[3,"svgIcon"],[1,"hidden","ml-2","mr-1","text-white","sm:block"],[1,"flex","flex-auto"],[1,"z-10","flex","flex-col","flex-auto","bg-white","dark:bg-default"],[1,"relative","grid"],["matSort","","matSortDisableClear","",1,"sticky","top-0","z-10","grid","gap-4","px-6","py-4","font-semibold","shadow","supplier-grid","md:px-8","text-md","text-secondary","bg-gray-50","dark:bg-slate-900"],[1,"flex","justify-start",3,"mat-sort-header"],[1,"text-center"],[1,"flex","justify-center",3,"mat-sort-header"],[1,"mr-7","text-end"],[1,"border-b","first-letter:z-10","sm:inset-x-0","sm:sticky","sm:bottom-0","sm:border-t","sm:border-b-0","bg-gray-50","dark:bg-gray-900",3,"ngClass","length","pageIndex","pageSize","pageSizeOptions","showFirstLastButtons"],[1,"z-0","grid","items-center","gap-4","px-6","py-3","border-b","supplier-grid","md:px-8"],[1,"truncate"],[1,"flex","justify-center"],[3,"checked","color"],[3,"diameter","color"],[1,"flex","flex-row","justify-end","gap-3","mr-2"],["mat-stroked-button","",1,"px-2","leading-6","min-w-10","min-h-7","h-7",3,"click"],[1,"icon-size-5",3,"svgIcon"],[3,"change","checked","color"],[1,"p-8","text-4xl","font-semibold","tracking-tight","text-center","border-t","sm:p-16"]],template:function(i,o){if(1&i&&(e.j41(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div")(5,"a",4),e.EFF(6,"Inicio"),e.k0s()(),e.j41(7,"div",5),e.nrm(8,"mat-icon",6),e.j41(9,"a",7),e.EFF(10,"Proveedores"),e.k0s()()(),e.j41(11,"div",8)(12,"h2",9),e.EFF(13," Proveedores "),e.k0s()()(),e.j41(14,"div",10)(15,"mat-form-field",11),e.nrm(16,"mat-icon",12)(17,"input",13),e.k0s(),e.j41(18,"button",14),e.bIt("click",function(){return o.openDialog(o.supplier,"add")}),e.nrm(19,"mat-icon",15),e.j41(20,"span",16),e.EFF(21,"Agregar"),e.k0s()()()(),e.j41(22,"div",17)(23,"div",18),e.DNE(24,Or,2,1),e.nI1(25,"async"),e.k0s()()()),2&i){let n;e.Y8G("fuseScrollbarOptions",e.lJ4(11,Ar)),e.R7$(8),e.Y8G("svgIcon","mat_solid:chevron_right"),e.R7$(7),e.Y8G("subscriptSizing","dynamic"),e.R7$(),e.Y8G("svgIcon","mat_solid:search"),e.R7$(),e.Y8G("formControl",o.searchInputControl)("autocomplete","off")("placeholder","Buscar proveedores"),e.R7$(2),e.Y8G("svgIcon","mat_solid:add"),e.R7$(5),e.vxM(24,(n=e.bMT(25,9,o.suppliers$))?24:-1,n)}},dependencies:[m.Jj,s.YN,s.me,s.BC,k.Hl,k.$z,P.RG,P.rl,P.JW,E.m_,E.An,x.fS,x.fg,$.Ou,$.iy,A.D6,A.LG,Y.mV,Y.sG,T.NQ,T.B4,T.aE,m.YU,s.X1,s.l_,v.Wk,ce.p],encapsulation:2,data:{animation:$r.X},changeDetection:0})}return r})();var qr=a(43801),Wr=a(76856),Kr=a(23301),ge=a(59013),_e=a(7561),eo=a(63425),to=a(16551);const ro=[{path:"suppliers",component:Qr,resolve:{suppliers:(r,c)=>(0,e.WQX)(Q).getSuppliers()}},{path:"purchases",component:I,children:[{path:"list",component:qe,resolve:{vouchers:_e.Q,paymentMethods:ge.v,purchases:Wr.FS}},{path:"form",component:Sr,resolve:{currencies:Kr.I,paymentMethods:ge.v,products:qr.bN,suppliers:(r,c)=>(0,e.WQX)(Q).findActiveSuppliers(),vouchers:_e.Q,uoms:eo.B,depots:to.MQ}},{path:"details",component:We}]}]}}]);