Taxes extends AppModel
Tax rule management
Table of Contents
Methods
| __construct() | Initialize Taxes |
| add() | Adds a tax rule to the system |
| delete() | Sets a tax to inactive |
| edit() | Updates a tax rule |
| get() | Fetches a tax |
| getAll() | Retrieves a list of all tax rules for a particular company |
| getTaxLevels() | Fetches all tax levels |
| getTaxStatus() | Fetchas all status types |
| getTaxTypes() | Fetches all tax types |
| validateStatus() | Validates a tax's 'status' field |
| validateType() | Validates a tax's 'type' field |
| getRules() | Returns the rule set for adding/editing taxes |
Methods
__construct()
Initialize Taxes
public
__construct() : mixed
add()
Adds a tax rule to the system
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of tax info including:
- company_id The company ID this tax rule applies to.
- level The tax level this rule will be apart of.
- name The name of the tax rule (optional, default NULL)
- amount The tax amount (optional, default 0.00)
- type The tax type (optional, default 'exclusive')
- country The country this tax rule will apply to (optional, defalut NULL)
- state The state this tax rule will apply to (optional, default NULL)
- status The status of this tax rule (optional, default 'active')
Return values
int —The ID of the tax rule created, void on error
delete()
Sets a tax to inactive
public
delete(int $tax_id) : mixed
Parameters
- $tax_id : int
-
The ID of the tax rule to mark deleted (inactive)
edit()
Updates a tax rule
public
edit(int $tax_id, array<string|int, mixed> $vars) : int
Parameters
- $tax_id : int
-
The tax ID
- $vars : array<string|int, mixed>
-
An array of tax info including:
- company_id The company ID this tax rule applies to.
- level The tax level this rule will be apart of.
- name The name of the tax rule (optional, default NULL)
- amount The tax amount (optional, default 0.00)
- type The tax type (optional, default 'exclusive')
- country The country this tax rule will apply to (optional, default NULL)
- state The state tis tax rule will apply to (optional, default NULL)
- status The status of this tax rule (optional, default 'active')
Return values
int —The ID of the tax rule created, void on error
get()
Fetches a tax
public
get(int $tax_id) : mixed
Parameters
- $tax_id : int
-
The tax ID
Return values
mixed —A stdClass objects representing the tax, false if it does not exist
getAll()
Retrieves a list of all tax rules for a particular company
public
getAll(int $company_id) : mixed
Parameters
- $company_id : int
-
The company ID
Return values
mixed —An array of stdClass objects representing tax rules, or false if none exist
getTaxLevels()
Fetches all tax levels
public
getTaxLevels() : array<string|int, mixed>
Return values
array<string|int, mixed> —A key=>value array of tax levels
getTaxStatus()
Fetchas all status types
public
getTaxStatus() : array<string|int, mixed>
Return values
array<string|int, mixed> —A key=>value array of tax statuses
getTaxTypes()
Fetches all tax types
public
getTaxTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A key=>value array of tax types
validateStatus()
Validates a tax's 'status' field
public
validateStatus(string $status) : bool
Parameters
- $status : string
-
The status to check
Return values
bool —True if the status is validated, false otherwise
validateType()
Validates a tax's 'type' field
public
validateType(string $type) : bool
Parameters
- $type : string
-
The type to check
Return values
bool —True if the type is validated, false otherwise
getRules()
Returns the rule set for adding/editing taxes
private
getRules() : array<string|int, mixed>
Return values
array<string|int, mixed> —Tax rules