biz9-store 1.0.10

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/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # BiZ9 Store
2
+ ** Description
3
+
4
+ ## Installation
5
+ Use the [npm](https://npm.com) installer to install.
6
+
7
+ ```bash
8
+ npm i biz9-store
9
+ ```
10
+
11
+ ## Required
12
+ *
13
+
14
+ ## Contents
15
+ *
16
+
17
+ ```
18
+ ## Credits
19
+ ### <a id="credit"></a>Credits
20
+
21
+ #### Company
22
+ - **BiZ9 Framework LLC**
23
+
24
+ #### Code
25
+ - [BiZ9 Framework Github](https://github.com/biz9framework)
26
+ - [BiZ9 Framework NPM](https://www.npmjs.com/~biz9framework)
27
+
28
+ #### E-mail
29
+ - [biz9framework@gmail.com](mailto:biz9framework@gmail.com)
30
+
31
+ #### Support
32
+ - [Cash App](https://cash.app/$bossappzstudio)
33
+
34
+ #### The BiZ9 Framework 🦾
35
+ ![BiZ9 Framework Logo](https://github.com/biz9framework/biz9-art/blob/main/biz9-framework/logo/logox250.png?raw=true)
36
+
37
+ **The BiZ9 Framework** is a developer friendly platform for building premium, polished, fast, professional and scalable business applications using the lastest rapid application development tools and techniques. The framework consists of libraries, commands, scripts, and packages for creating, maintaining, testing, and deploying both **mobile** and **website applications**. The primary 3rd party framework used are [**React**](https://react.dev/), [**React Native**](https://reactnative.dev/), [**Node.js**](http://Node.js), [**ExpressJS**](https://expressjs.com/), [**MongoDB**](https://www.mongodb.com/), [**Nginx**](https://nginx.org/), [**Redis**](https://redis.io/), [**Git**](https://git-scm.com/), and [**Bash**](https://www.gnu.org/software/bash/). **The BiZ9 Framework** focus is to be precise, routine, rapid, and customizable. The primary target devices for **The BiZ9 Framework** are [**Apple iOS**](https://developer.apple.com/), [**Android**](https://www.android.com/), [**Chrome**](https://www.google.com/chrome/), [**Safari**](https://www.apple.com/safari/), [**Firefox**](https://www.mozilla.org/en-US/firefox/), and [**Edge**](https://www.microsoft.com/en-us/edge/?form=MA13FJ). Other 3rd party Application Programming Interfaces (API) that are pre included are [**Amazon Web Service**](https://aws.amazon.com/), [**Stripe**](https://stripe.com/) and [**Bravely**](https://workbravely.com/).
38
+
39
+ - <a href="https://github.com/biz9framework" target="_blank">Biz9 Framework GitHub</a>
40
+ - <a href="https://bossappz.medium.com/what-is-the-biz9-framework-29731c49ad79" target="_blank">Biz9 Framework Blog</a>
41
+ - <a href="https://youtu.be/W_ZUmwZMFoc?si=4b5_6q9vPgi1IxPL" target="_blank">BoSS Mobile App Youtube Demo</a>
42
+
43
+ #### TaNK9 Code 👽
44
+ ![TaNK9 Code Head](https://github.com/biz9framework/biz9-art/blob/main/tank9code/head/tank9_headx250.png?raw=true)
45
+
46
+ **Brandon Poole Sr** also known as **‘TaNK’** is a technical lead and full stack software engineer with over 19 years of professional experience. He was born and raised in **Atlanta, Ga** and graduated with a Computer Information Systems **Bachelor of Science Degree** from [**Fort Valley State University**](https://www.fvsu.edu/). He is proficient in [**ASP.NET C#**](http://ASP.NET), [**ASP.NET MVC**](https://dotnet.microsoft.com/en-us/apps/aspnet/mvc), [**.NET Core**](https://dotnet.microsoft.com/en-us/download), [**Microsoft SQL Server**](https://www.microsoft.com/en-us/sql-server), [**IIS Web Server**](https://learn.microsoft.com/en-us/iis/get-started/introduction-to-iis/iis-web-server-overview), [**Node.js**](http://Node.js), [**React**](https://react.dev/), [**React Native**](https://reactnative.dev/), [**Framework7**](https://framework7.io/), [**Redis**](https://redis.io/), [**Amazon Web Services**](https://aws.amazon.com/), [**Apple iOS**](https://developer.apple.com/ios/), [**Android SDK**](https://developer.android.com/studio), [**MongoDB**](https://www.mongodb.com/), [**Redis**](https://redis.io/), [**NGINX**](https://nginx.org/), and [**Git**](https://git-scm.com/). He has worked as a software developer for Fortune 500 companies such as [**The Boeing Company**](https://www.boeing.com/), [**Georgia Pacific**](https://www.gp.com/), [**Colonial Pipeline**](https://www.colpipe.com/), [**Home Depot**](https://corporate.homedepot.com/) and [**United Parcel Services**](https://www.ups.com/us/en/home).
47
+
48
+ He is sometimes referred to as “the real Tank” from the movie [**The Matrix**](https://www.imdb.com/title/tt0133093/).
49
+
50
+ - **Tank9 TooLZ Book** [Amazon E-Book](https://a.co/d/2BDjSYb)
51
+ - [Tank9Code Blog](https://medium.com/@tank9code/about-brandon-poole-sr-ac2fe8e06a09)
52
+ - [Tank9Code Twitter](https://instagram.com/tank9code)
53
+ - [Tank9Code Instagram](https://instagram.com/tank9code)
54
+ - [Tank9Code Youtube](https://youtube.com/@tank9code)
55
+
56
+ #### TagZ:
57
+ ##### #BiZ9Framework
58
+ ##### #BoSSAppZ
59
+ ##### #Mobile
60
+ ##### #Apple
61
+ ##### #Android
62
+ ##### #ApplicationDevelopment
63
+ ##### #SoftwareFramework
64
+ ##### #Cloud
65
+ ##### #IOS
66
+ ##### #Linux
67
+ ##### #JavaScript
68
+ ##### #NoSQL
69
+ ##### #AppMoneyNoteZ
70
+ ##### #TaNK9Code
71
+ ##### Thank you for your time.
72
+ ##### Looking forward to working with you.
73
+ ### License
74
+ [MIT](https://choosealicense.com/licenses/mit/)
package/biz9_config ADDED
@@ -0,0 +1,4 @@
1
+ VERSION='1.0.10'
2
+ TITLE='BiZ9-Store'
3
+ REPO='git@github.com:biz9framework/biz9-store.git'
4
+ BRANCH='main'
package/index.js ADDED
@@ -0,0 +1,264 @@
1
+ /*
2
+ Copyright 2016 Certified CoderZ
3
+ Author: Brandon Poole Sr. (biz9framework@gmail.com)
4
+ License GNU General Public License v3.0
5
+ Description: BiZ9 Framework: Store
6
+ */
7
+ const {Scriptz}=require("biz9-scriptz");
8
+ const {Log,Str,Num,Obj}=require("biz9-utility");
9
+ const {Data_Logic,Data_Field} = require("/home/think1/www/doqbox/biz9-framework/biz9-data-logic/source");
10
+ class Store_Table {
11
+ //cart
12
+ static CART="cart_biz";
13
+ static CART_ITEM="cart_item_biz";
14
+ static CART_SUB_ITEM="cart_sub_item_biz";
15
+ //order
16
+ static ORDER_PAYMENT = 'order_payment_biz';
17
+ static ORDER="order_biz";
18
+ static ORDER_ITEM="order_item_biz";
19
+ static ORDER_SUB_ITEM="order_sub_item_biz";
20
+ static ORDER_PAYMENT="order_payment_biz";
21
+ //product
22
+ static PRODUCT = 'product_biz';
23
+ }
24
+ class Store_Field {
25
+ //cart
26
+ static CART_NUMBER = 'cart_number';
27
+ static CART_ID = 'cart_id';
28
+ static CART_ITEM_ID = 'cart_item_id';
29
+ //order
30
+ static ORDER_NUMBER = 'order_number';
31
+ static ORDER_ID = 'order_id';
32
+ static ORDER_ITEM_ID = 'order_item_id';
33
+ //other
34
+ static GRAND_TOTAL = 'grand_total';
35
+ }
36
+ class Store_Title {
37
+ //cart
38
+ static CART_ITEMS='Cart Items';
39
+ static CART_SUB_ITEMS='Cart Sub Items';
40
+ static CART_ITEMS='Cart Items';
41
+ static CART_SUB_ITEMS='Cart Sub Items';
42
+ //order
43
+ static ORDER_ITEMS='Order Items';
44
+ static ORDER_SUB_ITEMS='order Sub Items';
45
+ static ORDER_STATUS_NEW="New";
46
+ static ORDER_STATUS_OPEN="Open";
47
+ static ORDER_STATUS_COMPLETE="Complete";
48
+ static ORDER_STATUS_RETURNED="Returned";
49
+ static ORDER_STATUS_ON_HOLD="On Hold";
50
+ static ORDER_STATUS_CANCELLED="Cancelled";
51
+ }
52
+ class Store_Type {
53
+ //cart
54
+ static CART_SUB_TYPE_STANDARD = 'standard';
55
+ static CART_SUB_TYPE_SHIPPING = 'shipping';
56
+ static CART_SUB_TYPE_COUPON = 'coupon';
57
+ static CART_SUB_TYPE_GIFT_CARD = 'gift_card';
58
+ //order
59
+ static ORDER_STATUS_NEW="new";
60
+ static ORDER_STATUS_OPEN="open";
61
+ static ORDER_STATUS_COMPLETE="complete";
62
+ static ORDER_STATUS_RETURNED="returned";
63
+ static ORDER_STATUS_ON_HOLD="on_hold";
64
+ static ORDER_STATUS_CANCELLED="cancelled";
65
+ }
66
+ class Store_Logic {
67
+ //cart -- start
68
+ static get_cart = (user_id,option) => {
69
+ // - option - //
70
+ // - cart_code = 'CA'
71
+ option = !Obj.check_is_empty(option) ? option : {};
72
+ let cart_code = option.cart_code ? option.cart_code+"-" : "";
73
+ return Data_Logic.get(Store_Table.CART,0,{data:{user_id:user_id,cart_number:cart_code + Num.get_id(99999),grand_total:0,cart_items:[]}});
74
+ };
75
+ static get_cart_item = (parent_table,parent_id,quanity,cost) =>{
76
+ return Data_Logic.get(Store_Table.CART_ITEM,0,{data:{parent_table:parent_table,parent_id:parent_id,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_items:[]}});
77
+ };
78
+ static get_cart_sub_item = (cart_item_id,type,parent_table,parent_id,quanity,cost) =>{
79
+ return Data_Logic.get(Store_Table.CART_SUB_ITEM,0,{data:{type:type,cart_item_id:cart_item_id,quanity:quanity,cost:cost,parent_table:parent_table,parent_id:parent_id}});
80
+ };
81
+ static get_cart_sub_items = () =>{
82
+ return [
83
+ {title:Str.get_title(Title.CART_SUB_TYPE_STANDARD),label:Str.get_title(Title.CART_SUB_TYPE_STANDARD),type:Title.CART_SUB_TYPE_STANDARD},
84
+ {title:Str.get_title(Title.CART_SUB_TYPE_SHIPPING),label:Str.get_title(Title.CART_SUB_TYPE_SHIPPING),type:Title.CART_SUB_TYPE_SHIPPING},
85
+ {title:Str.get_title(Title.CART_SUB_TYPE_COUPON),label:Str.get_title(Title.CART_SUB_TYPE_COUPON),type:Title.CART_SUB_TYPE_COUPON},
86
+ {title:Str.get_title(Title.CART_SUB_TYPE_GIFT_CARD),label:Str.get_title(Title.CART_SUB_TYPE_GIFT_CARD),type:Title.CART_SUB_TYPE_GIFT_CARD}
87
+ ];
88
+ };
89
+ static get_cart_total = (cart) => {
90
+ let grand_total = 0;
91
+ cart.cart_items.forEach(cart_item => {
92
+ cart_item.sub_total = 0;
93
+ if(!isNaN(cart_item.cost)){
94
+ cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
95
+ grand_total = grand_total + cart_item.sub_total;
96
+ }
97
+ cart_item.cart_sub_items.forEach(cart_sub_item => {
98
+ cart_sub_item.sub_total = 0;
99
+ if(!isNaN(cart_sub_item.cost)){
100
+ cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
101
+ grand_total = grand_total + cart_sub_item.sub_total;
102
+ }
103
+ });
104
+ });
105
+ cart.grand_total = grand_total;
106
+ return cart;
107
+ };
108
+ //cart -- end
109
+ //order -- start
110
+ static get_order = (cart,option) => {
111
+ option = option?option:{};
112
+ let order_code = option.order_code ? option.order_code+"-" : "";
113
+ let order = Data_Logic.get(Store_Table.ORDER,0,{data:{
114
+ order_number:order_code + Num.get_id(99999),
115
+ user_id:cart.user_id,
116
+ cart_number:cart.cart_number,
117
+ grand_total:cart.grand_total,
118
+ status:Store_Type.ORDER_STATUS_NEW,
119
+ order_items:[]
120
+ }});
121
+ for(const key in cart) {
122
+ if(!Obj.check_is_array(cart[key]) && Obj.check_is_object(cart[key])
123
+ && key != Data_Field.ID && key != Data_Field.TABLE
124
+ && key != Data_Field.SOURCE && key != Data_Field.SOURCE_ID
125
+ && key != Data_Field.DATE_CREATE && key != Data_Field.DATE_SAVE)
126
+ {
127
+ order[key] = cart[key];
128
+ }
129
+ }
130
+ cart.cart_items.forEach(cart_item => {
131
+ let order_item = Data_Logic.get(Store_Table.ORDER_ITEM,0,{data:{
132
+ order_number:order.order_number,
133
+ parent_table:cart_item.parent_table,
134
+ parent_id:cart_item.parent_id,
135
+ user_id:order.user_id,
136
+ quanity:cart_item.quanity?cart_item.quanity:0,
137
+ cost:cart_item.cost?cart_item.cost:0,
138
+ order_sub_items:[]
139
+ }});
140
+ for(const key in cart_item){
141
+ if(!Obj.check_is_array(cart_item[key]) && Obj.check_is_object(cart_item[key])
142
+ && key != Data_Field.ID && key != Data_Field.TABLE
143
+ && key != Data_Field.SOURCE && key != Data_Field.SOURCE_ID
144
+ && key != Data_Field.DATE_CREATE && key != Data_Field.DATE_SAVE){
145
+ order_item[key] = cart_item[key]
146
+ }
147
+ }
148
+ cart_item.cart_sub_items.forEach(cart_sub_item => {
149
+ let order_sub_item = Data_Logic.get(Store_Table.ORDER_SUB_ITEM,0,{data:{
150
+ type:cart_sub_item.type,
151
+ cart_item_id:cart_sub_item.cart_item_id,
152
+ quanity:cart_sub_item.quanity,
153
+ cost:cart_sub_item.cost
154
+ }});
155
+ for(const key in cart_sub_item){
156
+ if(!Obj.check_is_array(order_sub_item[key]) && Obj.check_is_object(order_sub_item[key])
157
+ && key != Data_Field.ID && key != Data_Field.TABLE
158
+ && key != Data_Field.SOURCE && key != Data_Field.SOURCE_ID
159
+ && key != Data_Field.DATE_CREATE && key != Data_Field.DATE_SAVE){
160
+ order_sub_item[key] = cart_sub_item[key]
161
+ }
162
+ }
163
+ order_item.order_sub_items.push(order_sub_item);
164
+ });
165
+ order.order_items.push(order_item);
166
+ });
167
+ return order;
168
+ };
169
+ static get_order_statuses(){
170
+ return [
171
+ {value:Title.ORDER_STATUS_NEW,label:Title.ORDER_STATUS_NEW,title:Title.ORDER_STATUS_NEW},
172
+ {value:Title.ORDER_STATUS_OPEN,label:Title.ORDER_STATUS_OPEN,title:Title.ORDER_STATUS_OPEN},
173
+ {value:Title.ORDER_STATUS_COMPLETE,label:Title.ORDER_STATUS_COMPLETE,title:Title.ORDER_STATUS_COMPLETE},
174
+ {value:Title.ORDER_STATUS_RETURNED,label:Title.ORDER_STATUS_RETURNED,title:Title.ORDER_STATUS_RETURNED},
175
+ {value:Title.ORDER_STATUS_ON_HOLD,label:Title.ORDER_STATUS_ON_HOLD,title:Title.ORDER_STATUS_ON_HOLD},
176
+ {value:Title.ORDER_STATUS_CANCELLED,label:Title.ORDER_STATUS_CANCELLED,title:Title.ORDER_STATUS_CANCELLED},
177
+ ];
178
+ };
179
+ static get_order_total = (order) => {
180
+ let grand_total = 0;
181
+ order.order_items.forEach(order_item => {
182
+ order_item.sub_total = 0;
183
+ if(!isNaN(order_item.cost)){
184
+ order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
185
+ grand_total = grand_total + order_item.sub_total;
186
+ }
187
+ order_item.order_sub_items.forEach(order_sub_item => {
188
+ order_sub_item.sub_total = 0;
189
+ if(!isNaN(order_sub_item.cost)){
190
+ order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
191
+ grand_total = grand_total + order_sub_item.sub_total;
192
+ }
193
+ });
194
+ });
195
+ order.grand_total = grand_total;
196
+ return order;
197
+ };
198
+ static get_order_payment = (order_number,payment_method_type,payment_amount) => {
199
+ return Data_Logic.get(Store_Table.ORDER_PAYMENT,0,{data:
200
+ {
201
+ order_number:order_number,
202
+ payment_method_type:payment_method_type,
203
+ payment_amount:payment_amount,
204
+ transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
205
+ }});
206
+ };
207
+ //order -- end
208
+ //stock -- start
209
+ static get_stocks = () => {
210
+ const stocks=
211
+ [
212
+ { value: "0", label: "Out of Stock" },
213
+ { value: "1", label: "Only 1 Left" },
214
+ { value: "2", label: "Less Than 3 Left" },
215
+ { value: "3", label: "Availble" }
216
+ ];
217
+ return stocks;
218
+ };
219
+ static get_stock_by_value = (stock_val) => {
220
+ switch(stock_val)
221
+ {
222
+ case "0":
223
+ return 'Out of Stock';
224
+ break;
225
+ case "1":
226
+ return 'Only 1 Left';
227
+ break;
228
+ case "2":
229
+ return 'Less Than 3 Left';
230
+ break;
231
+ case "3":
232
+ return 'Availble';
233
+ break;
234
+ default:
235
+ return 'Availble';
236
+ break;
237
+ }
238
+ };
239
+ //stock -- end
240
+ //product -- start
241
+ static get_test_cost(){
242
+ return String(Num.get_id(999)) + "." + String(Num.get_id(99));
243
+ }
244
+ static get_test_product = (option) =>{
245
+ option = !Obj.check_is_empty(option) ? option : {title:'Product'};
246
+ let data = Data_Logic.get(Store_Table.PRODUCT,0,option);
247
+ data.cost = Store_Logic.get_test_cost();
248
+ data.old_cost = Store_Logic.get_test_cost();
249
+ data.category = "Category "+String(Num.get_id());
250
+ data.type = "Type "+String(Num.get_id());
251
+ data.sub_type = "Sub Type "+String(Num.get_id());
252
+ data.stock = String(Num.get_id(3-1));
253
+ data.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
254
+ return data;
255
+ };
256
+ //product -- end
257
+ }
258
+ module.exports = {
259
+ Store_Field,
260
+ Store_Title,
261
+ Store_Table,
262
+ Store_Type,
263
+ Store_Logic,
264
+ };
package/notez ADDED
@@ -0,0 +1,262 @@
1
+ -------------------------------- BiZ9 START - 2-9-2026 -----------------------------------------------------------
2
+ -- Blank
3
+ -------------------------------- BiZ9 END - 2-9-2026 -------------------------------------------------------------
4
+
5
+ -------------------------------- BiZ9 START - 2-20-2026 -----------------------------------------------------------
6
+ -- User Bk
7
+
8
+ -------------------------------- BiZ9 END - 2-20-2026 -------------------------------------------------------------
9
+
10
+
11
+
12
+ -------------------------------- BiZ9 START - 2-17-2026 -----------------------------------------------------------
13
+ -- Bk
14
+ class Order_Data {
15
+ //9_order_post
16
+ // -- ORDER-POST-START -- //
17
+ // - Order_Logic.get(cart);
18
+ // -- ORDER-POST-END -- //
19
+
20
+ static post = async (database,order,order_payments,option) => {
21
+ return new Promise((callback) => {
22
+ let error = null;
23
+ let cache = null;
24
+ let data = {};
25
+ option = !Obj.check_is_empty(option) ? option : {};
26
+ data.order = Data_Logic.get(Type.DATA_ORDER,0,{data:{order_number:order.order_number,cart_number:order.cart_number,user_id:order.user_id,grand_total:order.grand_total}});
27
+ data.order_items = [];
28
+ data.order_sub_items = [];
29
+ async.series([
30
+ async function(call) {
31
+ const [biz_error,biz_data] = await Cache.get(database.data_config);
32
+ cache = biz_data;
33
+ },
34
+ //post - order
35
+ function(call){
36
+ for(const key in order) {
37
+ if(!Obj.check_is_array(order[key]) && Obj.check_is_object(order[key])
38
+ && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
39
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
40
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE)
41
+ {
42
+ data.order[key] = order[key];
43
+ }
44
+ }
45
+ data.order[Type.FIELD_GRAND_TOTAL] = Order_Logic.get_total(order).grand_total;
46
+ Adapter.post_item(database,cache,Type.DATA_ORDER,data.order).then(([biz_error,biz_data])=>{
47
+ if(biz_error){
48
+ error=Log.append(error,biz_error);
49
+ }else{
50
+ data.order = biz_data;
51
+ call();
52
+ }
53
+ }).catch(err => {
54
+ Log.error('Data-Order-Post',err);
55
+ error=Log.append(error,err);
56
+ });
57
+ },
58
+ //post - order items
59
+ function(call){
60
+ if(order.order_items.length>0){
61
+ for(const order_item of order.order_items){
62
+ let post_order_item = Data_Logic.get(Type.DATA_ORDER_ITEM,0);
63
+ for(const key in order_item){
64
+ order_item.temp_row_id = Num.get_id();
65
+ if(!Obj.check_is_array(order_item[key]) && Obj.check_is_object(order_item[key])
66
+ && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
67
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
68
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
69
+ post_order_item[key] = order_item[key];
70
+ }
71
+ }
72
+ post_order_item[Type.FIELD_ORDER_ID] = data.order.id;
73
+ post_order_item[Type.FIELD_ORDER_NUMBER] = data.order.order_number;
74
+ post_order_item.temp_row_id = order_item.temp_row_id;
75
+ data.order_items.push(post_order_item);
76
+ }
77
+ Adapter.post_item_list(database,cache,data.order_items).then(([biz_error,biz_data])=>{
78
+ if(biz_error){
79
+ error=Log.append(error,biz_error);
80
+ }else{
81
+ data.order_items = biz_data;
82
+ call();
83
+ }
84
+ }).catch(err => {
85
+ Log.error('Data-Order-Post',err);
86
+ error=Log.append(error,err);
87
+ });
88
+ }
89
+ },
90
+ //post - order sub items
91
+ async function(call){
92
+ if(order.order_items.length>0){
93
+ for(const order_item of order.order_items){
94
+ for(const order_sub_item of order_item.order_sub_items){
95
+ let post_order_sub_item = Data_Logic.get(Type.DATA_ORDER_SUB_ITEM,0);
96
+ for(const key in order_sub_item){
97
+ order_sub_item.temp_row_id = Num.get_id();
98
+ if(!Obj.check_is_array(order_item[key]) && Obj.check_is_object(order_item[key])
99
+ && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
100
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
101
+ && key != Type.FIELD_DATE_CREATE && key != Type.FILED_DATE_SAVE){
102
+ post_order_sub_item[key] = order_sub_item[key];
103
+ }
104
+ }
105
+ post_order_sub_item[Type.FIELD_ORDER_ITEM_ID] =data.order_items.find(item_find => item_find.temp_row_id === order_item.temp_row_id).id;
106
+ post_order_sub_item[Type.FIELD_ORDER_ID] = data.order.id;
107
+ post_order_sub_item[Type.FIELD_ORDER_NUMBER] = data.order.order_number;
108
+ data.order_sub_items.push(post_order_sub_item);
109
+ }
110
+ }
111
+ const [biz_error,biz_data] = await Adapter.post_item_list(database,cache,data.order_sub_items);
112
+ if(biz_error){
113
+ error=Log.append(error,biz_error);
114
+ }else{
115
+ data.order_sub_items = biz_data;
116
+ }
117
+ }
118
+ },
119
+ //post - order_payments
120
+ async function(call){
121
+ if(order_payments.length>0){
122
+ const [biz_error,biz_data] = await Adapter.post_item_list(database,cache,order_payments);
123
+ if(biz_error){
124
+ error=Log.append(error,biz_error);
125
+ }else{
126
+ data.order_payments = biz_data;
127
+ }
128
+ }
129
+ },
130
+ //get - order
131
+ async function(call){
132
+ const [biz_error,biz_data] = await Order_Data.get(database,data.order.order_number,option);
133
+ if(biz_error){
134
+ error=Log.append(error,biz_error);
135
+ }else{
136
+ data.order = biz_data;
137
+ }
138
+ },
139
+ ]).then(result => {
140
+ callback([error,data.order]);
141
+ }).catch(err => {
142
+ Log.error("OrderData-Order-Item-Update",err);
143
+ callback([error,[]]);
144
+ });
145
+ });
146
+ };
147
+ //9_order_get
148
+ static get = (database,order_number) => {
149
+ return new Promise((callback) => {
150
+ let error = null;
151
+ let cache = null;
152
+ let data = {order:Data_Logic.get(Type.DATA_ORDER,0,{data:{order_number:order_number,order_items:[],user:Data_Logic.get(Type.DATA_USER,0)}})};
153
+ let order_parent_item_query = { $or: [] };
154
+ let order_sub_item_query = { $or: [] };
155
+ let order_sub_items = [];
156
+ async.series([
157
+ async function(call) {
158
+ const [biz_error,biz_data] = await Cache.get(database.data_config);
159
+ cache = biz_data;
160
+ },
161
+ //get_order
162
+ async function(call){
163
+ let foreign_order_item = Data_Logic.get_search_foreign(Type.SEARCH_ITEMS,Type.DATA_ORDER_ITEM,Type.FIELD_ORDER_ID,Type.FIELD_ID);
164
+ let foreign_user = Data_Logic.get_search_foreign(Type.SEARCH_ONE,Type.DATA_USER,Type.FIELD_ID,Type.FIELD_USER_ID,{title:'user'});
165
+ let order_option = { id_field:Type.FIELD_ORDER_NUMBER,foreigns:[foreign_order_item,foreign_user] };
166
+ const [biz_error,biz_data] = await Data.get(database,Type.DATA_ORDER,order_number,order_option);
167
+ if(biz_error){
168
+ error=Log.append(error,biz_error);
169
+ }else{
170
+ data.order = biz_data;
171
+ }
172
+ },
173
+ //9_foreigns //9_get_foreigns get_order_foreigns
174
+ function(call){
175
+ let foreign_order_sub_item = Data_Logic.get_search_foreign(Type.SEARCH_ITEMS,Type.DATA_ORDER_SUB_ITEM,Type.FIELD_ORDER_ITEM_ID,Type.FIELD_ID);
176
+ let option_order_sub_item = { foreigns:[foreign_order_sub_item] };
177
+ Foreign.get_data(database,cache,data.order.order_items,option_order_sub_item).then(([biz_error,biz_data])=>{
178
+ if(biz_error){
179
+ error=Log.append(error,biz_error);
180
+ }else{
181
+ data.order.order_items = biz_data;
182
+ call();
183
+ }
184
+ }).catch(err => {
185
+ Log.error('Data-Search-Simple-Foreign',err);
186
+ error=Log.append(error,err);
187
+ });
188
+ },
189
+ async function(call){
190
+ data.order = Order_Logic.get_total(data.order);
191
+ },
192
+ ]).then(result => {
193
+ callback([error,data.order]);
194
+ }).catch(err => {
195
+ Log.error("Order-Get",err);
196
+ callback([error,[]]);
197
+ });
198
+ });
199
+ };
200
+ //9_order_delete
201
+ static delete = async (database,id) => {
202
+ return new Promise((callback) => {
203
+ let data = {};
204
+ let error = null;
205
+ data.order = Data_Logic.get(Type.DATA_ORDER,id);
206
+ async.series([
207
+ //get_order
208
+ async function(call){
209
+ const [biz_error,biz_data] = await Data.get(database,Type.DATA_ORDER,id);
210
+ if(biz_error){
211
+ error=Log.append(error,biz_error);
212
+ }else{
213
+ data.order = biz_data;
214
+ }
215
+ },
216
+ async function(call){
217
+ const [biz_error,biz_data] = await Data.delete(database,Type.DATA_ORDER,id);
218
+ if(biz_error){
219
+ error=Log.append(error,biz_error);
220
+ }else{
221
+ data.order_delete = biz_data.item;
222
+ }
223
+ },
224
+ async function(call){
225
+ let search = Data_Logic.get_search(Type.DATA_ORDER_ITEM,{order_number:data.order.order_number},{},1,0);
226
+ const [biz_error,biz_data] = await Data.delete_search(database,search.data_type,search.filter);
227
+ if(biz_error){
228
+ error=Log.append(error,biz_error);
229
+ }else{
230
+ data.delete_order_item_search = biz_data;
231
+ }
232
+ },
233
+ async function(call){
234
+ let search = Data_Logic.get_search(Type.DATA_ORDER_SUB_ITEM,{order_number:data.order.order_number},{},1,0);
235
+ const [biz_error,biz_data] = await Data.delete_search(database,search.data_type,search.filter);
236
+ if(biz_error){
237
+ error=Log.append(error,biz_error);
238
+ }else{
239
+ data.delete_order_sub_item_search = biz_data;
240
+ }
241
+ },
242
+ async function(call){
243
+ let search = Data_Logic.get_search(Type.DATA_ORDER_PAYMENT,{order_number:data.order.order_number},{},1,0);
244
+ const [biz_error,biz_data] = await Data.delete_search(database,search.data_type,search.filter);
245
+ if(biz_error){
246
+ error=Log.append(error,biz_error);
247
+ }else{
248
+ data.delete_order_payment_search = biz_data;
249
+ }
250
+ },
251
+ ]).then(result => {
252
+ callback([error,data]);
253
+ }).catch(err => {
254
+ Log.error("OrderData-Order-Delete",err);
255
+ callback([error,[]]);
256
+ });
257
+ });
258
+ };
259
+ }
260
+
261
+ -------------------------------- BiZ9 END - 2-17-2026 -------------------------------------------------------------
262
+
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "biz9-store",
3
+ "version": "1.0.10",
4
+ "description": "** Description",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "Brandon Poole Sr (BiZ9 Framework LLC)",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "async": "^3.2.6",
13
+ "biz9-scriptz": "^5.8.25",
14
+ "biz9-utility": "^4.7.13"
15
+ },
16
+ "devDependencies": {},
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/biz9framework/biz9-store.git"
20
+ },
21
+ "keywords": [
22
+ "JavaScript",
23
+ "Async",
24
+ "DateTime",
25
+ "Form",
26
+ "Log",
27
+ "String",
28
+ "Object",
29
+ "Const",
30
+ "Await"
31
+ ],
32
+ "bugs": {
33
+ "url": "https://github.com/biz9framework/biz9-store/issues"
34
+ },
35
+ "homepage": "https://github.com/biz9framework/biz9-store#readme"
36
+ }
package/test.js ADDED
@@ -0,0 +1,64 @@
1
+ /*
2
+ Copyright 2016 Certified CoderZ
3
+ Author: Brandon Poole Sr. (biz9framework@gmail.com)
4
+ License GNU General Public License v3.0
5
+ Description: BiZ9 Framework: Store - Test
6
+ */
7
+ const async = require('async');
8
+ const assert = require('node:assert');
9
+ const {Log} = require("biz9-utility");
10
+ const {Data_Logic} = require("/home/think1/www/doqbox/biz9-framework/biz9-data-logic/source");
11
+ const {User_Logic} = require("/home/think1/www/doqbox/biz9-framework/biz9-user/source");
12
+ const {Store_Logic,Store_Type} = require("./index");
13
+
14
+ /*
15
+ * availble tests
16
+ - connect
17
+ */
18
+ /* --- TEST CONFIG START --- */
19
+ const APP_ID = 'test-stage-feb17';
20
+ /* --- TEST CONFIG END --- */
21
+
22
+ /* --- DATA CONFIG END --- */
23
+ //9_connect - 9_test_connect
24
+ describe('connect', function(){ this.timeout(25000);
25
+ it("_connect", function(done){
26
+ let error=null;
27
+ let database = {};
28
+ let data = {};
29
+ async.series([
30
+ async function(call){
31
+ //-->
32
+ let print_test = true;
33
+ //-- CART -- START
34
+ let user = User_Logic.get_test_user({generate_id:true});
35
+ let cart = Store_Logic.get_cart(user.id,{cart_code:'CA'});
36
+ let product_1 = Store_Logic.get_test_product({generate_id:true});
37
+ let cart_item_1 = Store_Logic.get_cart_item(product_1.table,product_1.id,1,Store_Logic.get_test_cost());
38
+ let product_sub_1 = Store_Logic.get_test_product({generate_id:true});
39
+ let cart_sub_item_1 = Store_Logic.get_cart_sub_item(cart_item_1.id,Store_Type.CART_SUB_TYPE_STANDARD,product_1.table,product_1.id,1,Store_Logic.get_test_cost());
40
+ cart_item_1.cart_sub_items.push(cart_sub_item_1);
41
+ cart.cart_items.push(cart_item_1);
42
+ //Log.w('22_cart',cart);
43
+ //-- CART -- END
44
+
45
+ //-- CART -- START
46
+ //
47
+ //-- ORDER -- START
48
+ let order = Store_Logic.get_order(cart);
49
+ Log.w('33_order',order);
50
+ //-- ORDER -- END
51
+
52
+
53
+ if(print_test){;
54
+ //Log.w('99_biz_data',biz_data);
55
+ }
56
+ },
57
+ ],
58
+ function(error, result){
59
+ console.log('CONNECT-DONE');
60
+ done();
61
+ });
62
+ });
63
+ });
64
+
package/test_run ADDED
@@ -0,0 +1,4 @@
1
+ echo 'BiZ9-Store Test'
2
+ run_test=$1
3
+ echo $run_test
4
+ mocha -g $run_test test.js