Skip to content

Commit

Permalink
OHRM5X-2076: Develop claim - expense API (orangehrm#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nethmin Dulsara authored Feb 24, 2023
1 parent cc7e14a commit 7cf3aa6
Show file tree
Hide file tree
Showing 19 changed files with 1,756 additions and 19 deletions.
50 changes: 47 additions & 3 deletions installer/Migration/V5_4_0/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public function up(): void

$this->updateLangStringVersion($this->getVersion());

if (!$this->getSchemaHelper()->tableExists(['
'])) {
if (!$this->getSchemaHelper()->tableExists(['ohrm_claim_event'])) {
$this->getSchemaHelper()->createTable('ohrm_claim_event')
->addColumn('id', Types::INTEGER, ['Autoincrement' => true])
->addColumn('name', Types::TEXT, ['Notnull' => true, 'Length' => 100])
Expand Down Expand Up @@ -192,6 +191,35 @@ public function up(): void
);
$this->getSchemaHelper()->addForeignKey('ohrm_enforce_password', $foreignKeyConstraint);

if (!$this->getSchemaHelper()->tableExists(['ohrm_expense'])) {
$this->getSchemaHelper()->createTable('ohrm_expense')
->addColumn('id', Types::INTEGER, ['Autoincrement' => true])
->addColumn('expense_type_id', Types::INTEGER, ['Notnull' => false])
->addColumn('date', Types::DATE_MUTABLE, ['Notnull' => false])
->addColumn('amount', Types::DECIMAL, ['Notnull' => false, 'Scale' => 2, 'Precision' => 12])
->addColumn('note', Types::TEXT, ['Notnull' => false])
->addColumn('request_id', Types::INTEGER, ['Notnull' => false])
->addColumn('is_deleted', Types::SMALLINT, ['Notnull' => true, 'Default' => 0])
->setPrimaryKey(['id'])
->create();
$foreignKeyConstraint1 = new ForeignKeyConstraint(
['expense_type_id'],
'ohrm_expense_type',
['id'],
'expenseTypeId',
['onDelete' => 'CASCADE']
);
$this->getSchemaHelper()->addForeignKey('ohrm_expense', $foreignKeyConstraint1);
$foreignKeyConstraint2 = new ForeignKeyConstraint(
['request_id'],
'ohrm_claim_request',
['id'],
'claimRequsetId',
['onDelete' => 'CASCADE']
);
$this->getSchemaHelper()->addForeignKey('ohrm_expense', $foreignKeyConstraint2);
}

$this->changeClaimExpenseTypeTableStatusToBoolean();
$this->modifyClaimTables();
$this->modifyClaimRequestCurrencyToForeignKey();
Expand Down Expand Up @@ -304,6 +332,19 @@ private function modifyClaimTables(): void
],
]);

$this->getSchemaHelper()->addOrChangeColumns('ohrm_expense', [
'date' => [
'Type' => Type::getType(Types::DATETIME_MUTABLE)
],
'note' => [
'Type' => Type::getType(Types::STRING),
'Length' => 1000
],
'is_deleted' => [
'Type' => Type::getType(Types::BOOLEAN),
],
]);

$this->getSchemaHelper()->renameColumn('ohrm_claim_request', 'currency', 'currency_id');
}

Expand Down Expand Up @@ -418,7 +459,10 @@ public function modifyDefaultRequiredPasswordStrength(): void
{
$value = $this->getConfigHelper()->getConfigValue('authentication.default_required_password_strength');

if ($value === "veryWeak" || $value === "weak" || $value === "better"
if (
$value === "veryWeak"
|| $value === "weak"
|| $value === "better"
|| $value === "medium"
|| $value === "strong"
|| $value === "strongest"
Expand Down
19 changes: 16 additions & 3 deletions installer/Migration/V5_4_0/permission/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,23 @@ apiv2_claim_request:
api: OrangeHRM\Claim\Api\ClaimRequestAPI
module: claim
allowed:
read: false
read: true
create: true
update: true
delete: false
permissions:
- { role: Admin, permission: { read: false, create: true, update: true, delete: false } }
- { role: ESS, permission: { read: false, create: false, update: true, delete: false } }
- { role: Admin, permission: { read: true, create: true, update: true, delete: false } }
- { role: ESS, permission: { read: true, create: true, update: true, delete: false } }

apiv2_claim_expense:
description: 'Claim - Claim Expenses'
api: OrangeHRM\Claim\Api\ClaimExpenseAPI
module: claim
allowed:
read: true
create: true
update: true
delete: true
permissions:
- { role: Admin, permission: { read: true, create: true, update: true, delete: true } }
- { role: ESS, permission: { read: true, create: true, update: true, delete: true } }
1 change: 0 additions & 1 deletion src/plugins/orangehrmClaimPlugin/Api/ClaimEventAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ protected function getNameRule(bool $update): ParamRule
);
}
$entityProperties->setIgnoreValues($ignoreValues);

return new ParamRule(
self::PARAMETER_NAME,
new Rule(Rules::STRING_TYPE),
Expand Down
Loading

0 comments on commit 7cf3aa6

Please sign in to comment.