Prechádzať zdrojové kódy

1.修改NPD,增加Create Back Order检查。

Pen Li 9 rokov pred
rodič
commit
bcec676c98

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 28
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,32 +2,4 @@
 <Bucket
    type = "0"
    version = "2.0">
-   <Breakpoints>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "iSales-NPD/AppDelegate.m"
-            timestampString = "513142121.064533"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "511"
-            endingLineNumber = "511"
-            landmarkName = "UncaughtExceptionHandler()"
-            landmarkType = "9">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            scope = "0"
-            stopOnStyle = "0">
-         </BreakpointContent>
-      </BreakpointProxy>
-   </Breakpoints>
 </Bucket>

+ 3 - 3
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -377,7 +377,7 @@
                     
                     
                     
-                    if(c<count)
+                    if(!appDelegate.can_create_backorder && c<count)
                     {
                         
                         UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Item is OUT OF STOCK and not available to order from NPD.\nAdd to cart anyway?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
@@ -524,8 +524,8 @@
     
     
 
-    
-    if(/*c<count*/c == 0)
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if(/*c<count*/!appDelegate.can_create_backorder && c == 0)
     {
         
         NSString *msg = nil;

+ 9 - 3
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -1035,7 +1035,9 @@ self.isrefreshing=false;
                         
                         if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) {
                             
-                            cell.btnaddCart.enabled = NO;
+                            if (!appDelegate.can_create_backorder) {
+                                cell.btnaddCart.enabled = NO;
+                            }
                             cell.btnNotifyMe.enabled = YES;
                             
                         } else {
@@ -1061,7 +1063,9 @@ self.isrefreshing=false;
                         } else {
                             // Purchase Order
                             if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) { // 缺货
-                                cell.btnaddCart.enabled = NO;
+                                if (!appDelegate.can_create_backorder) {
+                                    cell.btnaddCart.enabled = NO;
+                                }
                                 cell.btnNotifyMe.enabled = YES;
                             } else { // 未缺货
                                 cell.btnNotifyMe.enabled = NO;
@@ -1083,7 +1087,9 @@ self.isrefreshing=false;
                 cell.btnNotifyMe.hidden = NO;
                 
                 if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) { // 缺货
-                    cell.btnaddCart.enabled = NO;
+                    if (!appDelegate.can_create_backorder) {
+                        cell.btnaddCart.enabled = NO;
+                    }
                     cell.btnNotifyMe.enabled = YES;
                 } else { // 未缺货
                     cell.btnNotifyMe.enabled = NO;

+ 101 - 73
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -3834,7 +3834,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         count = [params[@"count"] intValue];
     }
     
-    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     NSString* product_id=params[@"product_id"];
     NSString* orderCode=params[@"orderCode"];
     NSString *qty = params[@"qty"];
@@ -3855,20 +3855,22 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             item_qty=[self model_stockUom:[arr_id[i] intValue] db:db];
         
         // 检查新加Model数量是否大于库存
-        __block BOOL needContinue = NO;
-        [iSalesDB jk_query:[NSString stringWithFormat:@"select availability from product where product_id = %@;",arr_id[i]] db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
-           
-            int availability = sqlite3_column_int(stmt, 0);
-            // 库存小于购买量为缺货
-            if (availability < item_qty || availability <= 0) {
-                number_of_outOfStock++;
-                needContinue = YES;
-            }
+        if (!appDelegate.can_create_backorder) {
+            __block BOOL needContinue = NO;
+            [iSalesDB jk_query:[NSString stringWithFormat:@"select availability from product where product_id = %@;",arr_id[i]] db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+                
+                int availability = sqlite3_column_int(stmt, 0);
+                // 库存小于购买量为缺货
+                if (availability < item_qty || availability <= 0) {
+                    number_of_outOfStock++;
+                    needContinue = YES;
+                }
+                
+            }];
             
-        }];
-        
-        if (needContinue) {
-            continue;
+            if (needContinue) {
+                continue;
+            }
         }
         
         int _id=[iSalesDB get_recordid:db table:@"offline_cart" where:[NSString stringWithFormat:@"so_no='%@' and product_id=%@",orderCode,arr_id[i]]];
@@ -3906,17 +3908,19 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                 
                 sql = [NSString stringWithFormat:@"select c.item_count + %ld,p.availability from product as p left join offline_cart as c on c.item_id = p.item_id where c._id = %d;",item_qty,_id];
                 __block BOOL update = YES;
-                [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
-                    
-                    int newQTY = sqlite3_column_int(stmt, 0);
-                    int availability = sqlite3_column_int(stmt, 1);
-                    
-                    if (newQTY > availability) { // 库存不够
-                        update = NO;
-                        number_of_outOfStock++;
-                    }
-
-                }];
+                if (!appDelegate.can_create_backorder) {
+                    [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+                        
+                        int newQTY = sqlite3_column_int(stmt, 0);
+                        int availability = sqlite3_column_int(stmt, 1);
+                        
+                        if (newQTY > availability) { // 库存不够
+                            update = NO;
+                            number_of_outOfStock++;
+                        }
+                        
+                    }];
+                }
                 
                 if (update) {
                     
@@ -3957,10 +3961,12 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     ret[@"wish_count"]=[NSNumber numberWithInt:wish_count ];
     ret[@"cart_count"]=[NSNumber numberWithInt:cart_count ];
     ret[@"result"]=[NSNumber numberWithInt:RESULT_TRUE ];
-    if (number_of_outOfStock > 0) {
-        ret[@"result"]=[NSNumber numberWithInt:8];
-        ret[@"err_msg"] = @"Out of Stock.\nNo more quantity available.\nPlease try again after sync.";
-        /*[NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock]*/
+    if (!appDelegate.can_create_backorder) {
+        if (number_of_outOfStock > 0) {
+            ret[@"result"]=[NSNumber numberWithInt:8];
+            ret[@"err_msg"] = @"Out of Stock.\nNo more quantity available.\nPlease try again after sync.";
+            /*[NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock]*/
+        }
     }
     
     [iSalesDB execSql:@"END TRANSACTION" db:db];
@@ -4496,6 +4502,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             [header setValue:[NSNumber numberWithBool:can_submit_order]   forKey:@"can_submit_order"];
             [header setValue:[NSNumber numberWithBool:can_set_tearsheet_price]   forKey:@"can_set_tearsheet_price"];
             [header setValue:[NSNumber numberWithBool:can_create_order]   forKey:@"can_create_order"];
+            [header setObject:@(YES) forKey:@"can_create_backorder"];
             
             [header setValue:[NSNumber numberWithBool:can_update_contact_info]   forKey:@"can_update_contact_info"];
             
@@ -9000,25 +9007,29 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
     NSString *_id = [self valueInParams:params key:@"cartitem_id"];
-    int item_count = [params[@"inputInt"] integerValue];
+    int item_count = [params[@"inputInt"] intValue];
     
     // 购买检查数量大于库存
-    NSString *checkSql = [NSString stringWithFormat:@"select p.availability from product as p left join offline_cart as c on c.item_id = p.item_id where c._id = %@;",_id];
-    __block BOOL out_of_stock = NO;
-    [iSalesDB jk_query:checkSql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
-        
-        int availability = sqlite3_column_int(stmt, 0);
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if (!appDelegate.can_create_backorder) {
+        NSString *checkSql = [NSString stringWithFormat:@"select p.availability from product as p left join offline_cart as c on c.item_id = p.item_id where c._id = %@;",_id];
+        __block BOOL out_of_stock = NO;
+        [iSalesDB jk_query:checkSql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+            
+            int availability = sqlite3_column_int(stmt, 0);
+            
+            if (availability < item_count) {
+                out_of_stock = YES;
+            }
+            
+        }];
         
-        if (availability < item_count) {
-            out_of_stock = YES;
+        if (out_of_stock) { // 缺货
+            [dic setValue:[NSNumber numberWithInteger:8] forKey:@"result"];
+            [dic setObject:@"Item is out of stock" forKey:@"err_msg"];
+            return [RAUtils dict2data:dic];
         }
-        
-    }];
-    
-    if (out_of_stock) { // 缺货
-        [dic setValue:[NSNumber numberWithInteger:8] forKey:@"result"];
-        [dic setObject:@"Item is out of stock" forKey:@"err_msg"];
-        return [RAUtils dict2data:dic];
+
     }
     
     NSString *sql = [NSString stringWithFormat:@"update offline_cart set item_count = %d where _id = %@;",item_count,_id];
@@ -10769,18 +10780,21 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     orderCode = [self translateSingleQuote:orderCode];
     
     // 缺货检查
-    BOOL out_of_stock = [self orderOutOfStock:params db:db];
-    if (out_of_stock) {
-        [iSalesDB close_db:db];
-        
-        NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
-        
-        [resultDic setObject:@"some item(s) are out of stock,please remove them from cart before placing order with NPD or try again after sync" forKey:@"err_msg"];
-        [resultDic setObject:[NSNumber numberWithInt:8] forKey:@"result"];
-        
-        return [RAUtils dict2data:resultDic];
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if (!appDelegate.can_create_backorder) {
+        BOOL out_of_stock = [self orderOutOfStock:params db:db];
+        if (out_of_stock) {
+            [iSalesDB close_db:db];
+            
+            NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
+            
+            [resultDic setObject:@"some item(s) are out of stock,please remove them from cart before placing order with NPD or try again after sync" forKey:@"err_msg"];
+            [resultDic setObject:[NSNumber numberWithInt:8] forKey:@"result"];
+            
+            return [RAUtils dict2data:resultDic];
+        }
+
     }
-    
     // UISetting
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
     NSString *cachefolder = [paths objectAtIndex:0];
@@ -11711,7 +11725,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
 
 + (NSData*)offline_movewish2cart:(NSMutableDictionary *)params {
     // cart中存在的Model在wish list move to cart之后,cart中Model数量为1
-    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     NSString *collectId = params[@"collectId"];
     NSString *sql = [NSString stringWithFormat:@"select w.product_id,w.qty,p.availability,w._id from wishlist as w left join product as p on w.product_id = p.product_id  where w._id in (%@);",collectId];
     
@@ -11729,28 +11743,39 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         
         int _id = sqlite3_column_int(stmt, 3);
         
-        // 库存小于购买量为缺货
-        if (availability >= item_qty) {
+        if (!appDelegate.can_create_backorder) {
+            // 库存小于购买量为缺货
+            if (availability >= item_qty) {
+                product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%d",productId]];
+                
+                qty = [qty stringByAppendingString:[NSString stringWithFormat:@",%d",item_qty]];
+                
+                [delete_collectId addObject:[NSString stringWithFormat:@"%d",_id]];
+                
+            } else {
+                number_of_outOfStock++;
+            }
+        } else {
+            
             product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%d",productId]];
             
             qty = [qty stringByAppendingString:[NSString stringWithFormat:@",%d",item_qty]];
             
             [delete_collectId addObject:[NSString stringWithFormat:@"%d",_id]];
-            
-        } else {
-            number_of_outOfStock++;
         }
 
     }];
     
     NSMutableDictionary *retDic = nil;
-    if (delete_collectId.count == 0) {
-        retDic = [NSMutableDictionary dictionary];
-        retDic[@"result"] = [NSNumber numberWithInteger:8];
-        retDic[@"err_msg"] = [NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock];
-        return [RAUtils dict2data:retDic];
+    if (!appDelegate.can_create_backorder) {
+        if (delete_collectId.count == 0) {
+            retDic = [NSMutableDictionary dictionary];
+            retDic[@"result"] = [NSNumber numberWithInteger:8];
+            retDic[@"err_msg"] = [NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock];
+            return [RAUtils dict2data:retDic];
+        }
+
     }
-    
     if (product_id.length > 1) {
         product_id = [product_id substringFromIndex:1];
     }
@@ -11775,11 +11800,14 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         
     }
     
-    if (number_of_outOfStock > 0) {
-        retDic[@"result"] = [NSNumber numberWithInteger:8];
-        retDic[@"err_msg"] = [NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock];
+    if (!appDelegate.can_create_backorder) {
+        if (number_of_outOfStock > 0) {
+            retDic[@"result"] = [NSNumber numberWithInteger:8];
+            retDic[@"err_msg"] = [NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock];
+        }
     }
     
+    
     return [RAUtils dict2data:retDic];
     
 }
@@ -11788,9 +11816,9 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
 
 + (NSData *)offline_portfolioList:(NSMutableDictionary *)params {
     
-    int sort = [[params valueForKey:@"sort"] integerValue];
-    int offset = [[params valueForKey:@"offset"] integerValue];
-    int limit = [[params valueForKey:@"limit"] integerValue];
+    int sort = [[params valueForKey:@"sort"] intValue];
+    int offset = [[params valueForKey:@"offset"] intValue];
+    int limit = [[params valueForKey:@"limit"] intValue];
     
     NSString *orderBy = @"";
     switch (sort) {

+ 1 - 1
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -3902,7 +3902,7 @@ repeat:
         
         appDelegate.alert_sold_in_quantities = [[objheader valueForKey:@"alert_sold_in_quantities"] boolValue];
         
-        
+        appDelegate.can_create_backorder = [[objheader valueForKey:@"can_create_backorder"] boolValue];
         
         appDelegate.ipad_perm =[objheader valueForKey:@"ipad_perm"] ;
         

+ 2 - 0
RedAnt ERP Mobile/iSales-NPD/AppDelegate.h

@@ -136,4 +136,6 @@
 
 @property (nonatomic,strong) NSMutableDictionary *urgencyDic;///<程序闪退需要保存的数据
 
+@property (nonatomic,assign) BOOL can_create_backorder;
+
 @end