Coverage for packages/clopos/src/integrify/clopos/schemas/orders/object.py: 100%

136 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-10-19 02:39 +0000

1from decimal import Decimal 

2from typing import Union 

3 

4from integrify.clopos.schemas.common.object import Service, Timestamp 

5from integrify.clopos.schemas.enums import DiscountType, OrderStatus 

6from integrify.clopos.schemas.products.object import Product 

7from integrify.clopos.schemas.sales.object import PaymentMethod, SaleType 

8from integrify.utils import UnsetField, UnsetOrNoneField 

9from pydantic import BaseModel 

10 

11 

12class ServiceIn(BaseModel): 

13 sale_type_id: int 

14 sale_type_name: str 

15 venue_id: int 

16 venue_name: str 

17 

18 

19class CustomerIn(BaseModel): 

20 id: int 

21 name: str 

22 customer_discount_type: UnsetField[int] = None 

23 phone: UnsetField[str] = None 

24 address: UnsetOrNoneField[str] 

25 

26 

27class ProductIn(BaseModel): 

28 product_id: int 

29 count: int 

30 product_modificators: UnsetOrNoneField[list[dict]] 

31 meta: UnsetOrNoneField[dict] 

32 

33 

34class OrderPayloadIn(BaseModel): 

35 service: ServiceIn 

36 customer: CustomerIn 

37 products: list[ProductIn] 

38 meta: UnsetOrNoneField[dict] 

39 

40 

41class OrderProductProduct(BaseModel): 

42 product: UnsetOrNoneField[Union['Product', list]] 

43 """The product information""" 

44 

45 count: int 

46 """The quantity of the product""" 

47 

48 status: UnsetOrNoneField[str] 

49 """The status of the product (e.g., "Active", "Inactive")""" 

50 

51 product_modificators: UnsetOrNoneField[list[dict]] 

52 """The modificators of the product""" 

53 

54 product_hash: UnsetOrNoneField[str] 

55 """The hash of the product""" 

56 

57 

58class OrderProductMeta(BaseModel): 

59 price: UnsetOrNoneField[Decimal] 

60 """The sales price of the product""" 

61 

62 order_product: OrderProductProduct 

63 """The product information""" 

64 

65 

66class OrderProduct(BaseModel): 

67 product_id: UnsetOrNoneField[int] 

68 """The product ID""" 

69 

70 count: int 

71 """The quantity of the product""" 

72 

73 product_modificators: UnsetOrNoneField[list[dict]] 

74 """The modificators of the product""" 

75 

76 meta: UnsetOrNoneField[OrderProductMeta] 

77 """The product information""" 

78 

79 

80class OrderCustomer(BaseModel): 

81 id: UnsetOrNoneField[int] 

82 """The customer ID""" 

83 

84 name: str 

85 """The name of the customer""" 

86 

87 phone: UnsetOrNoneField[str] 

88 """The phone number of the customer""" 

89 

90 address: UnsetOrNoneField[str] 

91 """The address of the customer""" 

92 

93 customer_discount_type: UnsetOrNoneField[DiscountType] # noqa: F821 

94 """The discount type of the customer""" 

95 

96 

97class OrderPayload(BaseModel): 

98 service: UnsetOrNoneField[Service] 

99 """The sale type of the order""" 

100 

101 customer: UnsetOrNoneField['OrderCustomer'] 

102 """The sale type of the order""" 

103 

104 products: UnsetOrNoneField[list[OrderProduct]] 

105 """The products in the order""" 

106 

107 meta: UnsetOrNoneField[dict] 

108 """The order information""" 

109 

110 customer_id: UnsetOrNoneField[int] 

111 """The customer ID of the order""" 

112 

113 sale_type_id: UnsetOrNoneField[int] 

114 """The sale type ID of the order""" 

115 

116 payload_updated_at: UnsetOrNoneField[str] 

117 """The timestamp of the last update to the payload""" 

118 

119 

120class OrderItem(BaseModel): 

121 id: int 

122 """The order item's identifier""" 

123 

124 product_id: int 

125 """The product ID of the order item""" 

126 

127 quantity: int 

128 """The quantity of the order item""" 

129 

130 unit_price: Decimal 

131 """The sales price of the order item""" 

132 

133 total_price: Decimal 

134 """The total sales price of the order item""" 

135 

136 

137class Order(Timestamp): 

138 id: int 

139 """The unique identifier for the order""" 

140 

141 venue_id: UnsetOrNoneField[int] 

142 """The ID of the venue associated with the order""" 

143 

144 type: UnsetOrNoneField[str] 

145 """The ID of the sale type associated with the order""" 

146 

147 integration: UnsetOrNoneField[str] 

148 """The integration channel associated with the order""" 

149 

150 integration_uuid: UnsetOrNoneField[str] 

151 """The UUID of the integration associated with the order""" 

152 

153 integration_id: UnsetOrNoneField[int] 

154 """The ID of the integration associated with the order""" 

155 

156 customer_ref_id: UnsetOrNoneField[str] 

157 """The reference ID of the customer associated with the order""" 

158 

159 integration_status: UnsetOrNoneField[str] 

160 """The status of the integration associated with the order""" 

161 

162 integration_response: UnsetOrNoneField[str] 

163 """The response from the integration associated with the order""" 

164 

165 customer_id: UnsetOrNoneField[int] 

166 """The ID of the customer associated with the order""" 

167 

168 receive_user_id: UnsetOrNoneField[int] 

169 """The ID of the user who received the order""" 

170 

171 receive_terminal_id: UnsetOrNoneField[int] 

172 """The ID of the terminal where the order was received""" 

173 

174 status: OrderStatus 

175 """Current lifecycle state. accepted orders are sent to the POS""" 

176 

177 payload: OrderPayload 

178 """ Payload of the order""" 

179 

180 receipt_id: UnsetOrNoneField[int] 

181 """Linked open receipt ID once the POS accepts the order""" 

182 

183 payment_status: UnsetOrNoneField[str] 

184 """ Payment state (e.g., pending, paid)""" 

185 

186 total_amount: UnsetOrNoneField[Decimal] 

187 """Order grand total""" 

188 

189 line_items: UnsetOrNoneField[list[OrderItem]] 

190 """Line items of the order""" 

191 

192 sale_type: UnsetOrNoneField[SaleType] 

193 """An object containing details of the associated sale type""" 

194 

195 payment_method_id: UnsetOrNoneField[int] 

196 """The ID of the payment method associated with the order""" 

197 

198 payment_method: UnsetOrNoneField[PaymentMethod] 

199 """An object containing details of the associated payment method""" 

200 

201 properties: UnsetOrNoneField[dict] 

202 """Additional properties of the order"""