|
@@ -4887,8 +4887,12 @@
|
|
|
// Shipping
|
|
// Shipping
|
|
|
ret[@"Shipping"] = shipping;
|
|
ret[@"Shipping"] = shipping;
|
|
|
|
|
|
|
|
|
|
+ int have_lift_gate = sqlite3_column_int(statement, 17);
|
|
|
lift_gate = sqlite3_column_double(statement, 13);
|
|
lift_gate = sqlite3_column_double(statement, 13);
|
|
|
// Liftgate Fee(No loading dock)
|
|
// Liftgate Fee(No loading dock)
|
|
|
|
|
+ if (!have_lift_gate) {
|
|
|
|
|
+ lift_gate = 0;
|
|
|
|
|
+ }
|
|
|
ret[@"Liftgate Fee(No loading dock)"] = [NSString stringWithFormat:@"$%.2f",lift_gate];
|
|
ret[@"Liftgate Fee(No loading dock)"] = [NSString stringWithFormat:@"$%.2f",lift_gate];
|
|
|
|
|
|
|
|
char *general_notes = (char*)sqlite3_column_text(statement, 14);
|
|
char *general_notes = (char*)sqlite3_column_text(statement, 14);
|
|
@@ -4906,7 +4910,7 @@
|
|
|
payment_type= "";
|
|
payment_type= "";
|
|
|
NSString *nspayment_type=[[NSString alloc]initWithUTF8String:payment_type];
|
|
NSString *nspayment_type=[[NSString alloc]initWithUTF8String:payment_type];
|
|
|
|
|
|
|
|
- int have_lift_gate = sqlite3_column_int(statement, 17);
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// order info
|
|
// order info
|
|
|
orderinfo = [self textFileName:@"order_info.html"];
|
|
orderinfo = [self textFileName:@"order_info.html"];
|
|
@@ -5275,6 +5279,121 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
++ (double) orderTotalPrice:(NSString *)so_id db:(sqlite3 *)db1 close:(BOOL)close{
|
|
|
|
|
+
|
|
|
|
|
+ double total = 0;
|
|
|
|
|
+
|
|
|
|
|
+ __block double payments_and_credist = 0;
|
|
|
|
|
+ __block double allItemPrice = 0;
|
|
|
|
|
+
|
|
|
|
|
+// sqlite3 *db1 = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+ if (so_id) {
|
|
|
|
|
+ NSString *modelSql = [NSString stringWithFormat:@"select c.product_id,c.price,c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id",so_id];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
+
|
|
|
|
|
+ [iSalesDB jk_query:modelSql db:db1 close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ int product_id = sqlite3_column_int(stmt, 0);
|
|
|
|
|
+
|
|
|
|
|
+ char *str_price = (char*)sqlite3_column_text(stmt, 1);
|
|
|
|
|
+
|
|
|
|
|
+ int item_id = sqlite3_column_int(stmt, 7);
|
|
|
|
|
+
|
|
|
|
|
+ NSString* Price=nil;
|
|
|
|
|
+ if(str_price==nil)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db1];
|
|
|
|
|
+ if(price==nil)
|
|
|
|
|
+ Price=@"No Price.";
|
|
|
|
|
+ else
|
|
|
|
|
+ Price=[NSString stringWithFormat:@"%.2f",price.floatValue];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Price=[NSString stringWithFormat:@"%.2f",[[[NSString alloc]initWithUTF8String:str_price] floatValue]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int discount = sqlite3_column_int(stmt, 2);
|
|
|
|
|
+ int item_count = sqlite3_column_int(stmt, 3);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ itemjson[@"combine"]=[self model_bundle:item_id db:db1 compute_part:false];
|
|
|
|
|
+
|
|
|
|
|
+ itemjson[@"The unit price"]=Price;
|
|
|
|
|
+
|
|
|
|
|
+ itemjson[@"product_id"] = [NSString stringWithFormat:@"%d",product_id];
|
|
|
|
|
+ itemjson[@"QTY"] = [NSString stringWithFormat:@"%d",item_count];
|
|
|
|
|
+
|
|
|
|
|
+ double subTotal = item_count * [Price doubleValue] * (1.0 - discount / 100.0);
|
|
|
|
|
+ if(itemjson[@"combine"] != nil)
|
|
|
|
|
+ {
|
|
|
|
|
+ // int citem=0;
|
|
|
|
|
+
|
|
|
|
|
+ int bcount=[[itemjson[@"combine"] valueForKey:@"count"] intValue];
|
|
|
|
|
+ for(int bc=0;bc<bcount;bc++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSDictionary * bitem = [itemjson[@"combine"] objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
|
|
|
|
|
+ int modulus= [[bitem valueForKey:@"modulus"] intValue];
|
|
|
|
|
+ double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
|
|
|
|
|
+ subTotal += uprice * modulus * item_count;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ itemjson[@"Subtotal"] = [NSString stringWithFormat:@"%.2f",subTotal];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ allItemPrice += subTotal;
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ payments_and_credist = allItemPrice;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // payments/Credits
|
|
|
|
|
+ payments_and_credist = 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // lift_gate handlingFee shippingFee
|
|
|
|
|
+ __block double lift_gate = 0;
|
|
|
|
|
+ __block double handlingFee = 0;
|
|
|
|
|
+ __block double shippingFee = 0;
|
|
|
|
|
+ NSString *orderSql = [NSString stringWithFormat:@"select lift_gate,lift_gate_value,handling_fee_value,shipping from offline_order where so_id = '%@';",so_id];
|
|
|
|
|
+
|
|
|
|
|
+ [iSalesDB jk_query:orderSql db:db1 close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ int have_lift_gate = sqlite3_column_int(stmt, 0);
|
|
|
|
|
+ if (have_lift_gate) {
|
|
|
|
|
+ lift_gate = sqlite3_column_double(stmt, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ handlingFee = sqlite3_column_double(stmt, 2);
|
|
|
|
|
+ shippingFee = sqlite3_column_double(stmt, 3);
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ // total
|
|
|
|
|
+ total = payments_and_credist + lift_gate + handlingFee + shippingFee;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (close) {
|
|
|
|
|
+ [iSalesDB close_db:db1];
|
|
|
|
|
+ }
|
|
|
|
|
+ return total;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(NSData*) offline_orderlist :(NSMutableDictionary *) params
|
|
+(NSData*) offline_orderlist :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
@@ -5376,8 +5495,8 @@
|
|
|
NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
|
|
NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
|
|
|
DebugLog(@"time: %@",nscreate_time);
|
|
DebugLog(@"time: %@",nscreate_time);
|
|
|
nscreate_time = [self changeDateTimeFormate:nscreate_time]; // 与在线统一
|
|
nscreate_time = [self changeDateTimeFormate:nscreate_time]; // 与在线统一
|
|
|
-
|
|
|
|
|
- double total_price = sqlite3_column_double(statement, 7);
|
|
|
|
|
|
|
+// double total_price = sqlite3_column_double(statement, 7);
|
|
|
|
|
+ double total_price = [self orderTotalPrice:[NSString stringWithUTF8String:soid]db:db close:NO];
|
|
|
|
|
|
|
|
NSString *customer_contact = [self textAtColumn:8 statement:statement];
|
|
NSString *customer_contact = [self textAtColumn:8 statement:statement];
|
|
|
|
|
|