Skip to content

BoQ Builder API Reference

BoQBuilder

BoQBuilder

BoQBuilder(phase='X83', version='3.3')

Programmatic builder for GAEB procurement documents.

Constructs a GAEBDocument from scratch with field validation, Decimal convenience, auto OZ generation, phase-aware rules, and version compatibility checks.

project

project(**kwargs)

Set project-level metadata (AwardInfo fields).

Common fields: no (project_no), name (project_name), currency, client. All AwardInfo fields accepted as kwargs.

add_lot

add_lot(rno, label, **kwargs)

Add a lot to the document.

add_category

add_category(rno, label, **kwargs)

Add a category to the implicit default lot (single-lot shortcut).

If no lots have been added, creates an implicit lot with rno="1".

build

build(strict=False, xsd_dir=None)

Assemble and return the GAEBDocument.

Parameters:

Name Type Description Default
strict bool

If True, raise ValueError on phase/version incompatibilities instead of adding warnings.

False
xsd_dir str | None

If provided, validate the built XML against XSD schemas.

None

Returns:

Type Description
GAEBDocument

A fully constructed GAEBDocument.

LotBuilder

LotBuilder

LotBuilder(rno, label, **kwargs)

Builder for a single lot, returned by BoQBuilder.add_lot().

add_category

add_category(rno, label, **kwargs)

Add a top-level category to this lot.

CategoryBuilder

CategoryBuilder

CategoryBuilder(rno, label, **kwargs)

Builder for a single BoQ category (section), returned by LotBuilder.add_category().

add_item

add_item(oz=None, short_text='', *, qty=None, unit=None, unit_price=None, total_price=None, item_type=NORMAL, **kwargs)

Add an item to this category.

Parameters:

Name Type Description Default
oz str | None

Ordinal number. If None, auto-generated from category rno + sequence.

None
short_text str

Short description text.

''
qty int | float | Decimal | None

Quantity (int/float/Decimal accepted, converted to Decimal).

None
unit str | None

Unit of measurement.

None
unit_price int | float | Decimal | None

Unit price (int/float/Decimal accepted).

None
total_price int | float | Decimal | None

Total price. If None and qty+unit_price are set, auto-computed.

None
item_type ItemType

Item type classification.

NORMAL
**kwargs Any

Any additional Item model field.

{}

Returns:

Type Description
ItemHandle

An ItemHandle for fluent post-construction (long text, attachments).

add_subcategory

add_subcategory(rno, label, **kwargs)

Add a nested subcategory within this category.

ItemHandle

ItemHandle

ItemHandle(item)

Handle returned by CategoryBuilder.add_item() for fluent post-construction.

set_long_text

set_long_text(text)

Set the item's long text from a plain string.

add_attachment

add_attachment(filename, data, mime_type='application/octet-stream')

Add a binary attachment to the item.