aa-ledger 0.9.8__py3-none-any.whl → 0.9.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {aa_ledger-0.9.8.dist-info → aa_ledger-0.9.9.1.dist-info}/METADATA +3 -1
  2. {aa_ledger-0.9.8.dist-info → aa_ledger-0.9.9.1.dist-info}/RECORD +78 -76
  3. ledger/__init__.py +9 -9
  4. ledger/api/api_helper/billboard_helper.py +55 -26
  5. ledger/api/ledger/admin.py +1 -1
  6. ledger/app_settings.py +18 -11
  7. ledger/constants.py +5 -0
  8. ledger/decorators.py +92 -11
  9. ledger/helpers/alliance.py +119 -91
  10. ledger/helpers/character.py +260 -252
  11. ledger/helpers/core.py +565 -565
  12. ledger/helpers/corporation.py +237 -187
  13. ledger/helpers/etag.py +2 -1
  14. ledger/helpers/ref_type.py +475 -475
  15. ledger/locale/cs_CZ/LC_MESSAGES/django.po +942 -932
  16. ledger/locale/de/LC_MESSAGES/django.mo +0 -0
  17. ledger/locale/de/LC_MESSAGES/django.po +961 -945
  18. ledger/locale/django.pot +942 -932
  19. ledger/locale/es/LC_MESSAGES/django.po +943 -933
  20. ledger/locale/fr_FR/LC_MESSAGES/django.po +942 -932
  21. ledger/locale/it_IT/LC_MESSAGES/django.po +942 -932
  22. ledger/locale/ja/LC_MESSAGES/django.po +943 -933
  23. ledger/locale/ko_KR/LC_MESSAGES/django.po +942 -932
  24. ledger/locale/nl_NL/LC_MESSAGES/django.po +942 -932
  25. ledger/locale/pl_PL/LC_MESSAGES/django.po +942 -932
  26. ledger/locale/ru/LC_MESSAGES/django.po +945 -935
  27. ledger/locale/sk/LC_MESSAGES/django.po +944 -934
  28. ledger/locale/uk/LC_MESSAGES/django.po +946 -936
  29. ledger/locale/zh_Hans/LC_MESSAGES/django.po +943 -933
  30. ledger/managers/character_mining_manager.py +66 -19
  31. ledger/managers/character_planetary_manager.py +1 -1
  32. ledger/migrations/0016_characterminingledger_price_per_unit.py +21 -0
  33. ledger/models/characteraudit.py +32 -1
  34. ledger/static/ledger/css/cards.css +1 -1
  35. ledger/static/ledger/css/table.css +1 -1
  36. ledger/static/ledger/js/charts.js +7 -227
  37. ledger/static/ledger/js/planetary.js +1 -0
  38. ledger/tasks.py +1 -8
  39. ledger/templates/ledger/allyledger/admin/alliance_administration.html +17 -8
  40. ledger/templates/ledger/allyledger/admin/alliance_overview.html +75 -89
  41. ledger/templates/ledger/allyledger/alliance_ledger.html +8 -10
  42. ledger/templates/ledger/bundles/ally-administration-bundles.html +2 -0
  43. ledger/templates/ledger/bundles/char-administration-bundles.html +2 -0
  44. ledger/templates/ledger/bundles/character-ledger-bundles.html +66 -64
  45. ledger/templates/ledger/bundles/corp-administration-bundles.html +2 -0
  46. ledger/templates/ledger/bundles/corporation-ledger-bundles.html +75 -73
  47. ledger/templates/ledger/charledger/admin/character_administration.html +10 -8
  48. ledger/templates/ledger/charledger/admin/character_overview.html +69 -86
  49. ledger/templates/ledger/charledger/character_ledger.html +11 -15
  50. ledger/templates/ledger/charledger/planetary/planetary_ledger.html +2 -6
  51. ledger/templates/ledger/corpledger/admin/corporation_administration.html +10 -8
  52. ledger/templates/ledger/corpledger/admin/corporation_overview.html +71 -83
  53. ledger/templates/ledger/corpledger/corporation_ledger.html +55 -14
  54. ledger/templates/ledger/partials/administration/alliance.html +28 -49
  55. ledger/templates/ledger/partials/administration/alliance_corporations.html +58 -0
  56. ledger/templates/ledger/partials/administration/corporation_characters.html +26 -28
  57. ledger/templates/ledger/partials/information/daily.html +1 -1
  58. ledger/templates/ledger/partials/information/day.html +1 -7
  59. ledger/templates/ledger/partials/information/hourly.html +1 -7
  60. ledger/templates/ledger/partials/information/summary.html +88 -84
  61. ledger/templates/ledger/partials/information/view_character_content.html +35 -35
  62. ledger/templates/ledger/partials/table/char-ledger.html +14 -5
  63. ledger/templates/ledger/partials/table/corp-ledger.html +3 -3
  64. ledger/templates/ledger/partials/view/card.html +2 -2
  65. ledger/tests/test_decarators.py +102 -17
  66. ledger/tests/test_helpers/test_etag.py +7 -6
  67. ledger/tests/test_managers/test_character_mining_manager.py +2 -1
  68. ledger/tests/test_models/test_characterminingledger.py +38 -2
  69. ledger/tests/test_tasks.py +4 -4
  70. ledger/tests/test_templatetags.py +5 -2
  71. ledger/tests/test_views/test_access.py +852 -852
  72. ledger/tests/testdata/esi.json +1 -2
  73. ledger/tests/testdata/eveuniverse.json +90 -48
  74. ledger/urls.py +66 -21
  75. ledger/views/alliance/alliance_ledger.py +4 -3
  76. ledger/views/corporation/corporation_ledger.py +25 -9
  77. {aa_ledger-0.9.8.dist-info → aa_ledger-0.9.9.1.dist-info}/WHEEL +0 -0
  78. {aa_ledger-0.9.8.dist-info → aa_ledger-0.9.9.1.dist-info}/licenses/LICENSE +0 -0
@@ -19,22 +19,18 @@ from app_utils.logging import LoggerAddTag
19
19
 
20
20
  # AA Ledger
21
21
  from ledger import __title__
22
- from ledger.app_settings import LEDGER_CACHE_STALE
22
+ from ledger.app_settings import LEDGER_CACHE_ENABLED, LEDGER_CACHE_STALE
23
+ from ledger.constants import NPC_ENTITIES
23
24
  from ledger.helpers.core import LedgerCore, LedgerEntity
24
25
  from ledger.helpers.ref_type import RefTypeManager
25
26
  from ledger.models.corporationaudit import (
26
27
  CorporationAudit,
28
+ CorporationWalletDivision,
27
29
  CorporationWalletJournalEntry,
28
30
  )
29
31
 
30
32
  logger = LoggerAddTag(get_extension_logger(__name__), __title__)
31
33
 
32
- NPC_ENTITIES = [
33
- 1000125, # Concord Bounties (Bounty Prizes, ESS
34
- 1000132, # Secure Commerce Commission (Market Fees)
35
- 1000413, # Air Laboratories (Daily Login Rewards, etc.)
36
- ]
37
-
38
34
 
39
35
  class CorporationData(LedgerCore):
40
36
  """Class to hold character data for the ledger."""
@@ -44,87 +40,95 @@ class CorporationData(LedgerCore):
44
40
  self,
45
41
  request: WSGIRequest,
46
42
  corporation: CorporationAudit,
47
- year=None,
48
- month=None,
49
- day=None,
43
+ division_id: int = None,
44
+ year: int = None,
45
+ month: int = None,
46
+ day: int = None,
50
47
  ):
51
48
  LedgerCore.__init__(self, year, month, day)
52
49
  self.request = request
53
50
  self.corporation = corporation
51
+ self.division_id = division_id
54
52
  self.auth_char_ids = self.auth_character_ids
55
53
 
56
54
  def setup_ledger(self, entity: LedgerEntity = None):
57
55
  """Setup the Ledger Data for the Corporation."""
58
- if entity is not None:
59
- if (
60
- self.request.GET.get("all", False)
61
- and entity.entity_id == self.corporation.corporation.corporation_id
62
- ):
63
- self.journal = CorporationWalletJournalEntry.objects.filter(
64
- self.filter_date,
65
- division__corporation=self.corporation,
66
- ).exclude( # Filter by date and division
67
- first_party_id=self.corporation.corporation.corporation_id,
68
- second_party_id=self.corporation.corporation.corporation_id,
69
- ) # exclude Transaction between the corporation itself
70
- else:
71
- character_ids = entity.get_alts_ids_or_self()
72
- self.journal = (
73
- CorporationWalletJournalEntry.objects.filter(
74
- self.filter_date,
75
- division__corporation=self.corporation,
76
- ) # Filter by date and division
77
- .filter(
78
- Q(first_party_id__in=character_ids)
79
- | Q(second_party_id__in=character_ids)
80
- ) # Filter only needed Character IDs
81
- .exclude(
82
- first_party_id=self.corporation.corporation.corporation_id,
83
- second_party_id=self.corporation.corporation.corporation_id,
84
- ) # exclude Transaction between the corporation itself
85
- )
56
+ corporation_id = self.corporation.corporation.corporation_id
86
57
 
87
- if entity.entity_id == self.corporation.corporation.corporation_id:
88
- self.journal = self.journal.filter(
89
- Q(first_party_id__in=NPC_ENTITIES)
90
- | Q(second_party_id__in=NPC_ENTITIES)
91
- )
92
-
93
- # If the entity is a corporation or alliance, we need to exclude the accounts Character IDs
94
- # from the journal to prevent double counting
95
- if entity.type in ["alliance", "corporation"]:
96
- exclude_ids = self.auth_char_ids - set(character_ids)
97
- self.journal = self.journal.exclude(
98
- Q(first_party_id__in=exclude_ids)
99
- | Q(second_party_id__in=exclude_ids)
100
- )
101
- # Get All Entities from the Journal
102
- self.entities = set(
103
- self.journal.values_list("second_party_id", flat=True)
104
- ) | set(self.journal.values_list("first_party_id", flat=True))
105
- else:
106
- self.journal = CorporationWalletJournalEntry.objects.filter(
107
- self.filter_date, division__corporation=self.corporation
108
- ).exclude( # Filter by date and division
109
- first_party_id=self.corporation.corporation.corporation_id,
110
- second_party_id=self.corporation.corporation.corporation_id,
111
- ) # exclude Transaction between the corporation itself
112
-
113
- # Evaluate the existing years for the view
114
- self.existing_years = (
115
- CorporationWalletJournalEntry.objects.filter(
116
- division__corporation=self.corporation
117
- )
118
- .exclude(date__year__isnull=True)
119
- .values_list("date__year", flat=True)
120
- .order_by("-date__year")
121
- .distinct()
58
+ # Base queryset filtered by date and corporation division
59
+ base_qs = self._base_journal_queryset()
60
+
61
+ if entity is None:
62
+ # No entity specified: show all entries for the corporation (except self-transfers)
63
+ self.journal = base_qs.exclude(
64
+ first_party_id=corporation_id, second_party_id=corporation_id
65
+ )
66
+ # Prepare auxiliary data used by the view
67
+ self.existing_years = self._compute_existing_years()
68
+ self.entities = self._compute_entities()
69
+ return
70
+
71
+ # If the entity is the corporation itself and "all" is set, show all entries
72
+ if self.request.GET.get("all", False) and entity.entity_id == corporation_id:
73
+ self.journal = base_qs.exclude(
74
+ first_party_id=corporation_id, second_party_id=corporation_id
75
+ )
76
+ self.entities = self._compute_entities()
77
+ return
78
+
79
+ # Regular entity filtering: include any rows where the entity is a first or second party
80
+ character_ids = entity.get_alts_ids_or_self()
81
+ qs = base_qs.filter(
82
+ Q(first_party_id__in=character_ids) | Q(second_party_id__in=character_ids)
83
+ )
84
+ qs = qs.exclude(first_party_id=corporation_id, second_party_id=corporation_id)
85
+
86
+ # If the entity is the corporation itself, include NPC transactions too
87
+ if entity.entity_id == corporation_id:
88
+ qs = qs.filter(
89
+ Q(first_party_id__in=NPC_ENTITIES) | Q(second_party_id__in=NPC_ENTITIES)
90
+ )
91
+
92
+ # If entity represents a corporation or alliance, exclude auth account character IDs
93
+ # that are not part of the current entity to avoid double counting
94
+ if entity.type in ["alliance", "corporation"]:
95
+ exclude_ids = self.auth_char_ids - set(character_ids)
96
+ qs = qs.exclude(
97
+ Q(first_party_id__in=exclude_ids) | Q(second_party_id__in=exclude_ids)
122
98
  )
123
99
 
124
- # Get All Entities from the Journal
125
- self.entities = set(
126
- self.journal.values_list("second_party_id", flat=True)
127
- ) | set(self.journal.values_list("first_party_id", flat=True))
100
+ self.journal = qs
101
+ self.entities = self._compute_entities()
102
+
103
+ def _base_journal_queryset(self):
104
+ """Return the base queryset filtered by the current date range and corporation division."""
105
+ if self.division_id is not None:
106
+ return CorporationWalletJournalEntry.objects.filter(
107
+ self.filter_date,
108
+ division__corporation=self.corporation,
109
+ division=self.division_id,
110
+ )
111
+ return CorporationWalletJournalEntry.objects.filter(
112
+ self.filter_date, division__corporation=self.corporation
113
+ )
114
+
115
+ def _compute_entities(self):
116
+ """Return a set of all entity IDs (first and second parties) present in the current journal."""
117
+ return set(self.journal.values_list("second_party_id", flat=True)) | set(
118
+ self.journal.values_list("first_party_id", flat=True)
119
+ )
120
+
121
+ def _compute_existing_years(self):
122
+ """Return the available years for journal entries for this corporation."""
123
+ return (
124
+ CorporationWalletJournalEntry.objects.filter(
125
+ division__corporation=self.corporation
126
+ )
127
+ .exclude(date__year__isnull=True)
128
+ .values_list("date__year", flat=True)
129
+ .order_by("-date__year")
130
+ .distinct()
131
+ )
128
132
 
129
133
  def create_entity_data(
130
134
  self,
@@ -190,32 +194,18 @@ class CorporationData(LedgerCore):
190
194
  "type": entity.type,
191
195
  }
192
196
 
193
- # Create the chord data for the billboard
194
- self.billboard.chord_add_data(
195
- chord_from=entity.entity_name,
196
- chord_to=_("Ratting (Wallet)"),
197
- value=bounty,
198
- )
199
- self.billboard.chord_add_data(
200
- chord_from=entity.entity_name,
201
- chord_to=_("ESS (Wallet)"),
202
- value=ess,
203
- )
204
- self.billboard.chord_add_data(
205
- chord_from=entity.entity_name,
206
- chord_to=_("Costs (Wallet)"),
207
- value=abs(costs),
208
- )
209
- self.billboard.chord_add_data(
210
- chord_from=entity.entity_name,
211
- chord_to=_("Miscellaneous (Wallet)"),
212
- value=abs(miscellaneous),
213
- )
214
-
215
197
  return char_data
216
198
 
217
199
  def generate_ledger_data(self) -> dict:
218
- """Generate the ledger data for the corporation."""
200
+ """
201
+ Generate the ledger data for the corporation.
202
+
203
+ This method processes the journal entries, builds the ledger data,
204
+ and prepares the context for rendering the corporation ledger view.
205
+ """
206
+ ledger = False
207
+ finished_entities = False
208
+
219
209
  self.setup_ledger()
220
210
 
221
211
  journal = self.journal.values(
@@ -246,10 +236,10 @@ class CorporationData(LedgerCore):
246
236
  # Get the journal hash and cache header
247
237
  ledger_hash = self._get_ledger_journal_hash(self.journal.values_list("pk"))
248
238
  ledger_header = self._get_ledger_header(
249
- self.corporation.corporation.corporation_id,
250
- self.year,
251
- self.month,
252
- self.day,
239
+ ledger_args=f"{self.corporation.corporation.corporation_id}_{self.division_id}",
240
+ year=self.year,
241
+ month=self.month,
242
+ day=self.day,
253
243
  )
254
244
  cache_header = cache.get(
255
245
  ledger_header,
@@ -264,40 +254,107 @@ class CorporationData(LedgerCore):
264
254
  ledger_key = self._build_ledger_cache_key(ledger_header)
265
255
 
266
256
  # Check if we have newest cached version of the ledger
267
- cached_ledger = self._get_cached_ledger(
268
- journal_up_to_date, ledger_key, ledger_hash
269
- )
270
- if cached_ledger is not None:
271
- return cached_ledger
272
-
273
- # Build the entries from the journal
274
- self.entries = {}
275
- for row in journal:
276
- self.entries.setdefault(row["pk"], []).append(row)
277
-
278
- ledger, finished_entities = self._process_accounts()
279
- self._process_remaining_entities(ledger, finished_entities)
280
- self._add_corporation_entity(ledger)
281
-
257
+ if journal_up_to_date and LEDGER_CACHE_ENABLED:
258
+ ledger = cache.get(f"{ledger_key}-data", False)
259
+ finished_entities = cache.get(f"{ledger_key}-finished_entities", False)
260
+
261
+ if finished_entities is False or ledger is False:
262
+ # Build the entries from the journal
263
+ self.entries = {}
264
+ for row in journal:
265
+ self.entries.setdefault(row["pk"], []).append(row)
266
+
267
+ # Process Auth Accounts first
268
+ ledger, finished_entities = self._process_auth_accounts()
269
+ # Process remaining entities
270
+ self._process_remaining_entities(ledger, finished_entities)
271
+ # Process corporation entity last to ensure it's always included
272
+ self._handle_entity(
273
+ ledger=ledger,
274
+ entity_id=self.corporation.corporation.corporation_id,
275
+ corporation_obj=self.corporation.corporation,
276
+ )
282
277
  # Finalize the billboard for the ledger.
283
278
  self.create_rattingbar(list(finished_entities))
284
- self.billboard.chord_handle_overflow()
279
+ self.create_chord(ledger)
285
280
 
286
- context = self._build_context(ledger_hash, ledger)
287
- cache.set(key=ledger_key, value=context, timeout=LEDGER_CACHE_STALE)
281
+ context = self._build_context(ledger=ledger)
282
+
283
+ # Create Cache
284
+ cache.set(key=f"{ledger_key}-data", value=ledger, timeout=LEDGER_CACHE_STALE)
285
+ cache.set(
286
+ key=f"{ledger_key}-finished_entities",
287
+ value=finished_entities,
288
+ timeout=LEDGER_CACHE_STALE,
289
+ )
288
290
  cache.set(
289
291
  key=self._get_ledger_header(
290
- self.corporation.corporation.corporation_id,
291
- self.year,
292
- self.month,
293
- self.day,
292
+ ledger_args=f"{self.corporation.corporation.corporation_id}_{self.division_id}",
293
+ year=self.year,
294
+ month=self.month,
295
+ day=self.day,
294
296
  ),
295
297
  value=ledger_hash,
296
298
  timeout=None, # Cache forever until the journal changes
297
299
  )
298
300
  return context
299
301
 
300
- def _process_accounts(self):
302
+ def _build_view_data(self, entity_id: int):
303
+ details_kwargs = {
304
+ "viewname": "corporation_details",
305
+ "corporation_id": self.corporation.corporation.corporation_id,
306
+ "entity_id": entity_id,
307
+ }
308
+ if self.division_id is not None:
309
+ details_kwargs["division_id"] = self.division_id
310
+ return details_kwargs
311
+
312
+ def _build_view_url(self, entity_id: int):
313
+ """Return the full URL for a corporation view for the given entity id.
314
+
315
+ This wraps create_url(**self._build_view_data(...)) so callers can
316
+ request the URL in a single, readable call without losing ordering.
317
+ """
318
+ return self.create_url(**self._build_view_data(entity_id=entity_id))
319
+
320
+ # pylint: disable=too-many-arguments
321
+ def _handle_entity(
322
+ self,
323
+ ledger: list,
324
+ entity_id: int,
325
+ character_obj=None,
326
+ corporation_obj=None,
327
+ alts=None,
328
+ add_finished: bool = True,
329
+ finished_ids=None,
330
+ ) -> set:
331
+ """Create entity object, add to ledger if it has data and return IDs to mark finished.
332
+
333
+ - ledger: list to append to
334
+ - entity_id: numeric id
335
+ - character_obj / corporation_obj: optional objects to attach to LedgerEntity
336
+ - alts: optional alts queryset passed to create_entity_data
337
+ - add_finished: whether to return ids that should be added to finished_entities
338
+ - finished_ids: explicit IDs (set or iterable) to mark finished (used for accounts)
339
+ """
340
+ details_url = self._build_view_url(entity_id)
341
+ entity_obj = LedgerEntity(
342
+ entity_id,
343
+ character_obj=character_obj,
344
+ corporation_obj=corporation_obj,
345
+ details_url=details_url,
346
+ )
347
+ char_data = self.create_entity_data(entity=entity_obj, alts=alts)
348
+ if char_data is None:
349
+ return set()
350
+ ledger.append(char_data)
351
+ if not add_finished:
352
+ return set()
353
+ if finished_ids is not None:
354
+ return set(finished_ids)
355
+ return {entity_id}
356
+
357
+ def _process_auth_accounts(self):
301
358
  """Process Auth Account information for the ledger."""
302
359
  ledger = []
303
360
  finished_entities = set()
@@ -309,27 +366,18 @@ class CorporationData(LedgerCore):
309
366
  alts = alts.filter(character__character_id__in=existing_alts)
310
367
  if not existing_alts:
311
368
  continue
312
- details_url = self.create_url(
313
- viewname="corporation_details",
314
- corporation_id=self.corporation.corporation.corporation_id,
315
- entity_id=account.main_character.character_id,
316
- )
317
- entity_obj = LedgerEntity(
318
- account.main_character.character_id,
319
- character_obj=account.main_character,
320
- details_url=details_url,
321
- )
322
- char_data = self.create_entity_data(
323
- entity=entity_obj,
324
- alts=alts,
369
+ finished_entities.update(
370
+ self._handle_entity(
371
+ ledger,
372
+ account.main_character.character_id,
373
+ character_obj=account.main_character,
374
+ alts=alts,
375
+ finished_ids=existing_alts,
376
+ )
325
377
  )
326
- if char_data is None:
327
- continue
328
- ledger.append(char_data)
329
- finished_entities.update(existing_alts)
330
378
  return ledger, finished_entities
331
379
 
332
- def _process_remaining_entities(self, ledger, finished_entities):
380
+ def _process_remaining_entities(self, ledger, finished_entities: set):
333
381
  """Process remaining entities for the ledger."""
334
382
  remaining_entities = self.entities - finished_entities
335
383
  if not remaining_entities:
@@ -339,56 +387,28 @@ class CorporationData(LedgerCore):
339
387
  continue
340
388
  if entity_id == self.corporation.corporation.corporation_id:
341
389
  continue
342
- details_url = self.create_url(
343
- viewname="corporation_details",
344
- corporation_id=self.corporation.corporation.corporation_id,
345
- entity_id=entity_id,
346
- )
347
- entity_obj = LedgerEntity(
348
- entity_id,
349
- details_url=details_url,
350
- )
351
- entity_data = self.create_entity_data(
352
- entity=entity_obj,
353
- )
354
- if entity_data is None:
355
- continue
356
- ledger.append(entity_data)
357
- finished_entities.add(entity_id)
358
-
359
- def _add_corporation_entity(self, ledger):
360
- """Add the corporation entity to the ledger."""
361
- corporation_entity = LedgerEntity(
362
- self.corporation.corporation.corporation_id,
363
- corporation_obj=self.corporation.corporation,
364
- details_url=self.create_url(
365
- viewname="corporation_details",
366
- corporation_id=self.corporation.corporation.corporation_id,
367
- entity_id=self.corporation.corporation.corporation_id,
368
- ),
369
- )
370
- corporation_data = self.create_entity_data(
371
- entity=corporation_entity,
372
- )
373
- if corporation_data is not None:
374
- ledger.append(corporation_data)
390
+ finished_entities.update(self._handle_entity(ledger, entity_id))
375
391
 
376
- def _build_context(self, journal_hash, ledger):
392
+ def _build_context(self, ledger):
377
393
  """Build the context for the ledger view."""
378
- return {
379
- "ledger_hash": journal_hash,
394
+ view = self._build_view_data(
395
+ entity_id=self.corporation.corporation.corporation_id
396
+ )
397
+
398
+ context = {
380
399
  "title": f"Corporation Ledger - {self.corporation.corporation.corporation_name}",
381
400
  "corporation_id": self.corporation.corporation.corporation_id,
401
+ "division_id": self.division_id,
382
402
  "billboard": json.dumps(self.billboard.dict.asdict()),
383
403
  "ledger": ledger,
404
+ "divisions": CorporationWalletDivision.objects.filter(
405
+ corporation=self.corporation
406
+ ).order_by("division_id"),
384
407
  "years": list(self.existing_years),
385
408
  "totals": self._calculate_totals(ledger),
386
- "view": self.create_view_data(
387
- viewname="corporation_details",
388
- corporation_id=self.corporation.corporation.corporation_id,
389
- entity_id=self.corporation.corporation.corporation_id,
390
- ),
409
+ "view": self.create_view_data(**view),
391
410
  }
411
+ return context
392
412
 
393
413
  def create_rattingbar(self, entities_ids: list = None):
394
414
  """Create the ratting bar for the view."""
@@ -402,4 +422,34 @@ class CorporationData(LedgerCore):
402
422
  .annotate_miscellaneous()
403
423
  )
404
424
  self.billboard.create_or_update_results(rattingbar)
405
- self.billboard.create_ratting_bar()
425
+ self._build_xy_chart(title=_("Ratting Bar"))
426
+
427
+ def create_chord(self, ledger_data: list[dict]):
428
+ """Create the chord chart for the view."""
429
+ if not ledger_data:
430
+ return
431
+
432
+ for entry in ledger_data:
433
+ entity_name = entry["entity"].entity_name
434
+ ledger = entry["ledger"]
435
+ self.billboard.chord_add_data(
436
+ chord_from=entity_name,
437
+ chord_to=_("Bounty (Wallet)"),
438
+ value=ledger.get("bounty", 0),
439
+ )
440
+ self.billboard.chord_add_data(
441
+ chord_from=entity_name,
442
+ chord_to=_("ESS (Wallet)"),
443
+ value=ledger.get("ess", 0),
444
+ )
445
+ self.billboard.chord_add_data(
446
+ chord_from=entity_name,
447
+ chord_to=_("Costs (Wallet)"),
448
+ value=abs(ledger.get("costs", 0)),
449
+ )
450
+ self.billboard.chord_add_data(
451
+ chord_from=entity_name,
452
+ chord_to=_("Miscellaneous (Wallet)"),
453
+ value=abs(ledger.get("miscellaneous", 0)),
454
+ )
455
+ self.billboard.chord_handle_overflow()
ledger/helpers/etag.py CHANGED
@@ -16,6 +16,7 @@ from app_utils.logging import LoggerAddTag
16
16
 
17
17
  # AA Ledger
18
18
  from ledger import __title__
19
+ from ledger.app_settings import LEDGER_CACHE_KEY
19
20
  from ledger.decorators import log_timing
20
21
  from ledger.errors import HTTPGatewayTimeoutError, NotModifiedError
21
22
 
@@ -26,7 +27,7 @@ MAX_ETAG_LIFE = 60 * 60 * 24 * 7 # 7 Days
26
27
 
27
28
  def get_etag_key(operation):
28
29
  """Get ETag Key"""
29
- return "ledger-" + operation._cache_key()
30
+ return f"{LEDGER_CACHE_KEY}-{operation._cache_key()}"
30
31
 
31
32
 
32
33
  def get_etag_header(operation):