POST | /eaccounting/invoice |
---|
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 InvoiceAddress:
corporate_identity_number: Optional[str] = None
invoice_address1: Optional[str] = None
invoice_address2: Optional[str] = None
invoice_city: Optional[str] = None
invoice_postal_code: Optional[str] = None
invoice_country_code: Optional[str] = None
class GreenTechnologyType(str, Enum):
NONE = 'None'
SOLAR_CELL_INSTALLATION = 'SolarCellInstallation'
ELECTRIC_ENERGY_STORAGE_INSTALLATION = 'ElectricEnergyStorageInstallation'
ELECTRIC_VEHICLE_CHARGING_POINT_INSTALLATION = 'ElectricVehicleChargingPointInstallation'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ContributionMargin:
amount: Optional[int] = None
percentage: Optional[int] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceLineQueryResponse:
article_number: Optional[str] = None
article_id: Optional[str] = None
is_service_article: bool = False
amount_no_vat: Decimal = decimal.Decimal(0)
percent_vat: Optional[Decimal] = None
line_number: int = 0
is_text_row: bool = False
text: Optional[str] = None
unit_price: Decimal = decimal.Decimal(0)
unit_abbreviation: Optional[str] = None
unit_abbreviation_english: Optional[str] = None
discount_percentage: Decimal = decimal.Decimal(0)
quantity: float = 0.0
is_work_cost: bool = False
is_vat_free: bool = False
cost_center_item_id1: Optional[str] = None
cost_center_item_id2: Optional[str] = None
cost_center_item_id3: Optional[str] = None
unit_id: Optional[str] = None
project_id: Optional[str] = None
work_cost_type: Optional[int] = None
work_hours: Optional[float] = None
material_costs: Optional[Decimal] = None
green_technology_type: Optional[GreenTechnologyType] = None
contribution_margin: Optional[ContributionMargin] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class VatSpecificationQueryResponse:
amount_invoice_currency: Decimal = decimal.Decimal(0)
vat_amount_invoice_currency: Decimal = decimal.Decimal(0)
vat_percent: Decimal = decimal.Decimal(0)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Person:
ssn: Optional[str] = None
amount: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class EAccountingTermsOfPaymentQueryResponse:
id: Optional[str] = None
name: Optional[str] = None
name_english: Optional[str] = None
number_of_days: int = 0
terms_of_payment_type_id: int = 0
terms_of_payment_type_text: Optional[str] = None
available_for_sales: bool = False
available_for_purchase: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class NoteQueryResponse:
id: Optional[str] = None
text: Optional[str] = None
created_utc: datetime.datetime = datetime.datetime(1, 1, 1)
modified_utc: datetime.datetime = datetime.datetime(1, 1, 1)
class EAccountingInvoiceSendTypes(str, Enum):
NONE = 'None'
AUTO_INVOICE_ELECTRONIC = 'AutoInvoiceElectronic'
AUTO_INVOICE_PRINT = 'AutoInvoicePrint'
AUTO_INVOICE_B2_C = 'AutoInvoiceB2C'
class PaymentStatus(str, Enum):
PAID = 'Paid'
UNPAID = 'Unpaid'
OVERDUE = 'Overdue'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreditedBy:
credit_invoice_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceQueryResponse:
invoice_id: Optional[str] = None
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
total_amount: Decimal = decimal.Decimal(0)
total_vat_amount: Decimal = decimal.Decimal(0)
customer_id: Optional[str] = None
rows: Optional[List[InvoiceLineQueryResponse]] = None
vat_specification: Optional[List[VatSpecificationQueryResponse]] = None
invoice_date: Optional[str] = None
due_date: Optional[str] = None
delivery_date: Optional[datetime.datetime] = None
persons: Optional[List[Person]] = None
invoice_customer_name: Optional[str] = None
invoice_address: Optional[InvoiceAddress] = None
customer_is_private_person: bool = False
terms_of_payment_id: Optional[str] = None
terms_of_payment_data: Optional[EAccountingTermsOfPaymentQueryResponse] = None
customer_email: Optional[str] = None
invoice_number: int = 0
customer_number: Optional[str] = None
notes: Optional[List[NoteQueryResponse]] = None
note_ids: Optional[List[str]] = None
created_utc: datetime.datetime = datetime.datetime(1, 1, 1)
modified_utc: datetime.datetime = datetime.datetime(1, 1, 1)
includes_vat: bool = False
send_type: Optional[EAccountingInvoiceSendTypes] = None
is_sold: bool = False
payment_date: Optional[datetime.datetime] = None
payment_status: Optional[PaymentStatus] = None
payment_status_title: Optional[str] = None
credited_by: Optional[List[CreditedBy]] = None
price_sign: Optional[str] = None
booking_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateInvoiceQueryResponse:
invoice: Optional[InvoiceQueryResponse] = None
invoice_uri: Optional[str] = None
response_status: Optional[ResponseStatus] = None
class RotPropertyTypes(IntEnum):
APARTMENT = 1
PROPERTY = 2
class RotReducedInvoicingTypes(str, Enum):
NORMAL = 'Normal'
ROT = 'Rot'
RUT = 'Rut'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateInvoice(InvoiceAddress, ICompany):
# @ApiMember(Description="The booking id, to be used to create the customer.", IsRequired=true)
booking_id: int = 0
"""
The booking id, to be used to create the customer.
"""
# @ApiMember(Description="The Term of payment Id, to be used to create the invoice.", IsRequired=true)
terms_of_payment_id: Optional[str] = None
"""
The Term of payment Id, to be used to create the invoice.
"""
# @ApiMember(Description="Note id's to add to this invoice")
notes: Optional[List[str]] = None
"""
Note id's to add to this invoice
"""
# @ApiMember(Description="Invoice Customer name")
invoice_customer_name: Optional[str] = None
"""
Invoice Customer name
"""
# @ApiMember(Description="Used for sending the invoice via Auto-invoice Default:None, 0 = None, 1 = AutoInvoiceElectronic, 2 = AutoInvoicePrint, 3 = AutoInvoiceB2C = ['0', '1', '2', '3'].", IsRequired=true)
send_type: Optional[EAccountingInvoiceSendTypes] = None
"""
Used for sending the invoice via Auto-invoice Default:None, 0 = None, 1 = AutoInvoiceElectronic, 2 = AutoInvoicePrint, 3 = AutoInvoiceB2C = ['0', '1', '2', '3'].
"""
# @ApiMember(Description="1 = Apartment, 2 = Property Leave blank or set to null if you do not intend to use ROT or Green Technology functionality.", IsRequired=true)
rot_property_type: Optional[RotPropertyTypes] = None
"""
1 = Apartment, 2 = Property Leave blank or set to null if you do not intend to use ROT or Green Technology functionality.
"""
# @ApiMember(Description="0 = Normal, 1 = Rot, 2 = Rut = ['0', '1', '2']", IsRequired=true)
rot_reduced_invoicing_type: Optional[RotReducedInvoicingTypes] = None
"""
0 = Normal, 1 = Rot, 2 = Rut = ['0', '1', '2']
"""
# @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
company_id: Optional[str] = None
"""
The company id, if empty will use the company id for the user you are logged in with.
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /eaccounting/invoice HTTP/1.1
Host: api.bokamera.se
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"BookingId":0,"Notes":["String"],"InvoiceCustomerName":"String","SendType":"None","RotPropertyType":"0","RotReducedInvoicingType":"Normal","CompanyId":"00000000-0000-0000-0000-000000000000","CorporateIdentityNumber":"String","InvoiceAddress1":"String","InvoiceAddress2":"String","InvoiceCity":"String","InvoicePostalCode":"String","InvoiceCountryCode":"String"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"Invoice":{"TotalAmount":0,"TotalVatAmount":0,"CustomerId":"String","Rows":[{"ArticleNumber":"String","ArticleId":"String","IsServiceArticle":false,"AmountNoVat":0,"PercentVat":0,"LineNumber":0,"IsTextRow":false,"Text":"String","UnitPrice":0,"UnitAbbreviation":"String","UnitAbbreviationEnglish":"String","DiscountPercentage":0,"Quantity":0,"IsWorkCost":false,"IsVatFree":false,"CostCenterItemId1":"String","CostCenterItemId2":"String","CostCenterItemId3":"String","UnitId":"String","ProjectId":"String","WorkCostType":0,"WorkHours":0,"MaterialCosts":0,"GreenTechnologyType":"None","ContributionMargin":{"Amount":0,"Percentage":0}}],"VatSpecification":[{"AmountInvoiceCurrency":0,"VatAmountInvoiceCurrency":0,"VatPercent":0}],"InvoiceDate":"String","DueDate":"String","DeliveryDate":"0001-01-01T00:00:00","Persons":[{"Ssn":"String","Amount":0}],"InvoiceCustomerName":"String","InvoiceAddress":{"CorporateIdentityNumber":"String","InvoiceAddress1":"String","InvoiceAddress2":"String","InvoiceCity":"String","InvoicePostalCode":"String","InvoiceCountryCode":"String"},"CustomerIsPrivatePerson":false,"TermsOfPaymentId":"String","TermsOfPaymentData":{"Id":"String","Name":"String","NameEnglish":"String","NumberOfDays":0,"TermsOfPaymentTypeId":0,"TermsOfPaymentTypeText":"String","AvailableForSales":false,"AvailableForPurchase":false},"CustomerEmail":"String","InvoiceNumber":0,"CustomerNumber":"String","Notes":[{"Id":"String","Text":"String"}],"NoteIds":["String"],"IncludesVat":false,"SendType":"None","IsSold":false,"PaymentDate":"0001-01-01T00:00:00","PaymentStatus":"Paid","PaymentStatusTitle":"String","CreditedBy":[{"CreditInvoiceId":"String"}],"PriceSign":"String","BookingId":"String"},"InvoiceUri":"String","ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}