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 stock_delivery_note_id: Option<Uuid>,
133 pub is_return: bool,
134 pub return_against: Option<Uuid>,
135 pub status: PosInvoiceStatus,
136 pub metadata: serde_json::Value,
137}
138
139#[derive(Debug, Clone, Serialize, Deserialize)]
141pub struct PosInvoiceSummary {
142 pub id: PosInvoiceId,
143 pub status: PosInvoiceStatus,
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct PosInvoiceRef {
149 pub id: PosInvoiceId,
150}
151
152#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
160pub struct PosInvoiceItemId(pub Uuid);
161
162impl PosInvoiceItemId {
163 pub fn new(id: Uuid) -> Self {
164 Self(id)
165 }
166
167 pub fn into_inner(self) -> Uuid {
168 self.0
169 }
170}
171
172impl From<Uuid> for PosInvoiceItemId {
173 fn from(id: Uuid) -> Self {
174 Self(id)
175 }
176}
177
178impl From<PosInvoiceItemId> for Uuid {
179 fn from(id: PosInvoiceItemId) -> Self {
180 id.0
181 }
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
188pub struct PosInvoiceItemDto {
189 pub id: PosInvoiceItemId,
190 pub pos_invoice_id: Uuid,
191 pub item_id: Uuid,
192 pub description: Option<String>,
193 pub client_uuid: Option<Uuid>,
194 pub course: Option<i32>,
195 pub quantity: Decimal,
196 pub unit_price: Decimal,
197 pub discount_amount: Decimal,
198 pub net_amount: Decimal,
199 pub revenue_account_id: Option<Uuid>,
200 pub metadata: serde_json::Value,
201}
202
203#[derive(Debug, Clone, Serialize, Deserialize)]
205pub struct PosInvoiceItemSummary {
206 pub id: PosInvoiceItemId,
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
211pub struct PosInvoiceItemRef {
212 pub id: PosInvoiceItemId,
213}
214
215#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
223pub struct PosPaymentId(pub Uuid);
224
225impl PosPaymentId {
226 pub fn new(id: Uuid) -> Self {
227 Self(id)
228 }
229
230 pub fn into_inner(self) -> Uuid {
231 self.0
232 }
233}
234
235impl From<Uuid> for PosPaymentId {
236 fn from(id: Uuid) -> Self {
237 Self(id)
238 }
239}
240
241impl From<PosPaymentId> for Uuid {
242 fn from(id: PosPaymentId) -> Self {
243 id.0
244 }
245}
246
247#[derive(Debug, Clone, Serialize, Deserialize)]
251pub struct PosPaymentDto {
252 pub id: PosPaymentId,
253 pub pos_invoice_id: Uuid,
254 pub payment_method: PosPaymentMethod,
255 pub amount: Decimal,
256 pub reference_no: Option<String>,
257 pub client_uuid: Option<Uuid>,
258 pub payment_entry_id: Option<Uuid>,
259 pub metadata: serde_json::Value,
260}
261
262#[derive(Debug, Clone, Serialize, Deserialize)]
264pub struct PosPaymentSummary {
265 pub id: PosPaymentId,
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize)]
270pub struct PosPaymentRef {
271 pub id: PosPaymentId,
272}
273
274#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
282pub struct PosProfileId(pub Uuid);
283
284impl PosProfileId {
285 pub fn new(id: Uuid) -> Self {
286 Self(id)
287 }
288
289 pub fn into_inner(self) -> Uuid {
290 self.0
291 }
292}
293
294impl From<Uuid> for PosProfileId {
295 fn from(id: Uuid) -> Self {
296 Self(id)
297 }
298}
299
300impl From<PosProfileId> for Uuid {
301 fn from(id: PosProfileId) -> Self {
302 id.0
303 }
304}
305
306#[derive(Debug, Clone, Serialize, Deserialize)]
310pub struct PosProfileDto {
311 pub id: PosProfileId,
312 pub branch_id: Option<Uuid>,
313 pub name: String,
314 pub default_customer_id: Option<Uuid>,
315 pub currency: String,
316 pub income_account_id: Option<Uuid>,
317 pub receivable_account_id: Option<Uuid>,
318 pub cash_account_id: Option<Uuid>,
319 pub write_off_account_id: Option<Uuid>,
320 pub tax_account_id: Option<Uuid>,
321 pub tax_rate: Decimal,
322 pub tax_template_ids: Option<serde_json::Value>,
323 pub warehouse_id: Option<Uuid>,
324 pub cogs_account_id: Option<Uuid>,
325 pub inventory_account_id: Option<Uuid>,
326 pub allow_discount: bool,
327 pub cash_rounding_strategy: PosCashRoundingStrategy,
328 pub cash_rounding_unit: Decimal,
329 pub status: PosProfileStatus,
330 pub metadata: serde_json::Value,
331}
332
333#[derive(Debug, Clone, Serialize, Deserialize)]
335pub struct PosProfileSummary {
336 pub id: PosProfileId,
337 pub name: String,
338 pub status: PosProfileStatus,
339}
340
341#[derive(Debug, Clone, Serialize, Deserialize)]
343pub struct PosProfileRef {
344 pub id: PosProfileId,
345}
346
347#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
355pub struct PosOpeningEntryId(pub Uuid);
356
357impl PosOpeningEntryId {
358 pub fn new(id: Uuid) -> Self {
359 Self(id)
360 }
361
362 pub fn into_inner(self) -> Uuid {
363 self.0
364 }
365}
366
367impl From<Uuid> for PosOpeningEntryId {
368 fn from(id: Uuid) -> Self {
369 Self(id)
370 }
371}
372
373impl From<PosOpeningEntryId> for Uuid {
374 fn from(id: PosOpeningEntryId) -> Self {
375 id.0
376 }
377}
378
379#[derive(Debug, Clone, Serialize, Deserialize)]
383pub struct PosOpeningEntryDto {
384 pub id: PosOpeningEntryId,
385 pub pos_profile_id: Uuid,
386 pub branch_id: Option<Uuid>,
387 pub cashier_party_id: Uuid,
388 pub opened_at: DateTime<Utc>,
389 pub opening_balances: Option<serde_json::Value>,
390 pub status: PosSessionStatus,
391 pub metadata: serde_json::Value,
392}
393
394#[derive(Debug, Clone, Serialize, Deserialize)]
396pub struct PosOpeningEntrySummary {
397 pub id: PosOpeningEntryId,
398 pub status: PosSessionStatus,
399}
400
401#[derive(Debug, Clone, Serialize, Deserialize)]
403pub struct PosOpeningEntryRef {
404 pub id: PosOpeningEntryId,
405}
406
407#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
415pub struct PosCashMovementId(pub Uuid);
416
417impl PosCashMovementId {
418 pub fn new(id: Uuid) -> Self {
419 Self(id)
420 }
421
422 pub fn into_inner(self) -> Uuid {
423 self.0
424 }
425}
426
427impl From<Uuid> for PosCashMovementId {
428 fn from(id: Uuid) -> Self {
429 Self(id)
430 }
431}
432
433impl From<PosCashMovementId> for Uuid {
434 fn from(id: PosCashMovementId) -> Self {
435 id.0
436 }
437}
438
439#[derive(Debug, Clone, Serialize, Deserialize)]
443pub struct PosCashMovementDto {
444 pub id: PosCashMovementId,
445 pub pos_profile_id: Uuid,
446 pub opening_entry_id: Uuid,
447 pub cashier_party_id: Uuid,
448 pub movement_type: PosCashMovementType,
449 pub amount: Decimal,
450 pub reason: Option<String>,
451 pub moved_at: DateTime<Utc>,
452 pub metadata: serde_json::Value,
453}
454
455#[derive(Debug, Clone, Serialize, Deserialize)]
457pub struct PosCashMovementSummary {
458 pub id: PosCashMovementId,
459}
460
461#[derive(Debug, Clone, Serialize, Deserialize)]
463pub struct PosCashMovementRef {
464 pub id: PosCashMovementId,
465}
466
467#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
475pub struct PosDiscountId(pub Uuid);
476
477impl PosDiscountId {
478 pub fn new(id: Uuid) -> Self {
479 Self(id)
480 }
481
482 pub fn into_inner(self) -> Uuid {
483 self.0
484 }
485}
486
487impl From<Uuid> for PosDiscountId {
488 fn from(id: Uuid) -> Self {
489 Self(id)
490 }
491}
492
493impl From<PosDiscountId> for Uuid {
494 fn from(id: PosDiscountId) -> Self {
495 id.0
496 }
497}
498
499#[derive(Debug, Clone, Serialize, Deserialize)]
503pub struct PosDiscountDto {
504 pub id: PosDiscountId,
505 pub name: String,
506 pub percentage: Decimal,
507 pub description: Option<String>,
508 pub metadata: serde_json::Value,
509}
510
511#[derive(Debug, Clone, Serialize, Deserialize)]
513pub struct PosDiscountSummary {
514 pub id: PosDiscountId,
515 pub name: String,
516}
517
518#[derive(Debug, Clone, Serialize, Deserialize)]
520pub struct PosDiscountRef {
521 pub id: PosDiscountId,
522}
523
524#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
532pub struct PosManagerPinId(pub Uuid);
533
534impl PosManagerPinId {
535 pub fn new(id: Uuid) -> Self {
536 Self(id)
537 }
538
539 pub fn into_inner(self) -> Uuid {
540 self.0
541 }
542}
543
544impl From<Uuid> for PosManagerPinId {
545 fn from(id: Uuid) -> Self {
546 Self(id)
547 }
548}
549
550impl From<PosManagerPinId> for Uuid {
551 fn from(id: PosManagerPinId) -> Self {
552 id.0
553 }
554}
555
556#[derive(Debug, Clone, Serialize, Deserialize)]
560pub struct PosManagerPinDto {
561 pub id: PosManagerPinId,
562 pub employee_party_id: Uuid,
563 pub pin_hash: String,
564 pub failed_attempts: i32,
565 pub locked_until: Option<DateTime<Utc>>,
566 pub last_attempt_at: Option<DateTime<Utc>>,
567 pub last_attempt_ip: Option<String>,
568 pub metadata: serde_json::Value,
569}
570
571#[derive(Debug, Clone, Serialize, Deserialize)]
573pub struct PosManagerPinSummary {
574 pub id: PosManagerPinId,
575}
576
577#[derive(Debug, Clone, Serialize, Deserialize)]
579pub struct PosManagerPinRef {
580 pub id: PosManagerPinId,
581}
582
583#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
591pub struct PosFloorPlanId(pub Uuid);
592
593impl PosFloorPlanId {
594 pub fn new(id: Uuid) -> Self {
595 Self(id)
596 }
597
598 pub fn into_inner(self) -> Uuid {
599 self.0
600 }
601}
602
603impl From<Uuid> for PosFloorPlanId {
604 fn from(id: Uuid) -> Self {
605 Self(id)
606 }
607}
608
609impl From<PosFloorPlanId> for Uuid {
610 fn from(id: PosFloorPlanId) -> Self {
611 id.0
612 }
613}
614
615#[derive(Debug, Clone, Serialize, Deserialize)]
619pub struct PosFloorPlanDto {
620 pub id: PosFloorPlanId,
621 pub branch_id: Option<Uuid>,
622 pub name: String,
623 pub position: Option<i32>,
624 pub metadata: serde_json::Value,
625}
626
627#[derive(Debug, Clone, Serialize, Deserialize)]
629pub struct PosFloorPlanSummary {
630 pub id: PosFloorPlanId,
631 pub name: String,
632}
633
634#[derive(Debug, Clone, Serialize, Deserialize)]
636pub struct PosFloorPlanRef {
637 pub id: PosFloorPlanId,
638}
639
640#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
648pub struct PosTableId(pub Uuid);
649
650impl PosTableId {
651 pub fn new(id: Uuid) -> Self {
652 Self(id)
653 }
654
655 pub fn into_inner(self) -> Uuid {
656 self.0
657 }
658}
659
660impl From<Uuid> for PosTableId {
661 fn from(id: Uuid) -> Self {
662 Self(id)
663 }
664}
665
666impl From<PosTableId> for Uuid {
667 fn from(id: PosTableId) -> Self {
668 id.0
669 }
670}
671
672#[derive(Debug, Clone, Serialize, Deserialize)]
676pub struct PosTableDto {
677 pub id: PosTableId,
678 pub pos_floor_plan_id: Uuid,
679 pub name: Option<String>,
680 pub seats: Option<i32>,
681 pub shape: Option<String>,
682 pub position: Option<serde_json::Value>,
683 pub metadata: serde_json::Value,
684}
685
686#[derive(Debug, Clone, Serialize, Deserialize)]
688pub struct PosTableSummary {
689 pub id: PosTableId,
690 pub name: Option<String>,
691}
692
693#[derive(Debug, Clone, Serialize, Deserialize)]
695pub struct PosTableRef {
696 pub id: PosTableId,
697}
698
699