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
- Vào Data Sources → Create data source, ở ô Type chọn Haravan.
- Điền form:
| Trường | Giá trị |
|---|---|
| Name | Tê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 |
| Description | Mô tả, không bắt buộc |

- 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
- Ở trang chi tiết source, bấm Authorize with Haravan.

- 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. - Haravan hiện danh sách quyền mà Elton xin. Xác nhận để cho Elton truy cập.

- 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.
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_attrong khoảng đã chọn; Refunds và Transactions theo các đơn đó. - Products, Customers, Inventory: bản ghi có
updated_attừ 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.
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ệu | Bảng | Khoá | Cách lấy | Phân vùng (partition) theo ngày |
|---|---|---|---|---|
| Orders | haravan_order | order_id | Đơn có updated_at trong khoảng lấy | created_at |
| Refunds | haravan_refund | refund_id | Theo các đơn của Orders (cần chọn Orders) | created_at |
| Transactions | haravan_transaction | transaction_id | Theo các đơn của Orders (cần chọn Orders) | created_at |
| Products | haravan_product | product_id | Sản phẩm có updated_at từ đầu khoảng lấy | created_at |
| Customers | haravan_customer | customer_id | Khách hàng có updated_at từ đầu khoảng lấy | created_at |
| Inventory | haravan_inventory | id | Tồn kho có updated_at từ đầu khoảng lấy | updated_at |
| Inventory Adjustments | haravan_inventory_adjustment | id | Toàn bộ, mỗi lần chạy | updated_at |
| Inventory Purchase Orders | haravan_inventory_purchase_order | id | Toàn bộ, mỗi lần chạy | updated_at |
| Inventory Purchase Receives | haravan_inventory_purchase_receive | id | Toàn bộ, mỗi lần chạy | updated_at |
| Inventory Transfers | haravan_inventory_transfer | id | Toàn bộ, mỗi lần chạy | updated_at |
| Store Locations | haravan_store_location | location_id | Toàn bộ, mỗi lần chạy | created_at |
| Users | haravan_user | user_id | Toà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ặcARRAY<STRUCT>nếu là danh sách), đọc trực tiếp bằng dấu chấm, ví dụbilling_address.phone, hoặcUNNEST(line_items)rồili.product_id. Đó làline_items,transactions,fulfillments,billing_address,shipping_address,shipping_linescủa đơn hàng;variants,options,imagescủa sản phẩm;addresses,default_addresscủa khách hàng. - Các cột dạng danh sách khác (ví dụ
discount_codes,refunds,line_itemscủ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ùngUNNESTvà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_id | Mã đơn (số), dùng để nối bảng |
name, order_number, number | Tên đơn hiển thị (ví dụ #100123), số đơn |
created_at, updated_at, confirmed_at, closed_at, cancelled_at | Thời điểm tạo, cập nhật, xác nhận, đóng, huỷ |
financial_status | Trạng thái thanh toán, ví dụ paid, pending |
fulfillment_status | Trạng thái giao hàng |
confirmed_status, closed_status, cancelled_status, order_processing_status | Trạng thái xác nhận, đóng, huỷ, xử lý đơn |
cancel_reason | Lý do huỷ |
customer_id, email, contact_email | Khách hàng và email |
currency | Tiền tệ |
total_line_items_price, total_discounts, subtotal_price, total_tax, total_price | Tổng tiền hàng, tổng giảm giá, tạm tính, thuế, tổng tiền đơn |
total_weight | Tổng cân nặng |
gateway, gateway_code | Phương thức thanh toán |
source, source_name | Kênh tạo đơn |
location_id, location_name | Chi nhánh tạo đơn |
assigned_location_id, assigned_location_name, assigned_location_at | Chi nhánh được giao xử lý đơn và thời điểm giao |
user_id, confirm_user | Nhâ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_site | Nguồ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_items | Sản phẩm trong đơn (cột lồng nhau), xem các trường bên dưới |
fulfillments | Cá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) |
transactions | Giao 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_lines | Phí vận chuyển (cột lồng nhau): code, price, source, title |
discount_codes, note_attributes, refunds | Mã giảm giá, thuộc tính ghi chú, các lần hoàn tiền (mảng chuỗi JSON) |
tags, note | Thẻ 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_id | Mã lần hoàn tiền |
order_id | Đơn được hoàn |
created_at | Thời điểm hoàn |
note | Ghi chú |
restock | Có nhập lại hàng vào kho không |
user_id, location_id | Nhân viên và chi nhánh thực hiện |
refund_line_items | Sản phẩm được hoàn (mảng chuỗi JSON, giữ nguyên như Haravan trả về) |
transactions | Giao 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_id | Mã giao dịch |
order_id | Đơn của giao dịch |
amount, currency | Số tiền, tiền tệ |
kind, status | Loại giao dịch và trạng thái |
gateway, is_cod_gateway | Phương thức thanh toán, có phải thu hộ (COD) không |
created_at | Thời điểm giao dịch |
user_id, location_id, device_id | Nhân viên, chi nhánh, thiết bị |
parent_id | Giao 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_details | Mã giao dịch phía Haravan, phía cổng thanh toán, và chi tiết thanh toán |
test | Giao 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_id | Mã sản phẩm, dùng để nối bảng |
title, handle, product_type, vendor, tags | Tên, đường dẫn, loại, nhà cung cấp, thẻ |
created_at, updated_at, published_at, published_scope | Thờ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 |
variants | Biế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… |
options | Thuộ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_id | Mã khách hàng, dùng để nối bảng |
first_name, last_name, email, phone | Thô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, gender | Ngày sinh, giới tính (dạng số) |
created_at, updated_at | Thời điểm tạo, cập nhật |
orders_count, total_spent, total_paid | Số đơ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, note | Nhóm khách hàng, thẻ, ghi chú |
state, verified_email, accepts_marketing | Trạ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 |
|---|---|
id | Mã bản ghi tồn kho (khoá của bảng) |
location_id | Chi nhánh |
product_id, variant_id | Sản phẩm và biến thể |
qty_onhand | Tồn thực tế trong kho |
qty_commited | Đã cam kết cho đơn (đang giữ hàng) |
qty_incoming | Đang về |
qty_available | Có thể bán |
updated_at | Thờ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, name | Mã, tên chi nhánh |
location_type, type, is_primary | Loạ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, zip | Mã địa chỉ |
phone, email | Liê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_id | Mã 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, phone | Thông tin nhân viên |
account_owner | Là chủ cửa hàng |
user_type | Loạ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ảng | Nối với bảng | Điều kiện nối | Quan hệ |
|---|---|---|---|
haravan_order | haravan_customer | customer_id = customer_id | nhiều đơn – 1 khách hàng |
haravan_order | haravan_product | line_items.product_id = product_id (tách line_items bằng UNNEST) | nhiều sản phẩm trong 1 đơn |
haravan_order | haravan_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_order | haravan_refund | order_id = order_id | 1 đơn – nhiều lần hoàn tiền |
haravan_order | haravan_transaction | order_id = order_id | 1 đơn – nhiều giao dịch |
haravan_order | haravan_store_location | location_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_order | haravan_user | user_id = user_id | nhiều đơn – 1 nhân viên |
haravan_customer | haravan_order | last_order_id = order_id | 1 khách hàng – đơn gần nhất |
haravan_inventory | haravan_product | product_id = product_id, và variant_id = variants.id | nhiều dòng tồn – 1 sản phẩm |
haravan_inventory | haravan_store_location | location_id = location_id | nhiều dòng tồn – 1 chi nhánh |
haravan_inventory_adjustment, haravan_inventory_purchase_order, haravan_inventory_purchase_receive | haravan_store_location | location_id = location_id | nhiều phiếu – 1 chi nhánh |
haravan_inventory_purchase_receive | haravan_inventory_purchase_order | ref_purchase_order_id = id | nhiều phiếu nhập – 1 đơn đặt hàng |
haravan_inventory_transfer | haravan_store_location | from_loc_id = location_id, hoặc to_loc_id = location_id | nhiều phiếu – 1 chi nhánh |
haravan_refund, haravan_transaction | haravan_user | user_id = user_id | nhiều – 1 |
Lưu ý khi nối:
- Mã sản phẩm có tên khác nhau:
product_idởharavan_product,haravan_inventoryvà trongline_itemscủa đơn. Mã biến thể làidtrongvariantscủ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ùngfrom_loc_idvà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ỗi | Nguyê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ống | Connection 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ảng | Cá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.