Skip to main content

Haravan

Elton lấy dữ liệu cửa hàng Haravan qua Haravan Omni API: đơn hàng, hoàn tiền, giao dịch thanh toán, sản phẩm, khách hàng, tồn kho, phiếu kho, chi nhánh và nhân viên. Elton được trao quyền bằng tài khoản Haravan của bạn (OAuth), và chỉ gửi yêu cầu đọc (GET), không tạo hay sửa dữ liệu trên Haravan.

1. Tạo data source và trao quyền​

Bước 1: Tạo data source​

  1. Vào Data Sources → Create data source, ở ô Type chọn Haravan.
  2. Điền form:
TrườngGiá trị
NameTên hiển thị của source, ví dụ Elton Haravan. Nên đặt tên gợi tới cửa hàng Haravan
DescriptionMô tả, không bắt buộc

  1. Bấm Create data source. Elton mở trang chi tiết của source vừa tạo.

Haravan không cần API key hay mật khẩu nhập vào form. Việc trao quyền làm ở bước 2.

Bước 2: Trao quyền cho Elton​

  1. Ở trang chi tiết source, bấm Authorize with Haravan.

  1. Elton chuyển sang trang đăng nhập của Haravan (accounts.haravan.com). Đăng nhập bằng tài khoản Haravan của cửa hàng cần lấy dữ liệu.
  2. Haravan hiện danh sách quyền mà Elton xin. Xác nhận để cho Elton truy cập.

  1. Haravan đưa bạn về trang chi tiết source. Nút đổi thành Re-authorize.

Mỗi source lấy dữ liệu của cửa hàng mà tài khoản đã trao quyền. Muốn lấy cửa hàng khác, bấm Re-authorize và đăng nhập tài khoản của cửa hàng đó, hoặc tạo một source mới (xem lưu ý về tên bảng ở mục 3).

Quyền truy cập Haravan cấp có thời hạn. Khi hết hạn, các lần chạy lỗi Token expired! Please reauthorize. cho đến khi bạn bấm Re-authorize trên trang chi tiết source và làm lại bước 2.

2. Tạo connection​

Khi tạo connection với source là Haravan, phần Source config có:

  • Select 1 or many type of data (bắt buộc, hiện sau khi chọn source Haravan): chọn một hoặc nhiều loại: Orders, Refunds, Transactions, Products, Customers, Inventory, Inventory Adjustments, Inventory Purchase Orders, Inventory Purchase Receives, Inventory Transfers, Store Locations, Users. Mỗi loại là một bảng ở destination (xem mục 3).
  • First run loads from (bắt buộc): ngày bắt đầu lấy dữ liệu ở lần chạy đầu tiên, cho các loại lấy theo ngày. Elton không tự giới hạn ngày bắt đầu.
  • Later runs rescan: các lần chạy sau, Elton lấy từ ngày của lần chạy thành công gần nhất (theo giờ UTC), lùi lại số ngày này: Last 1 day, Last 3 days, Last 7 days hoặc Last 30 days. Để trống thì lùi 1 ngày. Nhờ vậy đơn đã đổi trạng thái (thanh toán, giao hàng, huỷ, hoàn tiền…) vẫn được cập nhật.
warning

Refunds và Transactions chỉ được lấy khi connection chọn cả Orders: Elton lấy hoàn tiền và giao dịch cho từng đơn mà Orders vừa lấy. Chọn Refunds hoặc Transactions mà không chọn Orders thì hai bảng này không có dữ liệu.

Một số loại dữ liệu không theo hai tuỳ chọn ngày ở trên: chúng được lấy toàn bộ mỗi lần chạy. Cột Cách lấy ở mục 3 ghi rõ.

Với kiểu ghi Merge, bản ghi được cập nhật theo khoá của bảng: lấy lại cùng một bản ghi thì dòng cũ được thay, không bị nhân đôi. Với Append, mỗi lần lấy lại thêm một dòng mới.

Full reload lấy lại từ First run loads from. Partial reload lấy lại khoảng ngày bạn chọn:

  • Orders: đơn có updated_at trong khoảng đã chọn; Refunds và Transactions theo các đơn đó.
  • Products, Customers, Inventory: bản ghi có updated_at từ ngày bắt đầu của khoảng đến hiện tại (ngày kết thúc không giới hạn dữ liệu lấy về).
  • Các loại lấy toàn bộ mỗi lần chạy chạy như bình thường.

3. Haravan: dữ liệu được đồng bộ​

Bảng có tên dạng haravan_<loại>, không có hậu tố tên source hay tên cửa hàng. Ví dụ haravan_order.

warning

Mọi source Haravan ghi vào cùng một tên bảng. Nếu hai connection từ hai cửa hàng Haravan khác nhau cùng ghi vào một dataset, dữ liệu hai cửa hàng nằm chung bảng và các bảng không có cột phân biệt cửa hàng. Hãy cho mỗi cửa hàng một dataset riêng ở destination. Nếu phần cài đặt destination của connection (Choose my own settings) có ô Table name suffix, bạn cũng có thể đặt suffix khác nhau cho mỗi cửa hàng: Elton thêm _<suffix> vào cuối tên mọi bảng của connection.

Loại dữ liệuBảngKhoáCách lấyPhân vùng (partition) theo ngày
Ordersharavan_orderorder_idĐơn có updated_at trong khoảng lấycreated_at
Refundsharavan_refundrefund_idTheo các đơn của Orders (cần chọn Orders)created_at
Transactionsharavan_transactiontransaction_idTheo các đơn của Orders (cần chọn Orders)created_at
Productsharavan_productproduct_idSản phẩm có updated_at từ đầu khoảng lấycreated_at
Customersharavan_customercustomer_idKhách hàng có updated_at từ đầu khoảng lấycreated_at
Inventoryharavan_inventoryidTồn kho có updated_at từ đầu khoảng lấyupdated_at
Inventory Adjustmentsharavan_inventory_adjustmentidToàn bộ, mỗi lần chạyupdated_at
Inventory Purchase Ordersharavan_inventory_purchase_orderidToàn bộ, mỗi lần chạyupdated_at
Inventory Purchase Receivesharavan_inventory_purchase_receiveidToàn bộ, mỗi lần chạyupdated_at
Inventory Transfersharavan_inventory_transferidToàn bộ, mỗi lần chạyupdated_at
Store Locationsharavan_store_locationlocation_idToàn bộ, mỗi lần chạycreated_at
Usersharavan_useruser_idToàn bộ, mỗi lần chạy

"Khoảng lấy" là từ First run loads from ở lần chạy đầu, sau đó theo Later runs rescan (xem mục 2).

Cách lưu dữ liệu chung cho các bảng Haravan:

  • Một số cột dạng danh sách hoặc object là cột lồng nhau (trên BigQuery là RECORD, hoặc ARRAY<STRUCT> nếu là danh sách), đọc trực tiếp bằng dấu chấm, ví dụ billing_address.phone, hoặc UNNEST(line_items) rồi li.product_id. Đó là line_items, transactions, fulfillments, billing_address, shipping_address, shipping_lines của đơn hàng; variants, options, images của sản phẩm; addresses, default_address của khách hàng.
  • Các cột dạng danh sách khác (ví dụ discount_codes, refunds, line_items của phiếu kho) được lưu dạng mảng chuỗi (ARRAY<STRING>), mỗi phần tử là một object JSON giữ nguyên như Haravan trả về. Dùng UNNEST và JSON_VALUE để đọc.
  • Cột elton_created_at (thời điểm Elton lấy bản ghi) chỉ được ghi vào BigQuery khi connection dùng kiểu ghi Append. Với Merge (cập nhật theo khoá) và Overwrite, bảng ở BigQuery không có cột này.

Orders​

Bảng haravan_order: mỗi dòng là một đơn hàng. Elton lấy đơn có updated_at trong khoảng lấy, chia thành từng đoạn 7 ngày. Đơn đổi trạng thái sẽ được cập nhật ở lần chạy sau.

CộtÝ nghĩa
order_idMã đơn (số), dùng để nối bảng
name, order_number, numberTên đơn hiển thị (ví dụ #100123), số đơn
created_at, updated_at, confirmed_at, closed_at, cancelled_atThời điểm tạo, cập nhật, xác nhận, đóng, huỷ
financial_statusTrạng thái thanh toán, ví dụ paid, pending
fulfillment_statusTrạng thái giao hàng
confirmed_status, closed_status, cancelled_status, order_processing_statusTrạng thái xác nhận, đóng, huỷ, xử lý đơn
cancel_reasonLý do huỷ
customer_id, email, contact_emailKhách hàng và email
currencyTiền tệ
total_line_items_price, total_discounts, subtotal_price, total_tax, total_priceTổng tiền hàng, tổng giảm giá, tạm tính, thuế, tổng tiền đơn
total_weightTổng cân nặng
gateway, gateway_codePhương thức thanh toán
source, source_nameKênh tạo đơn
location_id, location_nameChi nhánh tạo đơn
assigned_location_id, assigned_location_name, assigned_location_atChi nhánh được giao xử lý đơn và thời điểm giao
user_id, confirm_userNhân viên tạo đơn, nhân viên xác nhận
utm_source, utm_medium, utm_campaign, utm_term, utm_content, landing_site, referring_siteNguồn truy cập của đơn online
ref_order_id, ref_order_number, ref_order_date, prev_order_id, prev_order_number, prev_order_dateĐơn tham chiếu và đơn trước của đơn này, nếu có
line_itemsSản phẩm trong đơn (cột lồng nhau), xem các trường bên dưới
fulfillmentsCác lần giao hàng (cột lồng nhau): đơn vị vận chuyển (tracking_company), mã vận đơn (tracking_number), trạng thái (status, carrier_status_code), tiền thu hộ (cod_amount), phí vận chuyển thực tế (real_shipping_fee), các mốc giao (ready_to_pick_date, picking_date, delivering_date, delivered_date, cancel_date…), địa chỉ nhận, và sản phẩm của lần giao (line_items)
transactionsGiao dịch thanh toán của đơn (cột lồng nhau): transaction_id, amount, kind, status, gateway, created_at…
billing_address, shipping_addressĐịa chỉ thanh toán, giao hàng (cột lồng nhau): name, phone, address1, ward, district, province, country…
shipping_linesPhí vận chuyển (cột lồng nhau): code, price, source, title
discount_codes, note_attributes, refundsMã giảm giá, thuộc tính ghi chú, các lần hoàn tiền (mảng chuỗi JSON)
tags, noteThẻ và ghi chú của đơn

Tất cả cột của haravan_order: order_id, name, number, order_number, processing_method, referring_site, created_at, updated_at, cancel_reason, cancelled_at, cart_token, checkout_token, closed_at, currency, customer_id, email, discount_codes, financial_status, fulfillment_status, tags, gateway, gateway_code, landing_site, landing_site_ref, note, source, source_name, subtotal_price, tax_lines, taxes_included, total_discounts, total_line_items_price, total_price, total_tax, total_weight, note_attributes, confirmed_at, closed_status, cancelled_status, confirmed_status, assigned_location_id, assigned_location_name, assigned_location_at, exported_confirm_at, user_id, device_id, location_id, location_name, ref_order_id, ref_order_date, ref_order_number, utm_source, utm_medium, utm_campaign, utm_term, utm_content, payment_url, contact_email, order_processing_status, prev_order_id, prev_order_number, prev_order_date, redeem_model, confirm_user, line_items, transactions, fulfillments, billing_address, shipping_address, shipping_lines, refunds, elton_created_at

Các trường của mỗi sản phẩm trong line_items: line_item_id, product_id, variant_id, sku, barcode, title, variant_title, name, vendor, type, quantity, fulfillable_quantity, fulfillment_service, fulfillment_status, price, price_original, price_promotion, actual_price, total_discount, applied_discounts (mảng chuỗi JSON), ma_cost_amount, grams, requires_shipping, gift_card, taxable, tax_lines, product_exists, not_allow_promotion, image (src).

Các trường của mỗi lần giao trong fulfillments: fulfillment_id, order_id, created_at, updated_at, receipt, status, tracking_company, tracking_company_code, tracking_numbers, tracking_number, tracking_url, tracking_urls, province, province_code, district, district_code, ward, ward_code, cod_amount, carrier_status_code, carrier_cod_status_code, location_id, location_name, note, carrier_service_package_name, coupon_code, ready_to_pick_date, picking_date, delivering_date, delivered_date, return_date, not_meet_customer_date, waiting_for_return_date, cod_paid_date, cod_receipt_date, cod_pending_date, cod_not_receipt_date, cancel_date, country, country_code, zip_code, city, real_shipping_fee, total_weight, package_length, package_width, package_height, shipping_notes, boxme_servicecode, transport_type, address, sender_phone, sender_name, carrier_service_code, from_longitude, from_latitude, to_longitude, to_latitude, sort_code, is_drop_off, is_insurance, insurance_price, is_open_box, request_id, carrier_options, note_attributes, first_name, last_name, shipping_phone, carrier_id, line_items (line_item_id, product_id, variant_id, sku, title, variant_title, name, vendor, quantity, fulfillable_quantity, fulfillment_service, fulfillment_status, price, grams, requires_shipping, variant_inventory_management, product_exists).

Refunds​

Bảng haravan_refund: mỗi dòng là một lần hoàn tiền của một đơn. Elton gọi API hoàn tiền cho từng đơn mà Orders lấy được trong lần chạy, nên cần chọn cả Orders.

CộtÝ nghĩa
refund_idMã lần hoàn tiền
order_idĐơn được hoàn
created_atThời điểm hoàn
noteGhi chú
restockCó nhập lại hàng vào kho không
user_id, location_idNhân viên và chi nhánh thực hiện
refund_line_itemsSản phẩm được hoàn (mảng chuỗi JSON, giữ nguyên như Haravan trả về)
transactionsGiao dịch hoàn tiền (mảng chuỗi JSON)

Tất cả cột của haravan_refund: refund_id, order_id, created_at, note, restock, user_id, location_id, refund_line_items, transactions, elton_created_at

Transactions​

Bảng haravan_transaction: mỗi dòng là một giao dịch thanh toán của một đơn (thu tiền, hoàn tiền…). Elton gọi API giao dịch cho từng đơn mà Orders lấy được trong lần chạy, nên cần chọn cả Orders. Cột transactions của bảng haravan_order cũng có các giao dịch này.

CộtÝ nghĩa
transaction_idMã giao dịch
order_idĐơn của giao dịch
amount, currencySố tiền, tiền tệ
kind, statusLoại giao dịch và trạng thái
gateway, is_cod_gatewayPhương thức thanh toán, có phải thu hộ (COD) không
created_atThời điểm giao dịch
user_id, location_id, device_idNhân viên, chi nhánh, thiết bị
parent_idGiao dịch gốc (ví dụ của một giao dịch hoàn tiền)
haravan_transaction_id, external_transaction_id, authorization, receipt, payment_detailsMã giao dịch phía Haravan, phía cổng thanh toán, và chi tiết thanh toán
testGiao dịch thử nghiệm

Tất cả cột của haravan_transaction: transaction_id, order_id, amount, authorization, created_at, device_id, gateway, kind, receipt, status, test, user_id, location_id, payment_details, parent_id, currency, haravan_transaction_id, external_transaction_id, send_email, is_cod_gateway, elton_created_at

Products​

Bảng haravan_product: mỗi dòng là một sản phẩm; các biến thể (màu, size…) nằm trong cột variants.

Lần chạy đầu chỉ lấy sản phẩm có updated_at từ First run loads from, nên sản phẩm không thay đổi gì từ trước ngày đó không có trong bảng. Muốn lấy đủ, chọn First run loads from đủ xa rồi chạy Full reload.

CộtÝ nghĩa
product_idMã sản phẩm, dùng để nối bảng
title, handle, product_type, vendor, tagsTên, đường dẫn, loại, nhà cung cấp, thẻ
created_at, updated_at, published_at, published_scopeThời điểm tạo, cập nhật, đăng bán, phạm vi đăng
only_hide_from_list, not_allow_promotionẨn khỏi danh sách, không cho áp khuyến mãi
variantsBiến thể (cột lồng nhau): id, sku, barcode, title, option1, option2, option3, price, compare_at_price, inventory_quantity, inventory_advance (qty_onhand, qty_available, qty_commited, qty_incoming), grams, position, image_id, created_at, updated_at…
optionsThuộc tính biến thể (cột lồng nhau): id, name, position
imagesẢnh (cột lồng nhau): id, src, position, created_at, updated_at

Tất cả cột của haravan_product: product_id, created_at, updated_at, title, handle, product_type, published_at, published_scope, tags, template_suffix, only_hide_from_list, not_allow_promotion, vendor, variants, options, images, elton_created_at

Các trường của mỗi biến thể trong variants: id, created_at, updated_at, barcode, compare_at_price, fulfillment_service, grams, inventory_management, inventory_policy, inventory_quantity, position, price, requires_shipping, sku, taxable, title, image_id, option1, option2, option3, inventory_advance (qty_available, qty_onhand, qty_commited, qty_incoming).

Customers​

Bảng haravan_customer: mỗi dòng là một khách hàng. Như Products, lần chạy đầu chỉ lấy khách hàng có updated_at từ First run loads from.

CộtÝ nghĩa
customer_idMã khách hàng, dùng để nối bảng
first_name, last_name, email, phoneThông tin liên hệ. Trên BigQuery, phone là số nguyên (INTEGER) nên không giữ số 0 ở đầu; phone trong default_address và addresses là chuỗi
birthday, genderNgày sinh, giới tính (dạng số)
created_at, updated_atThời điểm tạo, cập nhật
orders_count, total_spent, total_paidSố đơn, tổng chi tiêu, tổng đã thanh toán
last_order_id, last_order_nameĐơn gần nhất
group_name, tags, noteNhóm khách hàng, thẻ, ghi chú
state, verified_email, accepts_marketingTrạng thái tài khoản, email đã xác minh, đồng ý nhận marketing
default_address, addressesĐịa chỉ mặc định và mọi địa chỉ (cột lồng nhau): name, phone, address1, ward, district, province, country, default…

Tất cả cột của haravan_customer: customer_id, created_at, updated_at, email, phone, first_name, last_name, last_order_id, last_order_name, orders_count, total_spent, total_paid, state, note, tags, group_name, birthday, gender, verified_email, accepts_marketing, addresses, default_address, elton_created_at

Các trường của mỗi địa chỉ (addresses, default_address, và billing_address, shipping_address của đơn hàng): id, name, first_name, last_name, phone, company, address1, address2, ward, ward_code, district, district_code, city, province, province_code, country, country_code, zip, default.

Inventory​

Bảng haravan_inventory: mỗi dòng là số tồn của một biến thể tại một chi nhánh. Mỗi lần chạy, Elton lấy danh sách chi nhánh (trang đầu tiên Haravan trả về) và toàn bộ biến thể sản phẩm, rồi lấy các số tồn có updated_at từ đầu khoảng lấy.

CộtÝ nghĩa
idMã bản ghi tồn kho (khoá của bảng)
location_idChi nhánh
product_id, variant_idSản phẩm và biến thể
qty_onhandTồn thực tế trong kho
qty_commitedĐã cam kết cho đơn (đang giữ hàng)
qty_incomingĐang về
qty_availableCó thể bán
updated_atThời điểm số tồn thay đổi

Với kiểu ghi Merge, bảng giữ số tồn mới nhất của mỗi bản ghi tồn kho (cập nhật theo id), không lưu lịch sử theo ngày.

Tất cả cột của haravan_inventory: id, updated_at, location_id, product_id, variant_id, qty_onhand, qty_commited, qty_incoming, qty_available, elton_created_at

Inventory Adjustments, Purchase Orders, Purchase Receives, Transfers​

Bốn loại phiếu kho, mỗi loại một bảng, lấy toàn bộ mỗi lần chạy (không theo ngày). Sản phẩm của phiếu điều chỉnh, phiếu nhập và phiếu chuyển kho nằm trong line_items (mảng chuỗi JSON giữ nguyên như Haravan trả về). Đơn đặt hàng nhà cung cấp dùng cột line_item (một chuỗi, không phải mảng).

  • haravan_inventory_adjustment: phiếu điều chỉnh tồn kho. Cột chính: id, adjust_number, tran_date, location_id, type, reason, total_quantity, total_cost, note, tags, line_items.
  • haravan_inventory_purchase_order: đơn đặt hàng nhà cung cấp. Cột chính: id, purchase_number, ref_number, status, tran_date, completed_at, closed_at, location_id, supplier (chuỗi JSON), notes, line_item (chuỗi).
  • haravan_inventory_purchase_receive: phiếu nhập hàng. Cột chính: id, receive_number, ref_purchase_order_id (đơn đặt hàng gốc), ref_number, status, received_at, total, total_cost, location_id, location (chuỗi JSON), supplier (chuỗi JSON), notes, tags, line_items.
  • haravan_inventory_transfer: phiếu chuyển kho giữa hai chi nhánh. Cột chính: id, transfer_number, from_loc_id (chi nhánh chuyển), to_loc_id (chi nhánh nhận), status, tran_date, actived_at, received_at, total, reason, created_user, received_user, note, tags, line_items.

Tất cả cột của haravan_inventory_adjustment: id, created_at, updated_at, adjust_number, tran_date, location_id, type, total_quantity, reason, note, total_cost, tags, line_items, elton_created_at

Tất cả cột của haravan_inventory_purchase_order: id, created_at, updated_at, completed_at, closed_at, purchase_number, ref_number, notes, status, tran_date, location_id, supplier, line_item, elton_created_at

Tất cả cột của haravan_inventory_purchase_receive: id, created_at, updated_at, received_at, receive_number, ref_purchase_order_id, ref_number, notes, status, total, total_cost, location_id, tags, supplier, location, line_items, elton_created_at

Tất cả cột của haravan_inventory_transfer: id, created_at, updated_at, actived_at, received_at, transfer_number, from_loc_id, to_loc_id, reason, tran_date, note, total, status, created_user, received_user, tags, line_items, elton_created_at

Store Locations​

Bảng haravan_store_location: mỗi dòng là một chi nhánh (cửa hàng, kho). Lấy toàn bộ mỗi lần chạy. Elton chỉ đọc trang đầu tiên của danh sách chi nhánh mà Haravan trả về.

CộtÝ nghĩa
location_id, nameMã, tên chi nhánh
location_type, type, is_primaryLoại chi nhánh, chi nhánh chính
address1, address2, ward, district, city, province, country, country_nameĐịa chỉ
ward_code, district_code, province_code, country_code, zipMã địa chỉ
phone, emailLiên hệ. Trên BigQuery, phone, zip và ward_code là số nguyên (INTEGER) nên không giữ số 0 ở đầu

Tất cả cột của haravan_store_location: location_id, name, created_at, updated_at, location_type, email, address1, address2, zip, city, province, country, phone, country_code, country_name, province_code, district, district_code, ward, ward_code, is_primary, is_unavailable_quantity, type, elton_created_at

Users​

Bảng haravan_user: mỗi dòng là một nhân viên (tài khoản quản trị) của cửa hàng. Lấy toàn bộ mỗi lần chạy. Elton chỉ đọc trang đầu tiên của danh sách nhân viên mà Haravan trả về.

CộtÝ nghĩa
user_idMã nhân viên, khớp với user_id ở đơn hàng, hoàn tiền, giao dịch
first_name, last_name, email, phoneThông tin nhân viên
account_ownerLà chủ cửa hàng
user_typeLoại tài khoản

Tất cả cột của haravan_user: user_id, account_owner, bio, email, first_name, last_name, im, phone, receive_announcements, url, user_type, elton_created_at

4. Quan hệ giữa các bảng​

Các bảng Haravan nối với nhau qua mã đơn, mã khách hàng, mã sản phẩm, mã biến thể, mã chi nhánh và mã nhân viên. Chỉ nối các bảng của cùng một cửa hàng (xem cảnh báo về tên bảng ở mục 3).

BảngNối với bảngĐiều kiện nốiQuan hệ
haravan_orderharavan_customercustomer_id = customer_idnhiều đơn – 1 khách hàng
haravan_orderharavan_productline_items.product_id = product_id (tách line_items bằng UNNEST)nhiều sản phẩm trong 1 đơn
haravan_orderharavan_product (cột variants)line_items.variant_id = variants.id (tách cả hai)1 dòng sản phẩm – 1 biến thể
haravan_orderharavan_refundorder_id = order_id1 đơn – nhiều lần hoàn tiền
haravan_orderharavan_transactionorder_id = order_id1 đơn – nhiều giao dịch
haravan_orderharavan_store_locationlocation_id = location_id (chi nhánh tạo đơn), hoặc assigned_location_id = location_id (chi nhánh xử lý)nhiều đơn – 1 chi nhánh
haravan_orderharavan_useruser_id = user_idnhiều đơn – 1 nhân viên
haravan_customerharavan_orderlast_order_id = order_id1 khách hàng – đơn gần nhất
haravan_inventoryharavan_productproduct_id = product_id, và variant_id = variants.idnhiều dòng tồn – 1 sản phẩm
haravan_inventoryharavan_store_locationlocation_id = location_idnhiều dòng tồn – 1 chi nhánh
haravan_inventory_adjustment, haravan_inventory_purchase_order, haravan_inventory_purchase_receiveharavan_store_locationlocation_id = location_idnhiều phiếu – 1 chi nhánh
haravan_inventory_purchase_receiveharavan_inventory_purchase_orderref_purchase_order_id = idnhiều phiếu nhập – 1 đơn đặt hàng
haravan_inventory_transferharavan_store_locationfrom_loc_id = location_id, hoặc to_loc_id = location_idnhiều phiếu – 1 chi nhánh
haravan_refund, haravan_transactionharavan_useruser_id = user_idnhiều – 1

Lưu ý khi nối:

  • Mã sản phẩm có tên khác nhau: product_id ở haravan_product, haravan_inventory và trong line_items của đơn. Mã biến thể là id trong variants của sản phẩm, variant_id ở các bảng còn lại.
  • Mã chi nhánh là location_id ở hầu hết các bảng, riêng phiếu chuyển kho dùng from_loc_id và to_loc_id.
  • Ví dụ trên BigQuery, số lượng bán và tiền hàng theo sản phẩm, bỏ đơn đã huỷ:
SELECT p.product_id,
p.title,
SUM(li.quantity) AS quantity,
SUM(li.price * li.quantity) AS amount
FROM `dataset.haravan_order` o,
UNNEST(o.line_items) AS li
JOIN `dataset.haravan_product` p
ON p.product_id = li.product_id
WHERE o.cancelled_at IS NULL
GROUP BY p.product_id, p.title
ORDER BY amount DESC;

5. Lỗi thường gặp​

Khi Haravan trả lỗi, Elton đợi 5 giây và thử lại tối đa 6 lần, sau đó báo lỗi dạng <mã HTTP>: <nội dung Haravan trả về>.

LỗiNguyên nhân và cách xử lý
Token expired! Please reauthorize.Quyền truy cập Haravan đã hết hạn. Bấm Re-authorize ở trang chi tiết source và làm lại bước 2.
Lỗi bắt đầu bằng 401:Source chưa được trao quyền, hoặc quyền đã bị thu hồi trên Haravan. Bấm Authorize with Haravan (hoặc Re-authorize) và làm lại bước 2.
Lỗi bắt đầu bằng 429:Haravan giới hạn số lần gọi API. Elton đã giãn tốc độ gọi và thử lại; chạy lại connection sau, hoặc giảm tần suất chạy.
Bảng haravan_refund hoặc haravan_transaction trốngConnection chưa chọn Orders. Refunds và Transactions lấy theo các đơn của Orders (xem mục 2).
Dữ liệu hai cửa hàng nằm chung bảngCác connection Haravan cùng ghi vào một dataset. Tên bảng Haravan không có hậu tố cửa hàng; hãy dùng dataset riêng cho mỗi cửa hàng (xem mục 3).
Thiếu sản phẩm, khách hàng hoặc đơn cũLần chạy đầu chỉ lấy bản ghi có updated_at từ First run loads from. Sửa ngày này rồi chạy Full reload.
Không thấy ô Select 1 or many type of dataÔ này chỉ hiện sau khi chọn source Haravan cho connection.

Cách tính Billable Pipeline​

Cách tính phí theo số pipeline của từng loại source xem ở đây.