Skip to content

Instantly share code, notes, and snippets.

@lmon
Last active August 5, 2019 20:13
Show Gist options
  • Save lmon/de268da9fd167804e0a5ec6ebc116116 to your computer and use it in GitHub Desktop.
Save lmon/de268da9fd167804e0a5ec6ebc116116 to your computer and use it in GitHub Desktop.
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,
:merchant_allocation_micros => 0,
:food52_allocation_micros => -8000,
:created_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:rma_basket_item_id => nil,
:shipment_id => nil,
:return_shipment_id => nil,
:rma_misc_adjustment_item_id => nil,
:line_type => "tax_adjustment"
},
[1] #<RmaAllocationLine:0x000000000a610b70> {
:id => 9114,
:rma_id => 11439,
:description => "Return Shipping, RMA11439 - return",
:total_allocation_micros => 0,
:customer_allocation_micros => 0,
:merchant_allocation_micros => 0,
:food52_allocation_micros => 0,
:created_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:rma_basket_item_id => nil,
:shipment_id => nil,
:return_shipment_id => 10353,
:rma_misc_adjustment_item_id => nil,
:line_type => "return_shipping_charge"
},
[2] #<RmaAllocationLine:0x000000000a610760> {
:id => 9113,
:rma_id => 11439,
:description => "Refund for Emile Henry Ceramic Pizza Stone & Peel Kit - Merchant SKU: 799714",
:total_allocation_micros => 80000,
:customer_allocation_micros => 80000,
:merchant_allocation_micros => -40000,
:food52_allocation_micros => -40000,
:created_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:37 EDT -04:00,
:rma_basket_item_id => 4292,
:shipment_id => nil,
:return_shipment_id => nil,
:rma_misc_adjustment_item_id => nil,
:line_type => "item_refund"
}
]
=> nil
irb(main):008:0> ap DetailedRevenueLedgerItem.where(:rma_id=>rma.id)
[2019-08-05T20:05:11] DEBUG ActiveRecord::Base : DetailedRevenueLedgerItem Exists (1.0ms) SELECT 1 AS one FROM "detailed_revenue_ledger_items" WHERE "detailed_revenue_ledger_items"."rma_id" = $1 LIMIT $2 [["rma_id", 11439], ["LIMIT", 1]]
[2019-08-05T20:05:11] DEBUG ActiveRecord::Base : DetailedRevenueLedgerItem Load (2.6ms) SELECT "detailed_revenue_ledger_items".* FROM "detailed_revenue_ledger_items" WHERE "detailed_revenue_ledger_items"."rma_id" = $1 [["rma_id", 11439]]
[
[0] #<DetailedRevenueLedgerItem:0x000000000a0ff410> {
:id => 870436,
:revenue_vendor_id => 821,
:order_id => 575850,
:vendor_order_fulfillment_id => nil,
:shipment_id => nil,
:basket_item_id => 4533977,
:vendor_id => 821,
:vendor_brand_id => nil,
:product_sku_id => 18347,
:promo_code_id => nil,
:rma_id => 11439,
:order_adjustment_id => 13233,
:tax_line_item_id => nil,
:revenue_type => "item",
:description => "Refund for Emile Henry Ceramic Pizza Stone & Peel Kit - Merchant SKU: 799714",
:recognition_date => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:quantity => -1,
:total_revenue_micros => -40000,
:item_revenue_micros => -40000,
:shipping_revenue_micros => 0,
:dropship_fee_revenue_micros => 0,
:discount_revenue_micros => 0,
:credit_revenue_micros => 0,
:tax_revenue_micros => 0,
:rma_fees_revenue_micros => 0,
:misc_revenue_micros => 0,
:order_date => Mon, 05 Aug 2019 16:01:28 EDT -04:00,
:shipment_date => nil,
:adjustment_date => nil,
:rma_date => Mon, 05 Aug 2019 16:02:52 EDT -04:00,
:promo_code_code => nil,
:vendor_name => "Emile Henry",
:brand_name => nil,
:product_name => "Emile Henry Ceramic Pizza Stone & Peel Kit",
:vendor_sku_codes => "799714",
:created_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00
},
[1] #<DetailedRevenueLedgerItem:0x000000000a0fef88> {
:id => 870435,
:revenue_vendor_id => nil,
:order_id => 575850,
:vendor_order_fulfillment_id => nil,
:shipment_id => nil,
:basket_item_id => 4533977,
:vendor_id => 821,
:vendor_brand_id => nil,
:product_sku_id => 18347,
:promo_code_id => nil,
:rma_id => 11439,
:order_adjustment_id => 13233,
:tax_line_item_id => nil,
:revenue_type => "item",
:description => "Refund for Emile Henry Ceramic Pizza Stone & Peel Kit - Merchant SKU: 799714",
:recognition_date => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:quantity => -1,
:total_revenue_micros => -80000,
:item_revenue_micros => -80000,
:shipping_revenue_micros => 0,
:dropship_fee_revenue_micros => 0,
:discount_revenue_micros => 0,
:credit_revenue_micros => 0,
:tax_revenue_micros => 0,
:rma_fees_revenue_micros => 0,
:misc_revenue_micros => 0,
:order_date => Mon, 05 Aug 2019 16:01:28 EDT -04:00,
:shipment_date => nil,
:adjustment_date => nil,
:rma_date => Mon, 05 Aug 2019 16:02:52 EDT -04:00,
:promo_code_code => nil,
:vendor_name => "Emile Henry",
:brand_name => nil,
:product_name => "Emile Henry Ceramic Pizza Stone & Peel Kit",
:vendor_sku_codes => "799714",
:created_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00
},
[2] #<DetailedRevenueLedgerItem:0x000000000a0fed58> {
:id => 870434,
:revenue_vendor_id => nil,
:order_id => 575850,
:vendor_order_fulfillment_id => nil,
:shipment_id => nil,
:basket_item_id => nil,
:vendor_id => nil,
:vendor_brand_id => nil,
:product_sku_id => nil,
:promo_code_id => nil,
:rma_id => 11439,
:order_adjustment_id => 13233,
:tax_line_item_id => nil,
:revenue_type => "rma_shipping",
:description => "Return Shipping, RMA11439 - return",
:recognition_date => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:quantity => 1,
:total_revenue_micros => 0,
:item_revenue_micros => 0,
:shipping_revenue_micros => 0,
:dropship_fee_revenue_micros => 0,
:discount_revenue_micros => 0,
:credit_revenue_micros => 0,
:tax_revenue_micros => 0,
:rma_fees_revenue_micros => 0,
:misc_revenue_micros => 0,
:order_date => Mon, 05 Aug 2019 16:01:28 EDT -04:00,
:shipment_date => nil,
:adjustment_date => nil,
:rma_date => Mon, 05 Aug 2019 16:02:52 EDT -04:00,
:promo_code_code => nil,
:vendor_name => nil,
:brand_name => nil,
:product_name => nil,
:vendor_sku_codes => nil,
:created_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00
},
[3] #<DetailedRevenueLedgerItem:0x000000000a0feb00> {
:id => 870433,
:revenue_vendor_id => nil,
:order_id => 575850,
:vendor_order_fulfillment_id => 882113,
:shipment_id => 920019,
:basket_item_id => 4533977,
:vendor_id => 821,
:vendor_brand_id => nil,
:product_sku_id => 18347,
:promo_code_id => nil,
:rma_id => 11439,
:order_adjustment_id => 13233,
:tax_line_item_id => 2379440,
:revenue_type => "misc_tax_revenue",
:description => "Tax adjustment for Emile Henry Ceramic Pizza Stone & Peel Kit",
:recognition_date => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:quantity => 1,
:total_revenue_micros => -8000,
:item_revenue_micros => 0,
:shipping_revenue_micros => 0,
:dropship_fee_revenue_micros => 0,
:discount_revenue_micros => 0,
:credit_revenue_micros => 0,
:tax_revenue_micros => -8000,
:rma_fees_revenue_micros => 0,
:misc_revenue_micros => 0,
:order_date => Mon, 05 Aug 2019 16:01:28 EDT -04:00,
:shipment_date => Sat, 03 Aug 2019 16:02:36 EDT -04:00,
:adjustment_date => nil,
:rma_date => Mon, 05 Aug 2019 16:02:52 EDT -04:00,
:promo_code_code => nil,
:vendor_name => "Emile Henry",
:brand_name => nil,
:product_name => "Emile Henry Ceramic Pizza Stone & Peel Kit",
:vendor_sku_codes => "799714",
:created_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00,
:updated_at => Mon, 05 Aug 2019 16:04:39 EDT -04:00
}
]
=> nil
irb(main):009:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment