Skip to content

Instantly share code, notes, and snippets.

@brian56
Last active October 24, 2025 08:50
Show Gist options
  • Select an option

  • Save brian56/2618c057184a6ca7a9495e4dc474fe90 to your computer and use it in GitHub Desktop.

Select an option

Save brian56/2618c057184a6ca7a9495e4dc474fe90 to your computer and use it in GitHub Desktop.
6. Thay đổi giá trị đất - Thay đổi diện tích tính thuế hoặc đơn giá đất
graph TD
    subgraph "Điều chỉnh HĐ khi thay đổi Giá trị đất (reverse)<br/>"
        direction TB

        %% === INPUT CONTEXTS ===
        subgraph Inputs["Context Inputs"]
            A1["grand_total<br/>Giá trị HĐ hiện tại"]
            A2["discount_input<br/>Chiết khấu thêm"]
            A3["taxable_area<br/>DT tính thuế (m²)"]
            A4["land_unit_value<br/>Đơn giá đất/m²"]
            A5["tax_rate<br/>VAT (%)"]
            A6["maintenance_rate<br/>Tỷ lệ phí bảo trì (%)"]
        end

        %% === STEPS ===
        subgraph Steps["MathJS Computation Steps"]
            B1["land_value = taxable_area * land_unit_value"]
            B2["new_grand_total = grand_total - (discount_input ? discount_input : 0)"]
            B3["base_price_raw = <br/>(new_grand_total +<br/>(tax_rate/100) * land_value)<br/>/ ( 1 + (tax_rate / 100) + (maintenance_rate / 100) )"]
            B4["vat = (base_price_raw - land_value) * (tax_rate / 100)"]
            B5["maintenance_fee = base_price_raw * (maintenance_rate / 100)"]
            B6["grand_total_calc_raw = base_price_raw + vat + maintenance_fee"]
            B7["balancing_delta = new_grand_total - grand_total_calc_raw"]
            B8["base_price = base_price_raw + balancing_delta"]
            B9["grand_total = base_price + vat + maintenance_fee"]
        end

        %% === DEPENDENCIES ===
        A3 --> B1
        A4 --> B1

        A1 --> B2
        A2 --> B2

        B1 --> B3
        B2 --> B3
        A5 --> B3
        A6 --> B3

        B3 --> B4
        B1 --> B4
        A5 --> B4

        B3 --> B5
        A6 --> B5

        B3 --> B6
        B4 --> B6
        B5 --> B6

        B2 --> B7
        B6 --> B7

        B3 --> B8
        B7 --> B8

        B8 --> B9
        B4 --> B9
        B5 --> B9

        %% === OUTPUT ===
        subgraph Output["Final Result"]
            Z1["💰 grand_total<br/>Tổng giá trị HĐ (kết quả)"]
        end

        B9 --> Z1
    end
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment