backbone-pos 0.5.32

Point of sale — cashier session, ticket + multi-tender; orchestrates billing (revenue) + payment (settlement), posts no GL directly
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
//! Public types for Pos module
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! These DTOs are the ONLY types other modules should use.
//! They are decoupled from internal domain entities.

use serde::{Deserialize, Serialize};
use uuid::Uuid;
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use crate::domain::entity::*;

// ============================================================================
// POSCLOSINGENTRY TYPES
// ============================================================================

/// Type-safe ID for PosClosingEntry
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosClosingEntryId(pub Uuid);

impl PosClosingEntryId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosClosingEntryId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosClosingEntryId> for Uuid {
    fn from(id: PosClosingEntryId) -> Self {
        id.0
    }
}

/// Data transfer object for PosClosingEntry
///
/// This is the public representation of PosClosingEntry for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosClosingEntryDto {
    pub id: PosClosingEntryId,
    pub pos_profile_id: Uuid,
    pub opening_entry_id: Uuid,
    pub closed_at: DateTime<Utc>,
    pub cashier_party_id: Uuid,
    pub totals_by_method: Option<serde_json::Value>,
    pub grand_total: Decimal,
    pub invoice_count: i32,
    pub difference_total: Decimal,
    pub status: PosClosingStatus,
    pub metadata: serde_json::Value,
}

/// Summary view of PosClosingEntry for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosClosingEntrySummary {
    pub id: PosClosingEntryId,
    pub status: PosClosingStatus,
}

/// Reference to PosClosingEntry for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosClosingEntryRef {
    pub id: PosClosingEntryId,
}

// ============================================================================
// POSINVOICE TYPES
// ============================================================================

/// Type-safe ID for PosInvoice
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosInvoiceId(pub Uuid);

impl PosInvoiceId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosInvoiceId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosInvoiceId> for Uuid {
    fn from(id: PosInvoiceId) -> Self {
        id.0
    }
}

/// Data transfer object for PosInvoice
///
/// This is the public representation of PosInvoice for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceDto {
    pub id: PosInvoiceId,
    pub pos_profile_id: Uuid,
    pub opening_entry_id: Uuid,
    pub branch_id: Option<Uuid>,
    pub customer_id: Option<Uuid>,
    pub pos_table_id: Option<Uuid>,
    pub receipt_number: String,
    pub client_uuid: Option<Uuid>,
    pub posting_at: DateTime<Utc>,
    pub net_total: Decimal,
    pub tax_total: Decimal,
    pub grand_total: Decimal,
    pub rounding_adjustment: Decimal,
    pub rounded_total: Decimal,
    pub paid_total: Decimal,
    pub change_due: Decimal,
    pub billing_invoice_id: Option<Uuid>,
    pub payment_entry_id: Option<Uuid>,
    pub is_return: bool,
    pub return_against: Option<Uuid>,
    pub status: PosInvoiceStatus,
    pub metadata: serde_json::Value,
}

/// Summary view of PosInvoice for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceSummary {
    pub id: PosInvoiceId,
    pub status: PosInvoiceStatus,
}

/// Reference to PosInvoice for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceRef {
    pub id: PosInvoiceId,
}

// ============================================================================
// POSINVOICEITEM TYPES
// ============================================================================

/// Type-safe ID for PosInvoiceItem
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosInvoiceItemId(pub Uuid);

impl PosInvoiceItemId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosInvoiceItemId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosInvoiceItemId> for Uuid {
    fn from(id: PosInvoiceItemId) -> Self {
        id.0
    }
}

/// Data transfer object for PosInvoiceItem
///
/// This is the public representation of PosInvoiceItem for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceItemDto {
    pub id: PosInvoiceItemId,
    pub pos_invoice_id: Uuid,
    pub item_id: Uuid,
    pub description: Option<String>,
    pub client_uuid: Option<Uuid>,
    pub course: Option<i32>,
    pub quantity: Decimal,
    pub unit_price: Decimal,
    pub discount_amount: Decimal,
    pub net_amount: Decimal,
    pub revenue_account_id: Option<Uuid>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosInvoiceItem for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceItemSummary {
    pub id: PosInvoiceItemId,
}

/// Reference to PosInvoiceItem for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosInvoiceItemRef {
    pub id: PosInvoiceItemId,
}

// ============================================================================
// POSPAYMENT TYPES
// ============================================================================

/// Type-safe ID for PosPayment
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosPaymentId(pub Uuid);

impl PosPaymentId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosPaymentId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosPaymentId> for Uuid {
    fn from(id: PosPaymentId) -> Self {
        id.0
    }
}

/// Data transfer object for PosPayment
///
/// This is the public representation of PosPayment for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosPaymentDto {
    pub id: PosPaymentId,
    pub pos_invoice_id: Uuid,
    pub payment_method: PosPaymentMethod,
    pub amount: Decimal,
    pub reference_no: Option<String>,
    pub client_uuid: Option<Uuid>,
    pub payment_entry_id: Option<Uuid>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosPayment for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosPaymentSummary {
    pub id: PosPaymentId,
}

/// Reference to PosPayment for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosPaymentRef {
    pub id: PosPaymentId,
}

// ============================================================================
// POSPROFILE TYPES
// ============================================================================

/// Type-safe ID for PosProfile
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosProfileId(pub Uuid);

impl PosProfileId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosProfileId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosProfileId> for Uuid {
    fn from(id: PosProfileId) -> Self {
        id.0
    }
}

/// Data transfer object for PosProfile
///
/// This is the public representation of PosProfile for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosProfileDto {
    pub id: PosProfileId,
    pub branch_id: Option<Uuid>,
    pub name: String,
    pub default_customer_id: Option<Uuid>,
    pub currency: String,
    pub income_account_id: Option<Uuid>,
    pub receivable_account_id: Option<Uuid>,
    pub cash_account_id: Option<Uuid>,
    pub write_off_account_id: Option<Uuid>,
    pub tax_account_id: Option<Uuid>,
    pub tax_rate: Decimal,
    pub tax_template_ids: Option<serde_json::Value>,
    pub warehouse_id: Option<Uuid>,
    pub cogs_account_id: Option<Uuid>,
    pub inventory_account_id: Option<Uuid>,
    pub allow_discount: bool,
    pub cash_rounding_strategy: PosCashRoundingStrategy,
    pub cash_rounding_unit: Decimal,
    pub status: PosProfileStatus,
    pub metadata: serde_json::Value,
}

/// Summary view of PosProfile for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosProfileSummary {
    pub id: PosProfileId,
    pub name: String,
    pub status: PosProfileStatus,
}

/// Reference to PosProfile for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosProfileRef {
    pub id: PosProfileId,
}

// ============================================================================
// POSOPENINGENTRY TYPES
// ============================================================================

/// Type-safe ID for PosOpeningEntry
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosOpeningEntryId(pub Uuid);

impl PosOpeningEntryId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosOpeningEntryId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosOpeningEntryId> for Uuid {
    fn from(id: PosOpeningEntryId) -> Self {
        id.0
    }
}

/// Data transfer object for PosOpeningEntry
///
/// This is the public representation of PosOpeningEntry for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosOpeningEntryDto {
    pub id: PosOpeningEntryId,
    pub pos_profile_id: Uuid,
    pub branch_id: Option<Uuid>,
    pub cashier_party_id: Uuid,
    pub opened_at: DateTime<Utc>,
    pub opening_balances: Option<serde_json::Value>,
    pub status: PosSessionStatus,
    pub metadata: serde_json::Value,
}

/// Summary view of PosOpeningEntry for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosOpeningEntrySummary {
    pub id: PosOpeningEntryId,
    pub status: PosSessionStatus,
}

/// Reference to PosOpeningEntry for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosOpeningEntryRef {
    pub id: PosOpeningEntryId,
}

// ============================================================================
// POSCASHMOVEMENT TYPES
// ============================================================================

/// Type-safe ID for PosCashMovement
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosCashMovementId(pub Uuid);

impl PosCashMovementId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosCashMovementId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosCashMovementId> for Uuid {
    fn from(id: PosCashMovementId) -> Self {
        id.0
    }
}

/// Data transfer object for PosCashMovement
///
/// This is the public representation of PosCashMovement for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosCashMovementDto {
    pub id: PosCashMovementId,
    pub pos_profile_id: Uuid,
    pub opening_entry_id: Uuid,
    pub cashier_party_id: Uuid,
    pub movement_type: PosCashMovementType,
    pub amount: Decimal,
    pub reason: Option<String>,
    pub moved_at: DateTime<Utc>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosCashMovement for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosCashMovementSummary {
    pub id: PosCashMovementId,
}

/// Reference to PosCashMovement for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosCashMovementRef {
    pub id: PosCashMovementId,
}

// ============================================================================
// POSDISCOUNT TYPES
// ============================================================================

/// Type-safe ID for PosDiscount
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosDiscountId(pub Uuid);

impl PosDiscountId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosDiscountId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosDiscountId> for Uuid {
    fn from(id: PosDiscountId) -> Self {
        id.0
    }
}

/// Data transfer object for PosDiscount
///
/// This is the public representation of PosDiscount for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosDiscountDto {
    pub id: PosDiscountId,
    pub name: String,
    pub percentage: Decimal,
    pub description: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosDiscount for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosDiscountSummary {
    pub id: PosDiscountId,
    pub name: String,
}

/// Reference to PosDiscount for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosDiscountRef {
    pub id: PosDiscountId,
}

// ============================================================================
// POSMANAGERPIN TYPES
// ============================================================================

/// Type-safe ID for PosManagerPin
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosManagerPinId(pub Uuid);

impl PosManagerPinId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosManagerPinId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosManagerPinId> for Uuid {
    fn from(id: PosManagerPinId) -> Self {
        id.0
    }
}

/// Data transfer object for PosManagerPin
///
/// This is the public representation of PosManagerPin for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosManagerPinDto {
    pub id: PosManagerPinId,
    pub employee_party_id: Uuid,
    pub pin_hash: String,
    pub failed_attempts: i32,
    pub locked_until: Option<DateTime<Utc>>,
    pub last_attempt_at: Option<DateTime<Utc>>,
    pub last_attempt_ip: Option<String>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosManagerPin for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosManagerPinSummary {
    pub id: PosManagerPinId,
}

/// Reference to PosManagerPin for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosManagerPinRef {
    pub id: PosManagerPinId,
}

// ============================================================================
// POSFLOORPLAN TYPES
// ============================================================================

/// Type-safe ID for PosFloorPlan
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosFloorPlanId(pub Uuid);

impl PosFloorPlanId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosFloorPlanId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosFloorPlanId> for Uuid {
    fn from(id: PosFloorPlanId) -> Self {
        id.0
    }
}

/// Data transfer object for PosFloorPlan
///
/// This is the public representation of PosFloorPlan for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosFloorPlanDto {
    pub id: PosFloorPlanId,
    pub branch_id: Option<Uuid>,
    pub name: String,
    pub position: Option<i32>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosFloorPlan for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosFloorPlanSummary {
    pub id: PosFloorPlanId,
    pub name: String,
}

/// Reference to PosFloorPlan for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosFloorPlanRef {
    pub id: PosFloorPlanId,
}

// ============================================================================
// POSTABLE TYPES
// ============================================================================

/// Type-safe ID for PosTable
///
/// Use this instead of raw Uuid for type safety across modules.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PosTableId(pub Uuid);

impl PosTableId {
    pub fn new(id: Uuid) -> Self {
        Self(id)
    }

    pub fn into_inner(self) -> Uuid {
        self.0
    }
}

impl From<Uuid> for PosTableId {
    fn from(id: Uuid) -> Self {
        Self(id)
    }
}

impl From<PosTableId> for Uuid {
    fn from(id: PosTableId) -> Self {
        id.0
    }
}

/// Data transfer object for PosTable
///
/// This is the public representation of PosTable for other modules.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosTableDto {
    pub id: PosTableId,
    pub pos_floor_plan_id: Uuid,
    pub name: Option<String>,
    pub seats: Option<i32>,
    pub shape: Option<String>,
    pub position: Option<serde_json::Value>,
    pub metadata: serde_json::Value,
}

/// Summary view of PosTable for list displays
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosTableSummary {
    pub id: PosTableId,
    pub name: Option<String>,
}

/// Reference to PosTable for foreign key relationships
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosTableRef {
    pub id: PosTableId,
}

// ============================================================================
// CUSTOM TYPES
// ============================================================================

// <<< CUSTOM TYPES START >>>
// Add custom public types here
// <<< CUSTOM TYPES END >>>