Function __global->points_ledger_calculate

Definitions

sources/points.php

  • This is a low-level function to calculate the number of points directly from the ledger for the given criteria.This function accounts (adjusts) for reversed and refunded transactions as well.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$types integer No No required parameter N/A N/A The calculations we want to return (see LEDGER_TYPE_*)
$primary_member MEMBER No No required parameter N/A N/A The member to calculate (received: The member receiving the points) (sent and spent: the member using the points)
$secondary_member ?MEMBER No No Null N/A N/A Optionally filter to a secondary member (received: The member who sent the points to the primary member) (sent: The member who received the points from the primary member) (spent: always the system) (null: any member)
$where LONG_TEXT No No Blank (empty string) N/A N/A Optionally add additional WHERE to the SQL (should start with ' AND')

Returns

  • Map; key is a type based on $types, value is the tuple of [count of active transactions matching criteria, number of points, number of gift points]
  • Type: array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * This is a low-level function to calculate the number of points directly from the ledger for the given criteria.This function accounts (adjusts) for reversed and refunded transactions as well.
 *
 * @param  integer $types The calculations we want to return (see LEDGER_TYPE_*)
 * @param  MEMBER $primary_member The member to calculate (received: The member receiving the points) (sent and spent: the member using the points)
 * @param  ?MEMBER $secondary_member Optionally filter to a secondary member (received: The member who sent the points to the primary member) (sent: The member who received the points from the primary member) (spent: always the system) (null: any member)
 * @param  LONG_TEXT $where Optionally add additional WHERE to the SQL (should start with ' AND')
 * @return array Map; key is a type based on $types, value is the tuple of [count of active transactions matching criteria, number of points, number of gift points]
 */

function points_ledger_calculate(int $types, int $primary_member, ?int $secondary_member = null, string $where = '') : array