Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify connector should convert prices into numbers #4841

Closed
rohansingh opened this issue Jul 19, 2021 · 2 comments · Fixed by #5244
Closed

Shopify connector should convert prices into numbers #4841

rohansingh opened this issue Jul 19, 2021 · 2 comments · Fixed by #5244
Assignees
Labels
area/connectors Connector related issues lang/python type/enhancement New feature or request

Comments

@rohansingh
Copy link

Tell us about the problem you're trying to solve

Most price-related fields created by the Shopify connector are strings. For example, total_price on orders is a string. This makes it difficult to do simple math or create sales reports.

Describe the solution you’d like

I'd like the Shopify connector to transform price fields into numbers.

Describe the alternative you’ve considered or used

I could write a custom transformation with dbt, but it seems like the Shopify connector should natively do this.

Additional context

Discussion here:
https://airbytehq.slack.com/archives/C01MFR03D5W/p1626731077032400

Shopify's API returns prices as strings, often with a separate field specifying the currency. See fields like total_price and total_tax here:
https://shopify.dev/api/admin/rest/reference/orders/order#properties-2021-07

So it makes sense that the connector treats these as strings. However, it'd be really nice if it could handle the transformation.

Are you willing to submit a PR?

This is a bit beyond me at the moment.

@rohansingh rohansingh added the type/enhancement New feature or request label Jul 19, 2021
@sherifnada sherifnada added area/connectors Connector related issues lang/python labels Jul 19, 2021
@Zirochkaa Zirochkaa self-assigned this Jul 25, 2021
@Zirochkaa
Copy link
Contributor

Zirochkaa commented Jul 26, 2021

Scoping:

  • Look through each stream and change the type of field from "string" to "number" where field is actually a number (4-5 h because, at least for me, Shopify docs are very laggy and slow)
  • Create transform() function and apply it on each record in ShopifyStream.parse_response() and IncrementalShopifyStream.filter_records_newer_than_state() functions (~2h)
  • Check that transform() works for all streams (~1h)

Link to zira.

@vitaliizazmic
Copy link
Contributor

vitaliizazmic commented Aug 3, 2021

I detected next price fields, which should be changed to number:

  1. Abandoned checkouts

    • tax_lines
      • price
    • total_line_items_price
    • total_tax
    • subtotal_price
    • line_items
      • compare_at_price
      • line_price
      • discount_allocations
        • amount
      • tax_lines
        • price
      • price
    • total_discounts
    • shipping_lines
      • price
      • tax_lines
      • price
      • original_shop_price
      • original_shop_markup
    • customer
      • total_spent
    • total_price
  2. Collects

  3. Custom Collections

  4. Customers

    • total_spent
  5. Discount Codes

  6. Draft Orders

    • customer
      • total_spent
    • line_items
      • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • total_discount
      • total_discount_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • tax_lines
        • price
        • price_set
      • shop_money
        - amount
        • presentment_money
          • amount
    • shipping_line
      • tax_lines
        • price
    • price_set
      - shop_money
      - amount
      - presentment_money
      - amount
      • price
    • tax_lines
      • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
    • total_price
  7. Metafields

  8. Order Refunds

    • refund_line_items
      • subtotal_set
        • shop_money
          • amount
        • presentment_money
          • amount
    • total_tax_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_tax
    • line_item
      • price
      • tax_lines
        • price_set
          • shop_money
            • amount
          • presentment_money
            • amount
        • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • pre_tax_price
      • total_discount_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • discount_allocations
        • amount
        • amount_set
          • shop_money
            • amount
          • presentment_money
            • amount
      • pre_tax_price_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • total_discount
  9. Order Risks

    • score - this field has type error
  10. Orders

    • current_subtotal_price
    • current_subtotal_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • current_total_discounts
    • current_total_discounts_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • current_total_duties_set - should be checked type
    • current_total_price
    • current_total_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • current_total_tax
    • current_total_tax_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • original_total_duties_set - should be checked type
    • subtotal_price
    • subtotal_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • tax_lines
      • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
    • total_discounts
    • total_discounts_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_line_items_price
    • total_line_items_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_outstanding
    • total_price
    • total_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_price_usd
    • total_shipping_price_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_tax
    • total_tax_set
      • shop_money
        • amount
      • presentment_money
        • amount
    • total_tip_received
    • customer
      • total_spent
    • fulfillments
      • line_items
        • price
        • price_set
          • shop_money
            • amount
          • presentment_money
            • amount
        • total_discount
        • total_discount_set
          • shop_money
            • amount
          • presentment_money
            • amount
        • tax_lines
          • price
          • price_set
            • shop_money
              • amount
            • presentment_money
              • amount
    • line_items
      • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • total_discount
      • total_discount_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • tax_lines
        • price
        • price_set
          • shop_money
            • amount
          • presentment_money
            • amount
    • shipping_lines
      • discounted_price
      • discounted_price_set
        • shop_money
          • amount
        • presentment_money
          • amount
      • price
      • price_set
        • shop_money
          • amount
        • presentment_money
          • amount
  11. Pages

  12. Price Rules

  13. Products

    • variants
      • price
      • compare_at_price
      • presentment_prices
        • price
          • amount
        • compare_at_price
  14. Transactions

    • amount

vitaliizazmic added a commit that referenced this issue Aug 18, 2021
vitaliizazmic added a commit that referenced this issue Aug 18, 2021
vitaliizazmic added a commit that referenced this issue Sep 7, 2021
vitaliizazmic added a commit that referenced this issue Sep 17, 2021
* Source Shopify #4841 - update schemas, transform root properties

* Source Shopify #4841 - transform nested properties

* Source Shopify #4841 - ignore transforming for null values

* Source Shopify #4841 - improving according to PR review

* Source Shopify #4841 - create transformer

* Source Shopify #4841 - reformat

* Source Shopify #4841 - reformat(fix)

* Source Shopify #4841 - improving extracting schemas type

* Source Shopify #4841 - unit tests for transform solution

* Source Shopify #4841 - reformat

* Source Shopify - fix according to review

* Source Shopify - fix DRY

* Source Shopify - fix orders schema (add type)

* Source Shopify - fixing according to PR review

* Source Shopify - bump version

* Source Shopify - update changelogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues lang/python type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants