Skip to content

Instantly share code, notes, and snippets.

Merchant SKU,Inventory,Restock Date,
HNY.500.20.023.050,876,2019-12-31,
HNY.500.10.028.095,876,2019-12-31,
HNY.300.30.052.930,876,2019-12-31,
HNY.500.70.044.100.MRBL,876,2019-12-31,
HNY.500.70.045.000.MRBL,876,2019-12-31,
Merchant SKU,Inventory,Restock Date,Expectation,
1221623x,12,01-10-2019,skipped
1221618x,13,10-1-2019,skipped
HNY.500.20.025.050,,,blank
HNY.500.20.025.095,invalid,,error
HNY.500.20.025.050,16,2019-12-01,OK
HNY.500.20.025.095,17,2019-12-01,OK
Merchant SKU,Inventory,Restock Date,,,,
HNY.500.20.023.050,999,2019-12-31,valid+valid+valid,,,
HNY.500.10.028.095,888,2019-12-31,valid+valid+valid,,,
HNY.300.30.052.930,777,2019-12-31,valid+valid+valid,,,
HNY.500.70.044.100.MRBL,666,2019-12-31,valid+valid+valid,,,
HNY.500.70.045.000.MRBL,555,2019-12-31,valid+valid+valid,,,
HNY.500.70.046.000.MRBL,444,2019-12-31,valid+valid+valid,,,
HNY.500.70.040.000.CPR,333,2019-12-31,valid+valid+valid,,,
HNY.500.20.025.050,222,2019-12-31,valid+valid+valid,,,
HNY.500.30.001.000,111,2019-12-31,valid+valid+valid,,,
# Re-convert data
ActiveRecord::Base.transaction do
ProductSku.find_each do |product_sku|
product_sku.product_sku_merchant_skus = []
old_merchant_skus = YAML.safe_load(product_sku.DEPRECATED_custom_codes || '') || []
clean_codes = old_merchant_skus.map(&:strip).reject(&:blank?).uniq
clean_codes.each do |clean_code|
ProductSkuMerchantSku.create!(:product_sku_id => product_sku.id, :sku_name => clean_code)
Merchant SKU Inventory Restock Date
HNY.500.30.001.000 999 2019-12-31 valid+valid+valid
HNY.500.20.025.050 -999 2019-12-31 valid+invalid+valid
HNY.500.20.023.050 2019-12-31 valid+blank+valid
HNY.500.10.028.095 999 12-31-19 valid+valid+invalid
HNY.500.70.040.000.BRS 999 valid+valid+blank
HNY.500.70.040.000.CPR -999 12-31-19 valid+invalid+invalid
HNY.300.30.052.930 -999 valid+invalid+blank
HNY.500.70.044.100.MRBL 12-31-19 valid+blank+invalid
HNY.500.70.045.000.MRBL valid+blank+blank
{
"file_846": {
"header": true,
"delimiter": ",",
"mapping": {
"0": "merchant_sku",
"1": "inventory_value",
"2": "restock_date"
}
}
Merchant SKU Inventory Restock Date
75002-137 999 2019-12-31 valid+valid+valid
75000-667 -999 2019-12-31 valid+invalid+valid
75001-530 2019-12-31 valid+blank+valid
75000-668 999 12-31-19 valid+valid+invalid
75002-107 999 valid+valid+blank
75002-108 -999 12-31-19 valid+invalid+invalid
75000-999 -999 valid+invalid+blank
75000-993 12-31-19 valid+blank+invalid
75000-994 valid+blank+blank
2019-10-21T15:56:30] DEBUG ActiveRecord::Base : UserBillingGatewayInfo Load (0.9ms) SELECT "user_billing_gateway_infos".* FROM "user_billing_gateway_infos" WHERE "user_billing_gateway_infos"."gateway" = $1 AND "user_billing_gateway_infos"."token" = $2 LIMIT $3 [["gateway", "worldpay"], ["token", "4111111518931111"], ["LIMIT", 1]]
[2019-10-21T15:56:30] DEBUG ActiveRecord::Base : UserBillingInfo Load (0.9ms) SELECT "user_billing_infos".* FROM "user_billing_infos" WHERE "user_billing_infos"."hidden" = $1 AND "user_billing_infos"."id" = $2 [["hidden", false], ["id", 424226]]
[2019-10-21T15:56:30] INFO Rails : {"method":"POST","path":"/shop/admin/rmas/create","format":"html","controller":"Shop::Admin::RmasController","action":"create_rma","status":500,"error":"RuntimeError: Invalid payment method ''","duration":683.36,"view":0.0,"db":301.3,"dd":{"trace_id":8961126303114190952,"span_id":8636043102367750020},"ddsource":["ruby"],"http_status":null,"user_agent":null,"remote_addr":null,"tracking_code":null,"c
@lmon
lmon / GiftsCategory_cleaned-minus10
Last active August 21, 2019 17:11
Subcategory_Taxonomy2019-FINALCHANGES-JULY2019.csv-GiftsCategory_cleaned-minus10
product_id,product_name,x2019_subcategory_1,x2019_subcategory_2
6286,Degrenne Salam Insulated Teapot,Food Gift Sets,Food Gifts
6276,Cookie Maker & Storage Container (Set of 2),Kitchen Storage & Organization,Unique Gifts
6256,Perfect Slice Bread Knife,Knives,Cooking Gifts
6250,Portable Espresso Maker,Coffee & Tea Accessories,Unique Gifts
6249,"Smithey Cast Iron Chef Skillet, 10""",Frying Pans & Skillets,Cooking Gifts
6247,100% Extra Virgin Heirloom Olive Oil,Food Gift Sets,Food Gifts
6244,Hand-Painted Metallic Moon Coasters (Set of 4),Barware,Unique Gifts
6244,Hand-Painted Metallic Moon Coasters (Set of 4),Barware,Handmade Gifts
6243,Hand-Painted Brass Napkin Rings (Set of 4),Table Decor,Handmade Gifts
@lmon
lmon / gist:de268da9fd167804e0a5ec6ebc116116
Last active August 5, 2019 20:13
RMA allocation & ledger line updates
irb(main):007:0> ap rma.rma_allocation_lines
[2019-08-05T20:04:47] DEBUG ActiveRecord::Base : RmaAllocationLine Exists (0.9ms) SELECT 1 AS one FROM "rma_allocation_lines" WHERE "rma_allocation_lines"."rma_id" = $1 LIMIT $2 [["rma_id", 11439], ["LIMIT", 1]]
[2019-08-05T20:04:47] DEBUG ActiveRecord::Base : RmaAllocationLine Load (0.6ms) SELECT "rma_allocation_lines".* FROM "rma_allocation_lines" WHERE "rma_allocation_lines"."rma_id" = $1 [["rma_id", 11439]]
[
[0] #<RmaAllocationLine:0x000000000b3717b0> {
:id => 9115,
:rma_id => 11439,
:description => "Sales Tax",
:total_allocation_micros => 8000,
:customer_allocation_micros => 8000,