summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 22:42:03 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 22:42:03 +0800
commite9e2ea78fa012e909aff1b0f0838c321e496fb67 (patch)
tree12dc27f5d4a16f0e9277af8407a00398f8942c96
parent12150c2dff8d226987beb78c8d37f595d90502eb (diff)
nitems include item quantities that are more than 1
-rw-r--r--anteraja.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/anteraja.c b/anteraja.c
index 0e5f2e7..a3bc1c3 100644
--- a/anteraja.c
+++ b/anteraja.c
@@ -112,15 +112,15 @@ void anteraja_order(const char *order_number, const char *service, const char *s
+ ORDER_ITEM_PRICE + ORDER_ITEM_WEIGHT - strlen("%s") - 3 * strlen("%d")
+ strlen(",");
char item[length + 1];
- double weight = atof(items[i][WEIGHT]) * 1000.0;
- if (weight < 100.0)
- weight = 100.0;
+ int quantity = atoi(items[i][QUANTITY]);
double price = atof(items[i][PRICE]);
if (price < 1000.0)
price = 1000.0;
- sprintf(item, ORDER_ITEM, items[i][DESCRIPTION], atoi(items[i][QUANTITY]), (int)price,
- (int)weight);
+ double weight = atof(items[i][WEIGHT]) * 1000.0;
+ if (weight < 100.0)
+ weight = 100.0;
total_weight += weight;
+ sprintf(item, ORDER_ITEM, items[i][DESCRIPTION], quantity, (int)price, (int)weight);
if (json)
json = realloc(json, strlen(json) + length + 1);
else {
@@ -132,6 +132,7 @@ void anteraja_order(const char *order_number, const char *service, const char *s
strcat(json, ",");
else
json[strlen(json)] = '\0';
+ i += quantity - 1;
}
*post = malloc(strlen(ORDER_POST) + strlen(prefix) + strlen(order_number) + strlen(service)
+ ORDER_WEIGHT + strlen(sender_name) + strlen(sender_phone) + strlen(origin)