diff --git a/oder_canceled.json b/oder_canceled.json new file mode 100644 index 0000000..3d2067a --- /dev/null +++ b/oder_canceled.json @@ -0,0 +1,349 @@ +{ + "id": 820982911946154508, + "email": "jon@doe.ca", + "closed_at": null, + "created_at": "2021-04-23T16:34:36-05:00", + "updated_at": "2021-04-23T16:34:36-05:00", + "number": 234, + "note": null, + "token": "123456abcd", + "gateway": null, + "test": true, + "total_price": "129905.00", + "subtotal_price": "129895.00", + "total_weight": 0, + "total_tax": "0.00", + "taxes_included": false, + "currency": "COP", + "financial_status": "voided", + "confirmed": false, + "total_discounts": "5.00", + "total_line_items_price": "129900.00", + "cart_token": null, + "buyer_accepts_marketing": true, + "name": "#9999", + "referring_site": null, + "landing_site": null, + "cancelled_at": "2021-04-23T16:34:36-05:00", + "cancel_reason": "customer", + "total_price_usd": null, + "checkout_token": null, + "reference": null, + "user_id": null, + "location_id": null, + "source_identifier": null, + "source_url": null, + "processed_at": null, + "device_id": null, + "phone": null, + "customer_locale": "es", + "app_id": null, + "browser_ip": null, + "landing_site_ref": null, + "order_number": 1234, + "discount_applications": [{ + "type": "manual", + "value": "5.0", + "value_type": "fixed_amount", + "allocation_method": "across", + "target_selection": "explicit", + "target_type": "line_item", + "description": "Discount", + "title": "Discount" + }], + "discount_codes": [], + "note_attributes": [], + "payment_gateway_names": ["visa", "bogus"], + "processing_method": "", + "checkout_id": null, + "source_name": "web", + "fulfillment_status": "pending", + "tax_lines": [], + "tags": "", + "contact_email": "jon@doe.ca", + "order_status_url": "https:\\/\\/www.lanch.co\\/13526597696\\/orders\\/123456abcd\\/authenticate?key=abcdefg", + "presentment_currency": "COP", + "total_line_items_price_set": { + "shop_money": { + "amount": "129900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129900.00", + "currency_code": "COP" + } + }, + "total_discounts_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "total_shipping_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "subtotal_price_set": { + "shop_money": { + "amount": "129895.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129895.00", + "currency_code": "COP" + } + }, + "total_price_set": { + "shop_money": { + "amount": "129905.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129905.00", + "currency_code": "COP" + } + }, + "total_tax_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "line_items": [{ + "id": 866550311766439020, + "variant_id": 28754615959616, + "title": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "quantity": 1, + "sku": "042GL20423", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 3739133018176, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "70000.00", + "total_discount": "0.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "70000.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "70000.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/866550311766439020", + "tax_lines": [] + }, { + "id": 141249953214522974, + "variant_id": 39684515627163, + "title": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "quantity": 1, + "sku": "FXXI0037", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 6665708863643, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "59900.00", + "total_discount": "5.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "59900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "59900.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "discount_allocations": [{ + "amount": "5.00", + "discount_application_index": 0, + "amount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + } + }], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/141249953214522974", + "tax_lines": [] + }], + "fulfillments": [], + "refunds": [], + "total_tip_received": "0.0", + "original_total_duties_set": null, + "current_total_duties_set": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Order\\/820982911946154508", + "shipping_lines": [{ + "id": 271878346596884015, + "title": "Generic Shipping", + "price": "10.00", + "code": null, + "source": "shopify", + "phone": null, + "requested_fulfillment_service_id": null, + "delivery_category": null, + "carrier_identifier": null, + "discounted_price": "10.00", + "price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discounted_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "tax_lines": [] + }], + "billing_address": { + "first_name": "Bob", + "address1": "123 Billing Street", + "phone": "555-555-BILL", + "city": "Billtown", + "zip": "K2P0B0", + "province": "Kentucky", + "country": "United States", + "last_name": "Biller", + "address2": null, + "company": "My Company", + "latitude": null, + "longitude": null, + "name": "Bob Biller", + "country_code": "US", + "province_code": "KY" + }, + "shipping_address": { + "first_name": "Steve", + "address1": "123 Shipping Street", + "phone": "555-555-SHIP", + "city": "Shippington", + "zip": "40003", + "province": "Kentucky", + "country": "United States", + "last_name": "Shipper", + "address2": null, + "company": "Shipping Company", + "latitude": null, + "longitude": null, + "name": "Steve Shipper", + "country_code": "US", + "province_code": "KY" + }, + "customer": { + "id": 115310627314723954, + "email": "john@test.com", + "accepts_marketing": false, + "created_at": null, + "updated_at": null, + "first_name": "John", + "last_name": "Smith", + "orders_count": 0, + "state": "disabled", + "total_spent": "0.00", + "last_order_id": null, + "note": null, + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": null, + "tags": "", + "last_order_name": null, + "currency": "COP", + "accepts_marketing_updated_at": null, + "marketing_opt_in_level": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Customer\\/115310627314723954", + "default_address": { + "id": 715243470612851245, + "customer_id": 115310627314723954, + "first_name": null, + "last_name": null, + "company": null, + "address1": "123 Elm St.", + "address2": null, + "city": "Ottawa", + "province": "Ontario", + "country": "Canada", + "zip": "K2H7A8", + "phone": "123-123-1234", + "name": "", + "province_code": "ON", + "country_code": "CA", + "country_name": "Canada", + "default": true + } + } +} diff --git a/order_create.json b/order_create.json new file mode 100644 index 0000000..4d1e139 --- /dev/null +++ b/order_create.json @@ -0,0 +1,372 @@ +{ + "id": 3781395087515, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Order\\/3781395087515", + "app_id": 580111, + "browser_ip": "181.33.21.208", + "buyer_accepts_marketing": true, + "cancel_reason": null, + "cancelled_at": null, + "cart_token": null, + "checkout_id": 20221949870235, + "checkout_token": "c4ed7ab35fb02968d4494e8d0abb779d", + "client_details": { + "accept_language": "es-US,es;q=0.9,en-US;q=0.8,en;q=0.7", + "browser_height": 568, + "browser_ip": "181.33.21.208", + "browser_width": 360, + "session_hash": null, + "user_agent": "Mozilla\\/5.0 (Linux; Android 8.0.0; SM-G935U Build\\/R16NW; wv) AppleWebKit\\/537.36 (KHTML, like Gecko) Version\\/4.0 Chrome\\/90.0.4430.82 Mobile Safari\\/537.36 Instagram 184.0.0.30.117 Android (26\\/8.0.0; 640dpi; 1440x2560; samsung; SM-G935U; hero2qlteue; qcom; es_US; 285855803)" + }, + "closed_at": null, + "confirmed": true, + "contact_email": "redye-90@hotmail.com", + "created_at": "2021-04-23T16:22:18-05:00", + "currency": "COP", + "current_subtotal_price": "99900.00", + "current_subtotal_price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "current_total_discounts": "0.00", + "current_total_discounts_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "current_total_duties_set": null, + "current_total_price": "99900.00", + "current_total_price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "current_total_tax": "15950.42", + "current_total_tax_set": { + "shop_money": { + "amount": "15950.42", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "15950.42", + "currency_code": "COP" + } + }, + "customer_locale": "es", + "device_id": null, + "discount_codes": [], + "email": "redye-90@hotmail.com", + "financial_status": "pending", + "fulfillment_status": null, + "gateway": "mercado_pago", + "landing_site": "\\/wallets\\/checkouts.json", + "landing_site_ref": null, + "location_id": null, + "name": "#2143", + "note": null, + "note_attributes": [], + "number": 1143, + "order_number": 2143, + "order_status_url": "https:\\/\\/www.lanch.co\\/13526597696\\/orders\\/fe7873ff31d74a05b844583583bdfe02\\/authenticate?key=b5b76c12d28d8d934f5afd39c7ff404f", + "original_total_duties_set": null, + "payment_gateway_names": ["mercado_pago"], + "phone": null, + "presentment_currency": "COP", + "processed_at": "2021-04-23T16:22:17-05:00", + "processing_method": "offsite", + "reference": null, + "referring_site": "https:\\/\\/www.lanch.co\\/products\\/combo-estuche-vidrio-flexible-ringke-fusion-x-samsung-galaxy-note-10-plus?variant=34540401000603", + "source_identifier": null, + "source_name": "web", + "source_url": null, + "subtotal_price": "99900.00", + "subtotal_price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "tags": "", + "tax_lines": [{ + "price": "15950.42", + "rate": 0.19, + "title": "VAT", + "price_set": { + "shop_money": { + "amount": "15950.42", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "15950.42", + "currency_code": "COP" + } + } + }], + "taxes_included": true, + "test": false, + "token": "fe7873ff31d74a05b844583583bdfe02", + "total_discounts": "0.00", + "total_discounts_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "total_line_items_price": "99900.00", + "total_line_items_price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "total_outstanding": "99900.00", + "total_price": "99900.00", + "total_price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "total_price_usd": "27.48", + "total_shipping_price_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "total_tax": "15950.42", + "total_tax_set": { + "shop_money": { + "amount": "15950.42", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "15950.42", + "currency_code": "COP" + } + }, + "total_tip_received": "0.00", + "total_weight": 0, + "updated_at": "2021-04-23T16:22:23-05:00", + "user_id": null, + "billing_address": { + "first_name": "Eyder ", + "address1": "Calle 55#16 a 13 ", + "phone": "300 8634185", + "city": "Soledad", + "zip": "", + "province": "Atl\xc3\xa1ntico", + "country": "Colombia", + "last_name": "Torres ", + "address2": "", + "company": "1140835044 ", + "latitude": null, + "longitude": null, + "name": "Eyder Torres ", + "country_code": "CO", + "province_code": "ATL" + }, + "customer": { + "id": 5180918857883, + "email": "redye-90@hotmail.com", + "accepts_marketing": true, + "created_at": "2021-04-23T16:16:22-05:00", + "updated_at": "2021-04-23T16:22:18-05:00", + "first_name": "Eyder ", + "last_name": "Torres ", + "orders_count": 1, + "state": "disabled", + "total_spent": "99900.00", + "last_order_id": 3781395087515, + "note": null, + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": null, + "tags": "", + "last_order_name": "#2143", + "currency": "COP", + "accepts_marketing_updated_at": "2021-04-23T16:16:22-05:00", + "marketing_opt_in_level": "single_opt_in", + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Customer\\/5180918857883", + "default_address": { + "id": 6359637459099, + "customer_id": 5180918857883, + "first_name": "Eyder ", + "last_name": "Torres ", + "company": "1140835044 ", + "address1": "Calle 55#16 a 13 ", + "address2": "", + "city": "Soledad", + "province": "Atl\xc3\xa1ntico", + "country": "Colombia", + "zip": "", + "phone": "300 8634185", + "name": "Eyder Torres ", + "province_code": "ATL", + "country_code": "CO", + "country_name": "Colombia", + "default": true + } + }, + "discount_applications": [], + "fulfillments": [], + "line_items": [{ + "id": 9845157757083, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/9845157757083", + "fulfillable_quantity": 1, + "fulfillment_service": "manual", + "fulfillment_status": null, + "gift_card": false, + "grams": 0, + "name": "Combo Estuche Vidrio Flexible Ringke Fusion X Samsung Galaxy Note 10 Plus - Negro", + "origin_location": { + "id": 2150983401627, + "country_code": "CO", + "province_code": "DC", + "name": "Lanch - Accesorios Originales", + "address1": "Calle 1C Bis #31B-19", + "address2": "", + "city": "BOGOTA", + "zip": "111631" + }, + "price": "99900.00", + "price_set": { + "shop_money": { + "amount": "99900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "99900.00", + "currency_code": "COP" + } + }, + "product_exists": true, + "product_id": 5271472996507, + "properties": [], + "quantity": 1, + "requires_shipping": true, + "sku": "FUSG0029+ESSG0016", + "taxable": true, + "title": "Combo Estuche Vidrio Flexible Ringke Fusion X Samsung Galaxy Note 10 Plus", + "total_discount": "0.00", + "total_discount_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "variant_id": 34540401000603, + "variant_inventory_management": "shopify", + "variant_title": "Negro", + "vendor": "Ringke", + "tax_lines": [{ + "price": "15950.42", + "price_set": { + "shop_money": { + "amount": "15950.42", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "15950.42", + "currency_code": "COP" + } + }, + "rate": 0.19, + "title": "VAT" + }], + "duties": [], + "discount_allocations": [] + }], + "refunds": [], + "shipping_address": { + "first_name": "Eyder ", + "address1": "Calle 55#16 a 13 ", + "phone": "300 8634185", + "city": "Soledad", + "zip": "", + "province": "Atl\xc3\xa1ntico", + "country": "Colombia", + "last_name": "Torres ", + "address2": "", + "company": "1140835044 ", + "latitude": null, + "longitude": null, + "name": "Eyder Torres ", + "country_code": "CO", + "province_code": "ATL" + }, + "shipping_lines": [{ + "id": 3208443265179, + "carrier_identifier": null, + "code": "Deprisa", + "delivery_category": null, + "discounted_price": "0.00", + "discounted_price_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "phone": null, + "price": "0.00", + "price_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "requested_fulfillment_service_id": null, + "source": "shopify", + "title": "Deprisa", + "tax_lines": [], + "discount_allocations": [] + }] +} diff --git a/order_fulfilled.json b/order_fulfilled.json new file mode 100644 index 0000000..96b67af --- /dev/null +++ b/order_fulfilled.json @@ -0,0 +1,349 @@ +{ + "id": 820982911946154508, + "email": "jon@doe.ca", + "closed_at": null, + "created_at": "2021-04-23T16:34:03-05:00", + "updated_at": "2021-04-23T16:34:03-05:00", + "number": 234, + "note": null, + "token": "123456abcd", + "gateway": null, + "test": true, + "total_price": "129905.00", + "subtotal_price": "129895.00", + "total_weight": 0, + "total_tax": "0.00", + "taxes_included": false, + "currency": "COP", + "financial_status": "voided", + "confirmed": false, + "total_discounts": "5.00", + "total_line_items_price": "129900.00", + "cart_token": null, + "buyer_accepts_marketing": true, + "name": "#9999", + "referring_site": null, + "landing_site": null, + "cancelled_at": "2021-04-23T16:34:03-05:00", + "cancel_reason": "customer", + "total_price_usd": null, + "checkout_token": null, + "reference": null, + "user_id": null, + "location_id": null, + "source_identifier": null, + "source_url": null, + "processed_at": null, + "device_id": null, + "phone": null, + "customer_locale": "es", + "app_id": null, + "browser_ip": null, + "landing_site_ref": null, + "order_number": 1234, + "discount_applications": [{ + "type": "manual", + "value": "5.0", + "value_type": "fixed_amount", + "allocation_method": "across", + "target_selection": "explicit", + "target_type": "line_item", + "description": "Discount", + "title": "Discount" + }], + "discount_codes": [], + "note_attributes": [], + "payment_gateway_names": ["visa", "bogus"], + "processing_method": "", + "checkout_id": null, + "source_name": "web", + "fulfillment_status": "pending", + "tax_lines": [], + "tags": "", + "contact_email": "jon@doe.ca", + "order_status_url": "https:\\/\\/www.lanch.co\\/13526597696\\/orders\\/123456abcd\\/authenticate?key=abcdefg", + "presentment_currency": "COP", + "total_line_items_price_set": { + "shop_money": { + "amount": "129900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129900.00", + "currency_code": "COP" + } + }, + "total_discounts_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "total_shipping_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "subtotal_price_set": { + "shop_money": { + "amount": "129895.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129895.00", + "currency_code": "COP" + } + }, + "total_price_set": { + "shop_money": { + "amount": "129905.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129905.00", + "currency_code": "COP" + } + }, + "total_tax_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "line_items": [{ + "id": 866550311766439020, + "variant_id": 28754615959616, + "title": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "quantity": 1, + "sku": "042GL20423", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 3739133018176, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "70000.00", + "total_discount": "0.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "70000.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "70000.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/866550311766439020", + "tax_lines": [] + }, { + "id": 141249953214522974, + "variant_id": 39684515627163, + "title": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "quantity": 1, + "sku": "FXXI0037", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 6665708863643, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "59900.00", + "total_discount": "5.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "59900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "59900.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "discount_allocations": [{ + "amount": "5.00", + "discount_application_index": 0, + "amount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + } + }], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/141249953214522974", + "tax_lines": [] + }], + "fulfillments": [], + "refunds": [], + "total_tip_received": "0.0", + "original_total_duties_set": null, + "current_total_duties_set": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Order\\/820982911946154508", + "shipping_lines": [{ + "id": 271878346596884015, + "title": "Generic Shipping", + "price": "10.00", + "code": null, + "source": "shopify", + "phone": null, + "requested_fulfillment_service_id": null, + "delivery_category": null, + "carrier_identifier": null, + "discounted_price": "10.00", + "price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discounted_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "tax_lines": [] + }], + "billing_address": { + "first_name": "Bob", + "address1": "123 Billing Street", + "phone": "555-555-BILL", + "city": "Billtown", + "zip": "K2P0B0", + "province": "Kentucky", + "country": "United States", + "last_name": "Biller", + "address2": null, + "company": "My Company", + "latitude": null, + "longitude": null, + "name": "Bob Biller", + "country_code": "US", + "province_code": "KY" + }, + "shipping_address": { + "first_name": "Steve", + "address1": "123 Shipping Street", + "phone": "555-555-SHIP", + "city": "Shippington", + "zip": "40003", + "province": "Kentucky", + "country": "United States", + "last_name": "Shipper", + "address2": null, + "company": "Shipping Company", + "latitude": null, + "longitude": null, + "name": "Steve Shipper", + "country_code": "US", + "province_code": "KY" + }, + "customer": { + "id": 115310627314723954, + "email": "john@test.com", + "accepts_marketing": false, + "created_at": null, + "updated_at": null, + "first_name": "John", + "last_name": "Smith", + "orders_count": 0, + "state": "disabled", + "total_spent": "0.00", + "last_order_id": null, + "note": null, + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": null, + "tags": "", + "last_order_name": null, + "currency": "COP", + "accepts_marketing_updated_at": null, + "marketing_opt_in_level": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Customer\\/115310627314723954", + "default_address": { + "id": 715243470612851245, + "customer_id": 115310627314723954, + "first_name": null, + "last_name": null, + "company": null, + "address1": "123 Elm St.", + "address2": null, + "city": "Ottawa", + "province": "Ontario", + "country": "Canada", + "zip": "K2H7A8", + "phone": "123-123-1234", + "name": "", + "province_code": "ON", + "country_code": "CA", + "country_name": "Canada", + "default": true + } + } +} diff --git a/order_paid.json b/order_paid.json new file mode 100644 index 0000000..cbc2533 --- /dev/null +++ b/order_paid.json @@ -0,0 +1,349 @@ +{ + "id": 820982911946154508, + "email": "jon@doe.ca", + "closed_at": null, + "created_at": "2021-04-23T16:35:07-05:00", + "updated_at": "2021-04-23T16:35:07-05:00", + "number": 234, + "note": null, + "token": "123456abcd", + "gateway": null, + "test": true, + "total_price": "129905.00", + "subtotal_price": "129895.00", + "total_weight": 0, + "total_tax": "0.00", + "taxes_included": false, + "currency": "COP", + "financial_status": "voided", + "confirmed": false, + "total_discounts": "5.00", + "total_line_items_price": "129900.00", + "cart_token": null, + "buyer_accepts_marketing": true, + "name": "#9999", + "referring_site": null, + "landing_site": null, + "cancelled_at": "2021-04-23T16:35:07-05:00", + "cancel_reason": "customer", + "total_price_usd": null, + "checkout_token": null, + "reference": null, + "user_id": null, + "location_id": null, + "source_identifier": null, + "source_url": null, + "processed_at": null, + "device_id": null, + "phone": null, + "customer_locale": "es", + "app_id": null, + "browser_ip": null, + "landing_site_ref": null, + "order_number": 1234, + "discount_applications": [{ + "type": "manual", + "value": "5.0", + "value_type": "fixed_amount", + "allocation_method": "across", + "target_selection": "explicit", + "target_type": "line_item", + "description": "Discount", + "title": "Discount" + }], + "discount_codes": [], + "note_attributes": [], + "payment_gateway_names": ["visa", "bogus"], + "processing_method": "", + "checkout_id": null, + "source_name": "web", + "fulfillment_status": "pending", + "tax_lines": [], + "tags": "", + "contact_email": "jon@doe.ca", + "order_status_url": "https:\\/\\/www.lanch.co\\/13526597696\\/orders\\/123456abcd\\/authenticate?key=abcdefg", + "presentment_currency": "COP", + "total_line_items_price_set": { + "shop_money": { + "amount": "129900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129900.00", + "currency_code": "COP" + } + }, + "total_discounts_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "total_shipping_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "subtotal_price_set": { + "shop_money": { + "amount": "129895.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129895.00", + "currency_code": "COP" + } + }, + "total_price_set": { + "shop_money": { + "amount": "129905.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129905.00", + "currency_code": "COP" + } + }, + "total_tax_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "line_items": [{ + "id": 866550311766439020, + "variant_id": 28754615959616, + "title": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "quantity": 1, + "sku": "042GL20423", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 3739133018176, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "70000.00", + "total_discount": "0.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "70000.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "70000.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/866550311766439020", + "tax_lines": [] + }, { + "id": 141249953214522974, + "variant_id": 39684515627163, + "title": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "quantity": 1, + "sku": "FXXI0037", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 6665708863643, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "59900.00", + "total_discount": "5.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "59900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "59900.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "discount_allocations": [{ + "amount": "5.00", + "discount_application_index": 0, + "amount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + } + }], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/141249953214522974", + "tax_lines": [] + }], + "fulfillments": [], + "refunds": [], + "total_tip_received": "0.0", + "original_total_duties_set": null, + "current_total_duties_set": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Order\\/820982911946154508", + "shipping_lines": [{ + "id": 271878346596884015, + "title": "Generic Shipping", + "price": "10.00", + "code": null, + "source": "shopify", + "phone": null, + "requested_fulfillment_service_id": null, + "delivery_category": null, + "carrier_identifier": null, + "discounted_price": "10.00", + "price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discounted_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "tax_lines": [] + }], + "billing_address": { + "first_name": "Bob", + "address1": "123 Billing Street", + "phone": "555-555-BILL", + "city": "Billtown", + "zip": "K2P0B0", + "province": "Kentucky", + "country": "United States", + "last_name": "Biller", + "address2": null, + "company": "My Company", + "latitude": null, + "longitude": null, + "name": "Bob Biller", + "country_code": "US", + "province_code": "KY" + }, + "shipping_address": { + "first_name": "Steve", + "address1": "123 Shipping Street", + "phone": "555-555-SHIP", + "city": "Shippington", + "zip": "40003", + "province": "Kentucky", + "country": "United States", + "last_name": "Shipper", + "address2": null, + "company": "Shipping Company", + "latitude": null, + "longitude": null, + "name": "Steve Shipper", + "country_code": "US", + "province_code": "KY" + }, + "customer": { + "id": 115310627314723954, + "email": "john@test.com", + "accepts_marketing": false, + "created_at": null, + "updated_at": null, + "first_name": "John", + "last_name": "Smith", + "orders_count": 0, + "state": "disabled", + "total_spent": "0.00", + "last_order_id": null, + "note": null, + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": null, + "tags": "", + "last_order_name": null, + "currency": "COP", + "accepts_marketing_updated_at": null, + "marketing_opt_in_level": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Customer\\/115310627314723954", + "default_address": { + "id": 715243470612851245, + "customer_id": 115310627314723954, + "first_name": null, + "last_name": null, + "company": null, + "address1": "123 Elm St.", + "address2": null, + "city": "Ottawa", + "province": "Ontario", + "country": "Canada", + "zip": "K2H7A8", + "phone": "123-123-1234", + "name": "", + "province_code": "ON", + "country_code": "CA", + "country_name": "Canada", + "default": true + } + } +} diff --git a/order_updated.json b/order_updated.json new file mode 100644 index 0000000..28983b9 --- /dev/null +++ b/order_updated.json @@ -0,0 +1,349 @@ +{ + "id": 820982911946154508, + "email": "jon@doe.ca", + "closed_at": null, + "created_at": "2021-04-23T16:32:59-05:00", + "updated_at": "2021-04-23T16:32:59-05:00", + "number": 234, + "note": null, + "token": "123456abcd", + "gateway": null, + "test": true, + "total_price": "129905.00", + "subtotal_price": "129895.00", + "total_weight": 0, + "total_tax": "0.00", + "taxes_included": false, + "currency": "COP", + "financial_status": "voided", + "confirmed": false, + "total_discounts": "5.00", + "total_line_items_price": "129900.00", + "cart_token": null, + "buyer_accepts_marketing": true, + "name": "#9999", + "referring_site": null, + "landing_site": null, + "cancelled_at": "2021-04-23T16:32:59-05:00", + "cancel_reason": "customer", + "total_price_usd": null, + "checkout_token": null, + "reference": null, + "user_id": null, + "location_id": null, + "source_identifier": null, + "source_url": null, + "processed_at": null, + "device_id": null, + "phone": null, + "customer_locale": "es", + "app_id": null, + "browser_ip": null, + "landing_site_ref": null, + "order_number": 1234, + "discount_applications": [{ + "type": "manual", + "value": "5.0", + "value_type": "fixed_amount", + "allocation_method": "across", + "target_selection": "explicit", + "target_type": "line_item", + "description": "Discount", + "title": "Discount" + }], + "discount_codes": [], + "note_attributes": [], + "payment_gateway_names": ["visa", "bogus"], + "processing_method": "", + "checkout_id": null, + "source_name": "web", + "fulfillment_status": "pending", + "tax_lines": [], + "tags": "", + "contact_email": "jon@doe.ca", + "order_status_url": "https:\\/\\/www.lanch.co\\/13526597696\\/orders\\/123456abcd\\/authenticate?key=abcdefg", + "presentment_currency": "COP", + "total_line_items_price_set": { + "shop_money": { + "amount": "129900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129900.00", + "currency_code": "COP" + } + }, + "total_discounts_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "total_shipping_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "subtotal_price_set": { + "shop_money": { + "amount": "129895.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129895.00", + "currency_code": "COP" + } + }, + "total_price_set": { + "shop_money": { + "amount": "129905.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "129905.00", + "currency_code": "COP" + } + }, + "total_tax_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "line_items": [{ + "id": 866550311766439020, + "variant_id": 28754615959616, + "title": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "quantity": 1, + "sku": "042GL20423", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 3739133018176, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Vidrio Templado Spigen Glas.tR Slim HD Apple iPhone 8 \\/ 7", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "70000.00", + "total_discount": "0.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "70000.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "70000.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "0.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "0.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/866550311766439020", + "tax_lines": [] + }, { + "id": 141249953214522974, + "variant_id": 39684515627163, + "title": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "quantity": 1, + "sku": "FXXI0037", + "variant_title": null, + "vendor": null, + "fulfillment_service": "manual", + "product_id": 6665708863643, + "requires_shipping": true, + "taxable": true, + "gift_card": false, + "name": "Estuche Ringke Fusion X Xiaomi Redmi Note 10 Verde", + "variant_inventory_management": "shopify", + "properties": [], + "product_exists": true, + "fulfillable_quantity": 1, + "grams": 0, + "price": "59900.00", + "total_discount": "5.00", + "fulfillment_status": null, + "price_set": { + "shop_money": { + "amount": "59900.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "59900.00", + "currency_code": "COP" + } + }, + "total_discount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + }, + "discount_allocations": [{ + "amount": "5.00", + "discount_application_index": 0, + "amount_set": { + "shop_money": { + "amount": "5.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "5.00", + "currency_code": "COP" + } + } + }], + "duties": [], + "admin_graphql_api_id": "gid:\\/\\/shopify\\/LineItem\\/141249953214522974", + "tax_lines": [] + }], + "fulfillments": [], + "refunds": [], + "total_tip_received": "0.0", + "original_total_duties_set": null, + "current_total_duties_set": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Order\\/820982911946154508", + "shipping_lines": [{ + "id": 271878346596884015, + "title": "Generic Shipping", + "price": "10.00", + "code": null, + "source": "shopify", + "phone": null, + "requested_fulfillment_service_id": null, + "delivery_category": null, + "carrier_identifier": null, + "discounted_price": "10.00", + "price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discounted_price_set": { + "shop_money": { + "amount": "10.00", + "currency_code": "COP" + }, + "presentment_money": { + "amount": "10.00", + "currency_code": "COP" + } + }, + "discount_allocations": [], + "tax_lines": [] + }], + "billing_address": { + "first_name": "Bob", + "address1": "123 Billing Street", + "phone": "555-555-BILL", + "city": "Billtown", + "zip": "K2P0B0", + "province": "Kentucky", + "country": "United States", + "last_name": "Biller", + "address2": null, + "company": "My Company", + "latitude": null, + "longitude": null, + "name": "Bob Biller", + "country_code": "US", + "province_code": "KY" + }, + "shipping_address": { + "first_name": "Steve", + "address1": "123 Shipping Street", + "phone": "555-555-SHIP", + "city": "Shippington", + "zip": "40003", + "province": "Kentucky", + "country": "United States", + "last_name": "Shipper", + "address2": null, + "company": "Shipping Company", + "latitude": null, + "longitude": null, + "name": "Steve Shipper", + "country_code": "US", + "province_code": "KY" + }, + "customer": { + "id": 115310627314723954, + "email": "john@test.com", + "accepts_marketing": false, + "created_at": null, + "updated_at": null, + "first_name": "John", + "last_name": "Smith", + "orders_count": 0, + "state": "disabled", + "total_spent": "0.00", + "last_order_id": null, + "note": null, + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": null, + "tags": "", + "last_order_name": null, + "currency": "COP", + "accepts_marketing_updated_at": null, + "marketing_opt_in_level": null, + "admin_graphql_api_id": "gid:\\/\\/shopify\\/Customer\\/115310627314723954", + "default_address": { + "id": 715243470612851245, + "customer_id": 115310627314723954, + "first_name": null, + "last_name": null, + "company": null, + "address1": "123 Elm St.", + "address2": null, + "city": "Ottawa", + "province": "Ontario", + "country": "Canada", + "zip": "K2H7A8", + "phone": "123-123-1234", + "name": "", + "province_code": "ON", + "country_code": "CA", + "country_name": "Canada", + "default": true + } + } +} diff --git a/shopify.py b/shopify.py index da96fd9..8903eab 100644 --- a/shopify.py +++ b/shopify.py @@ -125,16 +125,6 @@ class Shopify(SaleWebChannel): }]) return party - # def get_shipment_api(self, shipment_id): - # if not shipment_id: - # return None - # # URI = 'https://%s:%s@%s/admin/api/2020-10/orders.json?ids=%s' % ( - # # self.api_key, self.password_api, self.host_name, order_id) - # URI = 'https://api.mercadolibre.com/shipments/%s?access_token=%s' % ( - # shipment_id, self.access_token) - # res = self.get_response(URI) - # return res.json() - def _return_sale(self, sale): pool = Pool() Sale = pool.get('sale.sale') @@ -253,8 +243,6 @@ class Shopify(SaleWebChannel): description = '' if not products: products = self._create_product(codes, line) - # self.raise_user_error('product_not_found') - # return False for product in products: Tax = _pool.get('account.tax') un_price = Tax.reverse_compute((Decimal(line['price']) - discount), @@ -292,19 +280,10 @@ class Shopify(SaleWebChannel): sale.state = 'cancel' else: Sale.quote([sale]) - sale.state = 'confirmed' print('*******************', sale.state ) sale.save() - # if sale_['fulfillment_status'] in ['fulfilled']: - # self._finish_sale(sale) return sale - # def cancel_sales(self, sales, pack_id=None): - # Sale = Pool().get('sale.sale') - # for sale in sales: - # sale.state = 'cancel' - # sale.save() - @classmethod def get_response(cls, URI, params={}): response = requests.get(URI, headers=HEADERS, params=urlencode(params)) @@ -323,23 +302,39 @@ class Shopify(SaleWebChannel): @classmethod def request_api(cls, data, header): - pool = Pool() - channel = cls._get_channel() response = {'status': 'error', 'msg': 'Fail in process !!!'} + channel = cls._get_channel() if not channel: return response if header.count('create'): - order_id = data.get('id') - URI = 'https://%s:%s@%s/admin/api/2020-10/orders.json?status=any&ids=%s' % ( - channel.api_key, channel.password_api, channel.host_name, order_id) - result = cls.get_response(URI).json() - res = channel._create_sale(result['orders'][0]) + res = channel._create_sale(data) if res: - response = { - 'status': 'ok', - 'msg': 'Successfull process !!!' - } - if header.count('fulfilled'): + response = {'status': 'ok', 'msg': 'Successfull create sale !!!'} + elif header.count('fulfilled'): + cls.order_fulfilled(data) + response = {'status': 'ok', 'msg': 'Successfull process sale !!!'} + elif header.count('paid'): + pass + elif header.count('updated'): + pass + elif header.coun('cancelled'): + cls.order_cancelled(data) + response = {'status': 'ok', 'msg': 'Successfull cancel sale !!!'} + return response + + @classmethod + def order_cancelled(cls, data): + order_id = data.get('id') + Sale = Pool().get('sale.sale') + sales = Sale.search([ + ('reference', '=', str(order_id)) + ]) + if not sales: + return response + Sale.cancel(sales) + + @classmethod + def order_fulfilled(cls, data): order_id = data.get('id') Sale = Pool().get('sale.sale') sales = Sale.search([ @@ -351,6 +346,8 @@ class Shopify(SaleWebChannel): sale = sales[0] if sale.invoices: return response + else: + Sale.confirm([sales]) if len(sales) > 1: # channel.upload_note(sale, 'Error, al generar factura orden duplicada') @@ -362,78 +359,3 @@ class Shopify(SaleWebChannel): 'comment': 'GUIA DE ENVIO NO. ' + data['fulfillments'][0]['tracking_number'], 'tracking_number': data['fulfillments'][0]['tracking_number'] }) - try: - channel._finish_sale(sale) - except: - pass - # channel.upload_note(sale, 'Error al finalizar factura') - response = {'status': 'ok', 'msg': 'Successfull process !!!'} - return response - - def _finish_sale(self, sale, type='invoice'): - ctx = self._get_context() - pool = Pool() - Sale = pool.get('sale.sale') - Invoice = pool.get('account.invoice') - Date = pool.get('ir.date') - with Transaction().set_context(ctx): - Sale.process([sale]) - # if not sale.invoices: - # return - # invoice = sale.invoices[0] - # invoice.invoice_date = Date.today() - # # if type == 'return': - # # sale_origin = sale.origin - # # if sale_origin.invoices: - # # inv_origin = sale_origin.invoices[0] - # # invoice.credit_note_concept = '2' - # # invoice.original_invoice = inv_origin.id - # invoice.save() - # Invoice.validate_invoice([invoice]) - # if invoice.invoice_type not in ('C', 'P', 'M'): - # try: - # invoice.submit([invoice]) - # if not invoice.cufe: - # return - # except: - # self.upload_note(sale, 'Error de envio DIAN') - # Invoice.post([invoice]) - # self.upload_note(sale, 'Factura generada') - # self.upload_invoice(sale) - - # def upload_invoice(self, sale): - # if not sale.reference or not sale.invoices: - # return - # - # invoice = sale.invoices[0] - # pack_id = sale.reference - # if sale.pack_id: - # pack_id = sale.pack_id - # URI = 'https://api.mercadolibre.com/packs/%s/fiscal_documents?access_token=%s' % ( - # pack_id, self.access_token) - # if sale.uploaded_invoice: - # response = requests.delete(URI) - # - # report = self.render_report(invoice) - # file = {"fiscal_document": report} - # response = requests.post(URI, files=file) - # print(response.status_code) - # message = 'Error al subir factura' - # if response.status_code in [200, 201, 202]: - # res = response.json() - # upload_ids = 'Upload ids: ' + ', '.join(list(res['ids'])) - # sale.write([sale], { - # 'uploaded_invoice': True, - # 'document_invoice': upload_ids, - # }) - # message = 'Factura Cargada exitosamente' - # self.upload_note(sale, message) - # - # def upload_note(self, sale, message): - # URI = 'https://%s:%s@%s/admin/api/2020-10/%s.json?' % ( - # self.api_key, self.password_api, self.host_name, sale.reference) - # params = {"id": sale.reference, "note": message} - # request = json.dumps(params) - # response = requests.put(URI, headers=HEADERS, data=request) - # if not response.status_code in [200, 201, 202]: - # self.send_mail_notification('error al crear nota en orden ' + sale.reference)