Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/68f068ac-7354-8009-a22d-26b4d7378725
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Các bước chi tiết (theo thứ tự) — làm trực tiếp trên Base === # Chuẩn bị ở bảng <code>ORDER_DETAILS</code> - Nếu chưa có, tạo 1 cột tính Line Cost (chi phí của dòng): - Tên: line_cost (Formula) - Công thức: {unit_cost} '' {quantity} - Ý nghĩa: giá vốn cho mỗi line. - Xác định discount là giá trị tiền (nếu là % thì cần chuyển sang tiền: {unit_price}''{quantity}*{discount_percent}/100). # Tạo Relation (liên kết) - Ở bảng ORDERS, thêm field kiểu Link to another table → link tới ORDER_DETAILS theo order_id. - Nếu ORDER_DETAILS đã có cột order_id dạng văn bản, khi tạo relation bạn chọn mapping bằng order_id. - Tên field gợi ý: order_items (Link to ORDER_DETAILS). - Khi link xong, bật/cho hiển thị các aggregated fields (rollup) cho trường liên quan. # Tạo Rollup fields trong <code>ORDERS</code> (kết quả là tổng theo một đơn) - revenue_total (Rollup on order_items → field: line_total → aggregation: SUM(values)) - Kết quả = tổng tiền bán cho đơn. - cost_total (Rollup on order_items → field: line_cost → aggregation: SUM(values)) - Kết quả = tổng giá vốn cho đơn. - promotion_total (Rollup on order_items → field: discount → aggregation: SUM(values)) - Kết quả = tổng chi phí khuyến mãi/giảm giá (đơn vị tiền). - Nếu bạn có phí vận chuyển hoặc fee khác trên ORDER_DETAILS, tạo rollup tương tự. # Tạo Formula fields để tính lợi nhuận (bằng cách dùng các rollup trên) Lưu ý: công thức dưới đây dùng tên cột như đã tạo — điều chỉnh tên nếu bạn đặt khác. - gross_margin (Formula - Currency) Công thức: ``<code> {revenue_total} - {cost_total} </code>`<code> (Gross = Revenue - Cost) - bonus_15pct (Formula - Currency) — nên trả thưởng chỉ khi gross positive: </code>`<code> IF({gross_margin} > 0, {gross_margin} * 0.15, 0) </code>`<code> (Nếu gross âm thì bonus = 0) - net_margin (Formula - Currency) </code>`<code> {gross_margin} - {promotion_total} - {bonus_15pct} </code>`<code> (Lợi nhuận ròng sau khuyến mãi và thưởng) - profit_loss_status (Formula - Single line / Single select) Có thể là Text formula: </code>`<code> IF({net_margin} > 0, "Profit", "Loss") </code>`<code> (Hoặc muốn phân biệt “Break-even” khi =0: IF({net_margin} > 0, "Profit", IF({net_margin} = 0, "Break-even", "Loss"))) # Kiểm tra logic với ví dụ - Ví dụ 1 đơn: revenue_total = 10,000; cost_total = 6,000; promotion_total = 500 → gross_margin = 4,000 → bonus_15pct = 600 → net_margin = 4,000 - 500 - 600 = 2,900 → Profit # Các lưu ý thực tế - Nếu discount trong ORDER_DETAILS lưu %, trước tiên tạo field discount_amount = {unit_price} '' {quantity} '' {discount_percent} / 100 rồi rollup discount_amount. - Nếu phí (shipping, tax) nằm ở bảng ORDERS (cấp đơn), cộng/trừ trực tiếp trong net_margin. - Nếu có hoa hồng nhân viên, thêm field commission = {net_margin} * commission_rate (tạo sau khi có net_margin). - Nếu muốn hiển thị phần trăm margin: gross_margin_pct = {gross_margin} / {revenue_total} (check chia cho 0).
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)