Spaces:
Sleeping
Sleeping
File size: 8,695 Bytes
f18d2f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
"""
Invoice Pricing Examples - Real-world pricing configurations
Examples showing how to configure different pricing models for projects.
"""
# Example 1: Tiered Pricing (Airtel Customer Service)
airtel_tiered_pricing = {
"title": "Airtel Customer Service 2025",
"project_type": "support",
"service_type": "other",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "tiered",
"currency": "KES",
"apply_per_invoice": True, # Reset count per invoice
"tax_rate": 16, # 16% VAT
"tiers": [
{
"tier_number": 1,
"from_ticket": 1,
"to_ticket": 500,
"rate_per_ticket": 3200,
"description": "First 500 tickets @ KES 3,200"
},
{
"tier_number": 2,
"from_ticket": 501,
"to_ticket": 800,
"rate_per_ticket": 2800,
"description": "Next 300 tickets @ KES 2,800"
},
{
"tier_number": 3,
"from_ticket": 801,
"to_ticket": None, # Unlimited
"rate_per_ticket": 2500,
"description": "All remaining tickets @ KES 2,500"
}
],
"notes": "Airtel customer service project - tiered pricing per invoice"
}
}
# Example 2: Cumulative Tiered Pricing
cumulative_tiered_pricing = {
"title": "Safaricom FTTH Rollout",
"project_type": "installation",
"service_type": "ftth",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "tiered",
"currency": "KES",
"apply_per_invoice": False, # Cumulative across project
"tax_rate": 16,
"tiers": [
{
"tier_number": 1,
"from_ticket": 1,
"to_ticket": 1000,
"rate_per_ticket": 5000,
"description": "First 1,000 installations @ KES 5,000"
},
{
"tier_number": 2,
"from_ticket": 1001,
"to_ticket": 5000,
"rate_per_ticket": 4500,
"description": "Next 4,000 installations @ KES 4,500"
},
{
"tier_number": 3,
"from_ticket": 5001,
"to_ticket": None,
"rate_per_ticket": 4000,
"description": "All remaining @ KES 4,000"
}
],
"notes": "Volume discount - cumulative across entire project"
}
}
# Example 3: Flat Rate Pricing
flat_rate_pricing = {
"title": "Standard FTTH Installations",
"project_type": "installation",
"service_type": "ftth",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "flat_rate",
"currency": "KES",
"rate_per_ticket": 5000,
"tax_rate": 16,
"notes": "Standard installation rate - KES 5,000 per installation"
}
}
# Example 4: Time-Based Pricing (Consultant)
time_based_pricing = {
"title": "Network Consulting Services",
"project_type": "maintenance",
"service_type": "other",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "time_based",
"currency": "USD",
"rate_per_unit": 25,
"rate_period": "hour",
"tax_rate": 0,
"notes": "Consultant hourly rate - USD 25/hour"
}
}
# Example 5: Custom Pricing (Distance-Based)
custom_pricing = {
"title": "Rural FTTH Project",
"project_type": "installation",
"service_type": "ftth",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "custom",
"currency": "KES",
"formula": "base_rate + (distance_km * distance_rate)",
"variables": {
"base_rate": 3000,
"distance_rate": 50
},
"tax_rate": 16,
"notes": "Base rate + KES 50 per km from hub"
}
}
# Example 6: No Pricing Rules (Manual Pricing)
no_pricing_rules = {
"title": "Custom Project",
"project_type": "installation",
"service_type": "ftth",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": None # Manual pricing required
}
# ============================================
# INVOICE GENERATION EXAMPLES
# ============================================
# Example: Generate Invoice with Tiered Pricing
generate_invoice_tiered = {
"project_id": "uuid-project",
"contractor_id": "uuid-contractor",
"client_id": "uuid-client",
"ticket_ids": ["uuid1", "uuid2", "..."], # 750 tickets
"title": "December 2025 Invoice",
"notes": "Monthly invoice for customer service tickets"
}
# Expected Result (750 tickets with Airtel pricing):
# Tier 1: 500 tickets × 3,200 = 1,600,000 KES
# Tier 2: 250 tickets × 2,800 = 700,000 KES
# Subtotal: 2,300,000 KES
# Tax (16%): 368,000 KES
# Total: 2,668,000 KES
# Example: Generate Invoice with Flat Rate
generate_invoice_flat = {
"project_id": "uuid-project",
"contractor_id": "uuid-contractor",
"client_id": "uuid-client",
"ticket_ids": ["uuid1", "uuid2", "..."], # 100 tickets
"title": "January 2025 Installations"
}
# Expected Result (100 tickets @ 5,000):
# Subtotal: 500,000 KES
# Tax (16%): 80,000 KES
# Total: 580,000 KES
# ============================================
# API EXAMPLES
# ============================================
# Create Project with Tiered Pricing
"""
POST /api/v1/projects
Content-Type: application/json
{
"title": "Airtel Customer Service 2025",
"project_type": "support",
"service_type": "other",
"client_id": "uuid-client",
"contractor_id": "uuid-contractor",
"invoice_pricing_rules": {
"pricing_model": "tiered",
"currency": "KES",
"apply_per_invoice": true,
"tax_rate": 16,
"tiers": [
{
"tier_number": 1,
"from_ticket": 1,
"to_ticket": 500,
"rate_per_ticket": 3200,
"description": "First 500 tickets"
},
{
"tier_number": 2,
"from_ticket": 501,
"to_ticket": 800,
"rate_per_ticket": 2800,
"description": "Next 300 tickets"
},
{
"tier_number": 3,
"from_ticket": 801,
"to_ticket": null,
"rate_per_ticket": 2500,
"description": "All remaining"
}
]
}
}
"""
# Generate Invoice (Automatic Pricing)
"""
POST /api/v1/invoices/generate
Content-Type: application/json
{
"project_id": "uuid-project",
"contractor_id": "uuid-contractor",
"client_id": "uuid-client",
"ticket_ids": ["uuid1", "uuid2", ...],
"title": "December 2025 Invoice"
}
Response:
{
"invoice": {
"id": "uuid",
"invoice_number": "INV-AIRTEL-2025-00142",
"subtotal": 2300000.00,
"tax_rate": 16.00,
"tax_amount": 368000.00,
"total_amount": 2668000.00,
"currency": "KES",
"line_items": [
{
"type": "pricing_tier",
"description": "First 500 tickets @ KES 3,200",
"quantity": 500,
"unit_price": 3200.00,
"total": 1600000.00,
"tier_number": 1
},
{
"type": "pricing_tier",
"description": "Next 300 tickets @ KES 2,800",
"quantity": 250,
"unit_price": 2800.00,
"total": 700000.00,
"tier_number": 2
}
],
"additional_metadata": {
"pricing_calculation": {
"pricing_model": "tiered",
"total_tickets": 750,
"tiers_applied": [
{
"tier_number": 1,
"from_ticket": 1,
"to_ticket": 500,
"tickets_in_tier": 500,
"rate_per_ticket": 3200,
"subtotal": 1600000
},
{
"tier_number": 2,
"from_ticket": 501,
"to_ticket": 750,
"tickets_in_tier": 250,
"rate_per_ticket": 2800,
"subtotal": 700000
}
]
}
}
}
}
"""
# Update Project Pricing Rules
"""
PUT /api/v1/projects/{project_id}
Content-Type: application/json
{
"invoice_pricing_rules": {
"pricing_model": "flat_rate",
"currency": "KES",
"rate_per_ticket": 4500,
"tax_rate": 16,
"notes": "Updated to flat rate"
}
}
"""
# Remove Pricing Rules (Switch to Manual)
"""
PUT /api/v1/projects/{project_id}
Content-Type: application/json
{
"invoice_pricing_rules": null
}
"""
|