Skip to content

Instantly share code, notes, and snippets.

@ToJans
Created August 20, 2025 18:22
Show Gist options
  • Save ToJans/6ac2da6d02e41f0c890d40af0077c074 to your computer and use it in GitHub Desktop.
Save ToJans/6ac2da6d02e41f0c890d40af0077c074 to your computer and use it in GitHub Desktop.

Fence Configurator - Pricing & Quote Rules

Overview

This document describes the business rules that generate quotes and pricing for the fence configurator system. The system calculates prices based on fence specifications, materials, beams, gates, and accessories.

Table of Contents

  1. Fence Types & Heights
  2. Beam Specifications
  3. Pricing Components
  4. Gate Pricing
  5. Calculation Flow
  6. Complete Price Breakdown

Fence Types & Heights

Available Fence Fill Types

Fill Type Description Available Heights (cm) Max Beam Span Options (cm)
Hortaplast Wire mesh fencing 100, 120, 150, 180, 200 200, 245, 290*
Chain-link Chain-link fencing 100, 120, 150, 180, 200, 250, 300 200, 245, 290*
3D Mat 3D panel fencing 100, 120, 150, 170, 200, 240 250 only
Double Bar Mat 6/5/6 panel fencing 100, 120, 140, 160, 180, 200, 240 250 only

*290cm span only available when base height ≤ 30cm

Base Height Restrictions

graph TD
    A[Max Beam Span] --> B{Span Value}
    B -->|200cm| C[Base Heights: 0, 30, 40, 50cm]
    B -->|245cm| D[Base Heights: 0, 30, 40cm]
    B -->|290cm| E[Base Heights: 0, 30cm]
    B -->|250cm| F[Base Height: 0cm only]
Loading

Beam Specifications

Beam Types & Dimensions

Beam Type Shape Diameter/Size When Used
Normal Round 48mm Chain-link/Hortaplast intermediate beams (unless wide enforced)
Normal Round 60mm All other normal beams or when wide enforced
Normal Square 60×60mm 3D Mat or Double Bar Mat
Corner/End Round 60mm At corners and ends
Gate Various - Adjacent to gates

Beam Height Calculation

The beam height is determined by fence height + base height + 60cm (in-ground depth):

Round Beams

  • Normal beams (48mm): 180, 200, 210, 220, 240, 260, 280cm
  • Normal beams (60mm) & End beams: 180, 200, 230, 260, 280, 300, 320, 380, 400cm

Square Beams

  • All square beams: 170, 190, 230, 250, 270, 320cm

Pricing Components

Main BOM (Bill of Materials) Categories

graph LR
    A[Total Quote] --> B[Fence Panels/Mesh]
    A --> C[Beams & Posts]
    A --> D[Gates]
    A --> E[Accessories]
    
    B --> B1[Panel Units]
    B --> B2[Wire Materials]
    
    C --> C1[Main Posts]
    C --> C2[Support Posts]
    
    E --> E1[Caps & Connectors]
    E --> E2[Base Components]
    E --> E3[Wire Accessories]
Loading

Fence Material Calculation

Material Type Unit Calculation Method
3D/Double Bar Mat Panels pieces ceiling(segment_width / (max_beam_span + 5))
Chain-link/Hortaplast 25m rolls segment_width / 100 / 25

Supporting Materials for Chain-link/Hortaplast

Component Quantity Calculation Notes
Tension Wire (spandraad) width × wire_count / 100 / 100 (100m units) 2 wires if height < 180cm, else 3
Binding Wire (binddraad) width / 100 / 100 (100m units) -
Wire Tensioners non_normal_beams × wire_count / 2 -
Tension Bars non_normal_beams pieces Length matches fence height
Tension Bar Holders ceiling(fence_height / 24) × non_normal_beams -
Top Bar (if enabled) width / 600 pieces (6m lengths) Not used with mat panels

Base Components

Component When Added Quantity
Concrete Plinth When base_height > 0 ceiling(width / (max_beam_span + 5)) pieces
Plinth Holders When beam has base 1 per normal beam, 2 per corner beam
Self-drilling Screws With plinth holders 2 per holder

Gate Pricing

Gate Types & Specifications

Gate Type Fill Options Size Format Color Rules
Single Gate Square part, 2D-DS, 3D-M-DS Width × Height RAL color based on style
Double Gate Standard only Width × Height RAL color based on style

Gate Color Mapping

IF fill_type = "2D-DS":
    IF base_color = "7016": use "7030"
    ELSE: use base_color
ELSE:
    IF base_color = "7016": use "9005 (BLACK)"
    ELSE: use mapped_color

Calculation Flow

Step-by-Step Process

flowchart TD
    A[Start: Fence Configuration] --> B[Calculate Segments]
    B --> C[Process Each Segment]
    
    C --> D{Segment > Max Span?}
    D -->|Yes| E[Split into Multiple Parts]
    D -->|No| F[Keep as Single Part]
    
    E --> G[Calculate Materials per Part]
    F --> G
    
    G --> H[Calculate Beams]
    H --> I[Merge Beams at Same Position]
    I --> J[Determine Beam Properties]
    
    J --> K[Add Accessories]
    K --> L[Process Gates]
    L --> M[Calculate Unit Prices]
    
    M --> N[Generate Final BOM]
    N --> O[Calculate Total Quote]
Loading

Beam Merging Rules

When multiple fence segments meet at a point:

  1. Type Priority (highest to lowest):

    • Gate > Corner > End > Normal
  2. Fill Type Priority (highest to lowest):

    • 3D Mat > Double Bar Mat > Chain-link/Hortaplast
  3. Height Calculation:

    • Use maximum height from all connecting segments

Price Calculation Formula

For each BOM item:
    unit_price = lookup from product catalog
    total = ceiling(amount) × unit_price
    
Total Quote = sum of all item totals

Special Rules & Constraints

Automatic Adjustments

Scenario Adjustment
Gate height > fence height Reduce to nearest standard height below fence
Base height incompatible with span Adjust to maximum allowed base height
Top bar with mat panels Automatically disabled

Enforcement Options

Setting Effect
enforceWideIntermediateBeams Forces all normal beams to 60mm diameter
enforceSupportBeams Adds support posts (270cm) at non-normal beam positions

Color & Style Options

Available RAL Colors

RAL Code Name Usage
9005 Black Standard option
6005 Green Standard option
7016 Anthracite Grey Maps to black for most components

Complete Price Breakdown

Full Component List with Calculations

This section provides a comprehensive overview of EVERY component that contributes to the final price, including all small items like screws, wire, caps, and connectors.

A. Fence Materials

Panel-based Fencing (3D Mat & Double Bar Mat)
Article # Item Code Description Calculation Formula Unit When Applied
[LOOKUP] FENCE 3D mat H {height} 3D paneel H {height*10} ceiling(segment_width / (max_beam_span + 5)) pcs 3D Mat fence type
[LOOKUP] FENCE double bar mat H {height} 6/5/6 paneel H {height*10} ceiling(segment_width / (max_beam_span + 5)) pcs Double Bar Mat fence type
Wire-based Fencing (Chain-link & Hortaplast)
Article # Item Code Description Calculation Formula Unit When Applied
[LOOKUP] FENCE chain-link H {height} harmonica {height*10} segment_width / 100 / 25 25m rolls Chain-link fence type
[LOOKUP] FENCE hortaplast H {height} hortaplast {height*10} segment_width / 100 / 25 25m rolls Hortaplast fence type

B. Wire Components (Chain-link/Hortaplast only)

Article # Item Code Description Calculation Formula Unit Details
SD-100 sd spandraad width × wire_count / 100 / 100 100m wire_count = 2 if height < 180cm, else 3
BD-100 bd binddraad width / 100 / 100 100m Used to attach mesh to posts
DS-001 ds draadspanners non_normal_beams × wire_count / 2 pcs For tensioning horizontal wires
SS-{H} ss {height} spanstaaf lengte {height*10} non_normal_beams pcs Length matches fence height
SSH-PVC ssh spanstaaf houder PVC ceiling(fence_height / 24) × non_normal_beams pcs Clips to hold tension bars

C. Beam/Post Components

Main Posts
Article # Item Code Description Calculation Formula Unit When Applied
[LOOKUP] Paal diam {diameter} L {length} Paal diam {diameter} L {length*10} 1 per beam position pcs Round normal beams
[LOOKUP] hoek-/eindpaal L {length} hoek-/eindpaal L {length*10} 1 per beam position pcs Round corner/end beams
[LOOKUP] palen 60x60 L {length} palen 60x60 L {length*10} 1 per beam position pcs Square beams (mat panels)
SP-270 Steunpaal 270 Steunpaal L 2700 non_normal_beams pcs When enforceSupportBeams = true
Post Caps & Accessories
Article # Item Code Description Calculation Formula Unit Beam Conditions
DD-{D} dd {diameter} dop diam {diameter} 1 per normal round beam pcs No top bar
DVK-{D} dvk {diameter} Doorvoerkop {diameter}/42 1 per normal round beam pcs With top bar
ISD-{D} isd {diameter} insteekdop {diameter}x{diameter} 1 per square beam pcs Square beams only
BGL-60 beugel beugel diam 60 1 per corner/end beam pcs Corner/end beams
ED-LIP einddop einddop met lip 2 for corner, 1 for end pcs Corner/end round beams
HLP-001 hlpstksj hulpstukjes 2 per corner beam pcs Corner beams only

D. Base/Foundation Components

Article # Item Code Description Calculation Formula Unit When Applied
[LOOKUP] BASE H {height} W {span} Betonplint {span}x{height}x3,5 ceiling(width / (max_beam_span + 5)) pcs base_height > 0
BPH-{D} bph {diameter} {shape} betonplinthouder diam {diameter} 280 1 per normal, 2 per corner pcs Beams with base, round
BPH-6060 bph 60x60 square betonplinthouder 60x60 1 per normal, 2 per corner pcs Beams with base, square
BPH-U betonplinthouder U-profiel betonplinthouder U-profiel 2 per corner/end beam pcs Corner/end with base
ZBS-38 zbs zelfborende schroef 38mm 2 per plinth holder pcs With plinth holders

E. Top Bar System (Chain-link/Hortaplast only)

Article # Item Code Description Calculation Formula Unit When Applied
BB-6000 bb bovenbuis 6000mm segment_width / 600 pcs topBar = true
BBC-ALU bbc koppelstuk BB ALU max(0, top_tubes - 1) pcs Multiple top tubes

F. Fasteners & Hardware

Article # Item Code Description Calculation Formula Unit When Applied
IBM8-SS ibm8 inox bout M8 Same as einddop count pcs With end caps
IMM8-SS imm8 inox moer M8 Same as einddop count pcs With end caps
ZBS-38 zbs zelfborende schroef 38mm 2 × plinth holders pcs Base installation

G. Gates & Accessories

Article # Gate Type Description Format Components Included
[LOOKUP] Single Gate Tuinpoort enkel {fill} compleet {W}x{H} RAL {color} Complete gate kit with hinges, lock, handles
[LOOKUP] Double Gate Tuinpoort dubbel compleet {W}x{H} RAL {color} Complete double gate kit with all hardware

Price Calculation Example

Let's walk through a complete example for a 10-meter fence section:

Configuration:
- Fence type: Chain-link
- Height: 180cm
- Base height: 30cm  
- Max beam span: 245cm
- Top bar: Yes
- Width: 1000cm (10m)

Component Breakdown:

FENCE MATERIALS:
- Chain-link 180cm: 1000 / 100 / 25 = 0.4 rolls × €X

WIRE COMPONENTS:
- Tension wire: 1000 × 3 / 100 / 100 = 0.3 × 100m × €Y
- Binding wire: 1000 / 100 / 100 = 0.1 × 100m × €Z
- Wire tensioners: 2 × 3 / 2 = 3 pcs × €A
- Tension bars 180cm: 2 pcs × €B
- Tension bar holders: ceiling(180/24) × 2 = 16 pcs × €C

BEAMS (5 positions: 0, 245, 490, 735, 1000cm):
- End posts (2×): 2 × €D
- Normal posts 48mm (3×): 3 × €E
- Round caps 48mm: 3 × €F
- End caps with lip: 2 × €G
- Brackets: 2 × €H
- Bolts & nuts M8: 2 sets × €I

BASE COMPONENTS:
- Concrete plinths 245×30: ceiling(1000/250) = 4 × €J
- Plinth holders: 5 × €K
- Self-drilling screws: 10 × €L

TOP BAR:
- Top tubes 6000mm: 1000/600 = 1.67 ≈ 2 × €M
- Tube connector: 1 × €N

TOTAL = Sum of all components × quantities × unit prices

Price Aggregation Rules

  1. Rounding: All quantities are rounded UP (ceiling function)

  2. Unit conversion:

    • Mesh materials: Convert to 25m roll units
    • Wire: Convert to 100m units
    • All other items: Individual pieces
  3. Color surcharge: Some items may have different prices based on RAL color:

    • Index 0: RAL 9005 (Black)
    • Index 1: RAL 6005 (Green)
    • Index 2: RAL 7016 (Anthracite)
  4. Missing prices: If product not found in catalog, defaults to -10000 (error flag)

Final Price Formula

Total_Quote = Σ(ceiling(item_quantity) × unit_price)

Where:
- item_quantity = calculated based on formulas above
- unit_price = productCatalog[productId].price

Cost Optimization Factors

The system automatically optimizes costs by:

  1. Beam spacing optimization: Uses maximum allowed span to minimize post count
  2. Material batching: Groups similar items for bulk pricing
  3. Automatic adjustments: Reduces gate heights if they exceed fence height
  4. Smart merging: Combines beam requirements at intersection points

Notes for Implementation

  • All measurements are internally stored in centimeters
  • Prices are retrieved from productCatalog using product IDs
  • Missing prices default to -10000 (error indicator)
  • All quantities are rounded up (ceiling function) for ordering
  • The system supports both metric display and internal calculations
  • Product mappings use color index for variant selection
  • BOM items are sorted by product ID for consistent output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment