mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Add min_stock_amount and best_before_days to KrogerConverter
This commit is contained in:
parent
5d980a9bd7
commit
53f1321e19
|
|
@ -38,11 +38,17 @@ class KrogerToGrocyConverter
|
|||
|
||||
$barcode = KrogerToGrocyConverter::ConvertUpcToBarcode($item["baseUpc"]);
|
||||
|
||||
$min_stock_amount = 1;
|
||||
$quantity = $item['quantity'];
|
||||
if ($item['weighted'] && array_key_exists('averageWeight', $item['detail']))
|
||||
{
|
||||
$quantity = round($item['quantity'] / $item['detail']['averageWeight']);
|
||||
}
|
||||
else if ($item['weighted'])
|
||||
{
|
||||
// this is semi-arbitrary; some things are bought by weight but with no way to determine quantity
|
||||
$min_stock_amount = $item['quantity'] / 4;
|
||||
}
|
||||
|
||||
$quantity_units = $default_quantity_units;
|
||||
if (array_key_exists('unitOfMeasure', $item))
|
||||
|
|
@ -57,8 +63,8 @@ class KrogerToGrocyConverter
|
|||
}
|
||||
}
|
||||
|
||||
$best_before_days = 21;
|
||||
$location = $default_location_id;
|
||||
|
||||
if (array_key_exists('categories', $item['detail']) && count($item['detail']['categories']) > 0)
|
||||
{
|
||||
$category = $item['detail']['categories'][0]['categoryCode'];
|
||||
|
|
@ -67,30 +73,36 @@ class KrogerToGrocyConverter
|
|||
case 1 /*adult beverage*/:
|
||||
$location = 3 /*pantry*/;
|
||||
$quantity_units = 10 /*bottle*/;
|
||||
$best_before_days = -1;
|
||||
break;
|
||||
case 6 /*bakery*/:
|
||||
case 7 /*baking goods*/:
|
||||
case 10 /*breakfast*/:
|
||||
case 12 /*canned and packaged*/:
|
||||
case 13 /*cleaning products*/:
|
||||
case 33 /*pasta, sauces, & grain*/:
|
||||
case 36 /*produce*/:
|
||||
case 73 /*natural & organic*/:
|
||||
case 75 /*personal care*/:
|
||||
case 76 /*health*/:
|
||||
$location = 3 /*pantry*/;
|
||||
$best_before_days = -1;
|
||||
break;
|
||||
case 36 /*produce*/:
|
||||
case 6 /*bakery*/:
|
||||
$location = 3 /*pantry*/;
|
||||
break;
|
||||
case 15 /*dairy*/:
|
||||
case 16 /*deli*/:
|
||||
case 28 /*meet & seafood*/:
|
||||
case 28 /*meat & seafood*/:
|
||||
$location = 2 /*fridge*/;
|
||||
break;
|
||||
case 20 /*frozen*/:
|
||||
$location = 6 /*freezer*/;
|
||||
$best_before_days = -1;
|
||||
break;
|
||||
case 37 /*snacks*/:
|
||||
case 77 /*candy*/:
|
||||
$location = 4 /*candy cupboard*/;
|
||||
$best_before_days = 360;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -102,16 +114,18 @@ class KrogerToGrocyConverter
|
|||
'qu_id_stock' => $quantity_units,
|
||||
'qu_factor_purchase_to_stock' => 1,
|
||||
'barcode' => $barcode,
|
||||
'default_best_before_days' => 21,
|
||||
'default_best_before_days' => $best_before_days,
|
||||
'quantity' => $quantity,
|
||||
'min_stock_amount' => $min_stock_amount,
|
||||
'transaction_date' => $transactionDate,
|
||||
'price_paid' => $item['pricePaid'],
|
||||
'price_paid' => $item['pricePaid'] / $item['quantity'],
|
||||
'picture_url' => (array_key_exists("mainImage", $item['detail']) ? $item['detail']['mainImage'] : null)
|
||||
);
|
||||
|
||||
array_push($products, $product);
|
||||
}
|
||||
}
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
|
|
|
|||
39
tests/testdata/receipts.json
vendored
39
tests/testdata/receipts.json
vendored
|
|
@ -110,6 +110,45 @@
|
|||
"pharmacy": false,
|
||||
"managerOverride": false,
|
||||
"weighted": false
|
||||
},
|
||||
{
|
||||
"itemIdentifier": "0000000004648",
|
||||
"baseUpc": "0000000004648",
|
||||
"department": "57",
|
||||
"unitOfMeasure": "LBR",
|
||||
"detail": {
|
||||
"upc": "0000000004648",
|
||||
"customerFacingSize": "1 lb",
|
||||
"description": "Mushrooms - Crimini - Bulk",
|
||||
"familyTreeCommodityCode": "613",
|
||||
"familyTreeDepartmentCode": "57",
|
||||
"familyTreeSubCommodityCode": "8067",
|
||||
"mainImage": "https://www.kroger.com/product/images/small/front/0000000004648",
|
||||
"soldInStore": true,
|
||||
"categories": [{
|
||||
"category": "Produce",
|
||||
"categoryCode": "36"
|
||||
}
|
||||
]
|
||||
},
|
||||
"quantity": 0.84,
|
||||
"totalSavings": 0,
|
||||
"extendedPrice": 3.35,
|
||||
"pricePaid": 3.35,
|
||||
"priceModifiers": [],
|
||||
"unitPrice": 3.99,
|
||||
"itemType": "NORMAL",
|
||||
"entryMethod": "KEYED_ITEM_CODE",
|
||||
"imageUrl": "https://www.kroger.com/product/images/small/front/0000000004648",
|
||||
"detailUrl": "/p/item/0000000004648",
|
||||
"sellableUpc": "0000000004648",
|
||||
"containerDeposit": false,
|
||||
"managerOverride": false,
|
||||
"weighted": true,
|
||||
"giftCard": false,
|
||||
"pharmacy": false,
|
||||
"fuel": false,
|
||||
"managerOverrideIgnored": false
|
||||
}
|
||||
],
|
||||
"transactionTime": "2020-03-21T09:14:00"
|
||||
|
|
|
|||
12
tests/testdata/receipts_expected.json
vendored
12
tests/testdata/receipts_expected.json
vendored
|
|
@ -14,5 +14,17 @@
|
|||
"barcode": "0072220005165",
|
||||
"quantity": 3,
|
||||
"transaction_date": "2020-03-21"
|
||||
}, {
|
||||
"name": "Mushrooms - Crimini - Bulk",
|
||||
"location_id": 3,
|
||||
"qu_id_purchase": 2,
|
||||
"qu_id_stock": 2,
|
||||
"qu_factor_purchase_to_stock": 1,
|
||||
"barcode": "0000000046480",
|
||||
"default_best_before_days": 21,
|
||||
"quantity": 0.84,
|
||||
"transaction_date": "2020-03-21",
|
||||
"price_paid": 3.988095238095238,
|
||||
"picture_url": "https:\/\/www.kroger.com\/product\/images\/small\/front\/0000000004648"
|
||||
}
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user