@@ -215,8 +215,7 @@ PyResult AccountService::GiveCash(PyCallArgs& call, PyInt* toID, PyFloat* amount
215
215
return GiveCash (call, toID, amount, reason.has_value ()?reason.value ()->content ():std::string ());
216
216
}
217
217
218
- PyResult AccountService::GiveCash (PyCallArgs &call, PyInt* toID, PyFloat* amount, std::string reason)
219
- {
218
+ PyResult AccountService::GiveCash (PyCallArgs &call, PyInt* toID, PyFloat* amount, std::string reason) {
220
219
if (is_log_enabled (ACCOUNT__CALL_DUMP)) {
221
220
sLog .Log ( " AccountService::Handle_GiveCash()" , " size=%lu" , call.tuple ->size ());
222
221
call.Dump (ACCOUNT__CALL_DUMP);
@@ -233,7 +232,15 @@ PyResult AccountService::GiveCash(PyCallArgs &call, PyInt* toID, PyFloat* amount
233
232
reasonStr += reason;
234
233
}
235
234
236
- TranserFunds (call.client ->GetCharacterID (), toID->value (), amount->value (), reasonStr.c_str (), Journal::EntryType::PlayerDonation, call.client ->GetCharacterID ());
235
+ TransferFunds (
236
+ call.client ->GetCharacterID (),
237
+ toID->value (),
238
+ amount->value (),
239
+ reasonStr.c_str (),
240
+ Journal::EntryType::PlayerDonation,
241
+ call.client ->GetCharacterID ()
242
+ );
243
+
237
244
return nullptr ;
238
245
}
239
246
@@ -273,43 +280,97 @@ PyResult AccountService::GiveCashFromCorpAccount(PyCallArgs &call, PyInt* toID,
273
280
reason += call.client ->GetCharName ();
274
281
}
275
282
276
- TranserFunds (call.client ->GetCorporationID (), toID->value (), amount->value (), reason.c_str (), Journal::EntryType::CorporationAccountWithdrawal, \
277
- call.client ->GetCharacterID (), fromAcctKey->value (), toAcctKey, call.client );
283
+ TransferFunds (
284
+ call.client ->GetCorporationID (),
285
+ toID->value (),
286
+ amount->value (),
287
+ reason.c_str (),
288
+ Journal::EntryType::CorporationAccountWithdrawal,
289
+ call.client ->GetCharacterID (),
290
+ fromAcctKey->value (),
291
+ toAcctKey,
292
+ call.client
293
+ );
294
+
278
295
return nullptr ;
279
296
}
280
297
281
- void AccountService::TranserFunds (uint32 fromID, uint32 toID, double amount, std::string reason /* ""*/ , uint8 entryTypeID /* Journal::EntryType::Undefined*/ , \
282
- uint32 referenceID/* 0*/ , uint16 fromKey/* Account::KeyType::Cash*/ , uint16 toKey/* Account::KeyType::Cash*/ ,
283
- Client* pClient/* nullptr*/ )
284
- {
285
- if (is_log_enabled (ACCOUNT__TRACE))
286
- _log (ACCOUNT__TRACE, " TranserFunds() - from: %u, to: %u, entry: %u, refID: %u, amount: %.2f, fKey: %u, tKey: %u" , \
287
- fromID, toID, entryTypeID, referenceID, amount, fromKey, toKey);
298
+ void AccountService::TransferFunds (
299
+ uint32 fromID,
300
+ uint32 toID,
301
+ double amount,
302
+ std::string reason /* ""*/ ,
303
+ uint8 entryTypeID /* Journal::EntryType::Undefined*/ ,
304
+ uint32 referenceID /* 0*/ ,
305
+ uint16 fromKey /* Account::KeyType::Cash*/ ,
306
+ uint16 toKey /* Account::KeyType::Cash*/ ,
307
+ Client* pClient /* nullptr*/
308
+ ) {
309
+ if (is_log_enabled (ACCOUNT__TRACE)) {
310
+ _log (ACCOUNT__TRACE,
311
+ " TransferFunds() - from: %u, to: %u, entry: %u, refID: %u, amount: %.2f, fKey: %u, tKey: %u" ,
312
+ fromID,
313
+ toID,
314
+ entryTypeID,
315
+ referenceID,
316
+ amount,
317
+ fromKey,
318
+ toKey
319
+ );
320
+ }
321
+
288
322
uint8 fromCurrency = Account::CreditType::ISK;
323
+
289
324
if (IsAUR (fromKey)) {
290
325
fromCurrency = Account::CreditType::AURUM;
291
326
} else if (IsDustKey (fromKey)) {
292
327
fromCurrency = Account::CreditType::MPLEX;
293
328
}
294
329
295
330
double newBalanceFrom (0 ), newBalanceTo (0 );
331
+
296
332
Client* pClientFrom (nullptr );
333
+
297
334
if (IsCharacterID (fromID)) {
298
335
pClientFrom = sEntityList .FindClientByCharID (fromID);
299
336
if (pClientFrom == nullptr ) {
300
- // sender is offline. xfer funds thru db.
337
+ // sender is offline. transfer funds through the database instead
301
338
newBalanceFrom = AccountDB::OfflineFundXfer (fromID, -amount, fromCurrency);
302
339
} else {
303
340
// this will throw if it fails
304
341
pClientFrom->AddBalance (-amount, fromCurrency);
305
342
newBalanceFrom = pClientFrom->GetBalance (fromCurrency);
306
343
}
307
- AccountDB::AddJournalEntry (fromID, entryTypeID, fromID, toID, fromCurrency, fromKey, -amount, newBalanceFrom, reason, referenceID);
344
+
345
+ AccountDB::AddJournalEntry (
346
+ fromID,
347
+ entryTypeID,
348
+ fromID,
349
+ toID,
350
+ fromCurrency,
351
+ fromKey,
352
+ -amount,
353
+ newBalanceFrom,
354
+ reason,
355
+ referenceID
356
+ );
308
357
} else if (IsPlayerCorp (fromID)) {
309
358
uint32 userID (0 );
310
- if (pClient != nullptr )
359
+ if (pClient != nullptr ) {
311
360
userID = pClient->GetCharacterID ();
312
- HandleCorpTransaction (fromID, entryTypeID, userID?userID:fromID, toID, fromCurrency, fromKey, -amount, reason, referenceID);
361
+ }
362
+
363
+ HandleCorpTransaction (
364
+ fromID,
365
+ entryTypeID,
366
+ userID ? userID : fromID,
367
+ toID,
368
+ fromCurrency,
369
+ fromKey,
370
+ -amount,
371
+ reason,
372
+ referenceID
373
+ );
313
374
} // fromID could be npc or _System. nothing to do on this side.
314
375
315
376
uint8 toCurrency = Account::CreditType::ISK;
@@ -320,6 +381,7 @@ void AccountService::TranserFunds(uint32 fromID, uint32 toID, double amount, std
320
381
}
321
382
322
383
Client* pClientTo (nullptr );
384
+
323
385
if (IsCharacterID (toID)) {
324
386
pClientTo = sEntityList .FindClientByCharID (toID);
325
387
if (pClientTo == nullptr ) {
@@ -329,24 +391,67 @@ void AccountService::TranserFunds(uint32 fromID, uint32 toID, double amount, std
329
391
// this will throw if it fails
330
392
pClientTo->AddBalance (amount, toCurrency);
331
393
/* * @todo if this DOES fail, return funds to origin. this needs a try/catch block */
332
- // TranserFunds (corpSCC, fromID, amount, reason, Journal::EntryType::Undefined, referenceID, fromKey, fromKey);
394
+ // TransferFunds (corpSCC, fromID, amount, reason, Journal::EntryType::Undefined, referenceID, fromKey, fromKey);
333
395
newBalanceTo = pClientTo->GetBalance (toCurrency);
334
396
}
335
- AccountDB::AddJournalEntry (toID, entryTypeID, fromID, toID, toCurrency, toKey, amount, newBalanceTo, reason, referenceID);
397
+
398
+ AccountDB::AddJournalEntry (
399
+ toID,
400
+ entryTypeID,
401
+ fromID,
402
+ toID,
403
+ toCurrency,
404
+ toKey,
405
+ amount,
406
+ newBalanceTo,
407
+ reason,
408
+ referenceID
409
+ );
336
410
} else if (IsPlayerCorp (toID)) {
337
411
uint32 userID (0 );
338
- if (pClient != nullptr )
412
+
413
+ if (pClient != nullptr ) {
339
414
userID = pClient->GetCharacterID ();
340
- HandleCorpTransaction (toID, entryTypeID, fromID, userID?userID:toID, toCurrency, toKey, amount, reason, referenceID);
415
+ }
416
+
417
+ HandleCorpTransaction (
418
+ toID,
419
+ entryTypeID,
420
+ fromID,
421
+ userID?userID:toID,
422
+ toCurrency,
423
+ toKey,
424
+ amount,
425
+ reason,
426
+ referenceID
427
+ );
341
428
return ;
342
429
} else {
343
- _log (ACCOUNT__TRACE, " TranserFunds() - toID: %s(%u) is neither player nor player corp. Not sending update." , \
344
- sDataMgr .GetCorpName (toID).c_str (), toID);
430
+ AccountDB::AddJournalEntry (
431
+ toID,
432
+ entryTypeID,
433
+ fromID,
434
+ toID,
435
+ toCurrency,
436
+ toKey,
437
+ amount,
438
+ newBalanceTo,
439
+ reason,
440
+ referenceID
441
+ );
442
+
443
+ _log (ACCOUNT__TRACE,
444
+ " TransferFunds() - toID: %s(%u) is neither player nor player corp. Not sending update." ,
445
+ sDataMgr .GetCorpName (toID).c_str (),
446
+ toID
447
+ );
448
+
345
449
return ;
346
450
}
347
451
348
- if ((pClientTo != nullptr ) and pClientTo->IsCharCreation ())
452
+ if ((pClientTo != nullptr ) and pClientTo->IsCharCreation ()) {
349
453
return ;
454
+ }
350
455
351
456
/* corp taxes...
352
457
* bounty prizes and mission rewards are taxed by the players corp based on corp tax rate.
@@ -355,13 +460,18 @@ void AccountService::TranserFunds(uint32 fromID, uint32 toID, double amount, std
355
460
*/
356
461
357
462
// are bounty payments grouped on timer?
358
- if ((entryTypeID == Journal::EntryType::BountyPrize)
359
- or (entryTypeID == Journal::EntryType::BountyPrizes))
360
- if ( sConfig . server . BountyPayoutDelayed )
361
- if (amount < sConfig .rates .TaxedAmount ) // is amount worth taxing? default is 75k
463
+ if ((entryTypeID == Journal::EntryType::BountyPrize) || (entryTypeID == Journal::EntryType::BountyPrizes)) {
464
+ if ( sConfig . server . BountyPayoutDelayed ) {
465
+ // is amount worth taxing? default is 75k
466
+ if (amount < sConfig .rates .TaxedAmount ) {
362
467
return ;
468
+ }
469
+ }
470
+ }
471
+
363
472
float tax = 0 ;
364
473
uint32 corpID = 0 ;
474
+
365
475
if (pClientTo != nullptr ) {
366
476
tax = pClientTo->GetCorpTaxRate () * amount;
367
477
corpID = pClientTo->GetCorporationID ();
@@ -372,24 +482,48 @@ void AccountService::TranserFunds(uint32 fromID, uint32 toID, double amount, std
372
482
}
373
483
374
484
// just in case something went wrong.....
375
- if (!IsCorp (corpID))
485
+ if (!IsCorp (corpID)) {
376
486
return ;
377
- // is tax worth the accounting hassle? (from corp pov) default is 5k
378
- if (tax < sConfig .rates .TaxAmount )
487
+ }
488
+
489
+ // is tax worth the accounting hassle? (from corp pov) default is 5k
490
+ if (tax < sConfig .rates .TaxAmount ) {
379
491
return ;
492
+ }
380
493
381
494
reason = " DESC: Corporation Tax on pirate bounty" ;
382
495
switch (entryTypeID) {
383
496
// Corp Taxed payment types
384
497
case Journal::EntryType::BountyPrize:
385
498
case Journal::EntryType::BountyPrizes: {
386
- TranserFunds (toID, corpID, tax, reason.c_str (), Journal::EntryType::CorporationTaxNpcBounties, referenceID);
499
+ TransferFunds (
500
+ toID,
501
+ corpID,
502
+ tax,
503
+ reason.c_str (),
504
+ Journal::EntryType::CorporationTaxNpcBounties,
505
+ referenceID
506
+ );
387
507
} break ;
388
508
case Journal::EntryType::AgentMissionReward: {
389
- TranserFunds (toID, corpID, tax, reason.c_str (), Journal::EntryType::CorporationTaxAgentRewards, referenceID);
509
+ TransferFunds (
510
+ toID,
511
+ corpID,
512
+ tax,
513
+ reason.c_str (),
514
+ Journal::EntryType::CorporationTaxAgentRewards,
515
+ referenceID
516
+ );
390
517
} break ;
391
518
case Journal::EntryType::AgentMissionTimeBonusReward: {
392
- TranserFunds (toID, corpID, tax, reason.c_str (), Journal::EntryType::CorporationTaxAgentBonusRewards, referenceID);
519
+ TransferFunds (
520
+ toID,
521
+ corpID,
522
+ tax,
523
+ reason.c_str (),
524
+ Journal::EntryType::CorporationTaxAgentBonusRewards,
525
+ referenceID
526
+ );
393
527
} break ;
394
528
}
395
529
}
0 commit comments