@darkpos/modifier

1.0.2 • Public • Published

modifier

TODO: description

Usage

const useModifier = require('@darkpos/modifier');

const options = {
    ...localization,
};

const modifierService = useModifiers(options);

//
const newModifier = modifierService.calculate(oldModifier);

Model samples:

usecase #1, General modifier
{
    "_id" : ObjectId("5eaae0698354d0d2d4df0e88"),
    "amount" : 10,
    "cost" : 0,
    "tags" : [ 
        "default"
    ],
    "attributes" : [ 
        "multiple",                                           -------> is identifier for modifiers
        "relatedItems",                                       -------> is identifier for items
        "required", 
        "hidden", 
        "bind",                                               -------> is identifier for properties.bindModifiers
        "print"
    ],
    "modifiers" : [ 
        ObjectId("5e8e0c5eea37c76bfbc56bec")
    ],
    "items" : [ 
        ObjectId("5e66be1fdda8a8a8bc9c3593")
    ],
    "_isDeleted" : false,
    "modifierId" : null,
    "name" : "sample #1",
    "sku" : "",
    "description" : "sample one discription",
    "type" : "fixed",
    "action" : "subtract",
    "isTax" : false,
    "group" : "Color",
    "properties" : {
        "enableAutoPopup" : true,
        "displayReplacePrompt" : true,
        "inheritModifiers" : true,
        "excludeFromSubscription" : true,
        "bindModifiers" : [ 
            {
                "_id" : "5e8d63031cc9cc089b7890cf",
                "name" : "10% propmotion",
                "description" : "",
                "attributes" : [ 
                    "promotion", 
                    "order"
                ],
                "amount" : 10,
                "type" : "percentage",
                "action" : "subtract",
                "isTax" : false,
                "group" : null,
                "sku" : "",
                "url" : "",
                "color" : "",
                "tags" : [ 
                    "default", 
                    "all"
                ],
                "properties" : null,
                "modifierId" : null,
                "__typename" : "Modifier",
                "modifiers" : [],
                "items" : []
            }
        ]
    },
    "color" : "#d50000",
    "url" : "",
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-04-30T14:27:54.091Z"),
    "_updatedAt" : ISODate("2020-04-30T14:27:54.091Z"),
    "__v" : 0
}
usecase #2, Department
/* 1 */
{
    "_id" : ObjectId("5e615649afb118e4b1dfc0d1"),
    "amount" : 0,
    "cost" : 0,
    "tags" : [],
    "attributes" : [ 
        "customerTagsExtend",                                   -----> is identifier for properties.customerTagExtends
        "removeModifiers",                                      -----> is identifier for properties.removeModifiers
        "department", 
        "print"
    ],
    "modifiers" : [],
    "items" : [ 
        ObjectId("5e615649afb118e4b1dfc0d2"), 
        ObjectId("5e615649afb118e4b1dfc0d3")
    ],
    "_isDeleted" : false,
    "name" : "Press Only",
    "sku" : "",
    "description" : "",
    "type" : "",
    "action" : "",
    "isTax" : false,
    "group" : "",
    "color" : "",
    "url" : "",
    "properties" : {
        "customerTagsExtend" : [ 
            "press only"                                         -----> if deparment, it will add tag to customer affects price level
        ],
        "code" : "P",                                            -----> if deparment, it has code to display
        "maxItems" : 0,                                          -----> if deparment, max item for split
        "tagSize" : "Small",                                     -----> if department, defines tag size for print
        "removeModifiers" : [ 
            {
                "_id" : "5d8c910bbef6972fa8a6d068",
                "name" : "Laundry",
                "description" : "",
                "attributes" : [ 
                    "department", 
                    "hidden", 
                    "required"
                ],
                "amount" : 0,
                "type" : "",
                "action" : "",
                "isTax" : false,
                "group" : "",
                "sku" : "",
                "url" : "",
                "color" : "",
                "tags" : [],
                "properties" : {
                    "code" : "L",
                    "maxItems" : 4
                },
                "modifierId" : null,
                "__typename" : "Modifier",
                "modifiers" : [],
                "items" : []
            }, 
            {
                "_id" : "5d8c8954d73e55b05d2bc1d4",
                "name" : "Dry Cleaning",
                "description" : "",
                "attributes" : [ 
                    "department", 
                    "hidden", 
                    "required"
                ],
                "amount" : 0,
                "type" : "",
                "action" : "",
                "isTax" : false,
                "group" : "",
                "sku" : "",
                "url" : "",
                "color" : "",
                "tags" : null,
                "properties" : {
                    "code" : "D",
                    "maxItems" : 4
                },
                "modifierId" : null,
                "__typename" : "Modifier",
                "modifiers" : [],
                "items" : []
            }, 
            {
                "_id" : "5d8c8f1fc77e1986a483a0fe",
                "name" : "Tailoring",
                "description" : "",
                "attributes" : [ 
                    "required", 
                    "department"
                ],
                "amount" : 0,
                "type" : "",
                "action" : "",
                "isTax" : false,
                "group" : "",
                "sku" : "",
                "url" : "",
                "color" : "",
                "tags" : [],
                "properties" : {
                    "code" : "T",
                    "maxItems" : 4,
                    "index" : 3
                },
                "modifierId" : null,
                "__typename" : "Modifier",
                "modifiers" : [],
                "items" : []
            }
        ]
    },
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-03-05T19:43:29.244Z"),
    "_updatedAt" : ISODate("2020-04-30T14:53:39.749Z"),
    "__v" : 0
}
usecase #3: Group
/* 1 */
{
    "_id" : ObjectId("5e615649afb118e4b1dfc106"),
    "amount" : 0,
    "cost" : 0,
    "tags" : [],
    "attributes" : [ 
        "group"                                               -------> is identifier for modifiers
    ],
    "modifiers" : [ 
        ObjectId("5e615649afb118e4b1dfc108"), 
        ObjectId("5e615649afb118e4b1dfc109"), 
        ObjectId("5e615649afb118e4b1dfc10a"), 
        ObjectId("5e615649afb118e4b1dfc10b"), 
        ObjectId("5e615649afb118e4b1dfc10c"), 
        ObjectId("5e615649afb118e4b1dfc10d"), 
        ObjectId("5e615649afb118e4b1dfc10e")
    ],
    "items" : [],
    "_isDeleted" : false,
    "modifierId" : null,
    "name" : "Blue",
    "sku" : "",
    "description" : "",
    "type" : "",
    "action" : "",
    "isTax" : false,
    "group" : null,
    "color" : "#2196f3",
    "url" : "",
    "properties" : {
        "singleValue" : true,                                    -------> How to be display on menu
        "includeInGroup" : true,                                 -------> How to be display on menu
        "displayAsTable" : true                                  -------> How to be display on menu
    },
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-03-05T19:43:30.122Z"),
    "_updatedAt" : ISODate("2020-04-30T15:02:59.751Z"),
    "__v" : 0
}
usecase #4: Discount
{
    "_id" : ObjectId("5eaae9a58354d0d2d4df0e99"),
    "amount" : 10,
    "cost" : 0,
    "tags" : [ 
        "default"
    ],
    "attributes" : [ 
        "discount",                                               -------> defines category of modifier
        "required", 
        "hidden", 
        "print", 
        "order"                                                   --------> it will be applied to Order
    ],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : false,
    "modifierId" : null,
    "name" : "10% discount",
    "sku" : "",
    "description" : "",
    "type" : "percentage",
    "action" : "subtract",
    "isTax" : false,
    "group" : null,
    "properties" : {
        "minItems" : 2                                            --------> Minimum items required 
    },
    "color" : "",
    "url" : "",
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-04-30T15:07:18.021Z"),
    "_updatedAt" : ISODate("2020-04-30T15:07:18.021Z"),
    "__v" : 0
}
usecase #5: Override
{
    "_id" : ObjectId("5eaaead98354d0d2d4df0e9c"),
    "amount" : 0,
    "cost" : 0,
    "tags" : [ 
        "default"
    ],
    "attributes" : [ 
        "priceOverride", 
        "required"
    ],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : false,
    "modifierId" : null,
    "name" : "override sample",
    "sku" : "",
    "description" : "",
    "type" : "",
    "action" : "",
    "isTax" : false,
    "group" : null,
    "properties" : {
        "actAsMultiplier" : true,                                   ------> to multiply the price or quantity
        "valueReplaceType" : "manual"                               ------> if it is manual or service
        "service":""                                                ------> to hold value for service: select from store.integrations
    },
    "color" : "",
    "url" : "",
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-04-30T15:12:26.211Z"),
    "_updatedAt" : ISODate("2020-04-30T15:12:26.211Z"),
    "__v" : 0
}
usecase #6: Preferences
{
    "_id" : ObjectId("5cd948a9e170cf80ab38a901"),
    "amount" : 0,
    "cost" : 0,
    "tags" : [],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : false,
    "name" : "Light",
    "sku" : "",
    "description" : "",
    "type" : "",
    "action" : "",
    "isTax" : false,
    "group" : "Starch",
    "color" : "#fe9700",
    "icon" : "",
    "url" : "",
    "_accountId" : ObjectId("5cc3e16916c73a0017e5bcd7"),
    "_storeId" : ObjectId("5cc3e16916c73a0017e5bcf1"),
    "attributes" : [ 
        "preferences", 
        "print"
    ],
    "_createdAt" : ISODate("2019-05-13T10:36:25.802Z"),
    "_updatedAt" : ISODate("2020-04-06T14:23:03.512Z"),
    "__v" : 0,
    "restrictions" : null,
    "properties" : {
        "badgeColor" : "#ffc107",
        "index" : 2,
        "code" : "L"
    },
    "_deletedAt" : ISODate("2019-12-01T15:59:56.605Z")
}
usecase #7: Promotion
{
    "_id" : ObjectId("5d63d052b7d9f147933eeeae"),
    "amount" : 100,
    "cost" : 0,
    "tags" : [ 
        "default", 
        "promotion"
    ],
    "attributes" : [ 
        "promotion"
    ],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : true,
    "name" : "Promotion#1",
    "sku" : "promo#1",
    "description" : "Promotion Modifier",
    "type" : "percentage",
    "action" : "subtract",
    "isTax" : false,
    "group" : "",
    "properties" : {
        "promotion" : {
            "numberOfUsesLimit" : 10,
            "dateLimit" : {
                "from" : "2019-08-25T12:26:00.000Z",
                "to" : "2019-09-23T13:26:00.000Z"
            },
            "storeCreditCharge" : 110,
            "creditForAnotherCustomer" : true,
            "customer" : "5d5aa78190e20d923a560f02",
            "numberOfUses" : 0
        }
    },
    "color" : "#03a9f4",
    "url" : "http://res.cloudinary.com/darkpos/image/upload/c_scale,h_120,w_120/v1547052861/icons/enlite/womens_shoe.png",
    "_accountId" : ObjectId("5d4d9bc4faba39001867862e"),
    "_storeId" : ObjectId("5d4d9bc4faba39001867864e"),
    "_createdAt" : ISODate("2019-08-26T12:28:04.130Z"),
    "_updatedAt" : ISODate("2019-09-18T09:05:37.643Z"),
    "__v" : 0,
    "_deletedAt" : ISODate("2019-09-18T09:05:37.642Z")
}

usecase #8: Tax
{
    "_id" : ObjectId("5e733d02af509dcebdade1da"),
    "amount" : 16,
    "cost" : 0,
    "tags" : [],
    "attributes" : [ 
        "tax",                                                              -----> belongs to category of tax
        "hidden", 
        "required", 
        "print"
    ],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : false,
    "modifierId" : null,
    "name" : "tax 16%",
    "sku" : "",
    "description" : "",
    "type" : "percentage",
    "action" : "add",
    "isTax" : false,                                                       ------> not being used!!!
    "group" : null,
    "color" : "",
    "url" : "",
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-03-19T09:36:05.912Z"),
    "_updatedAt" : ISODate("2020-04-30T15:48:50.434Z"),
    "__v" : 0,
    "properties" : null
}
usecase #9: List
{
    "_id" : ObjectId("5e615649afb118e4b1dfc0cc"),
    "amount" : 0,
    "cost" : 0,
    "tags" : [],
    "attributes" : [ 
        "hidden", 
        "list"
    ],
    "modifiers" : [],
    "items" : [],
    "_isDeleted" : false,
    "name" : "Spot Damage",
    "sku" : "",
    "description" : "",
    "type" : "",
    "action" : "",
    "isTax" : false,
    "group" : "",
    "properties" : {
        "listType" : "card",
        "listValues" : "Ink, Spot, Wine, Blood, Ketchup, Damaged",
        "compactList" : true
    },
    "color" : "",
    "url" : "",
    "modifierId" : null,
    "_accountId" : ObjectId("5b4e01ec785bec001185700b"),
    "_storeId" : ObjectId("5b4e0356785bec0011857033"),
    "_createdAt" : ISODate("2020-03-05T19:43:26.063Z"),
    "_updatedAt" : ISODate("2020-04-30T16:14:01.623Z"),
    "__v" : 0
}

/@darkpos/modifier/

    Package Sidebar

    Install

    npm i @darkpos/modifier

    Weekly Downloads

    0

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    67.6 kB

    Total Files

    119

    Last publish

    Collaborators

    • darkpos-dev
    • jeanlescure