1use serde::{Deserialize, Serialize};
9use uuid::Uuid;
10use chrono::{DateTime, Utc};
11use rust_decimal::Decimal;
12use crate::domain::entity::*;
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
22pub struct PosClosingEntryId(pub Uuid);
23
24impl PosClosingEntryId {
25 pub fn new(id: Uuid) -> Self {
26 Self(id)
27 }
28
29 pub fn into_inner(self) -> Uuid {
30 self.0
31 }
32}
33
34impl From<Uuid> for PosClosingEntryId {
35 fn from(id: Uuid) -> Self {
36 Self(id)
37 }
38}
39
40impl From<PosClosingEntryId> for Uuid {
41 fn from(id: PosClosingEntryId) -> Self {
42 id.0
43 }
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct PosClosingEntryDto {
51 pub id: PosClosingEntryId,
52 pub pos_profile_id: Uuid,
53 pub opening_entry_id: Uuid,
54 pub closed_at: DateTime<Utc>,
55 pub cashier_party_id: Uuid,
56 pub totals_by_method: Option<serde_json::Value>,
57 pub grand_total: Decimal,
58 pub invoice_count: i32,
59 pub difference_total: Decimal,
60 pub status: PosClosingStatus,
61 pub metadata: serde_json::Value,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct PosClosingEntrySummary {
67 pub id: PosClosingEntryId,
68 pub status: PosClosingStatus,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct PosClosingEntryRef {
74 pub id: PosClosingEntryId,
75}
76
77#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
85pub struct PosInvoiceId(pub Uuid);
86
87impl PosInvoiceId {
88 pub fn new(id: Uuid) -> Self {
89 Self(id)
90 }
91
92 pub fn into_inner(self) -> Uuid {
93 self.0
94 }
95}
96
97impl From<Uuid> for PosInvoiceId {
98 fn from(id: Uuid) -> Self {
99 Self(id)
100 }
101}
102
103impl From<PosInvoiceId> for Uuid {
104 fn from(id: PosInvoiceId) -> Self {
105 id.0
106 }
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct PosInvoiceDto {
114 pub id: PosInvoiceId,
115 pub pos_profile_id: Uuid,
116 pub opening_entry_id: Uuid,
117 pub branch_id: Option<Uuid>,
118 pub customer_id: Option<Uuid>,
119 pub pos_table_id: Option<Uuid>,
120 pub receipt_number: String,
121 pub client_uuid: Option<Uuid>,
122 pub posting_at: DateTime<Utc>,
123 pub net_total: Decimal,
124 pub tax_total: Decimal,
125 pub grand_total: Decimal,
126 pub rounding_adjustment: Decimal,
127 pub rounded_total: Decimal,
128 pub paid_total: Decimal,
129 pub change_due: Decimal,
130 pub billing_invoice_id: Option<Uuid>,
131 pub payment_entry_id: Option<Uuid>,
132 pub is_return: bool,
133 pub return_against: Option<Uuid>,
134 pub status: PosInvoiceStatus,
135 pub metadata: serde_json::Value,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140pub struct PosInvoiceSummary {
141 pub id: PosInvoiceId,
142 pub status: PosInvoiceStatus,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147pub struct PosInvoiceRef {
148 pub id: PosInvoiceId,
149}
150
151#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
159pub struct PosInvoiceItemId(pub Uuid);
160
161impl PosInvoiceItemId {
162 pub fn new(id: Uuid) -> Self {
163 Self(id)
164 }
165
166 pub fn into_inner(self) -> Uuid {
167 self.0
168 }
169}
170
171impl From<Uuid> for PosInvoiceItemId {
172 fn from(id: Uuid) -> Self {
173 Self(id)
174 }
175}
176
177impl From<PosInvoiceItemId> for Uuid {
178 fn from(id: PosInvoiceItemId) -> Self {
179 id.0
180 }
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize)]
187pub struct PosInvoiceItemDto {
188 pub id: PosInvoiceItemId,
189 pub pos_invoice_id: Uuid,
190 pub item_id: Uuid,
191 pub description: Option<String>,
192 pub client_uuid: Option<Uuid>,
193 pub course: Option<i32>,
194 pub quantity: Decimal,
195 pub unit_price: Decimal,
196 pub discount_amount: Decimal,
197 pub net_amount: Decimal,
198 pub revenue_account_id: Option<Uuid>,
199 pub metadata: serde_json::Value,
200}
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct PosInvoiceItemSummary {
205 pub id: PosInvoiceItemId,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
210pub struct PosInvoiceItemRef {
211 pub id: PosInvoiceItemId,
212}
213
214#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
222pub struct PosPaymentId(pub Uuid);
223
224impl PosPaymentId {
225 pub fn new(id: Uuid) -> Self {
226 Self(id)
227 }
228
229 pub fn into_inner(self) -> Uuid {
230 self.0
231 }
232}
233
234impl From<Uuid> for PosPaymentId {
235 fn from(id: Uuid) -> Self {
236 Self(id)
237 }
238}
239
240impl From<PosPaymentId> for Uuid {
241 fn from(id: PosPaymentId) -> Self {
242 id.0
243 }
244}
245
246#[derive(Debug, Clone, Serialize, Deserialize)]
250pub struct PosPaymentDto {
251 pub id: PosPaymentId,
252 pub pos_invoice_id: Uuid,
253 pub payment_method: PosPaymentMethod,
254 pub amount: Decimal,
255 pub reference_no: Option<String>,
256 pub client_uuid: Option<Uuid>,
257 pub payment_entry_id: Option<Uuid>,
258 pub metadata: serde_json::Value,
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize)]
263pub struct PosPaymentSummary {
264 pub id: PosPaymentId,
265}
266
267#[derive(Debug, Clone, Serialize, Deserialize)]
269pub struct PosPaymentRef {
270 pub id: PosPaymentId,
271}
272
273#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
281pub struct PosProfileId(pub Uuid);
282
283impl PosProfileId {
284 pub fn new(id: Uuid) -> Self {
285 Self(id)
286 }
287
288 pub fn into_inner(self) -> Uuid {
289 self.0
290 }
291}
292
293impl From<Uuid> for PosProfileId {
294 fn from(id: Uuid) -> Self {
295 Self(id)
296 }
297}
298
299impl From<PosProfileId> for Uuid {
300 fn from(id: PosProfileId) -> Self {
301 id.0
302 }
303}
304
305#[derive(Debug, Clone, Serialize, Deserialize)]
309pub struct PosProfileDto {
310 pub id: PosProfileId,
311 pub branch_id: Option<Uuid>,
312 pub name: String,
313 pub default_customer_id: Option<Uuid>,
314 pub currency: String,
315 pub income_account_id: Option<Uuid>,
316 pub receivable_account_id: Option<Uuid>,
317 pub cash_account_id: Option<Uuid>,
318 pub write_off_account_id: Option<Uuid>,
319 pub tax_account_id: Option<Uuid>,
320 pub tax_rate: Decimal,
321 pub tax_template_ids: Option<serde_json::Value>,
322 pub warehouse_id: Option<Uuid>,
323 pub cogs_account_id: Option<Uuid>,
324 pub inventory_account_id: Option<Uuid>,
325 pub allow_discount: bool,
326 pub cash_rounding_strategy: PosCashRoundingStrategy,
327 pub cash_rounding_unit: Decimal,
328 pub status: PosProfileStatus,
329 pub metadata: serde_json::Value,
330}
331
332#[derive(Debug, Clone, Serialize, Deserialize)]
334pub struct PosProfileSummary {
335 pub id: PosProfileId,
336 pub name: String,
337 pub status: PosProfileStatus,
338}
339
340#[derive(Debug, Clone, Serialize, Deserialize)]
342pub struct PosProfileRef {
343 pub id: PosProfileId,
344}
345
346#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
354pub struct PosOpeningEntryId(pub Uuid);
355
356impl PosOpeningEntryId {
357 pub fn new(id: Uuid) -> Self {
358 Self(id)
359 }
360
361 pub fn into_inner(self) -> Uuid {
362 self.0
363 }
364}
365
366impl From<Uuid> for PosOpeningEntryId {
367 fn from(id: Uuid) -> Self {
368 Self(id)
369 }
370}
371
372impl From<PosOpeningEntryId> for Uuid {
373 fn from(id: PosOpeningEntryId) -> Self {
374 id.0
375 }
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize)]
382pub struct PosOpeningEntryDto {
383 pub id: PosOpeningEntryId,
384 pub pos_profile_id: Uuid,
385 pub branch_id: Option<Uuid>,
386 pub cashier_party_id: Uuid,
387 pub opened_at: DateTime<Utc>,
388 pub opening_balances: Option<serde_json::Value>,
389 pub status: PosSessionStatus,
390 pub metadata: serde_json::Value,
391}
392
393#[derive(Debug, Clone, Serialize, Deserialize)]
395pub struct PosOpeningEntrySummary {
396 pub id: PosOpeningEntryId,
397 pub status: PosSessionStatus,
398}
399
400#[derive(Debug, Clone, Serialize, Deserialize)]
402pub struct PosOpeningEntryRef {
403 pub id: PosOpeningEntryId,
404}
405
406#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
414pub struct PosCashMovementId(pub Uuid);
415
416impl PosCashMovementId {
417 pub fn new(id: Uuid) -> Self {
418 Self(id)
419 }
420
421 pub fn into_inner(self) -> Uuid {
422 self.0
423 }
424}
425
426impl From<Uuid> for PosCashMovementId {
427 fn from(id: Uuid) -> Self {
428 Self(id)
429 }
430}
431
432impl From<PosCashMovementId> for Uuid {
433 fn from(id: PosCashMovementId) -> Self {
434 id.0
435 }
436}
437
438#[derive(Debug, Clone, Serialize, Deserialize)]
442pub struct PosCashMovementDto {
443 pub id: PosCashMovementId,
444 pub pos_profile_id: Uuid,
445 pub opening_entry_id: Uuid,
446 pub cashier_party_id: Uuid,
447 pub movement_type: PosCashMovementType,
448 pub amount: Decimal,
449 pub reason: Option<String>,
450 pub moved_at: DateTime<Utc>,
451 pub metadata: serde_json::Value,
452}
453
454#[derive(Debug, Clone, Serialize, Deserialize)]
456pub struct PosCashMovementSummary {
457 pub id: PosCashMovementId,
458}
459
460#[derive(Debug, Clone, Serialize, Deserialize)]
462pub struct PosCashMovementRef {
463 pub id: PosCashMovementId,
464}
465
466#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
474pub struct PosDiscountId(pub Uuid);
475
476impl PosDiscountId {
477 pub fn new(id: Uuid) -> Self {
478 Self(id)
479 }
480
481 pub fn into_inner(self) -> Uuid {
482 self.0
483 }
484}
485
486impl From<Uuid> for PosDiscountId {
487 fn from(id: Uuid) -> Self {
488 Self(id)
489 }
490}
491
492impl From<PosDiscountId> for Uuid {
493 fn from(id: PosDiscountId) -> Self {
494 id.0
495 }
496}
497
498#[derive(Debug, Clone, Serialize, Deserialize)]
502pub struct PosDiscountDto {
503 pub id: PosDiscountId,
504 pub name: String,
505 pub percentage: Decimal,
506 pub description: Option<String>,
507 pub metadata: serde_json::Value,
508}
509
510#[derive(Debug, Clone, Serialize, Deserialize)]
512pub struct PosDiscountSummary {
513 pub id: PosDiscountId,
514 pub name: String,
515}
516
517#[derive(Debug, Clone, Serialize, Deserialize)]
519pub struct PosDiscountRef {
520 pub id: PosDiscountId,
521}
522
523#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
531pub struct PosManagerPinId(pub Uuid);
532
533impl PosManagerPinId {
534 pub fn new(id: Uuid) -> Self {
535 Self(id)
536 }
537
538 pub fn into_inner(self) -> Uuid {
539 self.0
540 }
541}
542
543impl From<Uuid> for PosManagerPinId {
544 fn from(id: Uuid) -> Self {
545 Self(id)
546 }
547}
548
549impl From<PosManagerPinId> for Uuid {
550 fn from(id: PosManagerPinId) -> Self {
551 id.0
552 }
553}
554
555#[derive(Debug, Clone, Serialize, Deserialize)]
559pub struct PosManagerPinDto {
560 pub id: PosManagerPinId,
561 pub employee_party_id: Uuid,
562 pub pin_hash: String,
563 pub failed_attempts: i32,
564 pub locked_until: Option<DateTime<Utc>>,
565 pub last_attempt_at: Option<DateTime<Utc>>,
566 pub last_attempt_ip: Option<String>,
567 pub metadata: serde_json::Value,
568}
569
570#[derive(Debug, Clone, Serialize, Deserialize)]
572pub struct PosManagerPinSummary {
573 pub id: PosManagerPinId,
574}
575
576#[derive(Debug, Clone, Serialize, Deserialize)]
578pub struct PosManagerPinRef {
579 pub id: PosManagerPinId,
580}
581
582#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
590pub struct PosFloorPlanId(pub Uuid);
591
592impl PosFloorPlanId {
593 pub fn new(id: Uuid) -> Self {
594 Self(id)
595 }
596
597 pub fn into_inner(self) -> Uuid {
598 self.0
599 }
600}
601
602impl From<Uuid> for PosFloorPlanId {
603 fn from(id: Uuid) -> Self {
604 Self(id)
605 }
606}
607
608impl From<PosFloorPlanId> for Uuid {
609 fn from(id: PosFloorPlanId) -> Self {
610 id.0
611 }
612}
613
614#[derive(Debug, Clone, Serialize, Deserialize)]
618pub struct PosFloorPlanDto {
619 pub id: PosFloorPlanId,
620 pub branch_id: Option<Uuid>,
621 pub name: String,
622 pub position: Option<i32>,
623 pub metadata: serde_json::Value,
624}
625
626#[derive(Debug, Clone, Serialize, Deserialize)]
628pub struct PosFloorPlanSummary {
629 pub id: PosFloorPlanId,
630 pub name: String,
631}
632
633#[derive(Debug, Clone, Serialize, Deserialize)]
635pub struct PosFloorPlanRef {
636 pub id: PosFloorPlanId,
637}
638
639#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
647pub struct PosTableId(pub Uuid);
648
649impl PosTableId {
650 pub fn new(id: Uuid) -> Self {
651 Self(id)
652 }
653
654 pub fn into_inner(self) -> Uuid {
655 self.0
656 }
657}
658
659impl From<Uuid> for PosTableId {
660 fn from(id: Uuid) -> Self {
661 Self(id)
662 }
663}
664
665impl From<PosTableId> for Uuid {
666 fn from(id: PosTableId) -> Self {
667 id.0
668 }
669}
670
671#[derive(Debug, Clone, Serialize, Deserialize)]
675pub struct PosTableDto {
676 pub id: PosTableId,
677 pub pos_floor_plan_id: Uuid,
678 pub name: Option<String>,
679 pub seats: Option<i32>,
680 pub shape: Option<String>,
681 pub position: Option<serde_json::Value>,
682 pub metadata: serde_json::Value,
683}
684
685#[derive(Debug, Clone, Serialize, Deserialize)]
687pub struct PosTableSummary {
688 pub id: PosTableId,
689 pub name: Option<String>,
690}
691
692#[derive(Debug, Clone, Serialize, Deserialize)]
694pub struct PosTableRef {
695 pub id: PosTableId,
696}
697
698