# main.py
from datetime import datetime, timedelta
from ottimate.catalog.types.catalog_allowance_bulk_create_request_allowances_item import CatalogAllowanceBulkCreateRequestAllowancesItem
start_date = datetime.now()
allowances = [
CatalogAllowanceBulkCreateRequestAllowancesItem(
catalog_entry_id=catalog_entry_id,
amount=5.00,
start_date=start_date,
reference_id=f"bulk-allow-1-{time_now}"
),
CatalogAllowanceBulkCreateRequestAllowancesItem(
catalog_entry_id=catalog_entry_id,
amount=3.00,
start_date=start_date + timedelta(days=30),
reference_id=f"bulk-allow-2-{time_now}"
),
]
bulk_response = client.catalog.post_catalog_allowances_bulk(
ottimate_company_id=ottimate_company_id,
allowances=allowances
)
print(f"Bulk created {bulk_response.success_count} catalog allowances.")
if hasattr(bulk_response, "created") and bulk_response.created:
print("Created allowances:")
for allowance in bulk_response.created:
print(f" - ID: {allowance.get('id')}, Catalog Entry: {allowance.get('catalog_entry_id')}, Amount: {allowance.get('amount')}")
if hasattr(bulk_response, "updated") and bulk_response.updated:
print("Updated allowances:")
for allowance in bulk_response.updated:
print(f" - ID: {allowance.get('id')}, Catalog Entry: {allowance.get('catalog_entry_id')}, Amount: {allowance.get('amount')}")
if hasattr(bulk_response, "errors") and bulk_response.errors:
print("Failed allowances:")
for error in bulk_response.errors:
print(f" - Error: {error}")