Update Commercial order billing info
The updateCommercialOrderBillingInformation function updates the billing information for an existing commercial order. This function is crucial for order payment processing, allowing modification of billing addresses, payment methods, and financial details before order completion. It ensures accurate billing and payment processing for B2B transactions.
This function is typically used when billing address changes are required, payment method updates are needed, or when financial department coordination requires billing information modifications.
Process Flow
sequenceDiagram
participant User as User
participant Component as Vue Component
participant UCO as useCommercialOrder
participant Auth as Authentication
participant API as Order API
participant Payment as Payment Service
participant DB as Database
User->>Component: Update Billing Info
Component->>UCO: updateCommercialOrderBillingInformation(params)
UCO->>Auth: ensureAuthenticated()
alt Authentication Valid
Auth-->>UCO: Authenticated
UCO->>API: PUT /api/commercial-orders/{orderId}/billing-information
API->>Payment: Validate Billing Address
Payment-->>API: Address Valid
API->>DB: Update Order Billing Info
DB-->>API: Update Successful
API-->>UCO: Update Response
UCO-->>Component: Success Response
Component-->>User: Confirmation Message
else Authentication Failed
Auth-->>UCO: Authentication Error
UCO-->>Component: Error Response
Component-->>User: Redirect to Login
else Invalid Billing Address
Payment-->>API: Invalid Address
API-->>UCO: 400 Error
UCO-->>Component: Validation Error
Component-->>User: Show Validation Message
else Order Not Modifiable
API-->>UCO: 412 Error
UCO-->>Component: Precondition Failed
Component-->>User: Show Order Status Message
end
Call Parameters
Request Interface
interface UpdateCommercialOrderBillingInformationRequest {
orderId: string;
billingAddressId: string;
}Parameters Detail
| Parameter | Type | Required | Default | Example | Business Impact |
|---|---|---|---|---|---|
orderId | string | ✅ | - | "co-123456" | Identifies the order to update |
billingAddressId | string | ✅ | - | "addr-billing-789" | New billing address for payment processing |
Example Call
const { updateCommercialOrderBillingInformation } = useCommercialOrder();
// Update billing address for an order
const updateResult = await updateCommercialOrderBillingInformation({
orderId: "co-123456",
billingAddressId: "addr-billing-789",
});
console.log("Billing information updated:", updateResult.success);Composable Returns
Response Interface
interface UpdateCommercialOrderBillingInformationResponse {
success: boolean;
order: CommercialOrder;
message: string;
}Response Structure
{
"success": true,
"order": {
"id": "co-123456",
"reference": "CO-2024-001",
"status": "CREATED",
"totalPrice": 1250.99,
"totalPriceWithoutTax": 1042.49,
"totalTaxAmount": 208.5,
"totalShippingFees": 15.0,
"currency": "EUR",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-16T16:30:00Z",
"billingInformation": {
"method": "invoice",
"addressId": "addr-billing-789",
"address": {
"id": "addr-billing-789",
"name": "Acme Corp Finance Dept",
"company": "Acme Corporation",
"street": "789 Finance Boulevard",
"city": "Paris",
"postalCode": "75008",
"country": "France",
"phone": "+33 1 98 76 54 32",
"email": "[email protected]",
"vatNumber": "FR12345678901"
},
"paymentTerms": "NET30",
"purchaseOrderNumber": "PO-2024-001",
"notes": "Updated billing address for finance department"
},
"customFields": [
{
"externalId": "billing-change-reason",
"value": "Finance department relocation",
"type": "text",
"label": "Billing Change Reason"
}
]
},
"message": "Billing information updated successfully"
}Use Cases
1. Corporate Billing Address Changes
Handle billing address updates for corporate accounts:
- Update billing address when finance department relocates
- Change billing contact information for payment processing
- Modify VAT numbers for tax compliance
- Update purchase order references for accounting integration
2. Payment Method Modifications
Enable payment method changes before order completion:
- Switch from credit card to invoice billing
- Update payment terms for B2B transactions
- Modify credit limits and payment conditions
- Handle currency changes for international orders
3. Multi-Entity Billing Management
Support complex billing structures for large organizations:
- Handle subsidiary billing for parent companies
- Manage cost center allocations for departments
- Support split billing for shared services
- Coordinate billing for multi-location orders
4. Compliance and Audit Requirements
Ensure billing compliance and auditability:
- Maintain accurate billing records for audits
- Support regulatory compliance for international trade
- Handle tax jurisdiction changes for billing
- Document billing modifications for compliance tracking
This function provides comprehensive billing information management with proper validation, compliance checking, and payment processing integration.
Updated 3 months ago
