| Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
| POST | /voss/usage/{Id}/termination | Create voss usage termination | Add new product to company invoicing. Sends that product to VOSS System. |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SubscriptionItemTerminationReasonDto:
reason_id: Optional[str] = None
reason_name: Optional[str] = None
reason_external_id: Optional[str] = None
sub_reason_id: Optional[str] = None
sub_reason_name: Optional[str] = None
sub_reason_external_id: Optional[str] = None
comment: Optional[str] = None
class UsageBehaviourEnum(str, Enum):
FULL = 'Full'
NONE = 'None'
class CreditKindEnum(str, Enum):
NORMAL = 'Normal'
INTERNAL = 'Internal'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UsageCreditOptionsDto:
usage_behaviour: Optional[UsageBehaviourEnum] = None
credit_kind: Optional[CreditKindEnum] = None
class ProductTypeEnum(str, Enum):
MAIN = 'Main'
ADDON = 'Addon'
LICENSE = 'License'
USAGE = 'Usage'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerBalanceChangeItemDto:
product_type: Optional[ProductTypeEnum] = None
id: Optional[str] = None
name: Optional[str] = None
product_group_id: Optional[str] = None
product_group_name: Optional[str] = None
quantity: float = 0.0
amount: float = 0.0
discount_amount: float = 0.0
total_amount: float = 0.0
invoice_recipient_customer_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerBalanceChangeDto:
items: List[CustomerBalanceChangeItemDto] = field(default_factory=list)
total_amount: float = 0.0
total_discount_amount: float = 0.0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateUsageTerminationResult:
scheduled_date: datetime.datetime = datetime.datetime(1, 1, 1)
reason: Optional[SubscriptionItemTerminationReasonDto] = None
credit_options: Optional[UsageCreditOptionsDto] = None
customer_balance_change: Optional[CustomerBalanceChangeDto] = None
# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateVossUsageTermination:
# @ApiMember(Description="The company id", IsRequired=true)
company_id: Optional[str] = None
"""
The company id
"""
# @ApiMember(Description="Usage Id", IsRequired=true)
id: Optional[str] = None
"""
Usage Id
"""
invoice_line_texts: List[str] = field(default_factory=list)
termination_reason_comment: Optional[str] = None
termination_reason_id: Optional[str] = None
# @ApiMember(Description="Credit behaviour: <br /> 1. Full - usage will be credited in full <br /> 2. None - no credit will be created", IsRequired=true)
behaviour: Optional[UsageBehaviourEnum] = None
"""
Credit behaviour: <br /> 1. Full - usage will be credited in full <br /> 2. None - no credit will be created
"""
# @ApiMember(Description="Credit kind: <br /> 1. Normal - default credit type <br /> 2. Internal - corresponding credit will be marked as internal in invoice file line", IsRequired=true)
credit_kind: Optional[CreditKindEnum] = None
"""
Credit kind: <br /> 1. Normal - default credit type <br /> 2. Internal - corresponding credit will be marked as internal in invoice file line
"""
Python CreateVossUsageTermination DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /voss/usage/{Id}/termination HTTP/1.1
Host: api.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Id: String,
InvoiceLineTexts:
[
String
],
TerminationReasonComment: String,
Behaviour: Full,
CreditKind: Normal
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
}