@ancon/wildcat-utils 1.44.6 → 1.44.8
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.
- package/inventory/getDetailedProductVariantStock.d.ts +2 -2
- package/inventory/isDetailedProductOutOfStock.d.ts +2 -2
- package/inventory/isDetailedProductVariantOutOfStocks.d.ts +2 -2
- package/outlet/getListOutletOpeningHoursTable.js +1 -1
- package/outlet/getListOutletOpeningHoursTable.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function getDetailedProductVariantStock(productVariant:
|
|
1
|
+
import { PurchaseProductDetailsVariant } from '@ancon/wildcat-types';
|
|
2
|
+
export default function getDetailedProductVariantStock(productVariant: PurchaseProductDetailsVariant, outletId: string): import("@ancon/wildcat-types").ProductVariantOutletStock | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function isDetailedProductOutOfStock(outletId: string, productVariants?:
|
|
1
|
+
import { PurchaseProductDetailsVariant } from '@ancon/wildcat-types';
|
|
2
|
+
export default function isDetailedProductOutOfStock(outletId: string, productVariants?: PurchaseProductDetailsVariant[]): boolean | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function isDetailedProductVariantOutOfStock(productVariant:
|
|
1
|
+
import { PurchaseProductDetailsVariant } from '@ancon/wildcat-types';
|
|
2
|
+
export default function isDetailedProductVariantOutOfStock(productVariant: PurchaseProductDetailsVariant, outletId: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const T=require("moment"),t=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),O=require("../shared/generateId.js");require("react");const F=require("../time/getTimeSpanParts.js"),I=require("../date/createLocalTimezoneMoment.js"),W=require("../date/convertToLocalTimezone.js");require("../date/getTimezoneUtcOffsetDifference.js");const l=[{id:t.OrderFormat.EatIn,name:"eatIn"},{id:t.OrderFormat.TakeAway,name:"takeaway"},{id:t.OrderFormat.TableOrder,name:"tableOrder"},{id:t.OrderFormat.Delivery,name:"delivery"},{id:t.OrderFormat.BoxPickup,name:"boxPickup"}];function v(r){const s=W(T(r).startOf("day")
|
|
1
|
+
"use strict";const T=require("moment"),t=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),O=require("../shared/generateId.js");require("react");const F=require("../time/getTimeSpanParts.js"),I=require("../date/createLocalTimezoneMoment.js"),W=require("../date/convertToLocalTimezone.js");require("../date/getTimezoneUtcOffsetDifference.js");const l=[{id:t.OrderFormat.EatIn,name:"eatIn"},{id:t.OrderFormat.TakeAway,name:"takeaway"},{id:t.OrderFormat.TableOrder,name:"tableOrder"},{id:t.OrderFormat.Delivery,name:"delivery"},{id:t.OrderFormat.BoxPickup,name:"boxPickup"}];function v(r){const s=W(T(r).utc()).startOf("day"),e=[];for(let o=0;o<7;o+=1)e.push(s.clone().add(o,"day"));return e}function D(r){return[...r].sort((s,e)=>s.isoWeekday()-e.isoWeekday())}function M(r,s){const e=F(r.from),o=F(r.duration);if(r.type===t.IntervalType.Normal){const d=s.clone().add(e.hours,"hour").add(e.minutes,"minute"),m=d.clone().add(o);return{id:r.id,start:d.format("YYYY-MM-DDTHH:mm:ss"),end:m.format("YYYY-MM-DDTHH:mm:ss")}}if(r.type===t.IntervalType.Exception){const d=I(r.periodFrom),m=I(r.periodTo);if(s.isBetween(d,m,void 0,"[]")){const n=s.clone().add(e.hours,"hour").add(e.minutes,"minute"),i=n.clone().add(o);return{id:r.id,start:n.format("YYYY-MM-DDTHH:mm:ss"),end:i.format("YYYY-MM-DDTHH:mm:ss"),reason:r.reason}}return null}throw new Error("Invalid interval type")}function h(r,s,e){const o={[t.DayOfWeek.Monday]:1,[t.DayOfWeek.Tuesday]:2,[t.DayOfWeek.Wednesday]:3,[t.DayOfWeek.Thursday]:4,[t.DayOfWeek.Friday]:5,[t.DayOfWeek.Saturday]:6,[t.DayOfWeek.Sunday]:7,[t.DayOfWeek.Everyday]:null};for(let d=0;d<s.length;d+=1){const m=s[d],n=m.isoWeekday(),i=r.dayOfWeek,u=(o[i]??null)===n||i===t.DayOfWeek.Everyday;if(e[n]||(e[n]={isoWeekday:n,key:"",open:[],adjusted:[],closed:[]}),u){const a=M(r,m);a&&(e[n].key+=a.id,r.type===t.IntervalType.Normal&&r.state===t.IntervalState.Opened?e[n].open.push(a):r.type===t.IntervalType.Normal&&r.state===t.IntervalState.Closed?e[n].closed.push(a):r.type===t.IntervalType.Exception&&r.state===t.IntervalState.Opened?e[n].adjusted.push(a):r.type===t.IntervalType.Exception&&r.state===t.IntervalState.Closed&&e[n].closed.push(a))}}}function H(r){switch(r.type){case t.IntervalType.Exception:return O("interval-exception");case t.IntervalType.Normal:return O("interval-normal");default:return O("interval-unknown")}}function Y(r){const s=r.reduce((e,o)=>(l.forEach(d=>{g(d.id,o.orderFormats)&&(e[d.id]||(e[d.id]={orderFormat:d,intervals:[]}),e[d.id].intervals.push(...o.intervals.sort((m,n)=>m.dayOfWeek-n.dayOfWeek)))}),e),{});return Object.values(s)}function x(r,s){const e=s.reduce((o,d)=>d<=r?o+1:o,0);return r-e}function S(r){const{mergedTables:s}=r.reduce((e,o,d)=>{const m=e.mergedTables.findIndex(n=>n!==o&&!n.orderFormats.some(i=>o.orderFormats.some(p=>p.id===i.id))&&n.openingHours.every(i=>o.openingHours.some(p=>p.key===i.key))&&o.openingHours.every(i=>n.openingHours.some(p=>p.key===i.key)));if(m>=0){if(e.skipOrderFormats.some(a=>o.orderFormats.every(y=>y.id===a.id)))return e;const i=e.mergedTables[m];e.mergedTables.splice(m,1,{...i,orderFormats:[...o.orderFormats,...i.orderFormats]});const p=i.orderFormats.filter(a=>!e.skipOrderFormats.some(y=>y.id===a.id));p.length>0&&e.skipOrderFormats.push(...p);const u=x(d,[...e.removedIndexes]);return e.mergedTables.splice(u,1),e.removedIndexes.push(d),e}return e},{mergedTables:[...r],removedIndexes:[],skipOrderFormats:[]});return s}function E(r){return r.map(s=>({...s,intervals:s.intervals.map(e=>({...e,id:H(e)}))}))}function q(r,s){const e=Y(E(r.serviceDateTimes)),o=v(s),d=D(o),m=e.reduce((u,a)=>(u[a.orderFormat.id]||(u[a.orderFormat.id]={}),a.intervals.reduce((y,f)=>(h(f,d,y),y),u[a.orderFormat.id]),u),{}),n={[t.OrderFormat.EatIn]:l[0],[t.OrderFormat.TakeAway]:l[1],[t.OrderFormat.TableOrder]:l[2],[t.OrderFormat.Delivery]:l[3],[t.OrderFormat.BoxPickup]:l[4]},i=Object.entries(m).map(([u,a])=>({orderFormats:[n[Number(u)]],openingHours:Object.entries(a).map(([y,f])=>({isoWeekday:Number(y),key:f.key,open:f.open.sort((c,k)=>c.start.localeCompare(k.start)),adjusted:f.adjusted.sort((c,k)=>c.start.localeCompare(k.start)),closed:f.closed.sort((c,k)=>c.start.localeCompare(k.start))}))}));return S(i).sort((u,a)=>u.orderFormats[0].id-a.orderFormats[0].id)}module.exports=q;
|