Delete q
This commit is contained in:
parent
fd267aec0f
commit
5fb40ba3d2
1 changed files with 0 additions and 236 deletions
236
q
236
q
|
|
@ -1,236 +0,0 @@
|
|||
[1mdiff --git a/make_post_sell/models/crypto_payment.py b/make_post_sell/models/crypto_payment.py[m
|
||||
[1mindex 0a25a83..b7f0ff3 100644[m
|
||||
[1m--- a/make_post_sell/models/crypto_payment.py[m
|
||||
[1m+++ b/make_post_sell/models/crypto_payment.py[m
|
||||
[36m@@ -533,6 +533,13 @@[m [mclass CryptoPayment(RBase, Base):[m
|
||||
"""[m
|
||||
return self.status in self.INITIAL_WAITING_STATUSES[m
|
||||
[m
|
||||
[32m+[m[32m def _format_amount(self, amount: int) -> str:[m
|
||||
[32m+[m[32m """Convert atomic units to display format for the coin type."""[m
|
||||
[32m+[m[32m if self.coin_type == "XMR":[m
|
||||
[32m+[m[32m return f"{amount / 1e12:.12f}".rstrip("0").rstrip(".")[m
|
||||
[32m+[m[32m else: # BTC, LTC, BCH, DOGE all use 8 decimals[m
|
||||
[32m+[m[32m return f"{amount / 1e8:.8f}".rstrip("0").rstrip(".")[m
|
||||
[32m+[m
|
||||
def __str__(self) -> str:[m
|
||||
"""[m
|
||||
Human-readable string representation for logging and debugging.[m
|
||||
[36m@@ -540,45 +547,12 @@[m [mclass CryptoPayment(RBase, Base):[m
|
||||
Returns:[m
|
||||
str: Concise payment description for logs[m
|
||||
"""[m
|
||||
[31m- return self._format_payment_summary()[m
|
||||
[31m-[m
|
||||
[31m- def __repr__(self) -> str:[m
|
||||
[31m- """[m
|
||||
[31m- Developer-oriented string representation for debugging.[m
|
||||
[31m-[m
|
||||
[31m- Returns:[m
|
||||
[31m- str: Detailed payment description for debugging[m
|
||||
[31m- """[m
|
||||
[31m- return ([m
|
||||
[31m- f"CryptoPayment(id={self.uuid_str[:8]}, "[m
|
||||
[31m- f"status={self.status}, "[m
|
||||
[31m- f"coin={self.coin_type}, "[m
|
||||
[31m- f"expected={self.expected_amount}, "[m
|
||||
[31m- f"received={self.received_amount}, "[m
|
||||
[31m- f"confirmations={self.current_confirmations or 0}/{self.confirmations_required}, "[m
|
||||
[31m- f"invoice_id={self.invoice_id.hex[:8] if self.invoice_id else None})"[m
|
||||
[31m- )[m
|
||||
[31m-[m
|
||||
[31m- def _format_payment_summary(self) -> str:[m
|
||||
[31m- """[m
|
||||
[31m- Format payment as a concise summary for logging.[m
|
||||
[31m-[m
|
||||
[31m- Returns:[m
|
||||
[31m- str: Payment summary with key details[m
|
||||
[31m- """[m
|
||||
# Get amount information[m
|
||||
[31m- if self.coin_type == "XMR":[m
|
||||
[31m- expected_display = f"{self.expected_amount / 1e12:.6f}"[m
|
||||
[31m- received_display = f"{self.received_amount / 1e12:.6f}"[m
|
||||
[31m- elif self.coin_type == "DOGE":[m
|
||||
[31m- expected_display = f"{self.expected_amount / 1e8:.8f}"[m
|
||||
[31m- received_display = f"{self.received_amount / 1e8:.8f}"[m
|
||||
[31m- else: # BTC, LTC, BCH[m
|
||||
[31m- expected_display = f"{self.expected_amount / 1e8:.8f}"[m
|
||||
[31m- received_display = f"{self.received_amount / 1e8:.8f}"[m
|
||||
[32m+[m[32m expected_display = self._format_amount(self.expected_amount)[m
|
||||
[32m+[m[32m received_display = self._format_amount(self.received_amount)[m
|
||||
[m
|
||||
# Build status description[m
|
||||
[31m- status_desc = self._get_status_description()[m
|
||||
[32m+[m[32m status_desc = self.status[m
|
||||
[m
|
||||
# Format confirmations[m
|
||||
conf_desc = f"{self.current_confirmations or 0}/{self.confirmations_required}"[m
|
||||
[36m@@ -601,59 +575,22 @@[m [mclass CryptoPayment(RBase, Base):[m
|
||||
f"conf:{conf_desc} addr:{self.address[-8:]}{user_display}{shop_display}"[m
|
||||
)[m
|
||||
[m
|
||||
[31m- def _get_status_description(self) -> str:[m
|
||||
[31m- """[m
|
||||
[31m- Get human-readable status description for logging.[m
|
||||
[31m-[m
|
||||
[31m- Returns:[m
|
||||
[31m- str: Human-readable status description[m
|
||||
[31m- """[m
|
||||
[31m- status_descriptions = {[m
|
||||
[31m- # Initial/waiting states[m
|
||||
[31m- self.STATUS_PENDING: "waiting",[m
|
||||
[31m- # Active processing states[m
|
||||
[31m- self.STATUS_RECEIVED: "received",[m
|
||||
[31m- self.STATUS_CONFIRMED: "confirmed",[m
|
||||
[31m- self.STATUS_CONFIRMED_OVERPAY: "overpaid",[m
|
||||
[31m- # Refund processing states[m
|
||||
[31m- self.STATUS_CONFIRMED_OVERPAY_REFUNDED: "overpay-refunding",[m
|
||||
[31m- self.STATUS_LATEPAY_REFUNDED: "late-refunding",[m
|
||||
[31m- self.STATUS_UNDERPAID_REFUNDED: "underpay-refunding",[m
|
||||
[31m- self.STATUS_OUT_OF_STOCK_REFUNDED: "oos-refunding",[m
|
||||
[31m- self.STATUS_DOUBLEPAY_REFUNDED: "duplicate-refunding",[m
|
||||
[31m- # Completed refund states[m
|
||||
[31m- self.STATUS_CONFIRMED_OVERPAY_REFUNDED_COMPLETE: "overpay-refunded",[m
|
||||
[31m- self.STATUS_LATEPAY_REFUNDED_COMPLETE: "late-refunded",[m
|
||||
[31m- self.STATUS_UNDERPAID_REFUNDED_COMPLETE: "underpay-refunded",[m
|
||||
[31m- self.STATUS_OUT_OF_STOCK_REFUNDED_COMPLETE: "oos-refunded",[m
|
||||
[31m- self.STATUS_DOUBLEPAY_REFUNDED_COMPLETE: "duplicate-refunded",[m
|
||||
[31m- # No-refund states[m
|
||||
[31m- self.STATUS_CONFIRMED_OVERPAY_NOT_REFUNDED: "overpay-no-refund",[m
|
||||
[31m- self.STATUS_LATEPAY_NOT_REFUNDED: "late-no-refund",[m
|
||||
[31m- self.STATUS_UNDERPAID_NOT_REFUNDED: "underpay-no-refund",[m
|
||||
[31m- self.STATUS_OUT_OF_STOCK_NOT_REFUNDED: "oos-no-refund",[m
|
||||
[31m- self.STATUS_DOUBLEPAY_NOT_REFUNDED: "duplicate-no-refund",[m
|
||||
[31m- # Terminal states[m
|
||||
[31m- self.STATUS_EXPIRED: "expired",[m
|
||||
[31m- self.STATUS_CANCELLED: "cancelled",[m
|
||||
[31m- }[m
|
||||
[31m-[m
|
||||
[31m- return status_descriptions.get(self.status, self.status)[m
|
||||
[31m-[m
|
||||
[31m- def format_transaction_log(self, context: str = "") -> str:[m
|
||||
[32m+[m[32m def __repr__(self) -> str:[m
|
||||
"""[m
|
||||
[31m- Format payment for transaction logging with optional context.[m
|
||||
[31m-[m
|
||||
[31m- Args:[m
|
||||
[31m- context: Optional context (e.g., "processing", "refunding")[m
|
||||
[32m+[m[32m Developer-oriented string representation for debugging.[m
|
||||
[m
|
||||
Returns:[m
|
||||
[31m- str: Formatted transaction log entry[m
|
||||
[32m+[m[32m str: Detailed payment description for debugging[m
|
||||
"""[m
|
||||
[31m- base_msg = str(self)[m
|
||||
[31m- if context:[m
|
||||
[31m- return f"{context.capitalize()}: {base_msg}"[m
|
||||
[31m- return base_msg[m
|
||||
[32m+[m[32m return ([m
|
||||
[32m+[m[32m f"CryptoPayment(id={self.uuid_str[:8]}, "[m
|
||||
[32m+[m[32m f"status={self.status}, "[m
|
||||
[32m+[m[32m f"coin={self.coin_type}, "[m
|
||||
[32m+[m[32m f"expected={self.expected_amount}, "[m
|
||||
[32m+[m[32m f"received={self.received_amount}, "[m
|
||||
[32m+[m[32m f"confirmations={self.current_confirmations or 0}/{self.confirmations_required}, "[m
|
||||
[32m+[m[32m f"invoice_id={self.invoice_id.hex[:8] if self.invoice_id else None})"[m
|
||||
[32m+[m[32m )[m
|
||||
[m
|
||||
def format_amount_details(self) -> str:[m
|
||||
"""[m
|
||||
[36m@@ -662,18 +599,9 @@[m [mclass CryptoPayment(RBase, Base):[m
|
||||
Returns:[m
|
||||
str: Detailed amount breakdown[m
|
||||
"""[m
|
||||
[31m- if self.coin_type == "XMR":[m
|
||||
[31m- expected = f"{self.expected_amount / 1e12:.6f}"[m
|
||||
[31m- received = f"{self.received_amount / 1e12:.6f}"[m
|
||||
[31m- due = f"{self.due_amount / 1e12:.6f}" if self.due_amount > 0 else "0"[m
|
||||
[31m- elif self.coin_type == "DOGE":[m
|
||||
[31m- expected = f"{self.expected_amount / 1e8:.8f}"[m
|
||||
[31m- received = f"{self.received_amount / 1e8:.8f}"[m
|
||||
[31m- due = f"{self.due_amount / 1e8:.8f}" if self.due_amount > 0 else "0"[m
|
||||
[31m- else: # BTC, LTC, BCH[m
|
||||
[31m- expected = f"{self.expected_amount / 1e8:.8f}"[m
|
||||
[31m- received = f"{self.received_amount / 1e8:.8f}"[m
|
||||
[31m- due = f"{self.due_amount / 1e8:.8f}" if self.due_amount > 0 else "0"[m
|
||||
[32m+[m[32m expected = self._format_amount(self.expected_amount)[m
|
||||
[32m+[m[32m received = self._format_amount(self.received_amount)[m
|
||||
[32m+[m[32m due = self._format_amount(self.due_amount) if self.due_amount > 0 else "0"[m
|
||||
[m
|
||||
return f"expected:{expected} received:{received} due:{due} {self.coin_type}"[m
|
||||
[m
|
||||
[36m@@ -684,6 +612,5 @@[m [mclass CryptoPayment(RBase, Base):[m
|
||||
Returns:[m
|
||||
str: Confirmation status description[m
|
||||
"""[m
|
||||
[31m- status = "confirmed" if self.is_fully_confirmed else "pending"[m
|
||||
current = self.current_confirmations or 0[m
|
||||
[31m- return f"{status} ({current}/{self.confirmations_required})"[m
|
||||
[32m+[m[32m return f"{current}/{self.confirmations_required}"[m
|
||||
[1mdiff --git a/make_post_sell/tests/test_models.py b/make_post_sell/tests/test_models.py[m
|
||||
[1mindex d3101f7..fb97394 100644[m
|
||||
[1m--- a/make_post_sell/tests/test_models.py[m
|
||||
[1m+++ b/make_post_sell/tests/test_models.py[m
|
||||
[36m@@ -1499,49 +1499,6 @@[m [mclass TestCryptoPayment(unittest.TestCase):[m
|
||||
self.assertIn("received=0", result)[m
|
||||
self.assertIn("confirmations=0/10", result) # Should show 0 due to our fix[m
|
||||
[m
|
||||
[31m- def test_get_status_description_all_statuses(self):[m
|
||||
[31m- """Test _get_status_description for all status types."""[m
|
||||
[31m- status_mapping = {[m
|
||||
[31m- CryptoPayment.STATUS_PENDING: "waiting",[m
|
||||
[31m- CryptoPayment.STATUS_RECEIVED: "received",[m
|
||||
[31m- CryptoPayment.STATUS_CONFIRMED: "confirmed",[m
|
||||
[31m- CryptoPayment.STATUS_CONFIRMED_OVERPAY: "overpaid",[m
|
||||
[31m- CryptoPayment.STATUS_EXPIRED: "expired",[m
|
||||
[31m- CryptoPayment.STATUS_CANCELLED: "cancelled",[m
|
||||
[31m- CryptoPayment.STATUS_LATEPAY_REFUNDED: "late-refunding",[m
|
||||
[31m- CryptoPayment.STATUS_UNDERPAID_REFUNDED: "underpay-refunding",[m
|
||||
[31m- CryptoPayment.STATUS_DOUBLEPAY_REFUNDED: "duplicate-refunding",[m
|
||||
[31m- CryptoPayment.STATUS_LATEPAY_REFUNDED_COMPLETE: "late-refunded",[m
|
||||
[31m- CryptoPayment.STATUS_UNDERPAID_REFUNDED_COMPLETE: "underpay-refunded",[m
|
||||
[31m- CryptoPayment.STATUS_DOUBLEPAY_REFUNDED_COMPLETE: "duplicate-refunded",[m
|
||||
[31m- CryptoPayment.STATUS_LATEPAY_NOT_REFUNDED: "late-no-refund",[m
|
||||
[31m- CryptoPayment.STATUS_UNDERPAID_NOT_REFUNDED: "underpay-no-refund",[m
|
||||
[31m- CryptoPayment.STATUS_DOUBLEPAY_NOT_REFUNDED: "duplicate-no-refund",[m
|
||||
[31m- }[m
|
||||
[31m-[m
|
||||
[31m- for status, expected_desc in status_mapping.items():[m
|
||||
[31m- self.payment.status = status[m
|
||||
[31m- result = self.payment._get_status_description()[m
|
||||
[31m- self.assertEqual([m
|
||||
[31m- result, expected_desc, f"Status {status} should map to {expected_desc}"[m
|
||||
[31m- )[m
|
||||
[31m-[m
|
||||
[31m- def test_format_transaction_log_with_context(self):[m
|
||||
[31m- """Test format_transaction_log method with context."""[m
|
||||
[31m- self.payment.status = CryptoPayment.STATUS_RECEIVED[m
|
||||
[31m-[m
|
||||
[31m- result = self.payment.format_transaction_log("processing")[m
|
||||
[31m-[m
|
||||
[31m- self.assertIn("Processing:", result)[m
|
||||
[31m- self.assertIn("[received]", result)[m
|
||||
[31m-[m
|
||||
[31m- def test_format_transaction_log_without_context(self):[m
|
||||
[31m- """Test format_transaction_log method without context."""[m
|
||||
[31m- result = self.payment.format_transaction_log()[m
|
||||
[31m-[m
|
||||
[31m- # Should be same as str() when no context[m
|
||||
[31m- self.assertEqual(result, str(self.payment))[m
|
||||
[31m-[m
|
||||
def test_format_amount_details_xmr(self):[m
|
||||
"""Test format_amount_details for XMR."""[m
|
||||
self.payment.received_amount = 800000000000 # 0.8 XMR[m
|
||||
[1mdiff --git a/make_post_sell/views/crypto.py b/make_post_sell/views/crypto.py[m
|
||||
[1mindex 87f9b4b..37e493a 100644[m
|
||||
[1m--- a/make_post_sell/views/crypto.py[m
|
||||
[1m+++ b/make_post_sell/views/crypto.py[m
|
||||
[36m@@ -1332,8 +1332,6 @@[m [mdef crypto_debug_wallet_scan(request):[m
|
||||
"If transfers found = 0, wallet has no transaction history or RPC issue"[m
|
||||
)[m
|
||||
debug_output.append("\n=== DEBUG COMPLETE ===")[m
|
||||
[31m-[m
|
||||
return Response("\n".join(debug_output), content_type="text/plain")[m
|
||||
[31m-[m
|
||||
except Exception as e:[m
|
||||
return Response(f"Debug error: {e}", content_type="text/plain", status=500)[m
|
||||
Loading…
Add table
Add a link
Reference in a new issue