commit 8391c66241a5ce206b686572b1890932266388b8
parent abb4c99154580960c74d64b9466c4595bc09fa7b
Author: Carlosokumu <carlosokumu254@gmail.com>
Date: Tue, 24 Mar 2026 20:52:39 +0300
remove unused functions
Diffstat:
1 file changed, 14 insertions(+), 52 deletions(-)
diff --git a/dummy/usawa/gui/core/models.py b/dummy/usawa/gui/core/models.py
@@ -1,16 +1,17 @@
-from dataclasses import dataclass,field
-from typing import Optional,List, Union
+from dataclasses import dataclass, field
+from typing import Optional, List
from datetime import datetime
from pathlib import Path
+
@dataclass
class LedgerEntry:
- """Ledger entry data model"""
-
+ """DTO for ledger entry input, converted to usawa.Entry before adding to ledger."""
+
# Basic details
external_reference: Optional[str] = None
description: Optional[str] = None
-
+
# Transaction details
amount: float = 0.0
source_unit: str = ""
@@ -25,71 +26,32 @@ class LedgerEntry:
# Signers (public keys)
signer_pubkeys: List[str] = field(default_factory=list)
-
+
serial: Optional[int] = None
tx_date: Optional[datetime] = None
tx_reference: Optional[str] = None
date_registered: Optional[datetime] = None
parent_digest: Optional[str] = None
unit_index: Optional[int] = None
-
+
def validate(self) -> tuple[bool, str]:
"""Validate entry data"""
if self.amount <= 0:
return False, "Amount must be greater than 0"
-
+
if not self.source_unit or not self.dest_unit:
return False, "Unit/Currency is required for both source and destination"
-
+
if not self.source_type or not self.dest_type:
return False, "Account type is required for both source and destination"
-
+
if not self.source_path or not self.dest_path:
return False, "Account path is required for both source and destination"
-
- # Validate attachments
+
+ # Validate attachments
if self.attachments:
for filepath in self.attachments:
if not Path(filepath).exists():
return False, f"Attachment file not found: {filepath}"
-
+
return True, ""
-
- def __repr__(self):
- return (
- f"LedgerEntry("
- f"external_reference={self.external_reference!r}, "
- f"description={self.description!r}, "
- f"serial={self.serial!r}, "
- f"parent_digest={self.parent_digest}, "
- f"amount={self.amount}, "
- f"source_unit={self.source_unit}, "
- f"tx_ref={self.tx_reference}, "
- f"source_type={self.source_type}, "
- f"dest_unit={self.dest_unit}, "
- f"dest_type={self.dest_type})"
- f"attachments={self.attachments!r})"
- )
-
- def add_attachment(self, filepath: Union[str, List[str]]):
- """
- Add one or more attachment file paths
- """
- if isinstance(filepath, str):
- if filepath not in self.attachments:
- self.attachments.append(filepath)
- elif isinstance(filepath, list):
- for path in filepath:
- if path not in self.attachments:
- self.attachments.append(path)
- else:
- raise TypeError(f"filepath must be str or List[str], got {type(filepath)}")
-
- def remove_attachment(self, filepath: str):
- """Remove an attachment file path"""
- if filepath in self.attachments:
- self.attachments.remove(filepath)
-
- def get_attachment_count(self) -> int:
- """Get number of attachments"""
- return len(self.attachments)