@ancon/wildcat-utils 1.53.0-check-optimizations.2 → 1.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { CheckItemV2 } from '@ancon/wildcat-types';
1
+ import { CheckItem } from '@ancon/wildcat-types';
2
2
  import { OrganizedCheckItemModification } from './types';
3
3
  /**
4
4
  * Organizes all check item modifications including addon products into a array for easier visual representation.
@@ -7,4 +7,4 @@ import { OrganizedCheckItemModification } from './types';
7
7
  * @param addOnProducts - The list of check item add-on products.
8
8
  * @returns An array where the modifications are sorted by their modification kind and positions.
9
9
  */
10
- export default function getOrganizedCheckItemModifications(currency: string, modifications: CheckItemV2['modifications'] | undefined, addOnProducts: CheckItemV2['addOnProducts'] | undefined): OrganizedCheckItemModification[];
10
+ export default function getOrganizedCheckItemModifications(currency: string, modifications: CheckItem['modifications'], addOnProducts: CheckItem['addOnProducts']): OrganizedCheckItemModification[];
@@ -1 +1 @@
1
- "use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=(i??[]).reduce((a,u)=>{const{modification:A,position:s,freeAmount:f,name:y="",quantity:p,cost:g,replacementName:T}=u,m=g===0;if(u.modification===h.ModificationType.Add){(f>0||m)&&a.add.push({id:O(u,"-free"),modificationType:A,name:y,freeAmount:m?p:f,quantity:m?p:f,currency:n,position:s,cost:0});const q=p-f;q>0&&!m&&a.add.push({id:O(u),modificationType:A,name:y,quantity:q,freeAmount:0,currency:n,position:s,cost:g*q})}return u.modification===h.ModificationType.Replace&&a.replace.push({id:O(u),modificationType:A,name:y,replacementName:T,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),u.modification===h.ModificationType.Remove&&a.remove.push({id:O(u),modificationType:A,name:y,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),a},{add:[],replace:[],remove:[]}),o=(r??[]).reduce((a,u)=>{const{product:A,freeAmount:s=0,quantity:f,position:y,addOnGroupId:p,productPriceInclTax:g}=u,{hasVariants:T,variantName:m="",productName:q="",productId:B,variantId:F}=A??{},b=g.unitPrice===0;(s>0||b)&&a.push({id:`${p}-${B}-free`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:b?f:s,quantity:b?f:s,currency:n,position:y,cost:0,variantId:F});const w=f-s;return w>0&&!b&&a.push({id:`${p}-${B}`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:0,quantity:w,currency:n,position:y,cost:g.unitPrice*w,variantId:F}),a},[]);return[...C([...e,...o],["position"],["asc"]),...C(d,["position"],["asc"]),...C(t,["position"],["asc"])]}module.exports=K;
1
+ "use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=i.reduce((a,u)=>{const{modification:A,position:s,freeAmount:f,name:y,quantity:p,cost:g,replacementName:T}=u,m=g===0;if(u.modification===h.ModificationType.Add){(f>0||m)&&a.add.push({id:O(u,"-free"),modificationType:A,name:y,freeAmount:m?p:f,quantity:m?p:f,currency:n,position:s,cost:0});const q=p-f;q>0&&!m&&a.add.push({id:O(u),modificationType:A,name:y,quantity:q,freeAmount:0,currency:n,position:s,cost:g*q})}return u.modification===h.ModificationType.Replace&&a.replace.push({id:O(u),modificationType:A,name:y,replacementName:T,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),u.modification===h.ModificationType.Remove&&a.remove.push({id:O(u),modificationType:A,name:y,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),a},{add:[],replace:[],remove:[]}),o=(r||[]).reduce((a,u)=>{const{product:A,addOnFreeAmount:s,quantity:f,addOnPosition:y,addOnGroupId:p,productPriceInclTax:g}=u,{hasVariants:T,variantName:m,productName:q,productId:B,variantId:F}=A,b=g.unitPrice.amount===0;(s>0||b)&&a.push({id:`${p}-${B}-free`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:b?f:s,quantity:b?f:s,currency:n,position:y,cost:0,variantId:F});const w=f-s;return w>0&&!b&&a.push({id:`${p}-${B}`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:0,quantity:w,currency:n,position:y,cost:g.unitPrice.amount*w,variantId:F}),a},[]);return[...C([...e,...o],["position"],["asc"]),...C(d,["position"],["asc"]),...C(t,["position"],["asc"])]}module.exports=K;
@@ -8,10 +8,10 @@ import T from "./getUniqueCheckItemModificationId.mjs";
8
8
  import "../_baseIsEqual-4ee44a4c.mjs";
9
9
  import "../isObject-b8638513.mjs";
10
10
  function U(n) {
11
- return function(i, t, o) {
12
- for (var d = -1, r = Object(i), u = o(i), f = u.length; f--; ) {
13
- var a = u[n ? f : ++d];
14
- if (t(r[a], a, r) === !1)
11
+ return function(i, t, a) {
12
+ for (var e = -1, r = Object(i), u = a(i), f = u.length; f--; ) {
13
+ var o = u[n ? f : ++e];
14
+ if (t(r[o], o, r) === !1)
15
15
  break;
16
16
  }
17
17
  return i;
@@ -23,12 +23,12 @@ function V(n, i) {
23
23
  return n && z(n, i, L);
24
24
  }
25
25
  function H(n, i) {
26
- return function(t, o) {
26
+ return function(t, a) {
27
27
  if (t == null)
28
28
  return t;
29
29
  if (!P(t))
30
- return n(t, o);
31
- for (var d = t.length, r = i ? d : -1, u = Object(t); (i ? r-- : ++r < d) && o(u[r], r, u) !== !1; )
30
+ return n(t, a);
31
+ for (var e = t.length, r = i ? e : -1, u = Object(t); (i ? r-- : ++r < e) && a(u[r], r, u) !== !1; )
32
32
  ;
33
33
  return t;
34
34
  };
@@ -36,10 +36,10 @@ function H(n, i) {
36
36
  var J = H(V);
37
37
  const K = J;
38
38
  function W(n, i) {
39
- var t = -1, o = P(n) ? Array(n.length) : [];
40
- return K(n, function(d, r, u) {
41
- o[++t] = i(d, r, u);
42
- }), o;
39
+ var t = -1, a = P(n) ? Array(n.length) : [];
40
+ return K(n, function(e, r, u) {
41
+ a[++t] = i(e, r, u);
42
+ }), a;
43
43
  }
44
44
  function X(n, i) {
45
45
  var t = n.length;
@@ -49,22 +49,22 @@ function X(n, i) {
49
49
  }
50
50
  function Y(n, i) {
51
51
  if (n !== i) {
52
- var t = n !== void 0, o = n === null, d = n === n, r = F(n), u = i !== void 0, f = i === null, a = i === i, e = F(i);
53
- if (!f && !e && !r && n > i || r && u && a && !f && !e || o && u && a || !t && a || !d)
52
+ var t = n !== void 0, a = n === null, e = n === n, r = F(n), u = i !== void 0, f = i === null, o = i === i, d = F(i);
53
+ if (!f && !d && !r && n > i || r && u && o && !f && !d || a && u && o || !t && o || !e)
54
54
  return 1;
55
- if (!o && !r && !e && n < i || e && t && d && !o && !r || f && t && d || !u && d || !a)
55
+ if (!a && !r && !d && n < i || d && t && e && !a && !r || f && t && e || !u && e || !o)
56
56
  return -1;
57
57
  }
58
58
  return 0;
59
59
  }
60
60
  function _(n, i, t) {
61
- for (var o = -1, d = n.criteria, r = i.criteria, u = d.length, f = t.length; ++o < u; ) {
62
- var a = Y(d[o], r[o]);
63
- if (a) {
64
- if (o >= f)
65
- return a;
66
- var e = t[o];
67
- return a * (e == "desc" ? -1 : 1);
61
+ for (var a = -1, e = n.criteria, r = i.criteria, u = e.length, f = t.length; ++a < u; ) {
62
+ var o = Y(e[a], r[a]);
63
+ if (o) {
64
+ if (a >= f)
65
+ return o;
66
+ var d = t[a];
67
+ return o * (d == "desc" ? -1 : 1);
68
68
  }
69
69
  }
70
70
  return n.index - i.index;
@@ -75,110 +75,104 @@ function j(n, i, t) {
75
75
  return E(u, r.length === 1 ? r[0] : r);
76
76
  } : r;
77
77
  }) : i = [x];
78
- var o = -1;
78
+ var a = -1;
79
79
  i = q(i, Q(G));
80
- var d = W(n, function(r, u, f) {
81
- var a = q(i, function(e) {
82
- return e(r);
80
+ var e = W(n, function(r, u, f) {
81
+ var o = q(i, function(d) {
82
+ return d(r);
83
83
  });
84
- return { criteria: a, index: ++o, value: r };
84
+ return { criteria: o, index: ++a, value: r };
85
85
  });
86
- return X(d, function(r, u) {
86
+ return X(e, function(r, u) {
87
87
  return _(r, u, t);
88
88
  });
89
89
  }
90
- function C(n, i, t, o) {
91
- return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t = o ? void 0 : t, $(t) || (t = t == null ? [] : [t]), j(n, i, t));
90
+ function C(n, i, t, a) {
91
+ return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t = a ? void 0 : t, $(t) || (t = t == null ? [] : [t]), j(n, i, t));
92
92
  }
93
93
  function rn(n, i, t) {
94
- const { add: o, replace: d, remove: r } = (i ?? []).reduce(
95
- (a, e) => {
94
+ const { add: a, replace: e, remove: r } = i.reduce(
95
+ (o, d) => {
96
96
  const {
97
97
  modification: h,
98
- position: c,
99
- freeAmount: p,
100
- name: m = "",
98
+ position: p,
99
+ freeAmount: c,
100
+ name: m,
101
101
  quantity: s,
102
102
  cost: g,
103
103
  replacementName: O
104
- } = e, A = g === 0;
105
- if (e.modification === y.Add) {
106
- (p > 0 || A) && a.add.push({
107
- id: T(e, "-free"),
104
+ } = d, A = g === 0;
105
+ if (d.modification === y.Add) {
106
+ (c > 0 || A) && o.add.push({
107
+ id: T(d, "-free"),
108
108
  modificationType: h,
109
109
  name: m,
110
- freeAmount: A ? s : p,
111
- quantity: A ? s : p,
110
+ freeAmount: A ? s : c,
111
+ quantity: A ? s : c,
112
112
  currency: n,
113
- position: c,
113
+ position: p,
114
114
  cost: 0
115
115
  });
116
- const b = s - p;
117
- b > 0 && !A && a.add.push({
118
- id: T(e),
116
+ const b = s - c;
117
+ b > 0 && !A && o.add.push({
118
+ id: T(d),
119
119
  modificationType: h,
120
120
  name: m,
121
121
  quantity: b,
122
122
  freeAmount: 0,
123
123
  currency: n,
124
- position: c,
124
+ position: p,
125
125
  cost: g * b
126
126
  });
127
127
  }
128
- return e.modification === y.Replace && a.replace.push({
129
- id: T(e),
128
+ return d.modification === y.Replace && o.replace.push({
129
+ id: T(d),
130
130
  modificationType: h,
131
131
  name: m,
132
132
  replacementName: O,
133
- freeAmount: p,
133
+ freeAmount: c,
134
134
  quantity: s,
135
135
  currency: n,
136
- position: c,
136
+ position: p,
137
137
  cost: g
138
- }), e.modification === y.Remove && a.remove.push({
139
- id: T(e),
138
+ }), d.modification === y.Remove && o.remove.push({
139
+ id: T(d),
140
140
  modificationType: h,
141
141
  name: m,
142
- freeAmount: p,
142
+ freeAmount: c,
143
143
  quantity: s,
144
144
  currency: n,
145
- position: c,
145
+ position: p,
146
146
  cost: g
147
- }), a;
147
+ }), o;
148
148
  },
149
149
  {
150
150
  add: [],
151
151
  replace: [],
152
152
  remove: []
153
153
  }
154
- ), u = (t ?? []).reduce((a, e) => {
154
+ ), u = (t || []).reduce((o, d) => {
155
155
  const {
156
156
  product: h,
157
- freeAmount: c = 0,
158
- quantity: p,
159
- position: m,
157
+ addOnFreeAmount: p,
158
+ quantity: c,
159
+ addOnPosition: m,
160
160
  addOnGroupId: s,
161
161
  productPriceInclTax: g
162
- } = e, {
163
- hasVariants: O,
164
- variantName: A = "",
165
- productName: b = "",
166
- productId: w,
167
- variantId: B
168
- } = h ?? {}, M = g.unitPrice === 0;
169
- (c > 0 || M) && a.push({
162
+ } = d, { hasVariants: O, variantName: A, productName: b, productId: w, variantId: B } = h, M = g.unitPrice.amount === 0;
163
+ (p > 0 || M) && o.push({
170
164
  id: `${s}-${w}-free`,
171
165
  modificationType: y.Add,
172
166
  name: O ? A : b,
173
- freeAmount: M ? p : c,
174
- quantity: M ? p : c,
167
+ freeAmount: M ? c : p,
168
+ quantity: M ? c : p,
175
169
  currency: n,
176
170
  position: m,
177
171
  cost: 0,
178
172
  variantId: B
179
173
  });
180
- const k = p - c;
181
- return k > 0 && !M && a.push({
174
+ const k = c - p;
175
+ return k > 0 && !M && o.push({
182
176
  id: `${s}-${w}`,
183
177
  modificationType: y.Add,
184
178
  name: O ? A : b,
@@ -186,13 +180,13 @@ function rn(n, i, t) {
186
180
  quantity: k,
187
181
  currency: n,
188
182
  position: m,
189
- cost: g.unitPrice * k,
183
+ cost: g.unitPrice.amount * k,
190
184
  variantId: B
191
- }), a;
185
+ }), o;
192
186
  }, []);
193
187
  return [
194
- ...C([...o, ...u], ["position"], ["asc"]),
195
- ...C(d, ["position"], ["asc"]),
188
+ ...C([...a, ...u], ["position"], ["asc"]),
189
+ ...C(e, ["position"], ["asc"]),
196
190
  ...C(r, ["position"], ["asc"])
197
191
  ];
198
192
  }
@@ -1,8 +1,8 @@
1
- import { CheckItemModificationV2 } from '@ancon/wildcat-types';
1
+ import { CheckItemModification } from '@ancon/wildcat-types';
2
2
  /**
3
3
  * Generate a unique ID for a Check Item Modification
4
4
  * @param modification - Check Item Modification
5
5
  * @param suffix - Optional suffix to append to the ID
6
6
  * @returns Unique ID string
7
7
  */
8
- export default function getUniqueCheckItemModificationId(modification: CheckItemModificationV2, suffix?: string): string;
8
+ export default function getUniqueCheckItemModificationId(modification: CheckItemModification, suffix?: string): string;
@@ -1 +1 @@
1
- "use strict";function p(n,e){const{modification:i,ingredientId:o,replaceId:$,addOnGroupId:c,quantity:d,cost:a,freeAmount:r,name:t="",replacementName:m,position:u}=n;return`modification-${i}-${o}-${$??0}-${c??null}-${d}-${a}-${r}-${t}-${m??t}-${u}${e?`-${e}`:""}`}module.exports=p;
1
+ "use strict";function u(i,e){const{modification:n,ingredientId:o,replaceId:$,addOnGroupId:c,quantity:d,cost:a,freeAmount:r,name:t,replacementName:m,position:p}=i;return`modification-${n}-${o}-${$??0}-${c}-${d}-${a}-${r}-${t}-${m??t}-${p}${e?`-${e}`:""}`}module.exports=u;
@@ -1,4 +1,4 @@
1
- function p(n, e) {
1
+ function u(n, e) {
2
2
  const {
3
3
  modification: i,
4
4
  ingredientId: o,
@@ -7,12 +7,12 @@ function p(n, e) {
7
7
  quantity: d,
8
8
  cost: c,
9
9
  freeAmount: r,
10
- name: t = "",
10
+ name: t,
11
11
  replacementName: m,
12
- position: u
12
+ position: p
13
13
  } = n;
14
- return `modification-${i}-${o}-${$ ?? 0}-${a ?? null}-${d}-${c}-${r}-${t}-${m ?? t}-${u}${e ? `-${e}` : ""}`;
14
+ return `modification-${i}-${o}-${$ ?? 0}-${a}-${d}-${c}-${r}-${t}-${m ?? t}-${p}${e ? `-${e}` : ""}`;
15
15
  }
16
16
  export {
17
- p as default
17
+ u as default
18
18
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@ancon/wildcat-types"),s=require("../currency/getFormattedCurrency.js");require("../currency/getFormattedCurrencyPostfix.js");function M(e,t){return t?e-t>0?e-t:0:e}function f(e,t,i,r){const n=`${t}x ${e}`,o=M(t,i);if(o){const d=`(${o}x ${s(r.amount,r.currency)})`;return`${n} ${d}`}return n}function y(e){return e.reduce((i,r)=>{const{modification:n,name:o,freeAmount:d,quantity:p,cost:l,replacementName:m,totalCost:a}=r;switch(n){case u.ModificationType.Remove:i.removed.push(o);break;case u.ModificationType.Replace:{const c=`${o} → ${m} (${s(a.amount,a.currency)})`;i.replaced.push(c);break}default:{const c=f(o,p,d,l);i.added.push(c)}}return i},{added:[],removed:[],replaced:[]})}exports.default=y;exports.getAddModificationText=f;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@ancon/wildcat-types"),s=require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");function M(e,t){return t?e-t>0?e-t:0:e}function f(e,t,i,r){const n=`${t}x ${e}`,o=M(t,i);if(o){const d=`(${o}x ${s(r.amount,r.currency)})`;return`${n} ${d}`}return n}function y(e){return e.reduce((i,r)=>{const{modification:n,name:o,freeAmount:d,quantity:p,cost:l,replacementName:m,totalCost:u}=r;switch(n){case a.ModificationType.Remove:i.removed.push(o);break;case a.ModificationType.Replace:{const c=`${o} → ${m} (${s(u.amount,u.currency)})`;i.replaced.push(c);break}default:{const c=f(o,p,d,l);i.added.push(c)}}return i},{added:[],removed:[],replaced:[]})}exports.default=y;exports.getAddModificationText=f;
@@ -1,5 +1,6 @@
1
1
  import { ModificationType as u } from "@ancon/wildcat-types";
2
2
  import f from "../currency/getFormattedCurrency.mjs";
3
+ import "../currency/placeCurrencySymbol.mjs";
3
4
  import "../currency/getFormattedCurrencyPostfix.mjs";
4
5
  function $(t, e) {
5
6
  return e ? t - e > 0 ? t - e : 0 : t;
@@ -15,16 +16,16 @@ function l(t, e, o, r) {
15
16
  }
16
17
  return n;
17
18
  }
18
- function x(t) {
19
+ function y(t) {
19
20
  return t.reduce(
20
21
  (o, r) => {
21
22
  const {
22
23
  modification: n,
23
24
  name: i,
24
25
  freeAmount: d,
25
- quantity: s,
26
- cost: m,
27
- replacementName: p,
26
+ quantity: m,
27
+ cost: p,
28
+ replacementName: s,
28
29
  totalCost: c
29
30
  } = r;
30
31
  switch (n) {
@@ -32,7 +33,7 @@ function x(t) {
32
33
  o.removed.push(i);
33
34
  break;
34
35
  case u.Replace: {
35
- const a = `${i} → ${p} (${f(
36
+ const a = `${i} → ${s} (${f(
36
37
  c.amount,
37
38
  c.currency
38
39
  )})`;
@@ -42,9 +43,9 @@ function x(t) {
42
43
  default: {
43
44
  const a = l(
44
45
  i,
45
- s,
46
+ m,
46
47
  d,
47
- m
48
+ p
48
49
  );
49
50
  o.added.push(a);
50
51
  }
@@ -59,6 +60,6 @@ function x(t) {
59
60
  );
60
61
  }
61
62
  export {
62
- x as default,
63
+ y as default,
63
64
  l as getAddModificationText
64
65
  };
@@ -1 +1 @@
1
- "use strict";const i=require("./getCheckoutItemModifications.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/getFormattedCurrencyPostfix.js");function o(n){const{unitPrice:t,additionalPrice:e}=n.unitPriceInclTax;return{amount:t.amount+e.amount,currency:t.currency}}function r(n){return n.map(t=>({id:t.id,modificationText:i.getAddModificationText(t.product.name,t.quantity,t.addOnFreeAmount,o(t))}))}module.exports=r;
1
+ "use strict";const i=require("./getCheckoutItemModifications.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");function o(e){const{unitPrice:t,additionalPrice:n}=e.unitPriceInclTax;return{amount:t.amount+n.amount,currency:t.currency}}function r(e){return e.map(t=>({id:t.id,modificationText:i.getAddModificationText(t.product.name,t.quantity,t.addOnFreeAmount,o(t))}))}module.exports=r;
@@ -1,16 +1,17 @@
1
1
  import { getAddModificationText as i } from "./getCheckoutItemModifications.mjs";
2
2
  import "@ancon/wildcat-types";
3
3
  import "../currency/getFormattedCurrency.mjs";
4
+ import "../currency/placeCurrencySymbol.mjs";
4
5
  import "../currency/getFormattedCurrencyPostfix.mjs";
5
- function r(n) {
6
- const { unitPrice: t, additionalPrice: o } = n.unitPriceInclTax;
6
+ function r(o) {
7
+ const { unitPrice: t, additionalPrice: n } = o.unitPriceInclTax;
7
8
  return {
8
- amount: t.amount + o.amount,
9
+ amount: t.amount + n.amount,
9
10
  currency: t.currency
10
11
  };
11
12
  }
12
- function e(n) {
13
- return n.map((t) => ({
13
+ function m(o) {
14
+ return o.map((t) => ({
14
15
  id: t.id,
15
16
  modificationText: i(
16
17
  t.product.name,
@@ -21,5 +22,5 @@ function e(n) {
21
22
  }));
22
23
  }
23
24
  export {
24
- e as default
25
+ m as default
25
26
  };
package/checkout/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./getCheckoutItemModifications.js"),o=require("./getCheckoutProductName.js"),e=require("./getCheckoutOrderStatusTexts.js"),r=require("./getCheckoutItemsMappedByTicketItemStatus.js"),c=require("./isCheckoutOrderSummary.js"),i=require("./buildCheckoutRequestItem.js"),s=require("./getCheckoutGrandTotalAmount.js"),a=require("./getCheckoutRequestItemFromCheckoutItem.js"),k=require("./isCheckoutItemsAreEqual.js"),h=require("./checkoutHasWallet.js"),n=require("./getWalletMetaFromCheckout.js"),C=require("./isPreOrderServiceTime.js"),l=require("./isPreOrderCheckout.js"),q=require("./isUpdatingCheckoutAllowed.js"),d=require("./isCheckoutAlreadyPaidStatus.js"),t=require("./getCheckoutPaymentErrorTranslationTexts.js"),g=require("./isDeletingCheckoutAllowed.js"),m=require("./getTotalCheckoutItemsQuantity.js"),_=require("./getCheckoutPenguinLockersMetaData.js"),T=require("./getUniqueCheckoutPenguinDeliveryCodes.js"),p=require("./isWoltDeliveryInProgress.js"),y=require("./isWalletTopUpCheckoutItem.js"),I=require("./isWalletTopUpCheckout.js"),P=require("./getCheckoutWalletTopUpMetaData.js"),M=require("./isGiftCardCheckout.js"),D=require("./isGiftCardCheckoutItem.js"),G=require("./getCheckoutGiftCardMetaData.js"),f=require("./getCheckoutGuestGroupsMetaData.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/getFormattedCurrencyPostfix.js");require("../order/getCheckOrderItemsMappedByTicketItemStatus.js");require("../order/getCheckOrderMinimumStatusTicketItem.js");require("../toString-b771abdf.js");require("../isObjectLike-963267e9.js");require("../_baseIteratee-374c60ca.js");require("../_getTag-3d3032da.js");require("../isObject-361bd834.js");require("../_baseIsEqual-7e335f42.js");require("../identity-58f9497d.js");require("../order/getMultiProductSubProductsTicketItems.js");require("axios");require("../error/isSerializedAPIError.js");exports.getCheckoutGroupedModifications=u.default;exports.getCheckoutProductName=o;exports.TranslationKey=e.TranslationKey;exports.getCheckoutOrderStatusTexts=e.default;exports.getCheckoutItemsMappedByTicketItemStatus=r;exports.isCheckoutOrderSummary=c;exports.buildCheckoutRequestItem=i;exports.getCheckoutGrandTotalAmount=s;exports.getCheckoutRequestItemFromCheckoutItem=a;exports.isCheckoutItemsAreEqual=k;exports.checkoutHasWallet=h;exports.getWalletMetaFromCheckout=n;exports.isPreOrderServiceTime=C;exports.isPreOrderCheckout=l;exports.isUpdatingCheckoutAllowed=q;exports.isCheckoutAlreadyPaidStatus=d;exports.CheckoutPaymentErrorTranslationKey=t.CheckoutPaymentErrorTranslationKey;exports.getCheckoutPaymentErrorTranslationTexts=t.default;exports.isDeletingCheckoutAllowed=g;exports.getTotalCheckoutItemsQuantity=m;exports.getCheckoutPenguinLockersMetaData=_;exports.getUniqueCheckoutPenguinDeliveryCodes=T;exports.isWoltDeliveryInProgress=p;exports.isWalletTopUpCheckoutItem=y;exports.isWalletTopUpCheckout=I;exports.getCheckoutWalletTopUpMetaData=P;exports.isGiftCardCheckout=M;exports.isGiftCardCheckoutItem=D;exports.getCheckoutGiftCardMetaData=G;exports.getCheckoutGuestGroupsMetaData=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./getCheckoutItemModifications.js"),r=require("./getCheckoutProductName.js"),e=require("./getCheckoutOrderStatusTexts.js"),o=require("./getCheckoutItemsMappedByTicketItemStatus.js"),c=require("./isCheckoutOrderSummary.js"),i=require("./buildCheckoutRequestItem.js"),s=require("./getCheckoutGrandTotalAmount.js"),a=require("./getCheckoutRequestItemFromCheckoutItem.js"),k=require("./isCheckoutItemsAreEqual.js"),h=require("./checkoutHasWallet.js"),n=require("./getWalletMetaFromCheckout.js"),C=require("./isPreOrderServiceTime.js"),l=require("./isPreOrderCheckout.js"),q=require("./isUpdatingCheckoutAllowed.js"),d=require("./isCheckoutAlreadyPaidStatus.js"),t=require("./getCheckoutPaymentErrorTranslationTexts.js"),g=require("./isDeletingCheckoutAllowed.js"),m=require("./getTotalCheckoutItemsQuantity.js"),_=require("./getCheckoutPenguinLockersMetaData.js"),T=require("./getUniqueCheckoutPenguinDeliveryCodes.js"),p=require("./isWoltDeliveryInProgress.js"),y=require("./isWalletTopUpCheckoutItem.js"),I=require("./isWalletTopUpCheckout.js"),P=require("./getCheckoutWalletTopUpMetaData.js"),M=require("./isGiftCardCheckout.js"),D=require("./isGiftCardCheckoutItem.js"),G=require("./getCheckoutGiftCardMetaData.js"),f=require("./getCheckoutGuestGroupsMetaData.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");require("../order/getCheckOrderItemsMappedByTicketItemStatus.js");require("../order/getCheckOrderMinimumStatusTicketItem.js");require("../toString-b771abdf.js");require("../isObjectLike-963267e9.js");require("../_baseIteratee-374c60ca.js");require("../_getTag-3d3032da.js");require("../isObject-361bd834.js");require("../_baseIsEqual-7e335f42.js");require("../identity-58f9497d.js");require("../order/getMultiProductSubProductsTicketItems.js");require("axios");require("../error/isSerializedAPIError.js");exports.getCheckoutGroupedModifications=u.default;exports.getCheckoutProductName=r;exports.TranslationKey=e.TranslationKey;exports.getCheckoutOrderStatusTexts=e.default;exports.getCheckoutItemsMappedByTicketItemStatus=o;exports.isCheckoutOrderSummary=c;exports.buildCheckoutRequestItem=i;exports.getCheckoutGrandTotalAmount=s;exports.getCheckoutRequestItemFromCheckoutItem=a;exports.isCheckoutItemsAreEqual=k;exports.checkoutHasWallet=h;exports.getWalletMetaFromCheckout=n;exports.isPreOrderServiceTime=C;exports.isPreOrderCheckout=l;exports.isUpdatingCheckoutAllowed=q;exports.isCheckoutAlreadyPaidStatus=d;exports.CheckoutPaymentErrorTranslationKey=t.CheckoutPaymentErrorTranslationKey;exports.getCheckoutPaymentErrorTranslationTexts=t.default;exports.isDeletingCheckoutAllowed=g;exports.getTotalCheckoutItemsQuantity=m;exports.getCheckoutPenguinLockersMetaData=_;exports.getUniqueCheckoutPenguinDeliveryCodes=T;exports.isWoltDeliveryInProgress=p;exports.isWalletTopUpCheckoutItem=y;exports.isWalletTopUpCheckout=I;exports.getCheckoutWalletTopUpMetaData=P;exports.isGiftCardCheckout=M;exports.isGiftCardCheckoutItem=D;exports.getCheckoutGiftCardMetaData=G;exports.getCheckoutGuestGroupsMetaData=f;
@@ -1,33 +1,34 @@
1
- import { default as h } from "./getCheckoutItemModifications.mjs";
2
- import { default as g } from "./getCheckoutProductName.mjs";
3
- import { TranslationKey as y, default as I } from "./getCheckoutOrderStatusTexts.mjs";
4
- import { default as D } from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
5
- import { default as M } from "./isCheckoutOrderSummary.mjs";
6
- import { default as A } from "./buildCheckoutRequestItem.mjs";
7
- import { default as U } from "./getCheckoutGrandTotalAmount.mjs";
8
- import { default as O } from "./getCheckoutRequestItemFromCheckoutItem.mjs";
9
- import { default as E } from "./isCheckoutItemsAreEqual.mjs";
10
- import { default as F } from "./checkoutHasWallet.mjs";
11
- import { default as R } from "./getWalletMetaFromCheckout.mjs";
12
- import { default as B } from "./isPreOrderServiceTime.mjs";
13
- import { default as L } from "./isPreOrderCheckout.mjs";
14
- import { default as Q } from "./isUpdatingCheckoutAllowed.mjs";
15
- import { default as z } from "./isCheckoutAlreadyPaidStatus.mjs";
16
- import { CheckoutPaymentErrorTranslationKey as V, default as X } from "./getCheckoutPaymentErrorTranslationTexts.mjs";
17
- import { default as Z } from "./isDeletingCheckoutAllowed.mjs";
18
- import { default as $ } from "./getTotalCheckoutItemsQuantity.mjs";
19
- import { default as et } from "./getCheckoutPenguinLockersMetaData.mjs";
20
- import { default as rt } from "./getUniqueCheckoutPenguinDeliveryCodes.mjs";
21
- import { default as ut } from "./isWoltDeliveryInProgress.mjs";
22
- import { default as st } from "./isWalletTopUpCheckoutItem.mjs";
1
+ import { default as n } from "./getCheckoutItemModifications.mjs";
2
+ import { default as T } from "./getCheckoutProductName.mjs";
3
+ import { TranslationKey as I, default as P } from "./getCheckoutOrderStatusTexts.mjs";
4
+ import { default as G } from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
5
+ import { default as W } from "./isCheckoutOrderSummary.mjs";
6
+ import { default as S } from "./buildCheckoutRequestItem.mjs";
7
+ import { default as q } from "./getCheckoutGrandTotalAmount.mjs";
8
+ import { default as v } from "./getCheckoutRequestItemFromCheckoutItem.mjs";
9
+ import { default as w } from "./isCheckoutItemsAreEqual.mjs";
10
+ import { default as K } from "./checkoutHasWallet.mjs";
11
+ import { default as b } from "./getWalletMetaFromCheckout.mjs";
12
+ import { default as H } from "./isPreOrderServiceTime.mjs";
13
+ import { default as N } from "./isPreOrderCheckout.mjs";
14
+ import { default as j } from "./isUpdatingCheckoutAllowed.mjs";
15
+ import { default as J } from "./isCheckoutAlreadyPaidStatus.mjs";
16
+ import { CheckoutPaymentErrorTranslationKey as X, default as Y } from "./getCheckoutPaymentErrorTranslationTexts.mjs";
17
+ import { default as _ } from "./isDeletingCheckoutAllowed.mjs";
18
+ import { default as tt } from "./getTotalCheckoutItemsQuantity.mjs";
19
+ import { default as ot } from "./getCheckoutPenguinLockersMetaData.mjs";
20
+ import { default as at } from "./getUniqueCheckoutPenguinDeliveryCodes.mjs";
21
+ import { default as mt } from "./isWoltDeliveryInProgress.mjs";
22
+ import { default as ft } from "./isWalletTopUpCheckoutItem.mjs";
23
23
  import { default as lt } from "./isWalletTopUpCheckout.mjs";
24
- import { default as it } from "./getCheckoutWalletTopUpMetaData.mjs";
25
- import { default as ct } from "./isGiftCardCheckout.mjs";
26
- import { default as kt } from "./isGiftCardCheckoutItem.mjs";
27
- import { default as ht } from "./getCheckoutGiftCardMetaData.mjs";
28
- import { default as gt } from "./getCheckoutGuestGroupsMetaData.mjs";
24
+ import { default as dt } from "./getCheckoutWalletTopUpMetaData.mjs";
25
+ import { default as Ct } from "./isGiftCardCheckout.mjs";
26
+ import { default as xt } from "./isGiftCardCheckoutItem.mjs";
27
+ import { default as nt } from "./getCheckoutGiftCardMetaData.mjs";
28
+ import { default as Tt } from "./getCheckoutGuestGroupsMetaData.mjs";
29
29
  import "@ancon/wildcat-types";
30
30
  import "../currency/getFormattedCurrency.mjs";
31
+ import "../currency/placeCurrencySymbol.mjs";
31
32
  import "../currency/getFormattedCurrencyPostfix.mjs";
32
33
  import "../order/getCheckOrderItemsMappedByTicketItemStatus.mjs";
33
34
  import "../order/getCheckOrderMinimumStatusTicketItem.mjs";
@@ -42,34 +43,34 @@ import "../order/getMultiProductSubProductsTicketItems.mjs";
42
43
  import "axios";
43
44
  import "../error/isSerializedAPIError.mjs";
44
45
  export {
45
- V as CheckoutPaymentErrorTranslationKey,
46
- y as TranslationKey,
47
- A as buildCheckoutRequestItem,
48
- F as checkoutHasWallet,
49
- ht as getCheckoutGiftCardMetaData,
50
- U as getCheckoutGrandTotalAmount,
51
- h as getCheckoutGroupedModifications,
52
- gt as getCheckoutGuestGroupsMetaData,
53
- D as getCheckoutItemsMappedByTicketItemStatus,
54
- I as getCheckoutOrderStatusTexts,
55
- X as getCheckoutPaymentErrorTranslationTexts,
56
- et as getCheckoutPenguinLockersMetaData,
57
- g as getCheckoutProductName,
58
- O as getCheckoutRequestItemFromCheckoutItem,
59
- it as getCheckoutWalletTopUpMetaData,
60
- $ as getTotalCheckoutItemsQuantity,
61
- rt as getUniqueCheckoutPenguinDeliveryCodes,
62
- R as getWalletMetaFromCheckout,
63
- z as isCheckoutAlreadyPaidStatus,
64
- E as isCheckoutItemsAreEqual,
65
- M as isCheckoutOrderSummary,
66
- Z as isDeletingCheckoutAllowed,
67
- ct as isGiftCardCheckout,
68
- kt as isGiftCardCheckoutItem,
69
- L as isPreOrderCheckout,
70
- B as isPreOrderServiceTime,
71
- Q as isUpdatingCheckoutAllowed,
46
+ X as CheckoutPaymentErrorTranslationKey,
47
+ I as TranslationKey,
48
+ S as buildCheckoutRequestItem,
49
+ K as checkoutHasWallet,
50
+ nt as getCheckoutGiftCardMetaData,
51
+ q as getCheckoutGrandTotalAmount,
52
+ n as getCheckoutGroupedModifications,
53
+ Tt as getCheckoutGuestGroupsMetaData,
54
+ G as getCheckoutItemsMappedByTicketItemStatus,
55
+ P as getCheckoutOrderStatusTexts,
56
+ Y as getCheckoutPaymentErrorTranslationTexts,
57
+ ot as getCheckoutPenguinLockersMetaData,
58
+ T as getCheckoutProductName,
59
+ v as getCheckoutRequestItemFromCheckoutItem,
60
+ dt as getCheckoutWalletTopUpMetaData,
61
+ tt as getTotalCheckoutItemsQuantity,
62
+ at as getUniqueCheckoutPenguinDeliveryCodes,
63
+ b as getWalletMetaFromCheckout,
64
+ J as isCheckoutAlreadyPaidStatus,
65
+ w as isCheckoutItemsAreEqual,
66
+ W as isCheckoutOrderSummary,
67
+ _ as isDeletingCheckoutAllowed,
68
+ Ct as isGiftCardCheckout,
69
+ xt as isGiftCardCheckoutItem,
70
+ N as isPreOrderCheckout,
71
+ H as isPreOrderServiceTime,
72
+ j as isUpdatingCheckoutAllowed,
72
73
  lt as isWalletTopUpCheckout,
73
- st as isWalletTopUpCheckoutItem,
74
- ut as isWoltDeliveryInProgress
74
+ ft as isWalletTopUpCheckoutItem,
75
+ mt as isWoltDeliveryInProgress
75
76
  };
@@ -1 +1 @@
1
- "use strict";const N=require("./getFormattedCurrencyPostfix.js");function h(d=0,A="SEK",e=!0){let l=0;const c=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0,showAsManyDecimalsAsNeeded:(e==null?void 0:e.showAsManyDecimalsAsNeeded)??!1,maxAsManyDecimalsAsNeeded:(e==null?void 0:e.maxAsManyDecimalsAsNeeded)??8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:(e==null?void 0:e.onlyShowAsManyDecimalsAsNeededWhenZeroInt)??!0,showCurrencyPostfix:(e==null?void 0:e.showCurrencyPostfix)??!0}:{formatPostfix:e,trimTrailingZeros:!0,showAsManyDecimalsAsNeeded:!1,maxAsManyDecimalsAsNeeded:8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:!0,showCurrencyPostfix:!0};if(!d||Number.isNaN(Number(d)))l=0;else if(c.trimTrailingZeros&&Number.isInteger(Number(d)))l=d;else if(c.showAsManyDecimalsAsNeeded){l=Number(d).toFixed(c.maxAsManyDecimalsAsNeeded);const[u,s]=l.split("."),n=s!=null&&s.length>2?s.replace(/0+$/,""):s;(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt?u==="0":!0)&&u!=null&&n!=null&&n.length>2?l=`${u}.${n}`:l=Number(d).toFixed(2)}else l=Number(d).toFixed(2),c.trimTrailingZeros&&l.endsWith(".00")&&(l=Number.parseInt(l,10).toString());if(c.showCurrencyPostfix===!1)return`${l}`;const y=c.formatPostfix?N(A):A;return`${l} ${y}`}module.exports=h;
1
+ "use strict";const y=require("./placeCurrencySymbol.js");require("./getFormattedCurrencyPostfix.js");function N(d=0,s="SEK",e=!0){let l=0;const c=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0,showAsManyDecimalsAsNeeded:(e==null?void 0:e.showAsManyDecimalsAsNeeded)??!1,maxAsManyDecimalsAsNeeded:(e==null?void 0:e.maxAsManyDecimalsAsNeeded)??8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:(e==null?void 0:e.onlyShowAsManyDecimalsAsNeededWhenZeroInt)??!0,showCurrencyPostfix:(e==null?void 0:e.showCurrencyPostfix)??!0}:{formatPostfix:e,trimTrailingZeros:!0,showAsManyDecimalsAsNeeded:!1,maxAsManyDecimalsAsNeeded:8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:!0,showCurrencyPostfix:!0};if(!d||Number.isNaN(Number(d)))l=0;else if(c.trimTrailingZeros&&Number.isInteger(Number(d)))l=d;else if(c.showAsManyDecimalsAsNeeded){l=Number(d).toFixed(c.maxAsManyDecimalsAsNeeded);const[A,u]=l.split("."),n=u!=null&&u.length>2?u.replace(/0+$/,""):u;(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt?A==="0":!0)&&A!=null&&n!=null&&n.length>2?l=`${A}.${n}`:l=Number(d).toFixed(2)}else l=Number(d).toFixed(2),c.trimTrailingZeros&&l.endsWith(".00")&&(l=Number.parseInt(l,10).toString());return c.showCurrencyPostfix===!1?`${l}`:c.formatPostfix?y(l,s):`${l} ${s}`}module.exports=N;
@@ -1,5 +1,6 @@
1
- import N from "./getFormattedCurrencyPostfix.mjs";
2
- function D(d = 0, s = "SEK", e = !0) {
1
+ import N from "./placeCurrencySymbol.mjs";
2
+ import "./getFormattedCurrencyPostfix.mjs";
3
+ function D(d = 0, y = "SEK", e = !0) {
3
4
  let l = 0;
4
5
  const c = typeof e == "object" ? {
5
6
  formatPostfix: (e == null ? void 0 : e.formatPostfix) ?? !0,
@@ -26,10 +27,7 @@ function D(d = 0, s = "SEK", e = !0) {
26
27
  (c.onlyShowAsManyDecimalsAsNeededWhenZeroInt ? u === "0" : !0) && u != null && n != null && n.length > 2 ? l = `${u}.${n}` : l = Number(d).toFixed(2);
27
28
  } else
28
29
  l = Number(d).toFixed(2), c.trimTrailingZeros && l.endsWith(".00") && (l = Number.parseInt(l, 10).toString());
29
- if (c.showCurrencyPostfix === !1)
30
- return `${l}`;
31
- const y = c.formatPostfix ? N(s) : s;
32
- return `${l} ${y}`;
30
+ return c.showCurrencyPostfix === !1 ? `${l}` : c.formatPostfix ? N(l, y) : `${l} ${y}`;
33
31
  }
34
32
  export {
35
33
  D as default
@@ -1,3 +1,4 @@
1
1
  import getFormattedCurrency from './getFormattedCurrency';
2
2
  import getFormattedCurrencyPostfix from './getFormattedCurrencyPostfix';
3
- export { getFormattedCurrency, getFormattedCurrencyPostfix };
3
+ import placeCurrencySymbol from './placeCurrencySymbol';
4
+ export { getFormattedCurrency, getFormattedCurrencyPostfix, placeCurrencySymbol };
package/currency/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFormattedCurrency.js"),r=require("./getFormattedCurrencyPostfix.js");exports.getFormattedCurrency=e;exports.getFormattedCurrencyPostfix=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFormattedCurrency.js"),r=require("./getFormattedCurrencyPostfix.js"),t=require("./placeCurrencySymbol.js");exports.getFormattedCurrency=e;exports.getFormattedCurrencyPostfix=r;exports.placeCurrencySymbol=t;
@@ -1,6 +1,8 @@
1
- import { default as r } from "./getFormattedCurrency.mjs";
1
+ import { default as t } from "./getFormattedCurrency.mjs";
2
2
  import { default as a } from "./getFormattedCurrencyPostfix.mjs";
3
+ import { default as m } from "./placeCurrencySymbol.mjs";
3
4
  export {
4
- r as getFormattedCurrency,
5
- a as getFormattedCurrencyPostfix
5
+ t as getFormattedCurrency,
6
+ a as getFormattedCurrencyPostfix,
7
+ m as placeCurrencySymbol
6
8
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Place the currency symbol around an already formatted amount according to
3
+ * the currency's convention (ie "£4.50" or "4.50 kr")
4
+ * @param {string|number} formattedAmount - Formatted amount (ie "4.50")
5
+ * @param {string} currency - Currency string (ie "SEK")
6
+ * @return {string} - Amount with the currency symbol placed
7
+ */
8
+ export default function placeCurrencySymbol(formattedAmount: string | number, currency?: string | null): string;