biz9-logic 4.9.18 → 4.9.21

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.
Files changed (4) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +14 -9
  3. package/package.json +1 -1
  4. package/test.js +13 -12
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='8.8.8'
1
+ VERSION='8.9.1'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -450,7 +450,8 @@ class Page_Logic {
450
450
  };
451
451
  }
452
452
  class Order_Logic {
453
- static get_new = (cart) => {
453
+ static get_new = (cart,option) => {
454
+ option = option?option:{get_payment_plan:false,payment_plan:Title.ORDER_PAYMENT_PLAN_1,payment_plan_status:Title.ORDER_PAYMENT_STATUS_OPEN};
454
455
  let order = DataItem.get_new(DataType.ORDER,0,{
455
456
  order_number:Title.ORDER_NUMBER + Num.get_id(99999),
456
457
  parent_data_type:cart.parent_data_type,
@@ -459,14 +460,18 @@ class Order_Logic {
459
460
  grand_total:0,
460
461
  order_item_list:[]
461
462
  });
463
+ if(option.get_payment_plan){
464
+ order.payment_plan = option.payment_plan;
465
+ order.payment_status = option.payment_plan_status;
466
+ }
462
467
  cart.cart_item_list.forEach(cart_item => {
463
468
  let order_item = DataItem.get_new(DataType.ORDER_ITEM,0,{
464
469
  order_number:order.order_number,
465
470
  parent_data_type:cart_item.parent_data_type,
466
471
  parent_id:cart_item.parent_id,
467
472
  user_id:order.user_id,
468
- quanity:cart_item.quanity,
469
- cost:cart_item.cost,
473
+ quanity:cart_item.quanity?cart_item.quanity:0,
474
+ cost:cart_item.cost?cart_item.cost:0,
470
475
  order_sub_item_list:[]
471
476
  });
472
477
  cart_item.cart_sub_item_list.forEach(cart_sub_item => {
@@ -475,8 +480,8 @@ class Order_Logic {
475
480
  parent_data_type:cart_sub_item.parent_data_type,
476
481
  parent_id:cart_sub_item.parent_id,
477
482
  user_id:order.user_id,
478
- quanity:cart_sub_item.quanity,
479
- cost:cart_sub_item.cost
483
+ quanity:cart_sub_item.quanity?cart_sub_item.quanity:0,
484
+ cost:cart_sub_item.cost?cart_sub_item.cost:0
480
485
  })
481
486
  order_item.order_sub_item_list.push(order_sub_item);
482
487
  });
@@ -494,7 +499,7 @@ class Order_Logic {
494
499
  transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
495
500
  });
496
501
  };
497
- static get_total = (order) => {
502
+ static get_total = (order) => {
498
503
  let grand_total = 0;
499
504
  order.order_item_list.forEach(order_item => {
500
505
  order_item.sub_total = 0;
@@ -510,7 +515,7 @@ class Order_Logic {
510
515
  }
511
516
  });
512
517
  });
513
- order.grand_total = grand_total;
518
+ order.grand_total = grand_total;
514
519
  return order;
515
520
  };
516
521
  }
@@ -519,10 +524,10 @@ class Cart_Logic {
519
524
  return DataItem.get_new(DataType.CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_item_list:[]});
520
525
  };
521
526
  static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
522
- return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity,cost:cost?cost:0,cart_sub_item_list:[]});
527
+ return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_item_list:[]});
523
528
  };
524
529
  static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
525
- return DataItem.get_new(DataType.CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity,cost:cost?cost:0});
530
+ return DataItem.get_new(DataType.CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0});
526
531
  };
527
532
  static get_total = (cart) => {
528
533
  let grand_total = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.9.18",
3
+ "version": "4.9.21",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const series = require('async-series');
2
- const {DataItem,DataType,Page_Logic,Product_Logic,Type,Stat_Logic,Service_Logic,Blog_Post_Logic,Event_Logic,Demo_Logic,Cart_Logic} = require('./index');
2
+ const {DataItem,DataType,Page_Logic,Product_Logic,Type,Title,Stat_Logic,Service_Logic,Blog_Post_Logic,Event_Logic,Demo_Logic,Cart_Logic,Order_Logic} = require('./index');
3
3
  const {Log,Num,Str} = require('biz9-utility');
4
4
  const {Scriptz}= require('biz9-scriptz');
5
5
 
@@ -32,18 +32,19 @@ describe("connect", () => {
32
32
  function(call) {
33
33
  console.log('CONNECT-START');
34
34
 
35
+ //let post_cart = Cart_Logic.get_new(DataType.PRODUCT,0,);
35
36
  let post_cart = Cart_Logic.get_new(DataType.PRODUCT,0);
36
- let post_cart_list = [];
37
- let post_cart_item = Cart_Logic.get_new_cart_item(DataType.PRODUCT,123,post_cart.cart_number,1,30);
38
- let post_cart_sub_item = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,10);
39
- let post_cart_sub_item_2 = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,30);
40
- post_cart_item.cart_sub_item_list.push(post_cart_sub_item);
41
- post_cart_item.cart_sub_item_list.push(post_cart_sub_item_2);
42
- post_cart.cart_item_list.push(post_cart_item);
43
-
44
- Log.w('post_cart',post_cart);
45
- Log.w('post_cart_2',Cart_Logic.get_total(post_cart));
46
-
37
+ //let post_cart_list = [];
38
+ //let post_cart_item = Cart_Logic.get_new_cart_item(DataType.PRODUCT,123,post_cart.cart_number,1,30);
39
+ //let post_cart_sub_item = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,10);
40
+ //let post_cart_sub_item_2 = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,30);
41
+ //post_cart_item.cart_sub_item_list.push(post_cart_sub_item);
42
+ //post_cart_item.cart_sub_item_list.push(post_cart_sub_item_2);
43
+ //post_cart.cart_item_list.push(post_cart_item);
44
+
45
+ //Log.w('post_cart',post_cart);
46
+ Log.w('post_order',Order_Logic.get_new(post_cart,{get_payment_plan:true,payment_plan:Title.ORDER_PAYMENT_PLAN_1,payment_plan_status:Title.ORDER_PAYMENT_STATUS_OPEN}));
47
+ //Log.w('post_cart_2',Cart_Logic.get_total(post_cart));
47
48
 
48
49
  console.log('CONNECT-END');
49
50
  //call();