Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2363c2947d | |||
| 280f8cefa4 | |||
| 18936570c5 | |||
| f6b036976f | |||
| eb47c2a9bc | |||
| fb5a007fdc | |||
| 192a70d46e | |||
| 65eb1dfc62 | |||
| 07d442a654 | |||
| a2e37f5903 | |||
| 11bbfc1745 | |||
| e5075859c4 | |||
| 282e8705b2 | |||
| 91cbcf87db | |||
| bbd033f175 | |||
| a5f6d55151 | |||
| 4dd102f67d | |||
| cdcf08b209 |
@@ -1,16 +0,0 @@
|
|||||||
.git
|
|
||||||
.gitea
|
|
||||||
node_modules
|
|
||||||
vendor
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
|
||||||
storage/logs
|
|
||||||
storage/framework/cache
|
|
||||||
storage/framework/sessions
|
|
||||||
storage/framework/views
|
|
||||||
storage/debugbar
|
|
||||||
npm-debug.log
|
|
||||||
Dockerfile
|
|
||||||
docker-compose.yml
|
|
||||||
docker-compose.staging.yml
|
|
||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
APP_NAME=Lumen
|
|
||||||
APP_ENV=local
|
|
||||||
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
|
||||||
APP_DEBUG=true
|
|
||||||
APP_URL=http://localhost
|
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
|
||||||
LOG_LEVEL=debug
|
|
||||||
LOG_SLACK_WEBHOOK_URL=
|
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
|
||||||
DB_HOST=mysql
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_DATABASE=erahn_xtra
|
|
||||||
DB_USERNAME=root
|
|
||||||
DB_PASSWORD=root
|
|
||||||
|
|
||||||
DB_CONNECTION_7=mysql
|
|
||||||
DB_HOST_7=mysql
|
|
||||||
DB_PORT_7=3306
|
|
||||||
DB_DATABASE_7=master_erahn
|
|
||||||
DB_USERNAME_7=root
|
|
||||||
DB_PASSWORD_7=root
|
|
||||||
|
|
||||||
# DB_CONNECTION_3=mysql
|
|
||||||
# DB_HOST_3=127.0.0.1
|
|
||||||
# DB_PORT_3=3306
|
|
||||||
# DB_DATABASE_3=erahn_baling
|
|
||||||
# DB_USERNAME_3=root
|
|
||||||
# DB_PASSWORD_3=root
|
|
||||||
|
|
||||||
# DB_CONNECTION_4=mysql
|
|
||||||
# DB_HOST_4=127.0.0.1
|
|
||||||
# DB_PORT_4=3306
|
|
||||||
# DB_DATABASE_4=arrahn_ld
|
|
||||||
# DB_USERNAME_4=root
|
|
||||||
# DB_PASSWORD_4=root
|
|
||||||
|
|
||||||
# DB_CONNECTION_5=mysql
|
|
||||||
# DB_HOST_5=127.0.0.1
|
|
||||||
# DB_PORT_5=3306
|
|
||||||
# DB_DATABASE_5=erahn_segamat
|
|
||||||
# DB_USERNAME_5=root
|
|
||||||
# DB_PASSWORD_5=root
|
|
||||||
|
|
||||||
# DB_CONNECTION_6=mysql
|
|
||||||
# DB_HOST_6=127.0.0.1
|
|
||||||
# DB_PORT_6=3306
|
|
||||||
# DB_DATABASE_6=arrahn_kb2
|
|
||||||
# DB_USERNAME_6=spider
|
|
||||||
# DB_PASSWORD_6=G0dz!ll42020
|
|
||||||
|
|
||||||
|
|
||||||
# DB_CONNECTION_8=mysql
|
|
||||||
# DB_HOST_8=127.0.0.1
|
|
||||||
# DB_PORT_8=3306
|
|
||||||
# DB_DATABASE_8=arrahn_klanas
|
|
||||||
# DB_USERNAME_8=spider
|
|
||||||
# DB_PASSWORD_8=G0dz!ll42020
|
|
||||||
|
|
||||||
TENNANT_MASTER_DB=master_erahn
|
|
||||||
TENNANT_KAUNTER_DB=kaunter_erahn
|
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
|
||||||
QUEUE_CONNECTION=sync
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
APP_NAME=Lumen
|
|
||||||
APP_ENV=staging
|
|
||||||
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
|
||||||
APP_DEBUG=true
|
|
||||||
APP_URL=http://127.0.0.1:8090
|
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
|
||||||
|
|
||||||
# Unique host ports — change these if they collide with other containers on the server.
|
|
||||||
# Host nginx should proxy the staging domain to 127.0.0.1:${HTTP_PORT}
|
|
||||||
HTTP_PORT=8090
|
|
||||||
MYSQL_PUBLISH_PORT=3308
|
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
|
||||||
LOG_LEVEL=debug
|
|
||||||
LOG_SLACK_WEBHOOK_URL=
|
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
|
||||||
DB_HOST=mysql
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_DATABASE=erahn_xtra
|
|
||||||
DB_USERNAME=root
|
|
||||||
DB_PASSWORD=root
|
|
||||||
|
|
||||||
DB_CONNECTION_7=mysql
|
|
||||||
DB_HOST_7=mysql
|
|
||||||
DB_PORT_7=3306
|
|
||||||
DB_DATABASE_7=master_erahn
|
|
||||||
DB_USERNAME_7=root
|
|
||||||
DB_PASSWORD_7=root
|
|
||||||
|
|
||||||
DB_CONNECTION_2=mysql
|
|
||||||
DB_HOST_2=mysql
|
|
||||||
DB_PORT_2=3306
|
|
||||||
DB_DATABASE_2=erahn_xtra
|
|
||||||
DB_USERNAME_2=root
|
|
||||||
DB_PASSWORD_2=root
|
|
||||||
|
|
||||||
DB_CONNECTION_3=mysql
|
|
||||||
DB_HOST_3=mysql
|
|
||||||
DB_PORT_3=3306
|
|
||||||
DB_DATABASE_3=erahn_baling
|
|
||||||
DB_USERNAME_3=root
|
|
||||||
DB_PASSWORD_3=root
|
|
||||||
|
|
||||||
DB_CONNECTION_4=mysql
|
|
||||||
DB_HOST_4=mysql
|
|
||||||
DB_PORT_4=3306
|
|
||||||
DB_DATABASE_4=arrahn_ld
|
|
||||||
DB_USERNAME_4=root
|
|
||||||
DB_PASSWORD_4=root
|
|
||||||
|
|
||||||
DB_CONNECTION_5=mysql
|
|
||||||
DB_HOST_5=mysql
|
|
||||||
DB_PORT_5=3306
|
|
||||||
DB_DATABASE_5=erahn_segamat
|
|
||||||
DB_USERNAME_5=root
|
|
||||||
DB_PASSWORD_5=root
|
|
||||||
|
|
||||||
DB_CONNECTION_7=mysql
|
|
||||||
DB_HOST_7=mysql
|
|
||||||
DB_PORT_7=3306
|
|
||||||
DB_DATABASE_7=master_erahn
|
|
||||||
DB_USERNAME_7=root
|
|
||||||
DB_PASSWORD_7=root
|
|
||||||
|
|
||||||
DB_CONNECTION_6=mysql
|
|
||||||
DB_HOST_6=mysql
|
|
||||||
DB_PORT_6=3306
|
|
||||||
DB_DATABASE_6=erahn_test
|
|
||||||
DB_USERNAME_6=root
|
|
||||||
DB_PASSWORD_6=root
|
|
||||||
|
|
||||||
# DB_CONNECTION_8=mysql
|
|
||||||
# DB_HOST_8=mysql
|
|
||||||
# DB_PORT_8=3306
|
|
||||||
# DB_DATABASE_8=arrahn_klanas
|
|
||||||
# DB_USERNAME_8=spider
|
|
||||||
# DB_PASSWORD_8=G0dz!ll42020
|
|
||||||
|
|
||||||
TENNANT_MASTER_DB=master_erahn
|
|
||||||
TENNANT_KAUNTER_DB=kaunter_erahn
|
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
|
||||||
QUEUE_CONNECTION=sync
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
name: Build Docker Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- staging
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-backend:
|
|
||||||
runs-on: docker
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Login to Docker registry
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
|
||||||
docker login git.koppkb.com \
|
|
||||||
-u "${{ secrets.REGISTRY_USERNAME }}" \
|
|
||||||
--password-stdin
|
|
||||||
|
|
||||||
- name: Build & push backend image
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
IMAGE="git.koppkb.com/kopkb/api_arrahn"
|
|
||||||
TAGS="-t ${IMAGE}:${{ gitea.sha }}"
|
|
||||||
|
|
||||||
if [ "${{ gitea.ref_type }}" = "tag" ] && echo "${{ gitea.ref_name }}" | grep -q '^v'; then
|
|
||||||
TAGS="${TAGS} -t ${IMAGE}:${{ gitea.ref_name }}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ gitea.ref_name }}" = "staging" ]; then
|
|
||||||
TAGS="${TAGS} -t ${IMAGE}:staging"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Building and pushing backend: ${TAGS}"
|
|
||||||
docker buildx build \
|
|
||||||
--target staging \
|
|
||||||
--platform linux/amd64 \
|
|
||||||
--cache-from type=registry,ref=${IMAGE}:buildcache,ignore-error=true \
|
|
||||||
--cache-to type=registry,ref=${IMAGE}:buildcache,mode=max \
|
|
||||||
-f docker/php/Dockerfile \
|
|
||||||
${TAGS} \
|
|
||||||
--push .
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
name: Deploy to Staging
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
image_tag:
|
|
||||||
description: "Docker image tag to deploy (commit SHA, staging, or v*)"
|
|
||||||
required: true
|
|
||||||
default: "staging"
|
|
||||||
type: string
|
|
||||||
|
|
||||||
env:
|
|
||||||
APP_IMAGE: git.koppkb.com/kopkb/api_arrahn
|
|
||||||
DEPLOY_DIR: /home/arrahn/Project/api_arrahn
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: host
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ inputs.image_tag }}
|
|
||||||
|
|
||||||
- name: Login to Docker registry
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
|
||||||
docker login git.koppkb.com \
|
|
||||||
-u "${{ secrets.REGISTRY_USERNAME }}" \
|
|
||||||
--password-stdin
|
|
||||||
|
|
||||||
- name: Verify image exists in registry
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
|
||||||
IMAGE="${APP_IMAGE}:${IMAGE_TAG}"
|
|
||||||
|
|
||||||
echo "Checking if image exists: ${IMAGE}"
|
|
||||||
if ! docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
|
|
||||||
echo "ERROR: Image ${IMAGE} does not exist in registry!"
|
|
||||||
echo "Run the Build Docker Image workflow first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✓ ${IMAGE} found"
|
|
||||||
|
|
||||||
- name: Pull Docker image
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
|
||||||
docker pull "${APP_IMAGE}:${IMAGE_TAG}"
|
|
||||||
echo "✓ Image pulled successfully"
|
|
||||||
|
|
||||||
- name: Sync compose file and deploy
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
|
||||||
|
|
||||||
mkdir -p "${DEPLOY_DIR}/docker/nginx" "${DEPLOY_DIR}/docker/mysql"
|
|
||||||
cp docker-compose.staging.yml "${DEPLOY_DIR}/docker-compose.yml"
|
|
||||||
cp docker/nginx/default.conf "${DEPLOY_DIR}/docker/nginx/default.conf"
|
|
||||||
cp -R docker/mysql/init "${DEPLOY_DIR}/docker/mysql/"
|
|
||||||
|
|
||||||
if [ ! -f "${DEPLOY_DIR}/.env.staging" ]; then
|
|
||||||
if [ -f .env.staging ]; then
|
|
||||||
cp .env.staging "${DEPLOY_DIR}/.env.staging"
|
|
||||||
echo "Copied .env.staging from repo (first deploy). Edit ${DEPLOY_DIR}/.env.staging on the server if needed."
|
|
||||||
else
|
|
||||||
echo "ERROR: ${DEPLOY_DIR}/.env.staging is missing on the server"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${DEPLOY_DIR}"
|
|
||||||
|
|
||||||
export APP_IMAGE
|
|
||||||
export IMAGE_TAG
|
|
||||||
|
|
||||||
docker compose --env-file .env.staging -f docker-compose.yml pull app
|
|
||||||
docker compose --env-file .env.staging -f docker-compose.yml up -d --no-build --remove-orphans
|
|
||||||
|
|
||||||
echo "✓ Deployed IMAGE_TAG=${IMAGE_TAG}"
|
|
||||||
|
|
||||||
- name: Verify deployment
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
cd "${DEPLOY_DIR}"
|
|
||||||
|
|
||||||
echo "Waiting for services to start..."
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
for SERVICE in app web mysql; do
|
|
||||||
STATUS=$(docker compose --env-file .env.staging -f docker-compose.yml ps --status running --format '{{.Name}}' "$SERVICE" 2>/dev/null || true)
|
|
||||||
if [ -z "$STATUS" ]; then
|
|
||||||
echo "ERROR: ${SERVICE} is not running"
|
|
||||||
docker compose --env-file .env.staging -f docker-compose.yml ps
|
|
||||||
docker compose --env-file .env.staging -f docker-compose.yml logs --tail=50 "$SERVICE" || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✓ ${SERVICE} is running (${STATUS})"
|
|
||||||
done
|
|
||||||
|
|
||||||
HTTP_PORT=$(grep -E '^HTTP_PORT=' .env.staging 2>/dev/null | cut -d= -f2- | tr -d '"' || true)
|
|
||||||
HTTP_PORT=${HTTP_PORT:-8090}
|
|
||||||
|
|
||||||
check_health() {
|
|
||||||
NAME=$1
|
|
||||||
URL=$2
|
|
||||||
for i in 1 2 3 4 5 6; do
|
|
||||||
if curl -sf "$URL" > /dev/null; then
|
|
||||||
echo "✓ ${NAME} health check passed (${URL})"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
echo "Waiting for ${NAME}... attempt ${i}/6"
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
echo "ERROR: ${NAME} health check failed (${URL})"
|
|
||||||
docker compose --env-file .env.staging -f docker-compose.yml logs --tail=50 app web || true
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
check_health "api" "http://127.0.0.1:${HTTP_PORT}/health"
|
|
||||||
+1
-2
@@ -5,7 +5,6 @@ Homestead.yaml
|
|||||||
.env
|
.env
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
ray.php
|
ray.php
|
||||||
|
docker-compose.yml
|
||||||
/docker_src
|
/docker_src
|
||||||
/.vscode
|
/.vscode
|
||||||
**/.DS_Store
|
|
||||||
db-dump
|
|
||||||
@@ -1,17 +1 @@
|
|||||||
You know what is this when you in this project
|
You know what is this when you in this project
|
||||||
|
|
||||||
If you does't know what is this you probably in wrong project
|
|
||||||
|
|
||||||
```sql
|
|
||||||
--- for all ip
|
|
||||||
CREATE USER 'master_erahn'@'%' IDENTIFIED BY 'password';
|
|
||||||
|
|
||||||
--- for specific ip
|
|
||||||
CREATE USER 'kaunter_erahn'@'localhost' IDENTIFIED BY 'password';
|
|
||||||
|
|
||||||
GRANT ALL PRIVILEGES ON kaunter_erahn.* TO 'kaunter_erahn'@'%';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
```
|
|
||||||
|
|
||||||
Gadai=Pembiayaan
|
|
||||||
Tebus=penyelesaian penuh/ansuran
|
|
||||||
Vendored
BIN
Binary file not shown.
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class BatchPembiayaanOnline extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'batch_pembiayaan_online';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'batch_no',
|
|
||||||
'kodcaw',
|
|
||||||
'tarikh',
|
|
||||||
'slot',
|
|
||||||
'bilangan',
|
|
||||||
'jumlah_keseluruhan',
|
|
||||||
'status',
|
|
||||||
'pc_submitted_by',
|
|
||||||
'submitted_at',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -11,17 +11,6 @@ class Cawangan extends Model
|
|||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Display name from master table (`details_caw`).
|
|
||||||
* Keep this as the single mapping so callers do not guess nama/namacaw.
|
|
||||||
*/
|
|
||||||
public function getNamaCawanganAttribute()
|
|
||||||
{
|
|
||||||
$nama = trim((string) ($this->attributes['details_caw'] ?? ''));
|
|
||||||
|
|
||||||
return $nama !== '' ? $nama : (string) ($this->attributes['kodcaw'] ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class CawanganDebugConnections extends Command
|
|||||||
return $idToNameMap[$item['mysql']] !== $item['database'];
|
return $idToNameMap[$item['mysql']] !== $item['database'];
|
||||||
});
|
});
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
dump(sprintf('Connection %s not found in table %s.arrahn_master_db but present in config. Make sure both of connection exist in both app/config and arrahn_master_db', $tested_connection, config('tennant_database.master_db')));
|
dump(sprintf('Connection %s not found in table online_arrahn.arrahn_master_db but present in config. Make sure both of connection exist in both app/config and arrahn_master_db', $tested_connection));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -25,7 +25,6 @@ class Gadai extends Model
|
|||||||
'nilaimarhun',
|
'nilaimarhun',
|
||||||
'berat',
|
'berat',
|
||||||
'pinjaman',
|
'pinjaman',
|
||||||
'cara_terima',
|
|
||||||
'telahbayar',
|
'telahbayar',
|
||||||
'upahtelahbyr',
|
'upahtelahbyr',
|
||||||
'cajtelahbyr',
|
'cajtelahbyr',
|
||||||
@@ -74,7 +73,9 @@ class Gadai extends Model
|
|||||||
'tagkomuditi',
|
'tagkomuditi',
|
||||||
'tempohbayar',
|
'tempohbayar',
|
||||||
'lelong_tawarruq',
|
'lelong_tawarruq',
|
||||||
'tag_tebus'
|
'tag_tebus',
|
||||||
|
'kadarrebet',
|
||||||
|
'diskaun'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,7 @@ class Helper
|
|||||||
{
|
{
|
||||||
|
|
||||||
$online_arrahn_connection = array_filter(config('database.connections'), function ($connection) {
|
$online_arrahn_connection = array_filter(config('database.connections'), function ($connection) {
|
||||||
if ($connection['database'] === config('tennant_database.master_db')) {
|
if ($connection['database'] === 'online_arrahn') {
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -43,7 +43,7 @@ class Helper
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$non_cawangan_database = ['lelong', config('tennant_database.master_db'), config('tennant_database.kaunter_db')];
|
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
|
||||||
|
|
||||||
$all_cawangan_db = array_filter($all_active_db_keys, function ($db_key) use ($non_cawangan_database) {
|
$all_cawangan_db = array_filter($all_active_db_keys, function ($db_key) use ($non_cawangan_database) {
|
||||||
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
||||||
@@ -74,7 +74,7 @@ class Helper
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$non_cawangan_database = ['lelong', config('tennant_database.master_db'), config('tennant_database.kaunter_db')];
|
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
|
||||||
|
|
||||||
$all_cawangan_db = array_filter($all_inactive_db_keys, function ($db_key) use ($non_cawangan_database) {
|
$all_cawangan_db = array_filter($all_inactive_db_keys, function ($db_key) use ($non_cawangan_database) {
|
||||||
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ class BackupStokAuditController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function kiraupahTawarruqStokAudit($tempoh,$tempohbayar,$kadarupah,$bakipinjaman){
|
public function kiraupahTawarruqStokAudit($tempoh,$tempohbayar,$kadarupah,$bakipinjaman){
|
||||||
$tempoh = ($tempoh > 12) ? 12 : $tempoh;
|
|
||||||
$bilang_bln = $tempoh - $tempohbayar;
|
$bilang_bln = $tempoh - $tempohbayar;
|
||||||
|
|
||||||
if($bilang_bln > 12){
|
if($bilang_bln > 12){
|
||||||
@@ -458,7 +458,6 @@ class BackupStokAuditController extends Controller
|
|||||||
public function kiraupahTawarruqStokAuditUjrahOnePercent($tempoh,$tempohbayar,$kadarupah,$bakipinjaman,$nilaimarhun,$margin_semasa){
|
public function kiraupahTawarruqStokAuditUjrahOnePercent($tempoh,$tempohbayar,$kadarupah,$bakipinjaman,$nilaimarhun,$margin_semasa){
|
||||||
$onepercentservices = new V2Calculation();
|
$onepercentservices = new V2Calculation();
|
||||||
$upah = $onepercentservices->kiraanKeuntunganRebet($bakipinjaman,$nilaimarhun,$kadarupah,$margin_semasa);
|
$upah = $onepercentservices->kiraanKeuntunganRebet($bakipinjaman,$nilaimarhun,$kadarupah,$margin_semasa);
|
||||||
$tempoh = ($tempoh > 12) ? 12 : $tempoh;
|
|
||||||
$bilang_bln = $tempoh - $tempohbayar;
|
$bilang_bln = $tempoh - $tempohbayar;
|
||||||
$keuntungan_semasa = $bilang_bln * $upah['onepercent'];
|
$keuntungan_semasa = $bilang_bln * $upah['onepercent'];
|
||||||
$ujrah_semasa = $bilang_bln * $upah['ujrah'];
|
$ujrah_semasa = $bilang_bln * $upah['ujrah'];
|
||||||
|
|||||||
@@ -6,21 +6,15 @@ use App\Audit;
|
|||||||
use App\Polis;
|
use App\Polis;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
use App\LookupAlasan;
|
use App\LookupAlasan;
|
||||||
use App\Palsu;
|
|
||||||
use App\Gadai;
|
|
||||||
use App\Pampasan;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class BarangkesController extends Controller
|
class BarangkesController extends Controller
|
||||||
{
|
{
|
||||||
public function LaporanBarangKes(Request $request)
|
public function LaporanBarangKes(Request $request)
|
||||||
{
|
{
|
||||||
$status = $request->status;
|
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
||||||
|
|
||||||
@@ -28,7 +22,7 @@ class BarangkesController extends Controller
|
|||||||
return response()->json(['error' => 'Invalid kodcaw'], 403);
|
return response()->json(['error' => 'Invalid kodcaw'], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$palsu_query = Palsu::on($cawangan['mysql'])
|
$query = DB::connection($cawangan['mysql'])->table('palsu')
|
||||||
->select([
|
->select([
|
||||||
'tarikh',
|
'tarikh',
|
||||||
'norujukan',
|
'norujukan',
|
||||||
@@ -40,156 +34,10 @@ class BarangkesController extends Controller
|
|||||||
'untungonepercent',
|
'untungonepercent',
|
||||||
'untungcajlain'
|
'untungcajlain'
|
||||||
])
|
])
|
||||||
->when($request->filled('tarikh_mula') && $request->filled('tarikh_akhir'), function ($query) use ($request) {
|
->whereBetween('tarikh', [$request->tarikh_mula, $request->tarikh_akhir]);
|
||||||
return $query->whereBetween('tarikh', [$request->tarikh_mula, $request->tarikh_akhir]);
|
|
||||||
})
|
|
||||||
->with(['tebus:norujukan', 'gadai:norujukan,nokp']);
|
|
||||||
|
|
||||||
$palsu_array = $palsu_query->get()->toArray();
|
$result = $query->get();
|
||||||
$pampasan_array = Pampasan::on($cawangan['mysql'])->where('kodcaw', $request->kodcaw)->get()->toArray();
|
|
||||||
|
|
||||||
$indexedArray2 = collect($pampasan_array)->keyBy('norujukan');
|
return response()->json($result);
|
||||||
|
|
||||||
$merged = collect($palsu_array)->map(function ($item) use ($indexedArray2) {
|
|
||||||
$id = $item['norujukan'];
|
|
||||||
$itemArray = $item; // Already an array from toArray()
|
|
||||||
$additional = $indexedArray2->get($id, []);
|
|
||||||
|
|
||||||
// Add exists_in_tebus flag based on relationship
|
|
||||||
$itemArray['gadaian_sudah_tebus'] = !is_null($item['tebus']);
|
|
||||||
|
|
||||||
// Add nokp customer from gadai relationship
|
|
||||||
$itemArray['nokp'] = $item['gadai']['nokp'];
|
|
||||||
|
|
||||||
// Remove the tebus relationship data to keep response clean
|
|
||||||
unset($itemArray['tebus']);
|
|
||||||
unset($itemArray['gadai']);
|
|
||||||
|
|
||||||
|
|
||||||
return array_merge($itemArray, $additional);
|
|
||||||
})->values()->toArray();
|
|
||||||
|
|
||||||
$filteredResults = [];
|
|
||||||
|
|
||||||
$sudahTuntutSecaraManual = [
|
|
||||||
'011237240719-0015',
|
|
||||||
'011237240806-0011',
|
|
||||||
'011237240828-0001',
|
|
||||||
'011237240731-0026',
|
|
||||||
'011237240912-0009'
|
|
||||||
];
|
|
||||||
|
|
||||||
// if ($status == 'dituntut') {
|
|
||||||
// foreach ($merged as $pampasan) {
|
|
||||||
// if (isset($pampasan['status']) && $pampasan['status'] == 1) {
|
|
||||||
// $filteredResults[] = $pampasan;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if ($status == 'dituntut') {
|
|
||||||
foreach ($merged as $pampasan) {
|
|
||||||
if (
|
|
||||||
(isset($pampasan['status']) && $pampasan['status'] == 1)
|
|
||||||
|| in_array($pampasan['norujukan'], $sudahTuntutSecaraManual)
|
|
||||||
) {
|
|
||||||
$filteredResults[] = $pampasan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if ($status == 'belum-tuntut') {
|
|
||||||
// foreach ($merged as $pampasan) {
|
|
||||||
// if (!isset($pampasan['status'])) {
|
|
||||||
// $filteredResults[] = $pampasan;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if ($status == 'belum-tuntut') {
|
|
||||||
foreach ($merged as $pampasan) {
|
|
||||||
if (
|
|
||||||
!isset($pampasan['status'])
|
|
||||||
&& !in_array($pampasan['norujukan'], $sudahTuntutSecaraManual)
|
|
||||||
) {
|
|
||||||
$filteredResults[] = $pampasan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($status == 'all' || $status == null) {
|
|
||||||
$filteredResults = $merged;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($filteredResults);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request) //cara fifi ajar
|
|
||||||
{
|
|
||||||
|
|
||||||
$current = Carbon::now();
|
|
||||||
$kodcaw = $request->kodcaw;
|
|
||||||
$cawangan = Cawangan::on('mysql7')
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$insert = Palsu::on($cawangan['mysql'])->create([
|
|
||||||
'kodcaw' => $request->kodcaw,
|
|
||||||
'tarikh' => $current->toDateString(),
|
|
||||||
'norujukan' => $request->norujukan,
|
|
||||||
'teller' => $request->teller,
|
|
||||||
'nota' => $request->nota ? $request->nota : '',
|
|
||||||
'pembiayaan' => $request->pinjaman,
|
|
||||||
'nilaimarhun' => $request->nilaimarhun,
|
|
||||||
'jbg' => $request->jbg,
|
|
||||||
'untung' => $request->tunggakan,
|
|
||||||
'untungonepercent' => $request->tunggakanonepercent,
|
|
||||||
'untungcajlain' => $request->tunggakanujrah,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// return $insert;
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
'message' => 'Barang kes berjaya didaftar',
|
|
||||||
'data' => $insert
|
|
||||||
], 201);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request)
|
|
||||||
{
|
|
||||||
|
|
||||||
$current = Carbon::now();
|
|
||||||
$kodcaw = $request->kodcaw;
|
|
||||||
Log::info($request->all());
|
|
||||||
|
|
||||||
// Cari connection cawangan
|
|
||||||
$cawangan = Cawangan::on('mysql7')
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return response()->json([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Cawangan tidak dijumpai',
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update direct (ikut norujukan)
|
|
||||||
$palsu = palsu::on($cawangan['mysql'])
|
|
||||||
->where('norujukan', $request->norujukan)
|
|
||||||
->update([
|
|
||||||
'kodcaw' => $request->kodcaw,
|
|
||||||
'tarikh' => $request->tarikh,
|
|
||||||
'teller' => $request->teller,
|
|
||||||
'nota' => $request->nota ?? '',
|
|
||||||
'pembiayaan' => $request->pinjaman,
|
|
||||||
'nilaimarhun' => $request->nilaimarhun,
|
|
||||||
'jbg' => $request->jbg,
|
|
||||||
'untung' => $request->tunggakan,
|
|
||||||
'untungonepercent' => $request->tunggakanonepercent,
|
|
||||||
'untungcajlain' => $request->tunggakanujrah,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'success' => $palsu ? true : false,
|
|
||||||
'message' => $palsu ? 'Rekod gadai berjaya dikemaskini' : 'Rekod tidak dijumpai',
|
|
||||||
], 200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,6 @@ use App\Blacklist;
|
|||||||
use App\AuditCustomer;
|
use App\AuditCustomer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\TuntutBaki;
|
use App\TuntutBaki;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use App\Anggota;
|
use App\Anggota;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -396,7 +395,6 @@ class CustomerController extends Controller
|
|||||||
// 'nota_arcc'=>$request->nota_arcc,
|
// 'nota_arcc'=>$request->nota_arcc,
|
||||||
'telefon' => $request->telefon1,
|
'telefon' => $request->telefon1,
|
||||||
'telefon2' => $request->telefon2,
|
'telefon2' => $request->telefon2,
|
||||||
'telefon2' => $request->telefon2,
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return response()->json($customer_update, 200);
|
return response()->json($customer_update, 200);
|
||||||
@@ -748,7 +746,7 @@ class CustomerController extends Controller
|
|||||||
$customer = Customer::on($cawangan['mysql'])
|
$customer = Customer::on($cawangan['mysql'])
|
||||||
->where('kplama','=',$nokp)
|
->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
->orWhere('kpbaru','=',$nokp)
|
||||||
->rightJoin(config('tennant_database.master_db') . '.bank', 'bank.id', '=', 'customer.kodbank')
|
->rightJoin('online_arrahn.bank', 'bank.id', '=', 'customer.kodbank')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if(!empty($customer))
|
if(!empty($customer))
|
||||||
@@ -941,69 +939,6 @@ class CustomerController extends Controller
|
|||||||
return response()->json($customer);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AdminsearchCustomerBySAG(Request $request)
|
|
||||||
{
|
|
||||||
// Ambil kodcaw dari user login
|
|
||||||
$kodcaw = $request->kodcaw;
|
|
||||||
// $norujukan = $request->input('norujukan');
|
|
||||||
|
|
||||||
// Cari connection untuk cawangan
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
|
||||||
if (!$cawangan) {
|
|
||||||
return response()->json([], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$gadai = optional(Gadai::on($cawangan['mysql'])->where('norujukan',$request->norujukan)->first())->toArray() ?? [];
|
|
||||||
|
|
||||||
if(!empty($gadai)){
|
|
||||||
$customer = optional(Customer::on('mysql7')->where(function ($query) use ($gadai) {
|
|
||||||
$query->where('kpbaru',$gadai['nokp'])
|
|
||||||
->orWhere('kplama',$gadai['nokp']);
|
|
||||||
})->first())->toArray() ?? [];
|
|
||||||
}else{
|
|
||||||
return response()->json(['success' => false,'message' => 'norujukan tidak dijumpainya'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cara fifi ajar
|
|
||||||
$result = [[
|
|
||||||
'id' => $customer['id'],
|
|
||||||
'kodcaw' => $gadai['kodcaw'],
|
|
||||||
'norujukan' => $gadai['norujukan'],
|
|
||||||
'teller' => $gadai['teller'],
|
|
||||||
'nota' => $customer['nota'],
|
|
||||||
'pinjaman' => $gadai['pinjaman'],
|
|
||||||
'nilaimarhun' => $gadai['nilaimarhun'],
|
|
||||||
'jbg' => $gadai['jbg'],
|
|
||||||
'tunggakan' => $gadai['tunggakan'],
|
|
||||||
'tunggakanonepercent' => $gadai['tunggakanonepercent'],
|
|
||||||
'tunggakanujrah' => $gadai['tunggakanujrah'],
|
|
||||||
'nama' => $customer['nama'],
|
|
||||||
'kplama' => $customer['kplama'],
|
|
||||||
'kpbaru' => $customer['kpbaru'],
|
|
||||||
]];
|
|
||||||
|
|
||||||
// saya buat sendiri
|
|
||||||
// Join customer + gadai ikut nokp
|
|
||||||
// $result = DB::connection($cawangan['mysql'])
|
|
||||||
// ->table('gadai')
|
|
||||||
// ->join('online_arrahn.customer as c', function($join) {
|
|
||||||
// $join->on('gadai.nokp', '=', 'c.kpbaru')
|
|
||||||
// ->orOn('gadai.nokp', '=', 'c.kplama');
|
|
||||||
// })
|
|
||||||
// ->where('norujukan', $request->norujukan)
|
|
||||||
// ->select(
|
|
||||||
// 'id',
|
|
||||||
// 'gadai.kodcaw','gadai.norujukan','gadai.teller',
|
|
||||||
// 'c.nota','gadai.pinjaman','gadai.nilaimarhun','gadai.jbg',
|
|
||||||
// 'gadai.tunggakan','gadai.tunggakanonepercent','gadai.tunggakanujrah',
|
|
||||||
// 'c.nama','c.kpbaru','c.kplama'
|
|
||||||
// )
|
|
||||||
// ->take(5)
|
|
||||||
// ->get();
|
|
||||||
|
|
||||||
return response()->json($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function changepassword(Request $request, $kodcaw, $id) {
|
public function changepassword(Request $request, $kodcaw, $id) {
|
||||||
|
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
@@ -1103,27 +1038,6 @@ public function AdminsearchCustomerBySAG(Request $request)
|
|||||||
return response()->json($results);
|
return response()->json($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateTagPdpa(Request $request)
|
|
||||||
{
|
|
||||||
$tarikh_cetak_pdpa = Carbon::now()->toDateString();
|
|
||||||
|
|
||||||
$no_ic = $request->input('no_ic');
|
|
||||||
|
|
||||||
$customer = Customer::where('kplama', $no_ic)
|
|
||||||
->orWhere('kpbaru', $no_ic)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$customer) {
|
|
||||||
return response()->json(['error' => 'Customer not found.'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$customer->tag_pdpa = $request->input('tag_pdpa');
|
|
||||||
$customer->tarikh_cetak_pdpa = $tarikh_cetak_pdpa;
|
|
||||||
$customer->save();
|
|
||||||
|
|
||||||
return response()->json(['message' => 'Customer PDPA updated successfully.'], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public function createNotaArcc($kodcaw, Request $request)
|
// public function createNotaArcc($kodcaw, Request $request)
|
||||||
// {
|
// {
|
||||||
// $current = Carbon::now();
|
// $current = Carbon::now();
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use App\KomuditiTransaksi;
|
|||||||
use App\Advansur;
|
use App\Advansur;
|
||||||
use App\HistoryEmasSandaran;
|
use App\HistoryEmasSandaran;
|
||||||
use App\InOutMar;
|
use App\InOutMar;
|
||||||
use App\Services\Miscellaneous\StatistikService;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -588,78 +587,46 @@ class GadaiController extends Controller
|
|||||||
|
|
||||||
public function getLaporanGadaiRangeDate($kodcaw,Request $request){
|
public function getLaporanGadaiRangeDate($kodcaw,Request $request){
|
||||||
|
|
||||||
$mula = $request->mula;
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
$akhir = $request->akhir;
|
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent','tagbaru','diskaun')
|
||||||
|
->where('t_gadai','>=',$request->mula)
|
||||||
$gadai_data = Gadai::on($cawangan['mysql'])
|
->where('t_gadai','<=',$request->akhir)
|
||||||
->whereBetween('t_gadai', [$request->mula, $request->akhir])
|
|
||||||
->orderBy('t_gadai')
|
->orderBy('t_gadai')
|
||||||
->orderBy('teller')
|
->orderBy('teller')
|
||||||
->orderBy('sirig')
|
->orderBy('sirig')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$nokps = $gadai_data->pluck('nokp')->unique();
|
$gadai = [];
|
||||||
|
|
||||||
|
if($gadai_data){
|
||||||
|
foreach($gadai_data as $index=>$gadaiData){
|
||||||
|
$customer_info = Customer::on('mysql7')->where('kplama','=',$gadaiData['nokp'])->orWhere('kpbaru','=',$gadaiData['nokp'])->first();
|
||||||
|
array_push($gadai,[
|
||||||
|
"t_gadai"=> $gadaiData['t_gadai'],
|
||||||
|
"norujukan"=> $gadaiData['norujukan'],
|
||||||
|
"nama"=> $customer_info['nama'],
|
||||||
|
"nokp"=> $gadaiData['nokp'],
|
||||||
|
"semakbarcode"=> $gadaiData['semakbarcode'],
|
||||||
|
"masa"=> $gadaiData['masa'],
|
||||||
|
"berat"=> $gadaiData['berat'],
|
||||||
|
"nilaimarhun"=> $gadaiData['nilaimarhun'],
|
||||||
|
"pinjaman"=> $gadaiData['pinjaman'],
|
||||||
|
"upah12"=> $gadaiData['upah12'],
|
||||||
|
"percentpinj"=> $gadaiData['percentpinj'],
|
||||||
|
"alamat1"=> $customer_info['alamat1'],
|
||||||
|
"teller"=> $gadaiData['teller'],
|
||||||
|
"ujrah"=> $gadaiData['ujrah'],
|
||||||
|
"onepercent"=> $gadaiData['onepercent'],
|
||||||
|
"tagbaru"=> $gadaiData['tagbaru'],
|
||||||
|
"kadar_rebet" => $gadaiData['kadarrebet'],
|
||||||
|
"diskaun" => $gadaiData['diskaun']
|
||||||
|
|
||||||
$customers = Customer::on('mysql7')
|
|
||||||
->where(function($query) use ($nokps) {
|
|
||||||
$query->whereIn('kpbaru', $nokps)
|
|
||||||
->orWhereIn('kplama', $nokps);
|
|
||||||
})
|
|
||||||
->get()
|
|
||||||
->flatMap(fn($c) => [
|
|
||||||
$c->kpbaru => $c,
|
|
||||||
$c->kplama => $c
|
|
||||||
]);
|
]);
|
||||||
$gadai = $gadai_data->map(function ($g) use ($customers) {
|
|
||||||
|
|
||||||
foreach($customers as $key=>$value){
|
|
||||||
if($g->nokp == $value->kpbaru || $g->nokp == $value->kplama){
|
|
||||||
$customer = $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return response()->json($gadai);
|
||||||
|
|
||||||
"nama" => optional($customer)->nama,
|
|
||||||
"alamat1" => optional($customer)->alamat1,
|
|
||||||
"t_gadai" => $g->t_gadai,
|
|
||||||
"norujukan" => $g->norujukan,
|
|
||||||
"norujukan"=> $g->norujukan,
|
|
||||||
|
|
||||||
"nokp"=> $g->nokp,
|
|
||||||
"semakbarcode"=> $g->semakbarcode,
|
|
||||||
"masa"=> $g->masa,
|
|
||||||
"berat"=> $g->berat,
|
|
||||||
"nilaimarhun"=> $g->nilaimarhun,
|
|
||||||
"pinjaman"=> $g->pinjaman,
|
|
||||||
"upah12"=> $g->upah12,
|
|
||||||
"percentpinj"=> $g->percentpinj,
|
|
||||||
"alamat1"=> optional($customer)->alamat1,
|
|
||||||
"teller"=> $g->teller,
|
|
||||||
"ujrah"=> $g->ujrah,
|
|
||||||
"onepercent"=> $g->onepercent,
|
|
||||||
"tagbaru"=> $g->tagbaru,
|
|
||||||
"kodkerja"=> optional($customer)->kodkerja,
|
|
||||||
"bangsa"=> optional($customer)->bangsa,
|
|
||||||
|
|
||||||
];
|
|
||||||
});
|
|
||||||
// dd($gadai);
|
|
||||||
|
|
||||||
$statistikService = new StatistikService($kodcaw,$mula,$akhir);
|
|
||||||
$reportgadai = $statistikService->LaporanStatistik($gadai);
|
|
||||||
// dd($nokps);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'gadai' => $gadai,
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'mula' => $mula,
|
|
||||||
'akhir' => $akhir,
|
|
||||||
'statistik' => $reportgadai,
|
|
||||||
'jumlah' => $gadai->count(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLaporanBatalGadai($kodcaw,$tarikh){
|
public function getLaporanBatalGadai($kodcaw,$tarikh){
|
||||||
@@ -3906,13 +3873,11 @@ class GadaiController extends Controller
|
|||||||
public function updateTagLelong(Request $request){
|
public function updateTagLelong(Request $request){
|
||||||
$norujukan = $request->norujukan;
|
$norujukan = $request->norujukan;
|
||||||
$kodcaw = $request->kodcaw;
|
$kodcaw = $request->kodcaw;
|
||||||
$t_lelong = $request->t_lelong;
|
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first();
|
||||||
|
|
||||||
$updateTag = Gadai::on($cawangan->mysql)->where('norujukan',$norujukan)->update([
|
$updateTag = Gadai::on($cawangan->mysql)->where('norujukan',$norujukan)->update([
|
||||||
'taglel'=>1,
|
'taglel'=>1
|
||||||
't_lelong' => $t_lelong,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json('success');
|
return response()->json('success');
|
||||||
@@ -3925,8 +3890,7 @@ class GadaiController extends Controller
|
|||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first();
|
||||||
|
|
||||||
$updateTag = Gadai::on($cawangan->mysql)->where('norujukan',$norujukan)->update([
|
$updateTag = Gadai::on($cawangan->mysql)->where('norujukan',$norujukan)->update([
|
||||||
'taglel'=>0,
|
'taglel'=>0
|
||||||
't_lelong' => null,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json('success');
|
return response()->json('success');
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ class KelulusanController extends Controller
|
|||||||
{
|
{
|
||||||
$harini = Carbon::now();
|
$harini = Carbon::now();
|
||||||
$harini = new Carbon;
|
$harini = new Carbon;
|
||||||
$kelulusan = null;
|
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
$pengesahan = $request->pengesahan;
|
$pengesahan = $request->pengesahan;
|
||||||
@@ -196,33 +195,7 @@ class KelulusanController extends Controller
|
|||||||
|
|
||||||
$audit = new Audit();
|
$audit = new Audit();
|
||||||
$audit->users = (isset($request->namakhazanah) ? $request->namakhazanah : '');
|
$audit->users = (isset($request->namakhazanah) ? $request->namakhazanah : '');
|
||||||
$audit->actions = $request->actions ?? "pengesahan kelulusan 75%";
|
$audit->actions = "Pengesahan Kelulusan 75%";
|
||||||
|
|
||||||
// Only prepare detailed audit data for Pampasan approval
|
|
||||||
if($request->actions == 'Pengesahan Pembayaran Pampasan') {
|
|
||||||
// Prepare data for audit - ensure it's an array
|
|
||||||
$auditData = [];
|
|
||||||
|
|
||||||
// If kelulusan is a scalar (update result), create array structure
|
|
||||||
if (is_scalar($kelulusan) || is_null($kelulusan)) {
|
|
||||||
$auditData = ['update_result' => $kelulusan];
|
|
||||||
} else {
|
|
||||||
$auditData = $kelulusan;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add namapelulus and norujukanasal to the audit data
|
|
||||||
if(isset($request->namaoperasi)) {
|
|
||||||
$auditData['namapelulus'] = !empty($request->namaoperasi) ? $request->namaoperasi : null;
|
|
||||||
}
|
|
||||||
if(isset($request->norujukan)) {
|
|
||||||
$auditData['norujukan'] = !empty($request->norujukan) ? $request->norujukan : null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// For other actions, use simple kelulusan data
|
|
||||||
$auditData = $kelulusan;
|
|
||||||
}
|
|
||||||
|
|
||||||
$audit->new_data = json_encode($auditData);
|
|
||||||
$audit->kodcaw = $kodcaw;
|
$audit->kodcaw = $kodcaw;
|
||||||
$audit->created_at = $harini;
|
$audit->created_at = $harini;
|
||||||
$audit->updated_at = $harini;
|
$audit->updated_at = $harini;
|
||||||
@@ -350,7 +323,9 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
|
|
||||||
if($roles == "khazanah")
|
if($roles == "khazanah")
|
||||||
{
|
{
|
||||||
$createData = [
|
$kelulusan=Mohon::on($cawangan['mysql'])
|
||||||
|
->create([
|
||||||
|
|
||||||
'tarikh'=> $harini->toDateString(),
|
'tarikh'=> $harini->toDateString(),
|
||||||
'norujukan'=> $norujukan,
|
'norujukan'=> $norujukan,
|
||||||
'siri' => $request->siri,
|
'siri' => $request->siri,
|
||||||
@@ -364,14 +339,10 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
'jenistebus' => $request->jenistebus,
|
'jenistebus' => $request->jenistebus,
|
||||||
'teller' => $request->teller,
|
'teller' => $request->teller,
|
||||||
'pelulus' => ($request->pelulus) ? $request->pelulus : ''
|
'pelulus' => ($request->pelulus) ? $request->pelulus : ''
|
||||||
];
|
|
||||||
|
|
||||||
// Add peloperasi if status is Kelulusan Pengeluaran Pampasan
|
|
||||||
if($request->status == 'Kelulusan Pengeluaran Pampasan' && isset($request->peloperasi)) {
|
|
||||||
$createData['peloperasi'] = $request->peloperasi;
|
|
||||||
}
|
|
||||||
|
|
||||||
$kelulusan=Mohon::on($cawangan['mysql'])->create($createData);
|
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
else if($roles == "operasi")
|
else if($roles == "operasi")
|
||||||
{
|
{
|
||||||
@@ -398,7 +369,7 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
|
|
||||||
$audit = new Audit();
|
$audit = new Audit();
|
||||||
$audit->users = (isset($request->teller) ? $request->teller : '');
|
$audit->users = (isset($request->teller) ? $request->teller : '');
|
||||||
$audit->actions = $request->actions ?? "Minta Pengesahan kelulusan 75%";
|
$audit->actions = "Minta Pengesahan kelulusan 75%";
|
||||||
$audit->new_data = json_encode($kelulusan);
|
$audit->new_data = json_encode($kelulusan);
|
||||||
$audit->kodcaw = $kodcaw;
|
$audit->kodcaw = $kodcaw;
|
||||||
$audit->created_at = $harini;
|
$audit->created_at = $harini;
|
||||||
|
|||||||
@@ -145,11 +145,8 @@ class KomuditiController extends Controller
|
|||||||
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
||||||
|
|
||||||
$unit_current = $komuditi_current['unit_komuditi'];
|
$unit_current = $komuditi_current['unit_komuditi'];
|
||||||
$update_unit = $unit_current - $request->unit_komuditi;
|
|
||||||
|
|
||||||
// $unit_current = round((float) $komuditi_current['unit_komuditi'], 2);
|
$update_unit = $unit_current - $request->unit_komuditi;
|
||||||
// $unit_komuditi = round((float) $request->unit_komuditi, 2);
|
|
||||||
// $update_unit = round($unit_current - $unit_komuditi, 2);
|
|
||||||
|
|
||||||
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
||||||
'unit_komuditi' => $update_unit
|
'unit_komuditi' => $update_unit
|
||||||
@@ -157,7 +154,6 @@ class KomuditiController extends Controller
|
|||||||
|
|
||||||
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([
|
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([
|
||||||
'unit_komuditi' => $request->unit_komuditi,
|
'unit_komuditi' => $request->unit_komuditi,
|
||||||
// 'unit_komuditi' => $unit_komuditi,
|
|
||||||
'nosijil'=>$komuditi_current['no_sijil'],
|
'nosijil'=>$komuditi_current['no_sijil'],
|
||||||
'norujukan' => $request->norujukan,
|
'norujukan' => $request->norujukan,
|
||||||
'kodcaw' => $request->kodcaw ,
|
'kodcaw' => $request->kodcaw ,
|
||||||
|
|||||||
@@ -605,9 +605,9 @@ class LelongController extends Controller
|
|||||||
|
|
||||||
if($cawangan['tagarrahnbid'] == 1){
|
if($cawangan['tagarrahnbid'] == 1){
|
||||||
if(env('APP_ENV') != 'production'){
|
if(env('APP_ENV') != 'production'){
|
||||||
$link = 'http://niklah.arrahn.com.my/api/portalApi';
|
$link = 'https://adminbid-annur.erahn.com.my/api/portalApi';
|
||||||
}else{
|
}else{
|
||||||
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
|
$link = 'https://adminbid-annur.erahn.com.my/api/portalApi';
|
||||||
}
|
}
|
||||||
|
|
||||||
$lelong = Http::withOptions(['verify' => true])->get($link,[
|
$lelong = Http::withOptions(['verify' => true])->get($link,[
|
||||||
@@ -1069,36 +1069,19 @@ class LelongController extends Controller
|
|||||||
|
|
||||||
public function exportLelong(Request $request)
|
public function exportLelong(Request $request)
|
||||||
{
|
{
|
||||||
$currentDate = Carbon::now()->toDateString();
|
$currentDate = Carbon::now();
|
||||||
|
$currentDate = $currentDate->toDateString();
|
||||||
|
|
||||||
// --- Step 0: Dapatkan Cawangan ---
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
||||||
$cawangan = Cawangan::on('mysql7')
|
|
||||||
->where('kodcaw', $request->kodcaw)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
Log::error("Export Lelong gagal: cawangan tidak ditemui", ['kodcaw' => $request->kodcaw]);
|
|
||||||
return response()->json(['error' => 'Cawangan tidak ditemui'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info("Mula Export Lelong", [
|
|
||||||
'kodcaw' => $cawangan->kodcaw,
|
|
||||||
'nama_cawangan' => $cawangan->details_caw,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// --- Step 1: Batch (Cegah duplicate) ---
|
|
||||||
$batchlel = BatchLel::on($cawangan['mysql'])
|
$batchlel = BatchLel::on($cawangan['mysql'])
|
||||||
->where('kodcaw', $request->kodcaw)
|
->select('batchno')
|
||||||
->whereDate('tarikh', $request->tarikh)
|
->orderBy('batchno', 'desc')
|
||||||
->where('masadari', $request->masadari)
|
|
||||||
->where('masahingga', $request->masahingga)
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$batchlel) {
|
$newBatchNo = $batchlel->batchno + 1;
|
||||||
$lastBatchNo = BatchLel::on($cawangan['mysql'])->max('batchno') ?? 0;
|
|
||||||
$newBatchNo = $lastBatchNo + 1;
|
|
||||||
|
|
||||||
$batchlel = BatchLel::on($cawangan['mysql'])->create([
|
$newBatchLel = BatchLel::on($cawangan['mysql'])->create([
|
||||||
'kodcaw' => $request->kodcaw,
|
'kodcaw' => $request->kodcaw,
|
||||||
'batchno' => $newBatchNo,
|
'batchno' => $newBatchNo,
|
||||||
'tarikh' => $request->tarikh,
|
'tarikh' => $request->tarikh,
|
||||||
@@ -1108,40 +1091,22 @@ class LelongController extends Controller
|
|||||||
'masahingga' => $request->masahingga
|
'masahingga' => $request->masahingga
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Log::info("Batch baru dicipta", ['batchno' => $newBatchNo]);
|
$lelong = Lelong::on($cawangan['mysql'])
|
||||||
} else {
|
->select('sirilel')
|
||||||
$newBatchNo = $batchlel->batchno;
|
->orderBy('batchno', 'desc')
|
||||||
Log::info("Batch sedia ada digunakan", ['batchno' => $newBatchNo]);
|
->first();
|
||||||
}
|
|
||||||
|
|
||||||
// --- Step 2: Siri Lelong Terakhir ---
|
|
||||||
$lastSiriLelong = Lelong::on($cawangan['mysql'])->max('sirilel') ?? 0;
|
|
||||||
$lelong_arr = [];
|
|
||||||
|
|
||||||
// --- Step 3: Cegah duplicate Lelong ---
|
|
||||||
$existingNorujukan = Lelong::on($cawangan['mysql'])
|
|
||||||
->whereIn('norujukan', collect($request->lelongbid)->pluck('norujukan'))
|
|
||||||
->pluck('norujukan')
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
foreach ($request->lelongbid as $index) {
|
foreach ($request->lelongbid as $index) {
|
||||||
if (in_array($index['norujukan'], $existingNorujukan)) {
|
|
||||||
Log::warning("Skip Lelong duplicate", ['norujukan' => $index['norujukan']]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Step 4: Semak / cipta pembeli ---
|
$no_pembeli = Pembeli::on($cawangan['mysql'])->where('nokp', '=', $index['user_details']['nokp'])->select('nopembeli')->first();
|
||||||
$no_pembeli = Pembeli::on($cawangan['mysql'])
|
if ($no_pembeli) {
|
||||||
->where('nokp', $index['user_details']['nokp'])
|
$no_pembeli_data = $no_pembeli->nopembeli;
|
||||||
->value('nopembeli');
|
} else {
|
||||||
|
$last_no_pembeli = Pembeli::on($cawangan['mysql'])->select('nopembeli')->orderBy('nopembeli', 'desc')->first();
|
||||||
|
$no_pembeli_data = $last_no_pembeli->nopembeli + 1;
|
||||||
|
|
||||||
if (!$no_pembeli) {
|
$newPembeli = Pembeli::on($cawangan['mysql'])->create([
|
||||||
$last_no_pembeli = Pembeli::on($cawangan['mysql'])
|
'nopembeli' => $no_pembeli_data,
|
||||||
->max('nopembeli') ?? 0;
|
|
||||||
$no_pembeli = $last_no_pembeli + 1;
|
|
||||||
|
|
||||||
Pembeli::on($cawangan['mysql'])->create([
|
|
||||||
'nopembeli' => $no_pembeli,
|
|
||||||
'nokp' => $index['user_details']['nokp'],
|
'nokp' => $index['user_details']['nokp'],
|
||||||
'nama' => $index['user_details']['name'],
|
'nama' => $index['user_details']['name'],
|
||||||
'alamat1' => $index['user_details']['alamat'],
|
'alamat1' => $index['user_details']['alamat'],
|
||||||
@@ -1149,147 +1114,105 @@ class LelongController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Step 5: Update gadai ---
|
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$index['norujukan'])->update(array(
|
||||||
Gadai::on($cawangan['mysql'])
|
|
||||||
->where('norujukan', $index['norujukan'])
|
|
||||||
->update([
|
|
||||||
'sttebus' => "L",
|
'sttebus' => "L",
|
||||||
't_update' => $request->tarikh
|
't_update' => $request->tarikh
|
||||||
]);
|
));
|
||||||
|
|
||||||
// --- Step 6: Simpan data Lelong ---
|
$lelong_to_be_inserted = new Lelong();
|
||||||
$lelong_arr[] = [
|
$lelong_to_be_inserted->batchno = $newBatchNo;
|
||||||
'batchno' => $newBatchNo,
|
$lelong_to_be_inserted->sirilel = $lelong->sirilel + 1;
|
||||||
'sirilel' => ++$lastSiriLelong,
|
$lelong_to_be_inserted->kodcaw = $index['kodcaw'];
|
||||||
'kodcaw' => $index['kodcaw'],
|
$lelong_to_be_inserted->norujukan = $index['norujukan'];
|
||||||
'norujukan' => $index['norujukan'],
|
$lelong_to_be_inserted->t_lelong = $request->tarikh;
|
||||||
't_lelong' => $request->tarikh,
|
$lelong_to_be_inserted->hargaasas = $index['hargaasas'];
|
||||||
'hargaasas' => $index['hargaasas'],
|
$lelong_to_be_inserted->hargajual = $index['hargajual'];
|
||||||
'hargajual' => $index['hargajual'],
|
$lelong_to_be_inserted->glcode = "1000/010";
|
||||||
'glcode' => "1000/010",
|
$lelong_to_be_inserted->t_jual = $index['t_jual'];
|
||||||
't_jual' => $index['t_jual'],
|
$lelong_to_be_inserted->nopembeli = $no_pembeli_data;
|
||||||
'nopembeli' => $no_pembeli,
|
$lelong_to_be_inserted->jbg = $index['jbg'];
|
||||||
'jbg' => $index['jbg'],
|
$lelong_to_be_inserted->kadarupah = $index['kadarupah'];
|
||||||
'kadarupah' => $index['kadarupah'],
|
$lelong_to_be_inserted->upahsimpan = $index['upahsimpan'];
|
||||||
'upahsimpan' => $index['upahsimpan'],
|
$lelong_to_be_inserted->ansuran = $index['ansuran'];
|
||||||
'ansuran' => $index['ansuran'],
|
$lelong_to_be_inserted->nilaimarhun = $index['nilaimarhun'];
|
||||||
'nilaimarhun' => $index['nilaimarhun'],
|
$lelong_to_be_inserted->nilaimarhuns = $index['nmarhuns'];
|
||||||
'nilaimarhuns' => $index['nmarhuns'],
|
$lelong_to_be_inserted->pinjaman = $index['pinjaman'];
|
||||||
'pinjaman' => $index['pinjaman'],
|
$lelong_to_be_inserted->bakiupah = $index['bakiupah'];
|
||||||
'bakiupah' => $index['bakiupah'],
|
$lelong_to_be_inserted->cajlelong = $index['cajlelong'];
|
||||||
'cajlelong' => $index['cajlelong'],
|
$lelong_to_be_inserted->baki = $index['baki'];
|
||||||
'baki' => $index['baki'],
|
$lelong_to_be_inserted->teller = $index['teller'];
|
||||||
'teller' => $index['teller'],
|
$lelong_to_be_inserted->prkod = "01";
|
||||||
'prkod' => "01",
|
$lelong_to_be_inserted->kodgl = "1000/013";
|
||||||
'kodgl' => "1000/013",
|
$lelong_to_be_inserted->berat = $index['berat'];
|
||||||
'berat' => $index['berat'],
|
$lelong_to_be_inserted->marhun = $index['marhun'];
|
||||||
'marhun' => $index['marhun'],
|
$lelong_to_be_inserted->fasa = $index['fasa'];
|
||||||
'fasa' => $index['fasa'],
|
$lelong_to_be_inserted->ujrah = $index['ujrah'];
|
||||||
'ujrah' => $index['ujrah'],
|
$lelong_to_be_inserted->onepercent = $index['onepercent'];
|
||||||
'onepercent' => $index['onepercent'],
|
$lelong_to_be_inserted->tagujrah = $index['tagujrah'];
|
||||||
'tagujrah' => $index['tagujrah'],
|
|
||||||
];
|
$lelong_arr[] = $lelong_to_be_inserted->attributesToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lelong_arr) {
|
|
||||||
Lelong::on($cawangan['mysql'])->insert($lelong_arr);
|
Lelong::on($cawangan['mysql'])->insert($lelong_arr);
|
||||||
Log::info("Berjaya simpan lelong baru", ['total' => count($lelong_arr)]);
|
|
||||||
|
foreach ($request->lelongbidmarhun as $data) {
|
||||||
|
$lelmarhun_to_be_inserted = new LelMarhun();
|
||||||
|
$lelmarhun_to_be_inserted->kodcaw = $request->kodcaw;
|
||||||
|
$lelmarhun_to_be_inserted->norujukan = $data['norujukan'];
|
||||||
|
$lelmarhun_to_be_inserted->bil = $data['bil'];
|
||||||
|
$lelmarhun_to_be_inserted->marhun = $data['marhun'];
|
||||||
|
$lelmarhun_to_be_inserted->nota = $data['nota'];
|
||||||
|
$lelmarhun_to_be_inserted->karat = $data['karat'];
|
||||||
|
$lelmarhun_to_be_inserted->berat = $data['berat'];
|
||||||
|
$lelmarhun_to_be_inserted->harga = $data['harga'];
|
||||||
|
$lelmarhun_to_be_inserted->n_marhun = $data['n_marhun'];
|
||||||
|
$lelmarhun_to_be_inserted->hargaasas = $data['hargaasas'];
|
||||||
|
$lelmarhun_to_be_inserted->batch_no = $newBatchNo;
|
||||||
|
// $lelmarhun_to_be_inserted->beratasal = $;
|
||||||
|
|
||||||
|
$lelmarhun_arr[] = $lelmarhun_to_be_inserted->attributesToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Step 7: LELMARHUN (cegah duplicate) ---
|
|
||||||
if ($request->lelongbidmarhun) {
|
|
||||||
$existingMarhun = LelMarhun::on($cawangan['mysql'])
|
|
||||||
->whereIn('norujukan', collect($request->lelongbidmarhun)->pluck('norujukan'))
|
|
||||||
->pluck('norujukan')
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$lelmarhun_arr = collect($request->lelongbidmarhun)
|
|
||||||
->reject(fn($data) => in_array($data['norujukan'], $existingMarhun))
|
|
||||||
->map(function ($data) use ($request, $newBatchNo) {
|
|
||||||
return [
|
|
||||||
'kodcaw' => $request->kodcaw,
|
|
||||||
'norujukan' => $data['norujukan'],
|
|
||||||
'bil' => $data['bil'],
|
|
||||||
'marhun' => $data['marhun'],
|
|
||||||
'nota' => $data['nota'],
|
|
||||||
'karat' => $data['karat'],
|
|
||||||
'berat' => $data['berat'],
|
|
||||||
'harga' => $data['harga'],
|
|
||||||
'n_marhun' => $data['n_marhun'],
|
|
||||||
'hargaasas' => $data['hargaasas'],
|
|
||||||
'batch_no' => $newBatchNo
|
|
||||||
];
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
if ($lelmarhun_arr) {
|
|
||||||
LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr);
|
LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr);
|
||||||
Log::info("LelMarhun baru disimpan", ['total' => count($lelmarhun_arr)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Step 8: GL dan Tunai (check duplicate descpt) ---
|
if ($request->tunai != null) {
|
||||||
if ($request->tunai > 0) {
|
$tunai = Tunai::on($cawangan['mysql'])->create([
|
||||||
$existsTunai = Tunai::on($cawangan['mysql'])
|
|
||||||
->where('kodcaw', $request->kodcaw)
|
|
||||||
->where('tarikh', $request->tarikh)
|
|
||||||
->where('kodlaluan', 'LELONG')
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if (!$existsTunai) {
|
|
||||||
Tunai::on($cawangan['mysql'])->create([
|
|
||||||
'tarikh' => $request->tarikh,
|
'tarikh' => $request->tarikh,
|
||||||
'kodcaw' => $request->kodcaw,
|
'kodcaw' => $request->kodcaw,
|
||||||
'kodlaluan' => "LELONG",
|
'kodlaluan' => "LELONG",
|
||||||
'masuk' => $request->tunai,
|
'masuk' => $request->tunai,
|
||||||
'baki' => $request->tunai,
|
'baki' => $request->tunai,
|
||||||
]);
|
]);
|
||||||
Log::info("Rekod Tunai lelong dimasukkan");
|
|
||||||
} else {
|
|
||||||
Log::warning("Skip Tunai duplicate");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$glDescs = [
|
if ($request->gldetail != null) {
|
||||||
'SERAHAN LELONG ONLINE' => $request->gldetail,
|
$gldetail = GlDetail::on($cawangan['mysql'])->create([
|
||||||
'SERAHAN LELONG CDM' => $request->gldetailcdm,
|
'kodcaw' => $request->kodcaw,
|
||||||
];
|
'tarikh' => $request->tarikh,
|
||||||
|
'dtacct' => "1000/010",
|
||||||
|
'ktacct' => "1000/020",
|
||||||
|
'descpt' => "SERAHAN LELONG ONLINE, " . $request->tarikh,
|
||||||
|
'amaun' => $request->gldetail,
|
||||||
|
'teller' => "LELONG ONLINE",
|
||||||
|
'serahan' => $request->gldetail,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($glDescs as $desc => $amount) {
|
if ($request->gldetailcdm != null) {
|
||||||
if ($amount > 0) {
|
|
||||||
$existsGl = GlDetail::on($cawangan['mysql'])
|
|
||||||
->where('kodcaw', $request->kodcaw)
|
|
||||||
->where('tarikh', $request->tarikh)
|
|
||||||
->where('descpt', 'like', "%{$desc}%")
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if (!$existsGl) {
|
|
||||||
GlDetail::on($cawangan['mysql'])->create([
|
GlDetail::on($cawangan['mysql'])->create([
|
||||||
'kodcaw' => $request->kodcaw,
|
'kodcaw' => $request->kodcaw,
|
||||||
'tarikh' => $request->tarikh,
|
'tarikh' => $request->tarikh,
|
||||||
'dtacct' => "1000/010",
|
'dtacct' => "1000/010",
|
||||||
'ktacct' => "1000/020",
|
'ktacct' => "1000/020",
|
||||||
'descpt' => "{$desc}, {$request->tarikh}",
|
'descpt' => "SERAHAN LELONG CDM, " . $request->tarikh,
|
||||||
'amaun' => $amount,
|
'amaun' => $request->gldetailcdm,
|
||||||
'teller' => "LELONG ONLINE",
|
'teller' => "LELONG ONLINE",
|
||||||
'serahan' => $amount,
|
'serahan' => $request->gldetailcdm,
|
||||||
]);
|
]);
|
||||||
Log::info("Rekod GL dimasukkan", ['desc' => $desc]);
|
|
||||||
} else {
|
|
||||||
Log::warning("Skip GL duplicate", ['desc' => $desc]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Step 9: Log Akhir ---
|
return response()->json("success");
|
||||||
Log::info('Berjaya Export Cawangan:', [
|
|
||||||
'kodcaw' => $cawangan->kodcaw,
|
|
||||||
'nama_cawangan' => $cawangan->details_caw,
|
|
||||||
'batch_baru' => $newBatchNo,
|
|
||||||
'total_lelong' => count($lelong_arr),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response()->json(['status' => 'success']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRingkasanHarian(Request $request){
|
public function getRingkasanHarian(Request $request){
|
||||||
@@ -1395,53 +1318,42 @@ class LelongController extends Controller
|
|||||||
|
|
||||||
public function showAllLelongByCawanganBatchno($kodcaw)
|
public function showAllLelongByCawanganBatchno($kodcaw)
|
||||||
{
|
{
|
||||||
$item = ['PMT', 'batu', 'permata'];
|
$item = array('PMT','batu','permata');
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
// Semak kewujudan cawangan dulu
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
|
||||||
if (!$cawangan) {
|
|
||||||
return response()->json(['error' => 'Cawangan tidak dijumpai.'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ambil data lelong
|
|
||||||
$lelong_data = Lelong::on($cawangan['mysql'])
|
$lelong_data = Lelong::on($cawangan['mysql'])
|
||||||
->leftJoin('gadai', 'gadai.norujukan', '=', 'lelong.norujukan')
|
->leftJoin('gadai', 'gadai.norujukan', '=', 'lelong.norujukan')
|
||||||
->join('lelmarhun', 'lelmarhun.norujukan', '=', 'lelong.norujukan')
|
->join('lelmarhun', 'lelmarhun.norujukan', '=', 'lelong.norujukan')
|
||||||
->whereNull('upah12')
|
->whereNull('upah12')
|
||||||
->where(function ($query) use ($item) {
|
// ->where('lelong.marhun', 'like', '%PMT%')
|
||||||
foreach ($item as $i) {
|
// ->orWhere('lelong.marhun', 'like', '%batu%')
|
||||||
$query->orWhere('lelmarhun.nota', 'like', '%' . $i . '%');
|
// ->orWhere('lelong.marhun', 'like', '%permata%')
|
||||||
|
->Where(function ($query) use($item) {
|
||||||
|
for ($i = 0; $i < count($item); $i++){
|
||||||
|
$query->orwhere('lelmarhun.nota', 'like', '%' . $item[$i] .'%');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->orderBy('lelong.t_lelong','asc')
|
->orderBy('lelong.t_lelong','asc')
|
||||||
->select(
|
->select('lelong.t_lelong','gadai.t_gadai','gadai.nokp','lelong.pinjaman','lelong.baki','lelong.batchno','lelong.norujukan')
|
||||||
'lelong.t_lelong',
|
->whereNull('upah12')
|
||||||
'gadai.t_gadai',
|
|
||||||
'gadai.nokp',
|
|
||||||
'lelong.pinjaman',
|
|
||||||
'lelong.baki',
|
|
||||||
'lelong.batchno',
|
|
||||||
'lelong.norujukan'
|
|
||||||
)
|
|
||||||
->distinct()
|
->distinct()
|
||||||
->get();
|
->get();
|
||||||
|
// dd($lelong_data);
|
||||||
// Group by batch number
|
|
||||||
$groupbybatch = $lelong_data->groupBy('batchno');
|
$groupbybatch = $lelong_data->groupBy('batchno');
|
||||||
$lelong = [];
|
$lelong = [];
|
||||||
|
|
||||||
foreach ($groupbybatch as $batchno => $lelongData) {
|
foreach($groupbybatch as $index=>$lelongData){
|
||||||
$total_pembiayaan = $lelongData->sum('pinjaman');
|
$total_pembiayaan = $lelongData->sum('pinjaman');
|
||||||
$total_lelong = $lelongData->count();
|
// dd($total_pembiayaan);
|
||||||
$t_lelong = optional($lelongData->first())->t_lelong; // elak error kalau kosong
|
$total_lelong = $lelongData->count('norujukan');
|
||||||
|
array_push($lelong,[
|
||||||
$lelong[] = [
|
// "upah12"=> $lelongData->upah12,
|
||||||
't_lelong' => $t_lelong,
|
"t_lelong"=> $lelongData->groupBy('t_lelong'),
|
||||||
'batchno' => $batchno,
|
"batchno"=> $index,
|
||||||
'total_pembiayaan' => $total_pembiayaan,
|
"total_pembiayaan"=> $total_pembiayaan,
|
||||||
'total_lelong' => $total_lelong,
|
"total_lelong"=> $total_lelong,
|
||||||
'kodcaw' => $kodcaw,
|
"kodcaw"=> $kodcaw,
|
||||||
];
|
]);
|
||||||
|
// dd($lelong);
|
||||||
}
|
}
|
||||||
return response()->json($lelong);
|
return response()->json($lelong);
|
||||||
}
|
}
|
||||||
@@ -1983,30 +1895,4 @@ class LelongController extends Controller
|
|||||||
return response()->json($arrayblm);
|
return response()->json($arrayblm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBakiLelongByTeller($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
|
||||||
|
|
||||||
$date = $request->tarikh;
|
|
||||||
|
|
||||||
$rugiLelong = TuntutBaki::on($cawangan['mysql'])
|
|
||||||
->whereDate('tarikh', $date)
|
|
||||||
->where('jumlah', '<', 0)
|
|
||||||
->where('teller','=', $request->kodlaluan)
|
|
||||||
->sum('jumlah');
|
|
||||||
|
|
||||||
$bakiLelong = TuntutBaki::on($cawangan['mysql'])
|
|
||||||
->whereDate('tarikh', $date)
|
|
||||||
->where('jumlah', '>', 0)
|
|
||||||
->where('teller','=', $request->kodlaluan)
|
|
||||||
->sum('jumlah');
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'tarikh' => $date,
|
|
||||||
'cawangan' => $kodcaw,
|
|
||||||
'rugi_lelong' => $rugiLelong,
|
|
||||||
'baki_lelong' => $bakiLelong
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,10 +203,7 @@ class MarhunController extends Controller
|
|||||||
$marhun = Marhun::on($cawangan['mysql'])
|
$marhun = Marhun::on($cawangan['mysql'])
|
||||||
->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.tag_permata', 'marhun.berat_batu_permata')
|
->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.tag_permata', 'marhun.berat_batu_permata')
|
||||||
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
||||||
->rightJoin('master_erahn.customer as customer', function($join) {
|
->rightJoin('master_annur.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||||
$join->on('customer.kpbaru', '=', 'gadai.nokp')
|
|
||||||
->orOn('customer.kplama', '=', 'gadai.nokp');
|
|
||||||
})
|
|
||||||
->where('marhun.t_gadai','=',$tarikh)
|
->where('marhun.t_gadai','=',$tarikh)
|
||||||
->orderBy('marhun.t_gadai')
|
->orderBy('marhun.t_gadai')
|
||||||
->get();
|
->get();
|
||||||
@@ -224,10 +221,7 @@ class MarhunController extends Controller
|
|||||||
$marhun = Marhun::on($cawangan['mysql'])
|
$marhun = Marhun::on($cawangan['mysql'])
|
||||||
->select('marhun.norujukan','gadai.sttebus','gadai.pinjaman','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai')
|
->select('marhun.norujukan','gadai.sttebus','gadai.pinjaman','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai')
|
||||||
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
||||||
->rightJoin('master_erahn.customer as customer', function($join) {
|
->rightJoin('master_annur.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||||
$join->on('customer.kpbaru', '=', 'gadai.nokp')
|
|
||||||
->orOn('customer.kplama', '=', 'gadai.nokp');
|
|
||||||
})
|
|
||||||
->where('marhun.t_gadai','<=',$tarikh)
|
->where('marhun.t_gadai','<=',$tarikh)
|
||||||
->whereYear('marhun.t_gadai','=',$current->year)
|
->whereYear('marhun.t_gadai','=',$current->year)
|
||||||
->where('gadai.sttebus','=','')
|
->where('gadai.sttebus','=','')
|
||||||
|
|||||||
@@ -2,206 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Audit;
|
|
||||||
use App\MaxMutuEmas;
|
|
||||||
use App\MaxPinjaman;
|
use App\MaxPinjaman;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
class MaxPinjamanController extends Controller
|
class MaxPinjamanController extends Controller
|
||||||
{
|
{
|
||||||
public function getAllMaxPinjaman(Request $request)
|
public function getAllMaxPinjaman(){
|
||||||
{
|
|
||||||
if (config('parameter.max_mutuemas')) {
|
|
||||||
$data = MaxMutuEmas::on('mysql7')->select('karat', 'teller', 'pc', 'operasi')->get();
|
|
||||||
|
|
||||||
$calculateMargin = $this->calculateMaxPinjamanMutu($data, $request->mutu,$request->total_nilai_marhun);
|
|
||||||
|
|
||||||
$pinjaman = [
|
|
||||||
[
|
|
||||||
"user_type" => "teller",
|
|
||||||
"max" => $calculateMargin['teller'],
|
|
||||||
"teller_pinjaman" => $calculateMargin['teller_pinjaman']
|
|
||||||
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"user_type" => "khazanah",
|
|
||||||
"max" => $calculateMargin['pc'],
|
|
||||||
"pc_pinjaman" => $calculateMargin['pc_pinjaman']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"user_type" => "operasi",
|
|
||||||
"max" => $calculateMargin['operasi'],
|
|
||||||
"operasi_pinjaman" => $calculateMargin['operasi_pinjaman']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$pinjaman = MaxPinjaman::on('mysql7')->get();
|
$pinjaman = MaxPinjaman::on('mysql7')->get();
|
||||||
}
|
|
||||||
return response()->json($pinjaman);
|
return response()->json($pinjaman);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateMaxPinjamanMutu($data, $mutu,$totalMarhun)
|
|
||||||
{
|
|
||||||
$totalMaxMarhunPC = 0;
|
|
||||||
$totalMaxMarhunTeller = 0;
|
|
||||||
$totalMaxMarhunOperasi = 0;
|
|
||||||
|
|
||||||
if($mutu == null || $totalMarhun == 0){
|
|
||||||
return [
|
|
||||||
"pc" => 0,
|
|
||||||
"pc_pinjaman" => 0,
|
|
||||||
"teller" => 0,
|
|
||||||
"teller_pinjaman" => 0,
|
|
||||||
"operasi" => 0,
|
|
||||||
"operasi_pinjaman" => 0
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$mutuKarat = array_map(function($item) {
|
|
||||||
return $item[0];
|
|
||||||
}, $mutu);
|
|
||||||
$mutuNilai = array_map(function($item) {
|
|
||||||
return $item[1];
|
|
||||||
}, $mutu);
|
|
||||||
|
|
||||||
foreach($mutuKarat as $index => $karat){
|
|
||||||
$margin = $data->where('karat', $karat)->first();
|
|
||||||
if($margin){
|
|
||||||
$nilai = $mutuNilai[$index];
|
|
||||||
$totalMaxMarhunPC += round(($margin->pc/100) * $nilai, 2);
|
|
||||||
$totalMaxMarhunTeller += round(($margin->teller/100) * $nilai, 2);
|
|
||||||
$totalMaxMarhunOperasi += round(($margin->operasi/100) * $nilai, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$totalMaxPC = $totalMarhun > 0 ? ($totalMaxMarhunPC / $totalMarhun) * 100 : 0;
|
|
||||||
$totalMaxTeller = $totalMarhun > 0 ? ($totalMaxMarhunTeller / $totalMarhun) * 100 : 0;
|
|
||||||
$totalMaxOperasi = $totalMarhun > 0 ? ($totalMaxMarhunOperasi / $totalMarhun) * 100 : 0;
|
|
||||||
return [
|
|
||||||
"pc" => round($totalMaxPC,2),
|
|
||||||
"pc_pinjaman" => round(($totalMaxPC / 100) * $totalMarhun, 2),
|
|
||||||
"teller" => round($totalMaxTeller,2),
|
|
||||||
"teller_pinjaman" => round(($totalMaxTeller / 100) * $totalMarhun, 2),
|
|
||||||
"operasi" => round($totalMaxOperasi,2),
|
|
||||||
"operasi_pinjaman" => round(($totalMaxOperasi / 100) * $totalMarhun, 2)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getAllMaxMutuEmas(Request $request)
|
|
||||||
{
|
|
||||||
$maxmutuemas = MaxMutuEmas::on('mysql7')->get();
|
|
||||||
return response()->json($maxmutuemas);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSpecificMaxMutuEmas(Request $request)
|
|
||||||
{
|
|
||||||
$karat = $request->karat;
|
|
||||||
$nilaimarhun = $request->nilaimarhun;
|
|
||||||
|
|
||||||
$nilaimarhun = preg_replace('/[^0-9.]/', '', $nilaimarhun); // Remove non-numeric characters except decimal point
|
|
||||||
$nilaimarhun = is_numeric($nilaimarhun) ? (float)$nilaimarhun : 0;
|
|
||||||
|
|
||||||
$maxmutuemas = MaxMutuEmas::on('mysql7')->where('karat', $karat)->first();
|
|
||||||
|
|
||||||
if($maxmutuemas && $nilaimarhun > 0){
|
|
||||||
$maxmutuemas->maxteller = round(($maxmutuemas->teller/100) * $nilaimarhun, 2);
|
|
||||||
$maxmutuemas->maxpc = round(($maxmutuemas->pc/100) * $nilaimarhun, 2);
|
|
||||||
$maxmutuemas->maxoperasi = round(($maxmutuemas->operasi/100) * $nilaimarhun, 2);
|
|
||||||
} else if($maxmutuemas) {
|
|
||||||
$maxmutuemas->maxteller = 0;
|
|
||||||
$maxmutuemas->maxpc = 0;
|
|
||||||
$maxmutuemas->maxoperasi = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($maxmutuemas);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateMaxMutuEmas(Request $request)
|
|
||||||
{
|
|
||||||
// Validate the request manually for Lumen
|
|
||||||
$validator = \Illuminate\Support\Facades\Validator::make($request->all(), [
|
|
||||||
'recno' => 'required|integer',
|
|
||||||
'karat' => 'required|string|max:10',
|
|
||||||
'keterangan' => 'required|string|max:255',
|
|
||||||
'teller' => 'required|numeric|min:0|max:100',
|
|
||||||
'pc' => 'required|numeric|min:0|max:100',
|
|
||||||
'operasi' => 'required|numeric|min:0|max:100',
|
|
||||||
'username' => 'required|string|max:255'
|
|
||||||
], [
|
|
||||||
'recno.required' => 'Nombor rekod diperlukan.',
|
|
||||||
'recno.integer' => 'Nombor rekod mesti berupa nombor.',
|
|
||||||
'karat.required' => 'Karat diperlukan.',
|
|
||||||
'karat.string' => 'Karat mesti berupa teks.',
|
|
||||||
'karat.max' => 'Karat tidak boleh lebih dari 10 aksara.',
|
|
||||||
'keterangan.required' => 'Keterangan diperlukan.',
|
|
||||||
'keterangan.string' => 'Keterangan mesti berupa teks.',
|
|
||||||
'keterangan.max' => 'Keterangan tidak boleh lebih dari 255 aksara.',
|
|
||||||
'teller.required' => 'Peratus teller diperlukan.',
|
|
||||||
'teller.numeric' => 'Peratus teller mesti berupa nombor.',
|
|
||||||
'teller.min' => 'Peratus teller mestilah sekurang-kurangnya 0.',
|
|
||||||
'teller.max' => 'Peratus teller tidak boleh melebihi 100.',
|
|
||||||
'pc.required' => 'Peratus PC diperlukan.',
|
|
||||||
'pc.numeric' => 'Peratus PC mesti berupa nombor.',
|
|
||||||
'pc.min' => 'Peratus PC mestilah sekurang-kurangnya 0.',
|
|
||||||
'pc.max' => 'Peratus PC tidak boleh melebihi 100.',
|
|
||||||
'operasi.required' => 'Peratus operasi diperlukan.',
|
|
||||||
'operasi.numeric' => 'Peratus operasi mesti berupa nombor.',
|
|
||||||
'operasi.min' => 'Peratus operasi mestilah sekurang-kurangnya 0.',
|
|
||||||
'operasi.max' => 'Peratus operasi tidak boleh melebihi 100.',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'message' => 'Pengesahan gagal',
|
|
||||||
'errors' => $validator->errors()
|
|
||||||
], 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
$recno = $request->recno;
|
|
||||||
$karat = $request->karat;
|
|
||||||
$keterangan = $request->keterangan;
|
|
||||||
$teller = $request->teller;
|
|
||||||
$pc = $request->pc;
|
|
||||||
$operasi = $request->operasi;
|
|
||||||
$username = $request->username;
|
|
||||||
|
|
||||||
$current = \Carbon\Carbon::now();
|
|
||||||
|
|
||||||
$maxmutuemas = MaxMutuEmas::on('mysql7')->where('recno', $recno)->first();
|
|
||||||
|
|
||||||
if ($maxmutuemas) {
|
|
||||||
$oldmax = $maxmutuemas->toJson();
|
|
||||||
|
|
||||||
$maxmutuemas->karat = $karat;
|
|
||||||
$maxmutuemas->keterangan = $keterangan;
|
|
||||||
$maxmutuemas->teller = $teller;
|
|
||||||
$maxmutuemas->pc = $pc;
|
|
||||||
$maxmutuemas->operasi = $operasi;
|
|
||||||
$maxmutuemas->tarikhupdate = \Carbon\Carbon::now();
|
|
||||||
$maxmutuemas->save();
|
|
||||||
|
|
||||||
Audit::create([
|
|
||||||
'users' => $username,
|
|
||||||
'actions' => 'Penukaran Mutu Margin',
|
|
||||||
'norujukan' => '-',
|
|
||||||
'new_data' => $maxmutuemas->toJson(),
|
|
||||||
'old_data' => $oldmax,
|
|
||||||
'kodcaw' => 'OPERASI',
|
|
||||||
'created_at' => $current,
|
|
||||||
'updated_at' => $current,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'Max Mutu Emas updated successfully',
|
|
||||||
'data' => $maxmutuemas
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'message' => 'Record not found'
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Services\PembiayaanOnline\ModalOnlineService;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ModalOnlineController extends Controller
|
|
||||||
{
|
|
||||||
protected $service;
|
|
||||||
|
|
||||||
public function __construct(ModalOnlineService $service = null)
|
|
||||||
{
|
|
||||||
$this->service = $service ?: new ModalOnlineService();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function respond(array $result)
|
|
||||||
{
|
|
||||||
return response()->json($result['payload'], $result['status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/modal-online/{kodcaw}
|
|
||||||
* Read-only: does not create today's row.
|
|
||||||
*/
|
|
||||||
public function get($kodcaw)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->get($kodcaw));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Alias of get() — no longer auto-creates RM100k.
|
|
||||||
*/
|
|
||||||
public function getOrCreate($kodcaw)
|
|
||||||
{
|
|
||||||
return $this->get($kodcaw);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/{kodcaw}/reserve
|
|
||||||
*/
|
|
||||||
public function reserve($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->reserve($kodcaw, $request->input('amaun', 0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/initiate/modal-online?zone=all|{zone}
|
|
||||||
*/
|
|
||||||
public function initiate(Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->initiate($request->input('zone', 'all')));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/{kodcaw}/topup/request
|
|
||||||
* PC mohon had (hari pertama) atau tambah modal. Body: amaun, dimohon_oleh, nota?
|
|
||||||
*/
|
|
||||||
public function requestTopUp($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->requestTopUp(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('amaun', 0),
|
|
||||||
$request->input('dimohon_oleh', ''),
|
|
||||||
$request->input('nota')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/modal-online/{kodcaw}/topup/requests?status=&tarikh=
|
|
||||||
*/
|
|
||||||
public function listTopUpByCawangan($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->listTopUpRequests(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('status'),
|
|
||||||
$request->input('tarikh')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/modal-online/operasi/topup/requests?status=PENDING&tarikh=
|
|
||||||
*/
|
|
||||||
public function listTopUpOperasi(Request $request)
|
|
||||||
{
|
|
||||||
$status = $request->input('status', 'PENDING');
|
|
||||||
if ($status === 'all' || $status === '') {
|
|
||||||
$status = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respond($this->service->listTopUpRequests(
|
|
||||||
null,
|
|
||||||
$status,
|
|
||||||
$request->input('tarikh')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/operasi/topup/{id}/approve
|
|
||||||
* Body: diluluskan_oleh, nota?, amaun? (optional override)
|
|
||||||
*/
|
|
||||||
public function approveTopUp($id, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->approveTopUp(
|
|
||||||
$id,
|
|
||||||
$request->input('diluluskan_oleh', ''),
|
|
||||||
$request->input('nota'),
|
|
||||||
null,
|
|
||||||
$request->input('amaun')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/operasi/topup/{id}/reject
|
|
||||||
* Body: diluluskan_oleh, nota?
|
|
||||||
*/
|
|
||||||
public function rejectTopUp($id, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->rejectTopUp(
|
|
||||||
$id,
|
|
||||||
$request->input('diluluskan_oleh', ''),
|
|
||||||
$request->input('nota')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/{kodcaw}/close
|
|
||||||
* Body: ditutup_oleh
|
|
||||||
*/
|
|
||||||
public function close($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->close(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('ditutup_oleh', '')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/modal-online/operasi/eod?zone=all&tarikh=
|
|
||||||
*/
|
|
||||||
public function listToday(Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->listToday(
|
|
||||||
$request->input('zone', 'all'),
|
|
||||||
$request->input('tarikh')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/modal-online/operasi/eod/close-all
|
|
||||||
* Body: ditutup_oleh, zone?
|
|
||||||
*/
|
|
||||||
public function closeAll(Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->closeAll(
|
|
||||||
$request->input('ditutup_oleh', ''),
|
|
||||||
$request->input('zone', 'all')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Cawangan;
|
|
||||||
use App\Palsu;
|
|
||||||
use App\Pampasan;
|
|
||||||
use App\Panjar;
|
|
||||||
use App\Tebus;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Log\Logger;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class PampasanController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
public function terimaPampasan(Request $request)
|
|
||||||
{
|
|
||||||
$validated = $this->validate($request, [
|
|
||||||
'norujukan' => 'required|string',
|
|
||||||
'kodcaw' => 'required|string',
|
|
||||||
'jumlah_pampasan' => 'required|numeric',
|
|
||||||
'denominasi' => 'required|array',
|
|
||||||
'teller' => 'required|string',
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cawangan = $this->getCawangan($request->kodcaw);
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $request->kodcaw, 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pampasan = Pampasan::on($cawangan['mysql'])
|
|
||||||
->where('norujukan', $validated['norujukan'])
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$pampasan->update([
|
|
||||||
'jumlah_pampasan' => $validated['jumlah_pampasan'],
|
|
||||||
'denominasi' => isset($validated['denominasi']) ? json_encode($validated['denominasi']) : null,
|
|
||||||
'teller' => $validated['teller'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->successResponse('Pampasan berjaya dibayar.', $pampasan, 201);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateStatusPampasan(Request $request)
|
|
||||||
{
|
|
||||||
$norujukan = $request->norujukan;
|
|
||||||
|
|
||||||
$cawangan = $this->getCawangan($request->kodcaw);
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $request->kodcaw, 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tebus = Tebus::on($cawangan['mysql'])->where('norujukan', $norujukan)->first();
|
|
||||||
|
|
||||||
$pampasan = Pampasan::on($cawangan['mysql'])->where("norujukan", $norujukan)->first();
|
|
||||||
|
|
||||||
$pampasan->status = 1;
|
|
||||||
|
|
||||||
$pampasan->save();
|
|
||||||
|
|
||||||
// Update corresponding palsu table record status to 1
|
|
||||||
Palsu::on($cawangan['mysql'])
|
|
||||||
->where('norujukan', $norujukan)
|
|
||||||
->update(['status' => 1]);
|
|
||||||
|
|
||||||
return $this->successResponse('Status Pampasan berjaya dituntut.', $pampasan, 201);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPampasan(Request $request)
|
|
||||||
{
|
|
||||||
$cawangan_connection = Cawangan::where('kodcaw', $request->kodcaw)->first()->mysql;
|
|
||||||
|
|
||||||
$pampasan = Pampasan::on($cawangan_connection)
|
|
||||||
->when($request->filled('norujukan'), function ($query) use ($request) {
|
|
||||||
return $query->where('norujukan', $request->norujukan);
|
|
||||||
})
|
|
||||||
->get();
|
|
||||||
|
|
||||||
|
|
||||||
return $this->successResponse('Senarai pampasan', $pampasan, 201);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateAgreementPrintedAt(Request $request)
|
|
||||||
{
|
|
||||||
$validated = $this->validate($request, [
|
|
||||||
'norujukan' => 'required|string',
|
|
||||||
'kodcaw' => 'required|string',
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cawangan = $this->getCawangan($validated['kodcaw']);
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $validated['kodcaw'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
|
||||||
|
|
||||||
if (!$pampasan) {
|
|
||||||
return $this->errorResponse('Pampasan tidak dijumpai untuk norujukan: ' . $validated['norujukan'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pampasan->agreement_printed_at = Carbon::now();
|
|
||||||
$pampasan->save();
|
|
||||||
|
|
||||||
return $this->successResponse('Agreement printed timestamp berjaya dikemaskini.', $pampasan, 200);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initiatePampasan(Request $request)
|
|
||||||
{
|
|
||||||
$validated = $this->validate($request, [
|
|
||||||
'norujukan' => 'required|string',
|
|
||||||
'kodcaw' => 'required|string',
|
|
||||||
'teller' => 'required|string',
|
|
||||||
'baucerno' => 'required|string',
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cawangan = $this->getCawangan($validated['kodcaw']);
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $validated['kodcaw'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the palsu record
|
|
||||||
$palsu = Palsu::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
|
||||||
|
|
||||||
if (!$palsu) {
|
|
||||||
return $this->errorResponse('Barang kes tidak dijumpai untuk norujukan: ' . $validated['norujukan'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if pampasan already exists for this norujukan
|
|
||||||
$existingPampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
|
||||||
|
|
||||||
if ($existingPampasan) {
|
|
||||||
// If pampasan exists, just update the agreement_printed_at
|
|
||||||
$existingPampasan->agreement_printed_at = Carbon::now();
|
|
||||||
$existingPampasan->save();
|
|
||||||
|
|
||||||
return $this->successResponse('Agreement printed timestamp berjaya dikemaskini untuk pampasan sedia ada.', $existingPampasan, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create new pampasan record based on palsu data
|
|
||||||
$pampasan = Pampasan::on($cawangan['mysql'])->create([
|
|
||||||
'norujukan' => $palsu->norujukan,
|
|
||||||
'baucerno' => $validated['baucerno'],
|
|
||||||
'kodcaw' => $palsu->kodcaw,
|
|
||||||
'jumlah_pampasan' => $palsu->nilaimarhun,
|
|
||||||
'teller' => $validated['teller'],
|
|
||||||
'status' => 0,
|
|
||||||
'agreement_printed_at' => Carbon::now(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->successResponse('Pampasan berjaya daftar dari rekod barang kes.', $pampasan, 201);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getCawangan($kodcaw)
|
|
||||||
{
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $cawangan;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function errorResponse($message, $statusCode = 404)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'success' => false,
|
|
||||||
'message' => $message,
|
|
||||||
], $statusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function successResponse($message, $data = null, $statusCode = 200)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
'message' => $message,
|
|
||||||
'data' => $data,
|
|
||||||
], $statusCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Services\PembiayaanOnline\PembiayaanOnlineService;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class PembiayaanOnlineController extends Controller
|
|
||||||
{
|
|
||||||
protected $service;
|
|
||||||
|
|
||||||
public function __construct(PembiayaanOnlineService $service = null)
|
|
||||||
{
|
|
||||||
$this->service = $service ?: new PembiayaanOnlineService();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function respond(array $result)
|
|
||||||
{
|
|
||||||
return response()->json($result['payload'], $result['status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/{kodcaw}
|
|
||||||
*/
|
|
||||||
public function store($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->store($kodcaw, $request->all()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/by-norujukan/{norujukan}
|
|
||||||
*/
|
|
||||||
public function show($kodcaw, $norujukan)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->show($kodcaw, $norujukan));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/queue
|
|
||||||
*/
|
|
||||||
public function queue($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->queue($kodcaw, $request->input('status')));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PUT /api/pembiayaan-online/{kodcaw}/lines/{id}
|
|
||||||
*/
|
|
||||||
public function updateLine($kodcaw, $id, Request $request)
|
|
||||||
{
|
|
||||||
// Prefer only present keys so "has" semantics match previous controller.
|
|
||||||
$input = [];
|
|
||||||
foreach ([
|
|
||||||
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
|
||||||
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
|
||||||
] as $key) {
|
|
||||||
if ($request->has($key)) {
|
|
||||||
$input[$key] = $request->input($key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respond($this->service->updateLine($kodcaw, $id, $input));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/batches
|
|
||||||
*/
|
|
||||||
public function listBatches($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->listBatches(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('tarikh'),
|
|
||||||
$request->input('status')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/batches/{batchId}
|
|
||||||
*/
|
|
||||||
public function showBatch($kodcaw, $batchId)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->showBatch($kodcaw, $batchId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/{kodcaw}/batches/submit
|
|
||||||
*/
|
|
||||||
public function submitBatch($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->submitBatch(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('ids', []),
|
|
||||||
$request->input('pc_submitted_by', ''),
|
|
||||||
$request->input('slot')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/operasi/batches
|
|
||||||
*/
|
|
||||||
public function operasiListBatches(Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiListBatches(
|
|
||||||
$request->input('status', 'SUBMITTED'),
|
|
||||||
$request->input('tarikh')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}
|
|
||||||
*/
|
|
||||||
public function operasiShowBatch($kodcaw, $batchId)
|
|
||||||
{
|
|
||||||
return $this->showBatch($kodcaw, $batchId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/approve
|
|
||||||
*/
|
|
||||||
public function operasiApproveLine($kodcaw, $id, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiApproveLine(
|
|
||||||
$kodcaw,
|
|
||||||
$id,
|
|
||||||
$request->input('ops_by', '')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/reject
|
|
||||||
*/
|
|
||||||
public function operasiRejectLine($kodcaw, $id, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiRejectLine(
|
|
||||||
$kodcaw,
|
|
||||||
$id,
|
|
||||||
$request->input('ops_by', ''),
|
|
||||||
$request->input('reject_reason', '')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/approve
|
|
||||||
*/
|
|
||||||
public function operasiApproveBatch($kodcaw, $batchId, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiApproveBatch(
|
|
||||||
$kodcaw,
|
|
||||||
$batchId,
|
|
||||||
$request->input('ops_by', '')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/paid
|
|
||||||
* Body: ops_by, no_rujukan_bayaran, tarikh_bayaran?,
|
|
||||||
* bukti_data + bukti_filename + bukti_type OR bukti_file_id
|
|
||||||
*/
|
|
||||||
public function operasiMarkPaid($kodcaw, $id, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiMarkPaid($kodcaw, $id, $request->all()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/paid
|
|
||||||
*/
|
|
||||||
public function operasiMarkPaidBatch($kodcaw, $batchId, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->operasiMarkPaidBatch($kodcaw, $batchId, $request->all()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/bukti
|
|
||||||
*/
|
|
||||||
public function getBukti($kodcaw, $id)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->getBukti($kodcaw, $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
|
||||||
*/
|
|
||||||
public function paidQueue($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
return $this->respond($this->service->paidQueue(
|
|
||||||
$kodcaw,
|
|
||||||
$request->input('blast_sent')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/pembiayaan-online/{kodcaw}/paid/blast
|
|
||||||
* Body: ids[] (or ids), blast_by?
|
|
||||||
*/
|
|
||||||
public function markBlastSent($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
$ids = $request->input('ids', $request->input('id'));
|
|
||||||
return $this->respond($this->service->markBlastSent(
|
|
||||||
$kodcaw,
|
|
||||||
$ids,
|
|
||||||
$request->input('blast_by')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,11 +11,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
use App\Services\Reports\GadaianService as ReportGadaianService;
|
||||||
use App\Helper;
|
use App\Helper;
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\Pekerjaan;
|
|
||||||
use App\Poskod;
|
|
||||||
use App\TransactionOnline;
|
|
||||||
use Log;
|
|
||||||
use App\Services\Reports\RingkasanHarianService as ReportRingkasanHarianService;
|
use App\Services\Reports\RingkasanHarianService as ReportRingkasanHarianService;
|
||||||
|
|
||||||
|
|
||||||
@@ -167,484 +162,11 @@ public function getSummaryLaporanPelangganAktif(Request $request)
|
|||||||
return response()->json($response);
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActiveCawanganConnections()
|
|
||||||
{
|
|
||||||
$cawangan_details = Cawangan::select(['details_caw', 'mysql'])->get();
|
|
||||||
|
|
||||||
$cawangan_details = $cawangan_details->filter(fn($x) => !in_array(strtolower($x->details_caw), config('report.excluded_cawangan')));
|
|
||||||
|
|
||||||
$connection_active_cawangan = Helper::getActiveCawanganDbConnection();
|
|
||||||
|
|
||||||
return collect($cawangan_details->filter(fn($x) => in_array($x->mysql, $connection_active_cawangan)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSummaryLaporanDataPelanggan(Request $request)
|
|
||||||
{
|
|
||||||
$year = $request->year;
|
|
||||||
if (!$year) {
|
|
||||||
return response()->json(['error' => 'Sila pilih tahun'], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
$startOfYear = Carbon::create($year, 1, 1)->startOfDay();
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
|
|
||||||
Carbon::setLocale('ms');
|
|
||||||
|
|
||||||
// 1️⃣ Ambil semua pelanggan tahun ini
|
|
||||||
$pelanggan = Customer::whereYear('tarikhdaftar', $year)
|
|
||||||
->select('id','nama','kpbaru','kplama','t_lahir','jantina',
|
|
||||||
'kodkerja','poskod','kodcaw','tarikhdaftar','tujuangadai','nopelanggan')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$connections = $this->getActiveCawanganConnections();
|
|
||||||
|
|
||||||
// Ambil semua pekerjaan & poskod sekali untuk map cepat
|
|
||||||
$pekerjaanAll = Pekerjaan::pluck('keterangan','kodkerja');
|
|
||||||
$poskodAll = Poskod::with('daerah')->get()->keyBy('poskod');
|
|
||||||
|
|
||||||
// 2️⃣ Ambil semua nokp pelanggan
|
|
||||||
$nokps = $pelanggan->map(fn($p) => $p->kpbaru ?? $p->kplama)->filter()->values();
|
|
||||||
|
|
||||||
// 3️⃣ Ambil semua transaksi gadai + tebus untuk nokp tu dari semua cawangan
|
|
||||||
$allTransaksi = collect();
|
|
||||||
foreach ($connections as $conn) {
|
|
||||||
$data = DB::connection($conn->mysql)
|
|
||||||
->table('gadai as g')
|
|
||||||
->leftJoin('tebus as t', 'g.norujukan', '=', 't.norujukan')
|
|
||||||
->leftJoin('lelong as l', 'g.norujukan', '=', 'l.norujukan')
|
|
||||||
->whereIn('g.nokp', $nokps)
|
|
||||||
->whereBetween('g.t_gadai', [$startOfYear, $endOfYear]) // ⬅️ dalam tahun sahaja
|
|
||||||
->select(
|
|
||||||
'g.nokp',
|
|
||||||
'g.norujukan',
|
|
||||||
'g.t_gadai',
|
|
||||||
't.t_tebus',
|
|
||||||
'g.pinjaman',
|
|
||||||
'g.upah12',
|
|
||||||
'g.tempoh',
|
|
||||||
'l.t_lelong',
|
|
||||||
'g.sttebus',
|
|
||||||
)
|
|
||||||
->get();
|
|
||||||
$allTransaksi = $allTransaksi->concat($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4️⃣ Group by nokp
|
|
||||||
$transGrouped = $allTransaksi->groupBy('nokp');
|
|
||||||
|
|
||||||
// 5️⃣ Ambil semua norujukan transaksi online
|
|
||||||
$onlineNorujukan = TransactionOnline::pluck('norujukan')->unique()->values();
|
|
||||||
|
|
||||||
|
|
||||||
// 6️⃣ Map pelanggan
|
|
||||||
$result = $pelanggan->map(function($row) use ($transGrouped, $onlineNorujukan, $pekerjaanAll, $poskodAll, $year) {
|
|
||||||
|
|
||||||
$nokp = $row->kpbaru ?? $row->kplama ?? null;
|
|
||||||
|
|
||||||
$tempohData = $transGrouped->get($nokp, collect());
|
|
||||||
|
|
||||||
// Norujukan pelanggan spesifik
|
|
||||||
$norujukanPelanggan = $tempohData->pluck('norujukan')->unique()->values();
|
|
||||||
|
|
||||||
// Cara Bayaran
|
|
||||||
// $caraBayaran = $norujukanPelanggan->intersect($onlineNorujukan)->isNotEmpty() ? 'Online' : 'Kaunter';
|
|
||||||
$adaOnline = $norujukanPelanggan->contains(fn($nr) => isset($onlineNorujukan[$nr]));
|
|
||||||
$caraBayaran = $adaOnline ? 'Online' : 'Kaunter';
|
|
||||||
if ($adaOnline) {
|
|
||||||
\Log::info("Pelanggan {$row->nama} ({$nokp}): Bayaran Online - YA");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Bilangan transaksi
|
|
||||||
$bilTransaksi = $tempohData->count();
|
|
||||||
|
|
||||||
// Bilangan Belum tebus
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
$bilOutstanding = $tempohData
|
|
||||||
->filter(function ($row) use ($endOfYear) {
|
|
||||||
|
|
||||||
// masih belum tebus langsung
|
|
||||||
if (empty($row->sttebus)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// dah tebus, tapi tebus selepas hujung tahun
|
|
||||||
return Carbon::parse($row->t_tebus)->gt($endOfYear);
|
|
||||||
})
|
|
||||||
->count();
|
|
||||||
|
|
||||||
// Bilangan tebus
|
|
||||||
$bilTebus = $tempohData->whereNotNull('t_tebus')->count();
|
|
||||||
|
|
||||||
// Jumlah pinjaman
|
|
||||||
$jumlahPinjaman = $tempohData->sum('pinjaman');
|
|
||||||
|
|
||||||
// Jumlah ujrah ikut tempoh surat
|
|
||||||
$jumlahUjrah = $tempohData->reduce(function ($carry, $trx) {
|
|
||||||
if (!$trx->upah12 || !$trx->tempoh) return $carry;
|
|
||||||
return $carry + ($trx->upah12 / 12 * $trx->tempoh);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Tarikh mula & tamat
|
|
||||||
$tarikhMula = $tempohData->min('t_gadai');
|
|
||||||
$tarikhTamat = $tempohData->max('t_tebus');
|
|
||||||
$tarikhLelong = $tempohData->max('t_lelong');
|
|
||||||
|
|
||||||
// Tempoh Pajakan
|
|
||||||
if (!$tarikhMula) {
|
|
||||||
$tempohPajakan = '-';
|
|
||||||
} elseif (!$tarikhTamat || $tarikhMula == $tarikhTamat) {
|
|
||||||
$tempohPajakan = Carbon::parse($tarikhMula)->translatedFormat('M Y');
|
|
||||||
} else {
|
|
||||||
$tempohPajakan = Carbon::parse($tarikhMula)->translatedFormat('M Y') .
|
|
||||||
' - ' .
|
|
||||||
Carbon::parse($tarikhTamat)->translatedFormat('M Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hari sejak transaksi terakhir
|
|
||||||
$hariTempohPajakan = $tarikhMula
|
|
||||||
? Carbon::parse($tarikhMula)->diffInDays($tarikhTamat ? Carbon::parse($tarikhTamat) : Carbon::now())
|
|
||||||
: null;
|
|
||||||
|
|
||||||
// Tujuan gadai
|
|
||||||
$tujuangadai = $row->tujuangadai ?: '-';
|
|
||||||
|
|
||||||
// Status aktif: ada transaksi dalam tahun tu
|
|
||||||
$now = Carbon::now();
|
|
||||||
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
$startOfYear = Carbon::create($year, 1, 1)->startOfDay();
|
|
||||||
|
|
||||||
$statusAktif = $tempohData->contains(function ($trx) use ($startOfYear, $endOfYear) {
|
|
||||||
|
|
||||||
if (!$trx->t_gadai) return false;
|
|
||||||
|
|
||||||
$tGadai = Carbon::parse($trx->t_gadai);
|
|
||||||
$tTebus = $trx->t_tebus ? Carbon::parse($trx->t_tebus) : null;
|
|
||||||
|
|
||||||
// SAG wujud dalam tahun laporan
|
|
||||||
return
|
|
||||||
$tGadai->lte($endOfYear) &&
|
|
||||||
(
|
|
||||||
is_null($tTebus) || // belum ditebus
|
|
||||||
$tTebus->gte($startOfYear) // ditebus dalam / selepas tahun
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Umur
|
|
||||||
$umur = $row->t_lahir ? Carbon::parse($row->t_lahir)->age : null;
|
|
||||||
|
|
||||||
// Pekerjaan
|
|
||||||
$pekerjaan = $row->kodkerja
|
|
||||||
? ($pekerjaanAll[ltrim($row->kodkerja,'0')] ?? 'Lain-lain')
|
|
||||||
: '-';
|
|
||||||
|
|
||||||
// Daerah / lokasi
|
|
||||||
$lokasi = $row->poskod && isset($poskodAll[$row->poskod])
|
|
||||||
? $poskodAll[$row->poskod]->daerah->namadaerah ?? 'Lain-lain'
|
|
||||||
: 'Lain-lain';
|
|
||||||
|
|
||||||
return [
|
|
||||||
'cawangan' => $row->kodcaw ?? '-',
|
|
||||||
'nama' => $row->nama,
|
|
||||||
'nopelanggan' => $row->nopelanggan,
|
|
||||||
'nokp' => $nokp ?? '-',
|
|
||||||
'tarikhdaftar' => Carbon::parse($row->tarikhdaftar)->format('d-m-Y'),
|
|
||||||
'umur' => $umur,
|
|
||||||
'jantina' => $row->jantina ?? '-',
|
|
||||||
'pekerjaan' => $pekerjaan,
|
|
||||||
'daerah' => $lokasi,
|
|
||||||
'tempoh_pajakan' => $tempohPajakan,
|
|
||||||
'tarikh_mula' => $tarikhMula ? Carbon::parse($tarikhMula)->format('d-m-Y') : null,
|
|
||||||
'tarikh_tamat' => $tarikhTamat ? Carbon::parse($tarikhTamat)->format('d-m-Y') : null,
|
|
||||||
'hari_sejak_transaksi' => $hariTempohPajakan,
|
|
||||||
'bil_transaksi' => $bilTransaksi,
|
|
||||||
'bil_outstanding' => $bilOutstanding,
|
|
||||||
'bil_tebus' => $bilTebus,
|
|
||||||
'jumlah_pinjaman' => $jumlahPinjaman,
|
|
||||||
'norujukan' => $norujukanPelanggan,
|
|
||||||
'jumlah_ujrah' => $jumlahUjrah,
|
|
||||||
'tujuan_gadai' => $tujuangadai,
|
|
||||||
'status_aktif' => $statusAktif ? 'AKTIF' : 'TIDAK AKTIF',
|
|
||||||
'cara_bayaran' => $caraBayaran,
|
|
||||||
'tarikh_lelong' => $tarikhLelong ? Carbon::parse($tarikhLelong)->format('d-m-Y') : null,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'year' => $year,
|
|
||||||
'summary' => [
|
|
||||||
'total_pelanggan' => $result->count(),
|
|
||||||
'jumlah_cawangan' => $result->pluck('cawangan')->unique()->count(),
|
|
||||||
],
|
|
||||||
'pelanggan' => $result->values(),
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function formatTempohPajakan($start, $end)
|
|
||||||
{
|
|
||||||
if (!$start || !$end) {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
$mula = Carbon::parse($start);
|
|
||||||
$tamat = Carbon::parse($end);
|
|
||||||
|
|
||||||
if ($mula->year === $tamat->year) {
|
|
||||||
return $mula->translatedFormat('M') . ' – ' .
|
|
||||||
$tamat->translatedFormat('M Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $mula->translatedFormat('M Y') . ' – ' .
|
|
||||||
$tamat->translatedFormat('M Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getSummaryLaporanDataPelangganBycaw(Request $request)
|
|
||||||
{
|
|
||||||
$year = $request->year;
|
|
||||||
if (!$year) {
|
|
||||||
return response()->json(['error' => 'Sila pilih tahun'], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// INPUT CAWANGAN (MULTIPLE)
|
|
||||||
// ===============================
|
|
||||||
$cawangan = $request->input('cawangan', []);
|
|
||||||
|
|
||||||
if (!is_array($cawangan)) {
|
|
||||||
$cawangan = [$cawangan];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$startOfYear = Carbon::create($year, 1, 1)->startOfDay();
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
|
|
||||||
Carbon::setLocale('ms');
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 1️⃣ AMBIL PELANGGAN (FILTER CAWANGAN)
|
|
||||||
// ===============================
|
|
||||||
$pelangganQuery = Customer::whereYear('tarikhdaftar', $year);
|
|
||||||
|
|
||||||
if (!empty($cawangan)) {
|
|
||||||
$pelangganQuery->whereIn('kodcaw', $cawangan);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pelanggan = $pelangganQuery
|
|
||||||
->select(
|
|
||||||
'id','nama','kpbaru','kplama','t_lahir','jantina',
|
|
||||||
'kodkerja','poskod','kodcaw','tarikhdaftar',
|
|
||||||
'tujuangadai','nopelanggan'
|
|
||||||
)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
if ($pelanggan->isEmpty()) {
|
|
||||||
return response()->json([
|
|
||||||
'year' => $year,
|
|
||||||
'summary' => [
|
|
||||||
'total_pelanggan' => 0,
|
|
||||||
'jumlah_cawangan' => 0,
|
|
||||||
],
|
|
||||||
'pelanggan' => []
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 2️⃣ CONNECTION CAWANGAN
|
|
||||||
// ===============================
|
|
||||||
$connections = $this->getActiveCawanganConnections();
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 3️⃣ MASTER DATA
|
|
||||||
// ===============================
|
|
||||||
$pekerjaanAll = Pekerjaan::pluck('keterangan', 'kodkerja');
|
|
||||||
$poskodAll = Poskod::with('daerah')->get()->keyBy('poskod');
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 4️⃣ NOKP PELANGGAN
|
|
||||||
// ===============================
|
|
||||||
$nokps = $pelanggan
|
|
||||||
->map(fn($p) => $p->kpbaru ?? $p->kplama)
|
|
||||||
->filter()
|
|
||||||
->values();
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 5️⃣ TRANSAKSI GADAI / TEBUS
|
|
||||||
// ===============================
|
|
||||||
$allTransaksi = collect();
|
|
||||||
|
|
||||||
foreach ($connections as $conn) {
|
|
||||||
$data = DB::connection($conn->mysql)
|
|
||||||
->table('gadai as g')
|
|
||||||
->leftJoin('tebus as t', 'g.norujukan', '=', 't.norujukan')
|
|
||||||
->leftJoin('lelong as l', 'g.norujukan', '=', 'l.norujukan')
|
|
||||||
->whereIn('g.nokp', $nokps)
|
|
||||||
->whereBetween('g.t_gadai', [$startOfYear, $endOfYear])
|
|
||||||
->select(
|
|
||||||
'g.nokp',
|
|
||||||
'g.norujukan',
|
|
||||||
'g.t_gadai',
|
|
||||||
't.t_tebus',
|
|
||||||
'g.pinjaman',
|
|
||||||
'g.upah12',
|
|
||||||
'g.tempoh',
|
|
||||||
'l.t_lelong',
|
|
||||||
'g.sttebus'
|
|
||||||
)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$allTransaksi = $allTransaksi->concat($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$transGrouped = $allTransaksi->groupBy('nokp');
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 6️⃣ NORUJUKAN BAYARAN ONLINE
|
|
||||||
// ===============================
|
|
||||||
$onlineNorujukan = TransactionOnline::pluck('norujukan')->unique();
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 7️⃣ MAP DATA PELANGGAN
|
|
||||||
// ===============================
|
|
||||||
$result = $pelanggan->map(function ($row) use (
|
|
||||||
$transGrouped,
|
|
||||||
$onlineNorujukan,
|
|
||||||
$pekerjaanAll,
|
|
||||||
$poskodAll,
|
|
||||||
$year
|
|
||||||
) {
|
|
||||||
|
|
||||||
$nokp = $row->kpbaru ?? $row->kplama;
|
|
||||||
|
|
||||||
$tempohData = $transGrouped->get($nokp, collect());
|
|
||||||
|
|
||||||
$norujukanPelanggan = $tempohData->pluck('norujukan')->unique();
|
|
||||||
|
|
||||||
// Cara Bayaran
|
|
||||||
$adaOnline = $norujukanPelanggan
|
|
||||||
->intersect($onlineNorujukan)
|
|
||||||
->isNotEmpty();
|
|
||||||
|
|
||||||
$caraBayaran = $adaOnline ? 'Online' : 'Kaunter';
|
|
||||||
|
|
||||||
// Bilangan
|
|
||||||
$bilTransaksi = $tempohData->count();
|
|
||||||
|
|
||||||
$bilOutstanding = $tempohData->filter(function ($row) use ($year) {
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
|
|
||||||
if (empty($row->sttebus)) return true;
|
|
||||||
|
|
||||||
return Carbon::parse($row->t_tebus)->gt($endOfYear);
|
|
||||||
})->count();
|
|
||||||
|
|
||||||
$bilTebus = $tempohData->whereNotNull('t_tebus')->count();
|
|
||||||
|
|
||||||
// Jumlah
|
|
||||||
$jumlahPinjaman = $tempohData->sum('pinjaman');
|
|
||||||
|
|
||||||
$jumlahUjrah = $tempohData->reduce(function ($carry, $trx) {
|
|
||||||
if (!$trx->upah12 || !$trx->tempoh) return $carry;
|
|
||||||
return $carry + ($trx->upah12 / 12 * $trx->tempoh);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Tarikh
|
|
||||||
$tarikhMula = $tempohData->min('t_gadai');
|
|
||||||
$tarikhTamat = $tempohData->max('t_tebus');
|
|
||||||
$tarikhLelong = $tempohData->max('t_lelong');
|
|
||||||
|
|
||||||
// Tempoh Pajakan
|
|
||||||
if (!$tarikhMula) {
|
|
||||||
$tempohPajakan = '-';
|
|
||||||
} elseif (!$tarikhTamat || $tarikhMula == $tarikhTamat) {
|
|
||||||
$tempohPajakan = Carbon::parse($tarikhMula)->translatedFormat('M Y');
|
|
||||||
} else {
|
|
||||||
$tempohPajakan =
|
|
||||||
Carbon::parse($tarikhMula)->translatedFormat('M Y') .
|
|
||||||
' - ' .
|
|
||||||
Carbon::parse($tarikhTamat)->translatedFormat('M Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hari sejak transaksi terakhir
|
|
||||||
$hariTempohPajakan = $tarikhMula
|
|
||||||
? Carbon::parse($tarikhMula)->diffInDays($tarikhTamat ? Carbon::parse($tarikhTamat) : Carbon::now())
|
|
||||||
: null;
|
|
||||||
|
|
||||||
// Tujuan gadai
|
|
||||||
$tujuangadai = $row->tujuangadai ?: '-';
|
|
||||||
|
|
||||||
// Status aktif: ada transaksi dalam tahun tu
|
|
||||||
$now = Carbon::now();
|
|
||||||
|
|
||||||
// Status Aktif
|
|
||||||
$startOfYear = Carbon::create($year, 1, 1)->startOfDay();
|
|
||||||
$endOfYear = Carbon::create($year, 12, 31)->endOfDay();
|
|
||||||
|
|
||||||
$statusAktif = $tempohData->contains(function ($trx) use ($startOfYear, $endOfYear) {
|
|
||||||
if (!$trx->t_gadai) return false;
|
|
||||||
|
|
||||||
$tGadai = Carbon::parse($trx->t_gadai);
|
|
||||||
$tTebus = $trx->t_tebus ? Carbon::parse($trx->t_tebus) : null;
|
|
||||||
|
|
||||||
return $tGadai->lte($endOfYear) &&
|
|
||||||
(is_null($tTebus) || $tTebus->gte($startOfYear));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Umur
|
|
||||||
$umur = $row->t_lahir ? Carbon::parse($row->t_lahir)->age : null;
|
|
||||||
|
|
||||||
// Pekerjaan
|
|
||||||
$pekerjaan = $row->kodkerja
|
|
||||||
? ($pekerjaanAll[ltrim($row->kodkerja, '0')] ?? 'Lain-lain')
|
|
||||||
: '-';
|
|
||||||
|
|
||||||
// Daerah
|
|
||||||
$lokasi = $row->poskod && isset($poskodAll[$row->poskod])
|
|
||||||
? ($poskodAll[$row->poskod]->daerah->namadaerah ?? 'Lain-lain')
|
|
||||||
: 'Lain-lain';
|
|
||||||
|
|
||||||
|
|
||||||
return [
|
|
||||||
'cawangan' => $row->kodcaw,
|
|
||||||
'nama' => $row->nama,
|
|
||||||
'nopelanggan' => $row->nopelanggan,
|
|
||||||
'nokp' => $nokp,
|
|
||||||
'tarikhdaftar' => Carbon::parse($row->tarikhdaftar)->format('d-m-Y'),
|
|
||||||
'umur' => $umur,
|
|
||||||
'jantina' => $row->jantina,
|
|
||||||
'pekerjaan' => $pekerjaan,
|
|
||||||
'daerah' => $lokasi,
|
|
||||||
'tempoh_pajakan' => $tempohPajakan,
|
|
||||||
'tarikh_mula' => $tarikhMula ? Carbon::parse($tarikhMula)->format('d-m-Y') : null,
|
|
||||||
'tarikh_tamat' => $tarikhTamat ? Carbon::parse($tarikhTamat)->format('d-m-Y') : null,
|
|
||||||
'hari_sejak_transaksi' => $hariTempohPajakan,
|
|
||||||
'bil_transaksi' => $bilTransaksi,
|
|
||||||
'bil_outstanding' => $bilOutstanding,
|
|
||||||
'bil_tebus' => $bilTebus,
|
|
||||||
'jumlah_pinjaman' => $jumlahPinjaman,
|
|
||||||
'jumlah_ujrah' => $jumlahUjrah,
|
|
||||||
'tujuan_gadai' => $tujuangadai,
|
|
||||||
'cara_bayaran' => $caraBayaran,
|
|
||||||
'status_aktif' => $statusAktif ? 'AKTIF' : 'TIDAK AKTIF',
|
|
||||||
'tarikh_lelong' => $tarikhLelong
|
|
||||||
? Carbon::parse($tarikhLelong)->format('d-m-Y')
|
|
||||||
: null,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
$result = $result->sortBy('cawangan')->values();
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'year' => $year,
|
|
||||||
'cawangan' => $cawangan,
|
|
||||||
'summary' => [
|
|
||||||
'total_pelanggan' => $result->count(),
|
|
||||||
'jumlah_cawangan' => $result->pluck('cawangan')->unique()->count(),
|
|
||||||
],
|
|
||||||
'pelanggan' => $result,
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Reports;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Audit;
|
|
||||||
|
|
||||||
class AuditTrailController extends Controller
|
|
||||||
{
|
|
||||||
public function getAuditTrail(Request $request)
|
|
||||||
{
|
|
||||||
$limit = $request->get('limit', 100);
|
|
||||||
|
|
||||||
$audit_trails = Audit::query()
|
|
||||||
->when($request->filled('norujukan'), fn($q) => $q->where('norujukan', $request->norujukan))
|
|
||||||
->when($request->filled('actions'), fn($q) => $q->where('actions', $request->actions))
|
|
||||||
->orderBy('created_at', 'desc')
|
|
||||||
->limit($limit)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return response()->json($audit_trails);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function AuditTrailOperasi(Request $request)
|
|
||||||
{
|
|
||||||
$date_first = $request->get('date', null);
|
|
||||||
$date_till = $request->get('date_till', null);
|
|
||||||
|
|
||||||
$audit_trails = Audit::query()
|
|
||||||
->where('kodcaw', 'operasi')
|
|
||||||
->whereDate('created_at', '>=', $date_first)
|
|
||||||
->whereDate('created_at', '<=', $date_till)
|
|
||||||
->orderBy('created_at', 'asc')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$audit_trails->map(function ($audit) {
|
|
||||||
// Convert from UTC to Malaysia timezone (UTC+8)
|
|
||||||
$audit->created_at = $audit->created_at->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Get differences between old_data and new_data
|
|
||||||
$old_data = json_decode($audit->old_data, true) ?? [];
|
|
||||||
$new_data = json_decode($audit->new_data, true) ?? [];
|
|
||||||
|
|
||||||
$differences = [];
|
|
||||||
|
|
||||||
// Find changed fields
|
|
||||||
foreach ($new_data as $key => $new_value) {
|
|
||||||
if ($key === 'tarikhupdate') continue;
|
|
||||||
|
|
||||||
$old_value = $old_data[$key] ?? null;
|
|
||||||
if ($old_value !== $new_value) {
|
|
||||||
$differences[$key] = [
|
|
||||||
'old' => $old_value,
|
|
||||||
'new' => $new_value
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for removed fields
|
|
||||||
foreach ($old_data as $key => $old_value) {
|
|
||||||
if ($key === 'tarikhupdate') continue;
|
|
||||||
|
|
||||||
if (!array_key_exists($key, $new_data)) {
|
|
||||||
$differences[$key] = [
|
|
||||||
'old' => $old_value,
|
|
||||||
'new' => null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$audit->differences = $differences;
|
|
||||||
return $audit;
|
|
||||||
});
|
|
||||||
|
|
||||||
return response()->json($audit_trails);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -60,7 +60,6 @@ class LelonganController extends Controller
|
|||||||
sum(lelong.cajlain) as sum_cajlain,
|
sum(lelong.cajlain) as sum_cajlain,
|
||||||
sum(lelong.cajlelong) as sum_cajlelong,
|
sum(lelong.cajlelong) as sum_cajlelong,
|
||||||
sum(lelong.hargajual) as sum_hargajual,
|
sum(lelong.hargajual) as sum_hargajual,
|
||||||
sum(lelong.hargaasas) as sum_hargaasas,
|
|
||||||
sum(lelong.baki) as sum_baki'));
|
sum(lelong.baki) as sum_baki'));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,17 +46,10 @@ class OutstandingController extends Controller
|
|||||||
|
|
||||||
// Query outstanding summary for each branch
|
// Query outstanding summary for each branch
|
||||||
$summary_Outstanding_data = array_map(function ($db_connection) use ($endDate) {
|
$summary_Outstanding_data = array_map(function ($db_connection) use ($endDate) {
|
||||||
// SAG KES
|
|
||||||
$queryKes = Gadai::on($db_connection)
|
|
||||||
->selectRaw('COUNT(norujukan) as total_gadaian_kes, SUM(pinjaman) as sum_pinjaman_kes')
|
|
||||||
->where('tagbaru', 0)
|
|
||||||
->where('tagpalsu', 1)
|
|
||||||
->where('sttebus', '');
|
|
||||||
// SAG LAMA
|
// SAG LAMA
|
||||||
$queryLama = Gadai::on($db_connection)
|
$queryLama = Gadai::on($db_connection)
|
||||||
->selectRaw('COUNT(norujukan) as total_gadaian, SUM(pinjaman) as sum_pinjaman')
|
->selectRaw('COUNT(norujukan) as total_gadaian, SUM(pinjaman) as sum_pinjaman')
|
||||||
->where('tagbaru', 0)
|
->where('tagbaru', 0)
|
||||||
->where('tagpalsu', 0)
|
|
||||||
->where('sttebus', '');
|
->where('sttebus', '');
|
||||||
|
|
||||||
// SAG BARU
|
// SAG BARU
|
||||||
@@ -71,14 +64,12 @@ class OutstandingController extends Controller
|
|||||||
->where('sttebus', '');
|
->where('sttebus', '');
|
||||||
|
|
||||||
if (!empty($endDate)) {
|
if (!empty($endDate)) {
|
||||||
$queryKes->where('t_gadai', '<=', $endDate);
|
|
||||||
$queryLama->where('t_gadai', '<=', $endDate);
|
$queryLama->where('t_gadai', '<=', $endDate);
|
||||||
$queryBaru->where('t_gadai', '<=', $endDate);
|
$queryBaru->where('t_gadai', '<=', $endDate);
|
||||||
$queryAll->where('t_gadai', '<=', $endDate);
|
$queryAll->where('t_gadai', '<=', $endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
$queryKes->first()->toArray(),
|
|
||||||
$queryLama->first()->toArray(),
|
$queryLama->first()->toArray(),
|
||||||
$queryBaru->first()->toArray(),
|
$queryBaru->first()->toArray(),
|
||||||
$queryAll->first()->toArray()
|
$queryAll->first()->toArray()
|
||||||
@@ -127,12 +118,10 @@ class OutstandingController extends Controller
|
|||||||
if (!empty($endDate)) {
|
if (!empty($endDate)) {
|
||||||
$queryAll->where('tarikh', '=', $endDate);
|
$queryAll->where('tarikh', '=', $endDate);
|
||||||
}
|
}
|
||||||
$record = $queryAll->first();
|
|
||||||
|
|
||||||
return $record
|
|
||||||
? $record->toArray()
|
|
||||||
: ['bakieod' => 0];
|
|
||||||
|
|
||||||
|
return array_merge(
|
||||||
|
$queryAll->first()->toArray()
|
||||||
|
);
|
||||||
}, $active_cawangan_db_connection);
|
}, $active_cawangan_db_connection);
|
||||||
|
|
||||||
// Combine data with branch info
|
// Combine data with branch info
|
||||||
|
|||||||
@@ -1,129 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Reports;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Cawangan;
|
|
||||||
use App\Gadai;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
|
||||||
use App\Helper;
|
|
||||||
use App\Tebus;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
|
|
||||||
class SaringanGadaianController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getLaporanGadai(Request $request)
|
|
||||||
{
|
|
||||||
$startDate = $request->startDate ?? now()->startOfMonth()->toDateString();
|
|
||||||
$endDate = $request->endDate ?? now()->endOfMonth()->toDateString();
|
|
||||||
|
|
||||||
$active_dbs = Helper::getActiveCawanganDbConnection();
|
|
||||||
|
|
||||||
$cawangan = Cawangan::select('kodcaw', 'details_caw', 'mysql')
|
|
||||||
->whereIn('mysql', $active_dbs)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$responses = [];
|
|
||||||
|
|
||||||
foreach ($cawangan as $caw) {
|
|
||||||
|
|
||||||
$db = $caw->mysql;
|
|
||||||
|
|
||||||
$tgb = Tebus::on($db)
|
|
||||||
->join('gadai as g1', 'tebus.norujukan', '=', 'g1.norujukan')
|
|
||||||
->join('gadai as g2', function ($join) {
|
|
||||||
$join->on('g2.nokp', '=', 'g1.nokp')
|
|
||||||
->on('g2.t_gadai', '=', 'tebus.t_tebus')
|
|
||||||
->whereRaw('ABS(g2.berat - g1.berat) <= 0.02')
|
|
||||||
->whereColumn('g2.norujukan', '!=', 'g1.norujukan');
|
|
||||||
})
|
|
||||||
->whereBetween('tebus.t_tebus', [$startDate, $endDate])
|
|
||||||
->groupBy('tebus.norujukan')
|
|
||||||
->selectRaw("
|
|
||||||
tebus.norujukan as norujukan_tebus,
|
|
||||||
MAX(g2.norujukan) as norujukan_gadai_balik,
|
|
||||||
MAX(g2.nokp) as nokp,
|
|
||||||
MAX(g2.berat) as berat,
|
|
||||||
MAX(g2.nilaimarhun) as nilaimarhun,
|
|
||||||
MAX(g2.pinjaman) as pinjaman,
|
|
||||||
MAX(g2.t_gadai) as t_gadai,
|
|
||||||
MAX(g1.taglel) as taglel_lama
|
|
||||||
")
|
|
||||||
->get()
|
|
||||||
->map(function ($row) {
|
|
||||||
return [
|
|
||||||
'norujukan_tebus' => $row->norujukan_tebus,
|
|
||||||
'norujukan_gadai_balik' => $row->norujukan_gadai_balik,
|
|
||||||
'nokp' => $row->nokp,
|
|
||||||
'berat' => (float) $row->berat,
|
|
||||||
'nilaimarhun' => (float) $row->nilaimarhun,
|
|
||||||
'pinjaman' => (float) $row->pinjaman,
|
|
||||||
'taglel_lama' => $row->taglel_lama,
|
|
||||||
't_gadai' => $row->t_gadai,
|
|
||||||
'jenis' => $row->taglel_lama == 1 ? 'TGB_LELONG' : 'TGB_BIASA',
|
|
||||||
];
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$tgb_norujukan = array_column($tgb, 'norujukan_gadai_balik');
|
|
||||||
|
|
||||||
|
|
||||||
$gadai_biasa = DB::connection($db)
|
|
||||||
->table('gadai')
|
|
||||||
->whereBetween('t_gadai', [$startDate, $endDate])
|
|
||||||
->whereNotIn('norujukan', $tgb_norujukan)
|
|
||||||
->select([
|
|
||||||
DB::raw('NULL as norujukan_tebus'),
|
|
||||||
'norujukan as norujukan_gadai_balik',
|
|
||||||
'nokp',
|
|
||||||
'berat',
|
|
||||||
'nilaimarhun',
|
|
||||||
'pinjaman',
|
|
||||||
DB::raw('NULL as taglel_lama'),
|
|
||||||
't_gadai',
|
|
||||||
])
|
|
||||||
->get()
|
|
||||||
->map(function ($row) {
|
|
||||||
return [
|
|
||||||
'norujukan_tebus' => null,
|
|
||||||
'norujukan_gadai_balik' => $row->norujukan_gadai_balik,
|
|
||||||
'nokp' => $row->nokp,
|
|
||||||
'berat' => (float) $row->berat,
|
|
||||||
'nilaimarhun' => (float) $row->nilaimarhun,
|
|
||||||
'pinjaman' => (float) $row->pinjaman,
|
|
||||||
'taglel_lama' => null,
|
|
||||||
't_gadai' => $row->t_gadai,
|
|
||||||
'jenis' => 'GADAI_BIASA',
|
|
||||||
];
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
|
|
||||||
$details = collect($tgb)
|
|
||||||
->merge($gadai_biasa)
|
|
||||||
->unique('norujukan_gadai_balik')
|
|
||||||
->sortBy(['jenis', 't_gadai'])
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
|
|
||||||
$responses[] = [
|
|
||||||
'kodcaw' => $caw->kodcaw,
|
|
||||||
'details_caw' => $caw->details_caw,
|
|
||||||
'jumlah_surat' => count($details),
|
|
||||||
'total_tgb_lelong' => collect($details)->where('jenis', 'TGB_LELONG')->count(),
|
|
||||||
'total_tgb_biasa' => collect($details)->where('jenis', 'TGB_BIASA')->count(),
|
|
||||||
'total_gadai_biasa' => collect($details)->where('jenis', 'GADAI_BIASA')->count(),
|
|
||||||
'sum_berat' => collect($details)->sum('berat'),
|
|
||||||
'sum_nilai_marhun' => collect($details)->sum('nilaimarhun'),
|
|
||||||
'sum_pinjaman' => collect($details)->sum('pinjaman'),
|
|
||||||
'details' => $details,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($responses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Reports;
|
namespace App\Http\Controllers\Reports;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
use App\Gadai;
|
|
||||||
use App\Helper;
|
use App\Helper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class StokAuditController extends Controller
|
class StokAuditController extends Controller
|
||||||
{
|
{
|
||||||
@@ -40,40 +38,6 @@ class StokAuditController extends Controller
|
|||||||
|
|
||||||
public function getSummaryLaporanStokAudit(Request $request)
|
public function getSummaryLaporanStokAudit(Request $request)
|
||||||
{
|
{
|
||||||
$connections = $this->getActiveCawanganConnections();
|
|
||||||
|
|
||||||
// MODE 1: TARIKH SEMASA
|
|
||||||
if ($request->dateOption === 'current') {
|
|
||||||
|
|
||||||
$today = Carbon::today();
|
|
||||||
|
|
||||||
$total_audit = $connections->map(function ($connection) {
|
|
||||||
|
|
||||||
$data = Gadai::on($connection->mysql)
|
|
||||||
->where('tagpalsu', 0)
|
|
||||||
->where(function($q) {
|
|
||||||
$q->where('sttebus', '')
|
|
||||||
->orWhereNull('sttebus');
|
|
||||||
})
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'cawangan' => $connection->details_caw,
|
|
||||||
'bilangan_pembiayaan' => $data->count(),
|
|
||||||
'berat' => $data->sum('berat'),
|
|
||||||
'nilai_marhun' => $data->sum('nilaimarhun'),
|
|
||||||
'baki_pembiayaan' => $data->sum('bakipjm'),
|
|
||||||
'pembiayaan' => $data->sum('pinjaman'),
|
|
||||||
'upah_belum_bayar' => $data->sum('upahblmbyar'),
|
|
||||||
'total_utg_onepercent' => 0,
|
|
||||||
'total_ujrah' => $data->sum('ujrah'),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
// MODE 2: BULAN TERTENTU
|
|
||||||
else {
|
|
||||||
|
|
||||||
$month = $request->month;
|
$month = $request->month;
|
||||||
$year = $request->year;
|
$year = $request->year;
|
||||||
|
|
||||||
@@ -95,24 +59,34 @@ class StokAuditController extends Controller
|
|||||||
'total_ujrah' => $data->sum('ujrah'),
|
'total_ujrah' => $data->sum('ujrah'),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// TOTAL SEMUA CAWANGAN
|
$getTotalAcrossCawangan = function($property) use($total_audit) {
|
||||||
$total_all = [
|
$total = array_reduce($total_audit->toArray(), function($carry, $subarray) use($property) {
|
||||||
|
return $carry + $subarray[$property];
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return $total;
|
||||||
|
};
|
||||||
|
|
||||||
|
$total_all_cawangan_audit = [
|
||||||
'cawangan' => 'Total Semua Cawangan',
|
'cawangan' => 'Total Semua Cawangan',
|
||||||
'bilangan_pembiayaan' => $total_audit->sum('bilangan_pembiayaan'),
|
'bilangan_pembiayaan' => $getTotalAcrossCawangan('bilangan_pembiayaan'),
|
||||||
'berat' => $total_audit->sum('berat'),
|
'berat' => $getTotalAcrossCawangan('berat'),
|
||||||
'nilai_marhun' => $total_audit->sum('nilai_marhun'),
|
'nilai_marhun' => $getTotalAcrossCawangan('nilai_marhun'),
|
||||||
'baki_pembiayaan' => $total_audit->sum('baki_pembiayaan'),
|
'baki_pembiayaan' => $getTotalAcrossCawangan('baki_pembiayaan'),
|
||||||
'pembiayaan' => $total_audit->sum('pembiayaan'),
|
'pembiayaan' => $getTotalAcrossCawangan('pembiayaan'),
|
||||||
'upah_belum_bayar' => $total_audit->sum('upah_belum_bayar'),
|
'upah_belum_bayar' => $getTotalAcrossCawangan('upah_belum_bayar'),
|
||||||
'total_utg_onepercent' => $total_audit->sum('total_utg_onepercent'),
|
'total_utg_onepercent' => $getTotalAcrossCawangan('total_utg_onepercent'),
|
||||||
'total_ujrah' => $total_audit->sum('total_ujrah'),
|
'total_ujrah' => $getTotalAcrossCawangan('total_ujrah'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$total_audit->push($total_all);
|
$total_audit->push($total_all_cawangan_audit);
|
||||||
|
|
||||||
|
if (sizeof($total_audit) == 0) {
|
||||||
|
return response()->json('failed', 200);
|
||||||
|
} else {
|
||||||
return response()->json($total_audit, 200);
|
return response()->json($total_audit, 200);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -475,9 +475,6 @@ class StokAuditController extends Controller
|
|||||||
|
|
||||||
// Filter audit
|
// Filter audit
|
||||||
$rekodaudit = $audit->filter(function ($item) use ($tarikhTerkiniT, $tarikhTerkiniA) {
|
$rekodaudit = $audit->filter(function ($item) use ($tarikhTerkiniT, $tarikhTerkiniA) {
|
||||||
if ($item->lelong_tawarruq == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$norujukan = $item->norujukan;
|
$norujukan = $item->norujukan;
|
||||||
|
|
||||||
$adaTebusTerkini = isset($tarikhTerkiniT[$norujukan]) &&
|
$adaTebusTerkini = isset($tarikhTerkiniT[$norujukan]) &&
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class TebusController extends Controller
|
|||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$tebus_data = Tebus::on($cawangan['mysql'])
|
$tebus_data = Tebus::on($cawangan['mysql'])
|
||||||
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru')
|
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru','tebus.diskaun_rebate')
|
||||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||||
// ->join('online_arrahn.customer as cust', function($join)
|
// ->join('online_arrahn.customer as cust', function($join)
|
||||||
// {
|
// {
|
||||||
@@ -232,7 +232,8 @@ class TebusController extends Controller
|
|||||||
"nokp"=>$tebusData['nokp'],
|
"nokp"=>$tebusData['nokp'],
|
||||||
"jbg"=>$tebusData['jbg'],
|
"jbg"=>$tebusData['jbg'],
|
||||||
"ujrah"=>$trans['ujrah_rebet'],
|
"ujrah"=>$trans['ujrah_rebet'],
|
||||||
"onepercent"=>$trans['onepercent_rebet']
|
"onepercent"=>$trans['onepercent_rebet'],
|
||||||
|
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -274,7 +275,8 @@ class TebusController extends Controller
|
|||||||
'tebus.jbg',
|
'tebus.jbg',
|
||||||
'tebus.ujrah',
|
'tebus.ujrah',
|
||||||
'tebus.onepercent',
|
'tebus.onepercent',
|
||||||
'gad.tagbaru'
|
'gad.tagbaru',
|
||||||
|
'tebus.diskaun_rebate'
|
||||||
)
|
)
|
||||||
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
|
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
|
||||||
->where('tebus.t_tebus', '>=', $request->mula)
|
->where('tebus.t_tebus', '>=', $request->mula)
|
||||||
@@ -310,7 +312,8 @@ class TebusController extends Controller
|
|||||||
"jbg"=>$tebusData['jbg'],
|
"jbg"=>$tebusData['jbg'],
|
||||||
"ujrah"=>$trans['ujrah_rebet'],
|
"ujrah"=>$trans['ujrah_rebet'],
|
||||||
"onepercent"=>$trans['onepercent_rebet'],
|
"onepercent"=>$trans['onepercent_rebet'],
|
||||||
"tagbaru"=>$tebusData['tagbaru']
|
"tagbaru"=>$tebusData['tagbaru'],
|
||||||
|
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -1672,6 +1675,37 @@ class TebusController extends Controller
|
|||||||
return response($rebet);
|
return response($rebet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RebetPromoCalculation($kodcaw,Request $request)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
|
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2','tebus.norujukan','=','db2.norujukan')
|
||||||
|
// ->where('tebus.t_tebus','>','2021-04-13')
|
||||||
|
->where('tebus.t_tebus','<=',$request->tarikh)
|
||||||
|
->where('db2.hargajualan','>','0') // tambahan 2021-05-07
|
||||||
|
->whereNotNull('db2.hargajualan')
|
||||||
|
->sum('diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function PelarasanRebate($kodcaw,Request $request)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
|
|
||||||
|
// Jumlah diskaun_rebate dari 13/5/2025 hingga tarikh semasa
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||||
|
->whereBetween('tebus.t_tebus', ['2025-05-13', $request->tarikh])
|
||||||
|
->where('db2.hargajualan', '>', 0)
|
||||||
|
->where('db2.t_gadai', '>', '2023-05-21')
|
||||||
|
->whereNotNull('db2.hargajualan')
|
||||||
|
->sum('diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
public function RebetCalculationLejer($kodcaw,Request $request)
|
public function RebetCalculationLejer($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
@@ -1687,6 +1721,21 @@ class TebusController extends Controller
|
|||||||
return response($rebet);
|
return response($rebet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RebetPromoCalculationLejer($kodcaw,Request $request)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
|
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2','tebus.norujukan','=','db2.norujukan')
|
||||||
|
->where('tebus.t_tebus','>=',$request->mula)
|
||||||
|
->where('tebus.t_tebus','<=',$request->hingga)
|
||||||
|
->where('db2.hargajualan','>','0')
|
||||||
|
->whereNotNull('db2.hargajualan')
|
||||||
|
->sum('diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
public function getUpahLamaToday($kodcaw,$norujukan)
|
public function getUpahLamaToday($kodcaw,$norujukan)
|
||||||
{
|
{
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Cawangan;
|
|||||||
use App\Gadai;
|
use App\Gadai;
|
||||||
use App\GlDetail;
|
use App\GlDetail;
|
||||||
use App\Http\Controllers\TebusController as TebusController;
|
use App\Http\Controllers\TebusController as TebusController;
|
||||||
use App\Lelong;
|
|
||||||
use App\Services\Loggers\OnlineTransactionLoggerService;
|
use App\Services\Loggers\OnlineTransactionLoggerService;
|
||||||
use App\Services\OnePercentServices;
|
use App\Services\OnePercentServices;
|
||||||
use App\Support\v2\Calculation;
|
use App\Support\v2\Calculation;
|
||||||
@@ -769,51 +768,7 @@ class TransactionOnlineController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CustomerInfoLelong(Request $request){
|
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
|
||||||
$totalBakiLelong = 0;
|
|
||||||
$totalRugiLelong = 0;
|
|
||||||
|
|
||||||
foreach ($cawangan_all as $index => $cawangan) {
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])
|
|
||||||
->where('nokp', '=', $request->ic)
|
|
||||||
->where('sttebus','=','L')
|
|
||||||
->orderBy('t_gadai', 'desc')
|
|
||||||
->get()->toArray();
|
|
||||||
|
|
||||||
if (sizeof($gadai) != 0) {
|
|
||||||
foreach ($gadai as $gad) {
|
|
||||||
$bakilelong = Lelong::on($cawangan['mysql'])
|
|
||||||
->where(function($query) {
|
|
||||||
$query->whereNull('trkhtuntut')
|
|
||||||
->orWhere('trkhtuntut', '=', '');
|
|
||||||
})
|
|
||||||
->where('norujukan', '=' ,$gad['norujukan'])
|
|
||||||
->where('baki', '>=', 0)
|
|
||||||
->sum('baki');
|
|
||||||
|
|
||||||
$rugilelong = Lelong::on($cawangan['mysql'])
|
|
||||||
->where(function($query) {
|
|
||||||
$query->whereNull('trkhtuntut')
|
|
||||||
->orWhere('trkhtuntut', '=', '');
|
|
||||||
})
|
|
||||||
->where('norujukan', '=' ,$gad['norujukan'])
|
|
||||||
->where('baki','<',0)
|
|
||||||
->sum('baki');
|
|
||||||
|
|
||||||
$totalBakiLelong += $bakilelong;
|
|
||||||
$totalRugiLelong += $rugilelong;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
'message' => 'Data retrieved successfully',
|
|
||||||
'data' => [
|
|
||||||
'bakilelong' => $totalBakiLelong,
|
|
||||||
'rugilelong' => $totalRugiLelong,
|
|
||||||
]
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,21 +165,6 @@ class TunaiController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTunaiByTarikh(Request $request)
|
|
||||||
{
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
||||||
|
|
||||||
$tunai = Tunai::on($cawangan['mysql'])
|
|
||||||
->where([['kodcaw','=',$request->kodcaw],
|
|
||||||
['tarikh','=',$request->tarikh],
|
|
||||||
['kodlaluan','=',$request->kodlaluan]
|
|
||||||
])
|
|
||||||
->orderBy('tarikh','desc')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
return response()->json($tunai);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTunaiPast($kodcaw,Request $request)
|
public function getTunaiPast($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\GlDetail;
|
|||||||
use App\imbangdugalama;
|
use App\imbangdugalama;
|
||||||
use App\GlCode;
|
use App\GlCode;
|
||||||
use App\Panjar;
|
use App\Panjar;
|
||||||
|
use App\Tebus;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -400,19 +401,18 @@ class VaultController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$bakiakhirVault = $vault ? $vault['bakiakhir'] : 0;
|
|
||||||
|
|
||||||
if($total != 0)
|
if($total != 0)
|
||||||
{
|
{
|
||||||
$totalbakiakhirtunai = $bakiakhirVault + $total;
|
$totalbakiakhirtunai = $vault['bakiakhir'] + $total;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$totalbakiakhirtunai = $bakiakhirVault;
|
$totalbakiakhirtunai = $vault['bakiakhir'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($totalbakiakhirtunai);
|
return response()->json($totalbakiakhirtunai);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function TunaiDiTanganLejer($kodcaw,Request $request)
|
public function TunaiDiTanganLejer($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -456,26 +456,18 @@ class VaultController extends Controller
|
|||||||
|
|
||||||
return response()->json($arraytunaiditangan,200);
|
return response()->json($arraytunaiditangan,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function laporanPetiBesi($kodcaw,$tarikh)
|
public function laporanPetiBesi($kodcaw,$tarikh)
|
||||||
{
|
{
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return response()->json(['error' => 'Cawangan tidak dijumpai'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$vault=Vault::on($cawangan['mysql'])
|
$vault=Vault::on($cawangan['mysql'])
|
||||||
->where('kodcaw','=',$kodcaw)
|
->where('kodcaw','=',$kodcaw)
|
||||||
->where('tarikh','=', $tarikh)
|
->where('tarikh','=', $tarikh)
|
||||||
->orderby('tarikh','desc')
|
->orderby('tarikh','desc')->first();
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$vault) {
|
|
||||||
return response()->json(['error' => 'Tiada data pada tarikh tersebut'], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($vault);
|
return response()->json($vault);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,8 @@ namespace App\Http\Controllers;
|
|||||||
use App\WTDDraft;
|
use App\WTDDraft;
|
||||||
use App\TuntutBaki;
|
use App\TuntutBaki;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
use App\Customer;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Helper;
|
|
||||||
use App\SerahBaki;
|
|
||||||
use App\WTD;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
@@ -38,154 +34,4 @@ class WTDController extends Controller
|
|||||||
|
|
||||||
return response()->json($tuntutbaki);
|
return response()->json($tuntutbaki);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSummaryWtd(Request $request){
|
|
||||||
|
|
||||||
$startDate = $request->startDate ?? now()->startOfMonth()->toDateString();
|
|
||||||
$endDate = $request->endDate ?? now()->endOfMonth()->toDateString();
|
|
||||||
|
|
||||||
$active_dbs = Helper::getActiveCawanganDbConnection();
|
|
||||||
|
|
||||||
$cawangan = Cawangan::select('kodcaw', 'details_caw', 'mysql')
|
|
||||||
->whereIn('mysql', $active_dbs)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$responses = [];
|
|
||||||
|
|
||||||
foreach ($cawangan as $caw) {
|
|
||||||
|
|
||||||
$db = $caw->mysql;
|
|
||||||
|
|
||||||
$tuntutbaki = TuntutBaki::on($db)
|
|
||||||
->join('serahbaki', 'serahbaki.t_jual', '=', 'tuntutbaki.tarikh')
|
|
||||||
->join('gadai', 'gadai.norujukan', '=', 'tuntutbaki.norujukan')
|
|
||||||
->whereBetween('tuntutbaki.tarikh', [$startDate, $endDate])
|
|
||||||
->where('tuntutbaki.teller', 'DM')
|
|
||||||
->where('serahbaki.aktif', 1)
|
|
||||||
->selectRaw("
|
|
||||||
gadai.nokp as nokp,
|
|
||||||
tuntutbaki.norujukan as norujukan,
|
|
||||||
tuntutbaki.jumlah as jumlah,
|
|
||||||
serahbaki.batchno as batchno,
|
|
||||||
serahbaki.t_jual as t_jual,
|
|
||||||
serahbaki.t_htr_ag as t_htr_ag
|
|
||||||
")
|
|
||||||
->orderByRaw('CAST(serahbaki.batchno AS UNSIGNED)')
|
|
||||||
->orderBy('tuntutbaki.norujukan')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$nokps = $tuntutbaki
|
|
||||||
->pluck('nokp')
|
|
||||||
->filter() // elak null
|
|
||||||
//->unique()
|
|
||||||
->values();
|
|
||||||
|
|
||||||
$customers = Customer::on('mysql7')
|
|
||||||
->whereIn('kplama', $nokps)
|
|
||||||
->orWhereIn('kpbaru', $nokps)
|
|
||||||
->get()
|
|
||||||
->keyBy(function ($item) {
|
|
||||||
return $item->kpbaru ?: $item->kplama;
|
|
||||||
});
|
|
||||||
|
|
||||||
$wtd_det = [];
|
|
||||||
|
|
||||||
foreach ($tuntutbaki as $tuntut) {
|
|
||||||
|
|
||||||
$nokp = $tuntut->nokp;
|
|
||||||
$cust = $customers->get($nokp);
|
|
||||||
|
|
||||||
$wtd_det[] = [
|
|
||||||
"norujukan" => $tuntut->norujukan,
|
|
||||||
"nokp" => $nokp,
|
|
||||||
"jumlah" => (float) $tuntut->jumlah,
|
|
||||||
"batchno" => $tuntut->batchno,
|
|
||||||
"t_proses" => $tuntut->t_jual,
|
|
||||||
"t_htr_ag" => $tuntut->t_htr_ag,
|
|
||||||
"nama_cust" => $cust->nama ?? null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$details = collect($wtd_det)
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
$responses[] = [
|
|
||||||
'kodcaw' => $caw->kodcaw,
|
|
||||||
'details_caw' => $caw->details_caw,
|
|
||||||
// WEB
|
|
||||||
'jumlah_surat' => count($details),
|
|
||||||
'sum_baki' => collect($details)->sum('jumlah'),
|
|
||||||
// EXCEL
|
|
||||||
'details' => $details,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return response()->json($responses);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDebugWtd(Request $request){
|
|
||||||
|
|
||||||
$startDate = $request->startDate ?? now()->startOfMonth()->toDateString();
|
|
||||||
$endDate = $request->endDate ?? now()->endOfMonth()->toDateString();
|
|
||||||
|
|
||||||
$active_dbs = Helper::getActiveCawanganDbConnection();
|
|
||||||
|
|
||||||
$cawangan = Cawangan::select('kodcaw', 'details_caw', 'mysql')
|
|
||||||
->whereIn('mysql', $active_dbs)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$responses = [];
|
|
||||||
|
|
||||||
foreach ($cawangan as $caw) {
|
|
||||||
|
|
||||||
$db = $caw->mysql;
|
|
||||||
|
|
||||||
$serahbaki = SerahBaki::on($db)
|
|
||||||
->whereBetween('t_jual', [$startDate, $endDate])
|
|
||||||
->where('aktif', 1)
|
|
||||||
//->selectRaw("baki as serahb")
|
|
||||||
->sum('baki');;
|
|
||||||
//->get();
|
|
||||||
|
|
||||||
$tuntutbaki = TuntutBaki::on($db)
|
|
||||||
->whereBetween('tarikh', [$startDate, $endDate])
|
|
||||||
->where('teller', 'DM')
|
|
||||||
//->selectRaw("jumlah as tuntutb")
|
|
||||||
->sum('jumlah');
|
|
||||||
//->get();
|
|
||||||
|
|
||||||
$twtd = WTD::on($db)
|
|
||||||
->whereBetween('tarikh', [$startDate, $endDate])
|
|
||||||
//->selectRaw("wtd as twtd")
|
|
||||||
->sum('wtd');
|
|
||||||
//->get();
|
|
||||||
|
|
||||||
$wtd_det = [];
|
|
||||||
|
|
||||||
$wtd_det[] = [
|
|
||||||
"serahb" => $serahbaki,
|
|
||||||
"tuntutb" => $tuntutbaki,
|
|
||||||
"twtd" => $twtd,
|
|
||||||
];
|
|
||||||
|
|
||||||
$details = collect($wtd_det)
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
//dd($details);
|
|
||||||
|
|
||||||
$responses[] = [
|
|
||||||
'kodcaw' => $caw->kodcaw,
|
|
||||||
'details_caw' => $caw->details_caw,
|
|
||||||
//collect($details)->sum('jumlah'),
|
|
||||||
// WEB
|
|
||||||
'serahb' => collect($details)->sum('serahb'),
|
|
||||||
'tuntutb' => collect($details)->sum('tuntutb'),
|
|
||||||
'twtd' => collect($details)->sum('twtd'),
|
|
||||||
//'debugwtd' => $details,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return response()->json($responses);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,26 +4,17 @@ namespace App;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Pampasan extends Model
|
class KadarRebet extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'pampasan';
|
protected $table = 'kadar_rebet';
|
||||||
public $timestamps = true;
|
public $timestamps = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
|
||||||
'norujukan',
|
|
||||||
'baucerno',
|
|
||||||
'kodcaw',
|
|
||||||
'jumlah_pampasan',
|
|
||||||
'denominasi',
|
|
||||||
'teller',
|
|
||||||
'nota',
|
|
||||||
'agreement_printed_at',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,4 +23,9 @@ class Pampasan extends Model
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
// protected $hidden = [];
|
// protected $hidden = [];
|
||||||
|
|
||||||
|
function transaction()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class MaxMutuEmas extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'max_mutuemas';
|
|
||||||
protected $primaryKey = 'recno';
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'recno', 'karat', 'keterangan', 'teller', 'pc', 'operasi', 'tarikhupdate'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that should be cast to native types.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $casts = [
|
|
||||||
'teller' => 'decimal:2',
|
|
||||||
'pc' => 'decimal:2',
|
|
||||||
'operasi' => 'decimal:2',
|
|
||||||
'tarikhupdate' => 'datetime',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes excluded from the model's JSON form.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
// protected $hidden = [];
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ModalOnline extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'modal_online';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'tarikh',
|
|
||||||
'kodcaw',
|
|
||||||
'had',
|
|
||||||
'digunakan',
|
|
||||||
'baki',
|
|
||||||
'tambah',
|
|
||||||
'kurang',
|
|
||||||
'ditutup',
|
|
||||||
'ditutup_oleh',
|
|
||||||
'ditutup_at',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ namespace App;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
||||||
use App\Audit;
|
use App\Audit;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
@@ -22,7 +21,6 @@ class Palsu extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'recno',
|
'recno',
|
||||||
'kodcaw',
|
'kodcaw',
|
||||||
'tarikh',
|
|
||||||
'norujukan',
|
'norujukan',
|
||||||
'teller',
|
'teller',
|
||||||
'nota',
|
'nota',
|
||||||
@@ -32,7 +30,6 @@ class Palsu extends Model
|
|||||||
'untungonepercent',
|
'untungonepercent',
|
||||||
'untungcajlain',
|
'untungcajlain',
|
||||||
'pembiayaan',
|
'pembiayaan',
|
||||||
'status',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// public static function boot()
|
// public static function boot()
|
||||||
@@ -90,14 +87,4 @@ class Palsu extends Model
|
|||||||
// {
|
// {
|
||||||
// return $this->belongsTo(Daerah::class, 'koddaerah', 'koddaerah');
|
// return $this->belongsTo(Daerah::class, 'koddaerah', 'koddaerah');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function tebus(): HasOne
|
|
||||||
{
|
|
||||||
return $this->hasOne(Tebus::class, 'norujukan', 'norujukan');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function gadai(): HasOne
|
|
||||||
{
|
|
||||||
return $this->hasOne(Gadai::class, 'norujukan', 'norujukan');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class PembiayaanOnline extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'pembiayaan_online';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'norujukan',
|
|
||||||
'nokp',
|
|
||||||
'nopelanggan',
|
|
||||||
'nama_pelanggan',
|
|
||||||
'kodcaw',
|
|
||||||
'pinjaman',
|
|
||||||
'kodbank',
|
|
||||||
'nama_bank',
|
|
||||||
'noakaun',
|
|
||||||
'nama_akaun',
|
|
||||||
'bukti_akaun_file_id',
|
|
||||||
'borang_file_id',
|
|
||||||
'status',
|
|
||||||
'reject_reason',
|
|
||||||
'rejected_by',
|
|
||||||
'rejected_at',
|
|
||||||
'batch_id',
|
|
||||||
'bukti_file_id',
|
|
||||||
'no_rujukan_bayaran',
|
|
||||||
'tarikh_bayaran',
|
|
||||||
'paid_at',
|
|
||||||
'created_by',
|
|
||||||
'pc_submitted_by',
|
|
||||||
'ops_by',
|
|
||||||
'nota',
|
|
||||||
'blast_sent',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class RequestModalOnline extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'request_modal_online';
|
|
||||||
protected $connection = 'mysql7';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'kodcaw',
|
|
||||||
'tarikh',
|
|
||||||
'amaun',
|
|
||||||
'dimohon_oleh',
|
|
||||||
'status',
|
|
||||||
'diluluskan_oleh',
|
|
||||||
'nota',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Miscellaneous;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Cawangan;
|
|
||||||
use App\Gadai;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
|
||||||
use App\Helper;
|
|
||||||
use App\Tebus;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
|
|
||||||
|
|
||||||
class StatistikService
|
|
||||||
{
|
|
||||||
protected $kodcaw;
|
|
||||||
protected $mysql;
|
|
||||||
protected $mula;
|
|
||||||
protected $akhir;
|
|
||||||
|
|
||||||
public function __construct($kodcaw,$mula,$akhir)
|
|
||||||
{
|
|
||||||
$this->kodcaw = $kodcaw;
|
|
||||||
$this->mysql = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->value('mysql');
|
|
||||||
$this->mula = $mula;
|
|
||||||
$this->akhir = $akhir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function LaporanStatistik($gadai) : array
|
|
||||||
{
|
|
||||||
$reportPembiayaan = $this->countPawnByType($gadai);
|
|
||||||
$reportLoanAmount = $this->countPawnByLoan($gadai);
|
|
||||||
$reportMarhunValue = $this->countMarhunByValue($gadai);
|
|
||||||
$reportMarhunMargin = $this->countMarhunByMargin($gadai);
|
|
||||||
$reportCustomerJob = $this->countCustomerByJob($gadai);
|
|
||||||
$reportCustomerRace = $this->countCustomerByRace($gadai);
|
|
||||||
// dd($reportCustomerRace);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'reportPembiayaan' => $reportPembiayaan,
|
|
||||||
'reportLoanAmount' => $reportLoanAmount,
|
|
||||||
'reportMarhunValue' => $reportMarhunValue,
|
|
||||||
'reportMarhunMargin' => $reportMarhunMargin,
|
|
||||||
'reportCustomerJob' => $reportCustomerJob,
|
|
||||||
'reportCustomerRace' => $reportCustomerRace,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countPawnByType($gadai)
|
|
||||||
{
|
|
||||||
$pembiayaanbaru = Tebus::on($this->mysql)
|
|
||||||
->join('gadai as g1', 'tebus.norujukan', '=', 'g1.norujukan')
|
|
||||||
->join('gadai as g2', function ($join) {
|
|
||||||
$join->on('g2.nokp', '=', 'g1.nokp')
|
|
||||||
->on('g2.t_gadai', '=', 'tebus.t_tebus')
|
|
||||||
->whereRaw('ABS(g2.berat - g1.berat) <= 0.02')
|
|
||||||
->whereColumn('g2.norujukan', '!=', 'g1.norujukan');
|
|
||||||
})
|
|
||||||
->whereBetween('tebus.t_tebus', [$this->mula, $this->akhir])
|
|
||||||
->groupBy('tebus.norujukan')
|
|
||||||
->selectRaw("
|
|
||||||
tebus.norujukan as norujukan_tebus,
|
|
||||||
MAX(g2.norujukan) as norujukanpembiayaansemula,
|
|
||||||
MAX(g1.taglel) as taglel_lama
|
|
||||||
")
|
|
||||||
->get()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$pembiayaanbaruNorujukan = array_column($pembiayaanbaru, 'norujukanpembiayaansemula');
|
|
||||||
$filteredNorujukanLelongan = array_column(
|
|
||||||
array_filter($pembiayaanbaru, function ($item) {
|
|
||||||
return $item['taglel_lama'] == 1;
|
|
||||||
}),
|
|
||||||
'norujukanpembiayaansemula'
|
|
||||||
);
|
|
||||||
$filteredPSNorujukan = array_column(
|
|
||||||
array_filter($pembiayaanbaru, function ($item) {
|
|
||||||
return $item['taglel_lama'] == 0;
|
|
||||||
}),
|
|
||||||
'norujukanpembiayaansemula'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$pembiayaanbaru = $gadai->whereIn('norujukan', $filteredPSNorujukan)->count();
|
|
||||||
$pembiayaansemula = $gadai->whereNotIn('norujukan', $pembiayaanbaruNorujukan)->count();
|
|
||||||
$lelongan = $gadai->whereIn('norujukan', $filteredNorujukanLelongan)->count();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'pembiayaanbaru' => $pembiayaanbaru,
|
|
||||||
'pembiayaansemula' => $pembiayaansemula,
|
|
||||||
'lelongan' => $lelongan
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countPawnByLoan($gadai)
|
|
||||||
{
|
|
||||||
return collect($gadai)->countBy(function ($item) {
|
|
||||||
$loan = $item['pinjaman'];
|
|
||||||
|
|
||||||
if ($loan <= 400.99) return '< 400.99';
|
|
||||||
if ($loan >= 401 && $loan <= 2000) return '401 - 2000';
|
|
||||||
if ($loan >= 2001 && $loan <= 24999) return '2001 - 2499';
|
|
||||||
if ($loan >= 2500) return '>= 2500';
|
|
||||||
if ($loan > 101000) return '>101000';
|
|
||||||
})->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countMarhunByValue($gadai)
|
|
||||||
{
|
|
||||||
return collect($gadai)->countBy(function ($item) {
|
|
||||||
$nilaimarhun = $item['nilaimarhun'];
|
|
||||||
|
|
||||||
if ($nilaimarhun <= 400.99) return '< 1-400';
|
|
||||||
if ($nilaimarhun >= 401 && $nilaimarhun <= 2000) return '401-2000';
|
|
||||||
if ($nilaimarhun > 2001) return '> 2001';
|
|
||||||
})->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countMarhunByMargin($gadai)
|
|
||||||
{
|
|
||||||
return collect($gadai)->countBy(function ($item) {
|
|
||||||
$margin= $item['percentpinj'];
|
|
||||||
|
|
||||||
if ($margin >= 10 && $margin <= 40.99) return '10-40.99';
|
|
||||||
if ($margin >= 41 && $margin <= 60.99) return '41-60.99';
|
|
||||||
if ($margin >= 61 && $margin <= 80) return '> 61-80';
|
|
||||||
})->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countCustomerByJob($gadai)
|
|
||||||
{
|
|
||||||
$jobMap = [
|
|
||||||
1 => 'Peniaga',
|
|
||||||
2 => 'Pekerja Swasta',
|
|
||||||
3 => 'Pekerja Kerajaan',
|
|
||||||
4 => 'Bekerja Sendiri',
|
|
||||||
5 => 'Suri Rumah',
|
|
||||||
6 => 'Lain-lain',
|
|
||||||
];
|
|
||||||
|
|
||||||
return collect($gadai)->countBy(function ($item) use ($jobMap) {
|
|
||||||
$kodkerja = floatval($item['kodkerja']);
|
|
||||||
return $jobMap[$kodkerja] ?? 'Lain-lain';
|
|
||||||
})->toArray();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countCustomerByRace($gadai){
|
|
||||||
|
|
||||||
$raceMap = [
|
|
||||||
'M' => 'Melayu',
|
|
||||||
'C' => 'Cina',
|
|
||||||
'I' => 'India',
|
|
||||||
'L' => 'Lain-lain',
|
|
||||||
];
|
|
||||||
|
|
||||||
return collect($gadai)->countBy(function ($item) use ($raceMap) {
|
|
||||||
return $raceMap[$item['bangsa']] ?? 'Lain-lain';
|
|
||||||
|
|
||||||
})->toArray();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,858 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\PembiayaanOnline;
|
|
||||||
|
|
||||||
use App\Cawangan;
|
|
||||||
use App\ModalOnline;
|
|
||||||
use App\RequestModalOnline;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ModalOnlineService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed,mysql?:string}
|
|
||||||
*/
|
|
||||||
public function resolveMysql($kodcaw)
|
|
||||||
{
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
|
||||||
|
|
||||||
if (!$cawangan) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => ['message' => 'Cawangan tidak dijumpai'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => null,
|
|
||||||
'mysql' => $cawangan['mysql'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function todayDate()
|
|
||||||
{
|
|
||||||
return Carbon::now()->toDateString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function findPending($kodcaw)
|
|
||||||
{
|
|
||||||
return RequestModalOnline::on('mysql7')
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('status', 'PENDING')
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function pendingPayload($pending)
|
|
||||||
{
|
|
||||||
return $pending ? $pending->toArray() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function missingSnapshot($kodcaw, $tarikh, $pending = null)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'tarikh' => $tarikh,
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'had' => 0.00,
|
|
||||||
'digunakan' => 0.00,
|
|
||||||
'baki' => 0.00,
|
|
||||||
'tambah' => 0.00,
|
|
||||||
'kurang' => 0.00,
|
|
||||||
'ditutup' => 0,
|
|
||||||
'missing' => true,
|
|
||||||
'pending_request' => $this->pendingPayload($pending),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function recalcBaki($modal)
|
|
||||||
{
|
|
||||||
$modal->baki = round(
|
|
||||||
(float) $modal->had + (float) $modal->tambah - (float) $modal->kurang - (float) $modal->digunakan,
|
|
||||||
2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get today's modal_online row. Does not create — PC must request had from Operasi.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function get($kodcaw)
|
|
||||||
{
|
|
||||||
$resolved = $this->resolveMysql($kodcaw);
|
|
||||||
if (!$resolved['ok']) {
|
|
||||||
return $resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mysql = $resolved['mysql'];
|
|
||||||
$tarikh = $this->todayDate();
|
|
||||||
$pending = $this->findPending($kodcaw);
|
|
||||||
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$modal) {
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => $this->missingSnapshot($kodcaw, $tarikh, $pending),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$payload = $modal->toArray();
|
|
||||||
$payload['missing'] = false;
|
|
||||||
$payload['pending_request'] = $this->pendingPayload($pending);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => $payload,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use get(). Kept so existing callers do not auto-seed RM100k.
|
|
||||||
*/
|
|
||||||
public function getOrCreate($kodcaw)
|
|
||||||
{
|
|
||||||
return $this->get($kodcaw);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reserve amount inside an existing branch DB connection (caller may wrap in transaction).
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function reserveAmountOnConnection($mysql, $kodcaw, $amaun, $tarikh = null)
|
|
||||||
{
|
|
||||||
$amaun = round((float) $amaun, 2);
|
|
||||||
if ($amaun <= 0) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'Amaun tidak sah'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tarikh = $tarikh ?: Carbon::now()->toDateString();
|
|
||||||
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$modal) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Modal online belum diwujudkan. Sila mohon had daripada Operasi terlebih dahulu.',
|
|
||||||
'missing' => true,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int) ($modal->ditutup ?? 0) === 1) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Modal online hari ini sudah ditutup (EOD)',
|
|
||||||
'modal_online' => $modal,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((float) $modal->baki < $amaun) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Baki modal online tidak mencukupi',
|
|
||||||
'baki' => (float) $modal->baki,
|
|
||||||
'amaun' => $amaun,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$modal->digunakan = round((float) $modal->digunakan + $amaun, 2);
|
|
||||||
$modal->baki = round(
|
|
||||||
(float) $modal->had + (float) $modal->tambah - (float) $modal->kurang - (float) $modal->digunakan,
|
|
||||||
2
|
|
||||||
);
|
|
||||||
$modal->save();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => $modal,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reserve amount from today's online float (transactional).
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function reserve($kodcaw, $amaun)
|
|
||||||
{
|
|
||||||
$resolved = $this->resolveMysql($kodcaw);
|
|
||||||
if (!$resolved['ok']) {
|
|
||||||
return $resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mysql = $resolved['mysql'];
|
|
||||||
$amaun = round((float) $amaun, 2);
|
|
||||||
|
|
||||||
if ($amaun <= 0) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'Amaun tidak sah'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $amaun) {
|
|
||||||
return $this->reserveAmountOnConnection($mysql, $kodcaw, $amaun);
|
|
||||||
});
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('ModalOnline reserve failed: ' . $e->getMessage());
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 500,
|
|
||||||
'payload' => ['message' => 'Gagal reserve modal online'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Had is no longer auto-seeded. Returns how many branches already have a row today.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function initiate($zone = 'all')
|
|
||||||
{
|
|
||||||
$current = $this->todayDate();
|
|
||||||
|
|
||||||
if ($zone == 'all') {
|
|
||||||
$cawanganAll = Cawangan::on('mysql7')->get();
|
|
||||||
} else {
|
|
||||||
$cawanganAll = Cawangan::on('mysql7')->where('zone', $zone)->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
$existing = 0;
|
|
||||||
$missing = 0;
|
|
||||||
|
|
||||||
foreach ($cawanganAll as $cawangan) {
|
|
||||||
try {
|
|
||||||
$exists = ModalOnline::on($cawangan['mysql'])
|
|
||||||
->where('kodcaw', $cawangan['kodcaw'])
|
|
||||||
->where('tarikh', $current)
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($exists) {
|
|
||||||
$existing++;
|
|
||||||
} else {
|
|
||||||
$missing++;
|
|
||||||
}
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::warning('initiate modal_online skip ' . $cawangan['kodcaw'] . ': ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'tarikh' => $current,
|
|
||||||
'created' => 0,
|
|
||||||
'existing' => $existing,
|
|
||||||
'missing' => $missing,
|
|
||||||
'message' => 'Modal online tidak di-initiate automatik. PC perlu mohon had daripada Operasi.',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PC request opening had (or extra top-up) from Operasi.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function requestTopUp($kodcaw, $amaun, $dimohonOleh, $nota = null)
|
|
||||||
{
|
|
||||||
$resolved = $this->resolveMysql($kodcaw);
|
|
||||||
if (!$resolved['ok']) {
|
|
||||||
return $resolved;
|
|
||||||
}
|
|
||||||
$mysql = $resolved['mysql'];
|
|
||||||
|
|
||||||
$amaun = round((float) $amaun, 2);
|
|
||||||
$dimohonOleh = trim((string) $dimohonOleh);
|
|
||||||
|
|
||||||
if ($amaun <= 0) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'Amaun tidak sah'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
if ($dimohonOleh === '') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'dimohon_oleh diperlukan'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tarikh = $this->todayDate();
|
|
||||||
$pending = $this->findPending($kodcaw);
|
|
||||||
|
|
||||||
if ($pending) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 409,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Masih ada permohonan modal online PENDING untuk cawangan ini',
|
|
||||||
'request' => $pending,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($modal && (int) ($modal->ditutup ?? 0) === 1) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Modal online hari ini sudah ditutup (EOD). Tidak boleh mohon.',
|
|
||||||
'modal_online' => $modal,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$jenis = $modal ? 'TOPUP' : 'HAD';
|
|
||||||
|
|
||||||
$request = RequestModalOnline::on('mysql7')->create([
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'tarikh' => $tarikh,
|
|
||||||
'amaun' => $amaun,
|
|
||||||
'dimohon_oleh' => $dimohonOleh,
|
|
||||||
'status' => 'PENDING',
|
|
||||||
'nota' => $nota,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 201,
|
|
||||||
'payload' => [
|
|
||||||
'request' => $request,
|
|
||||||
'jenis' => $jenis,
|
|
||||||
'modal_online' => $modal ?: $this->missingSnapshot($kodcaw, $tarikh, $request),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List top-up requests.
|
|
||||||
* For PC: pass kodcaw. For Operasi: omit kodcaw (all branches).
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function listTopUpRequests($kodcaw = null, $status = null, $tarikh = null)
|
|
||||||
{
|
|
||||||
$query = RequestModalOnline::on('mysql7')->newQuery();
|
|
||||||
|
|
||||||
if ($kodcaw) {
|
|
||||||
$query->where('kodcaw', $kodcaw);
|
|
||||||
}
|
|
||||||
if ($status) {
|
|
||||||
$query->where('status', $status);
|
|
||||||
}
|
|
||||||
if ($tarikh) {
|
|
||||||
$query->where('tarikh', $tarikh);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $query->orderBy('id', 'desc')->get();
|
|
||||||
|
|
||||||
$cawMap = [];
|
|
||||||
if (!$kodcaw) {
|
|
||||||
foreach (Cawangan::on('mysql7')->get() as $caw) {
|
|
||||||
$cawMap[$caw->kodcaw] = $caw->nama_cawangan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
$item = $row->toArray();
|
|
||||||
if (!$kodcaw) {
|
|
||||||
$item['cawangan_nama'] = $cawMap[$row->kodcaw] ?? null;
|
|
||||||
}
|
|
||||||
$data[] = $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'bilangan' => count($data),
|
|
||||||
'data' => $data,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Operasi approve: first request of the day sets had; later requests add tambah.
|
|
||||||
* Optional $amaunOverride lets operasi lulus a different amount than dimohon.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function approveTopUp($requestId, $diluluskanOleh, $nota = null, $expectedKodcaw = null, $amaunOverride = null)
|
|
||||||
{
|
|
||||||
$diluluskanOleh = trim((string) $diluluskanOleh);
|
|
||||||
if ($diluluskanOleh === '') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'diluluskan_oleh diperlukan'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$req = RequestModalOnline::on('mysql7')->where('id', $requestId)->first();
|
|
||||||
if (!$req) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => ['message' => 'Permohonan tidak dijumpai'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($expectedKodcaw && $req->kodcaw !== $expectedKodcaw) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => ['message' => 'Permohonan tidak dijumpai'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($req->status !== 'PENDING') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Hanya permohonan PENDING boleh diluluskan',
|
|
||||||
'status' => $req->status,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$kodcaw = $req->kodcaw;
|
|
||||||
$resolved = $this->resolveMysql($kodcaw);
|
|
||||||
if (!$resolved['ok']) {
|
|
||||||
return $resolved;
|
|
||||||
}
|
|
||||||
$mysql = $resolved['mysql'];
|
|
||||||
$amaunDimohon = round((float) $req->amaun, 2);
|
|
||||||
$amaun = $amaunDimohon;
|
|
||||||
if ($amaunOverride !== null && $amaunOverride !== '') {
|
|
||||||
$amaun = round((float) $amaunOverride, 2);
|
|
||||||
if ($amaun <= 0) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'Amaun diluluskan tidak sah'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tarikh = $this->todayDate();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$applied = DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $tarikh, $amaun) {
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$jenis = 'TOPUP';
|
|
||||||
|
|
||||||
if (!$modal) {
|
|
||||||
$modal = ModalOnline::on($mysql)->create([
|
|
||||||
'tarikh' => $tarikh,
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'had' => $amaun,
|
|
||||||
'digunakan' => 0.00,
|
|
||||||
'baki' => $amaun,
|
|
||||||
'tambah' => 0.00,
|
|
||||||
'kurang' => 0.00,
|
|
||||||
'ditutup' => 0,
|
|
||||||
]);
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('id', $modal->id)
|
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
|
||||||
$jenis = 'HAD';
|
|
||||||
} else {
|
|
||||||
if ((int) ($modal->ditutup ?? 0) === 1) {
|
|
||||||
throw new \RuntimeException('MODAL_ONLINE_CLOSED');
|
|
||||||
}
|
|
||||||
|
|
||||||
$modal->tambah = round((float) $modal->tambah + $amaun, 2);
|
|
||||||
$this->recalcBaki($modal);
|
|
||||||
$modal->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['modal' => $modal, 'jenis' => $jenis];
|
|
||||||
});
|
|
||||||
|
|
||||||
$modal = $applied['modal'];
|
|
||||||
$jenis = $applied['jenis'];
|
|
||||||
|
|
||||||
$req->status = 'APPROVED';
|
|
||||||
$req->diluluskan_oleh = $diluluskanOleh;
|
|
||||||
$req->amaun = $amaun;
|
|
||||||
|
|
||||||
$notes = [];
|
|
||||||
if (abs($amaun - $amaunDimohon) >= 0.01) {
|
|
||||||
$notes[] = 'Amaun dimohon RM ' . number_format($amaunDimohon, 2)
|
|
||||||
. ', diluluskan RM ' . number_format($amaun, 2);
|
|
||||||
}
|
|
||||||
if ($nota !== null && trim((string) $nota) !== '') {
|
|
||||||
$notes[] = trim((string) $nota);
|
|
||||||
}
|
|
||||||
if ($notes) {
|
|
||||||
$existing = trim((string) $req->nota);
|
|
||||||
$req->nota = $existing === ''
|
|
||||||
? implode(' | ', $notes)
|
|
||||||
: $existing . ' | ' . implode(' | ', $notes);
|
|
||||||
}
|
|
||||||
$req->save();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'request' => $req->fresh(),
|
|
||||||
'jenis' => $jenis,
|
|
||||||
'modal_online' => $modal,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
if ($e->getMessage() === 'MODAL_ONLINE_CLOSED') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'Modal online hari ini sudah ditutup (EOD). Tidak boleh lulus permohonan.'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
Log::error('approveTopUp failed: ' . $e->getMessage());
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 500,
|
|
||||||
'payload' => ['message' => 'Gagal lulus permohonan modal online'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Operasi reject top-up request.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function rejectTopUp($requestId, $diluluskanOleh, $nota = null, $expectedKodcaw = null)
|
|
||||||
{
|
|
||||||
$diluluskanOleh = trim((string) $diluluskanOleh);
|
|
||||||
if ($diluluskanOleh === '') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'diluluskan_oleh diperlukan'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$req = RequestModalOnline::on('mysql7')->where('id', $requestId)->first();
|
|
||||||
if (!$req) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => ['message' => 'Permohonan tidak dijumpai'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($expectedKodcaw && $req->kodcaw !== $expectedKodcaw) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => ['message' => 'Permohonan tidak dijumpai'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($req->status !== 'PENDING') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Hanya permohonan PENDING boleh ditolak',
|
|
||||||
'status' => $req->status,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$req->status = 'REJECTED';
|
|
||||||
$req->diluluskan_oleh = $diluluskanOleh;
|
|
||||||
if ($nota !== null && trim((string) $nota) !== '') {
|
|
||||||
$req->nota = trim(
|
|
||||||
trim((string) $req->nota) === ''
|
|
||||||
? (string) $nota
|
|
||||||
: $req->nota . ' | ' . $nota
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$req->save();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => ['request' => $req],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EOD close for one branch: return unused baki via kurang, mark ditutup.
|
|
||||||
* Also auto-rejects PENDING top-up requests for the branch.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function close($kodcaw, $ditutupOleh)
|
|
||||||
{
|
|
||||||
$resolved = $this->resolveMysql($kodcaw);
|
|
||||||
if (!$resolved['ok']) {
|
|
||||||
return $resolved;
|
|
||||||
}
|
|
||||||
$mysql = $resolved['mysql'];
|
|
||||||
|
|
||||||
$ditutupOleh = trim((string) $ditutupOleh);
|
|
||||||
if ($ditutupOleh === '') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'ditutup_oleh diperlukan'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tarikh = Carbon::now()->toDateString();
|
|
||||||
$now = Carbon::now();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$result = DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $tarikh, $ditutupOleh, $now) {
|
|
||||||
$modal = ModalOnline::on($mysql)
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$modal) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 404,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Tiada modal online hari ini untuk ditutup. Teller belum mohon / PC belum lulus had.',
|
|
||||||
'missing' => true,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int) ($modal->ditutup ?? 0) === 1) {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 409,
|
|
||||||
'payload' => [
|
|
||||||
'message' => 'Modal online sudah ditutup untuk hari ini',
|
|
||||||
'modal_online' => $modal,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$unused = round((float) $modal->baki, 2);
|
|
||||||
$modal->kurang = round((float) $modal->kurang + $unused, 2);
|
|
||||||
$modal->baki = round(
|
|
||||||
(float) $modal->had + (float) $modal->tambah - (float) $modal->kurang - (float) $modal->digunakan,
|
|
||||||
2
|
|
||||||
);
|
|
||||||
$modal->ditutup = 1;
|
|
||||||
$modal->ditutup_oleh = $ditutupOleh;
|
|
||||||
$modal->ditutup_at = $now;
|
|
||||||
$modal->save();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'modal_online' => $modal,
|
|
||||||
'dikembalikan' => $unused,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!$result['ok']) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pendingRejected = RequestModalOnline::on('mysql7')
|
|
||||||
->where('kodcaw', $kodcaw)
|
|
||||||
->where('status', 'PENDING')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
foreach ($pendingRejected as $req) {
|
|
||||||
$req->status = 'REJECTED';
|
|
||||||
$req->diluluskan_oleh = $ditutupOleh;
|
|
||||||
$tag = 'Auto reject: EOD close';
|
|
||||||
$req->nota = trim((string) $req->nota) === ''
|
|
||||||
? $tag
|
|
||||||
: trim($req->nota) . ' | ' . $tag;
|
|
||||||
$req->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['payload']['pending_topup_ditolak'] = $pendingRejected->count();
|
|
||||||
return $result;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('modal online close failed: ' . $e->getMessage());
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 500,
|
|
||||||
'payload' => ['message' => 'Gagal tutup modal online'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Operasi: list today's modal_online across branches.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function listToday($zone = 'all', $tarikh = null)
|
|
||||||
{
|
|
||||||
$tarikh = $tarikh ?: Carbon::now()->toDateString();
|
|
||||||
|
|
||||||
if ($zone == 'all') {
|
|
||||||
$cawanganAll = Cawangan::on('mysql7')->get();
|
|
||||||
} else {
|
|
||||||
$cawanganAll = Cawangan::on('mysql7')->where('zone', $zone)->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = [];
|
|
||||||
foreach ($cawanganAll as $cawangan) {
|
|
||||||
try {
|
|
||||||
$modal = ModalOnline::on($cawangan['mysql'])
|
|
||||||
->where('kodcaw', $cawangan['kodcaw'])
|
|
||||||
->where('tarikh', $tarikh)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$row = $modal ? $modal->toArray() : [
|
|
||||||
'tarikh' => $tarikh,
|
|
||||||
'kodcaw' => $cawangan['kodcaw'],
|
|
||||||
'had' => 0,
|
|
||||||
'digunakan' => 0,
|
|
||||||
'baki' => 0,
|
|
||||||
'tambah' => 0,
|
|
||||||
'kurang' => 0,
|
|
||||||
'ditutup' => 0,
|
|
||||||
'missing' => true,
|
|
||||||
];
|
|
||||||
$row['cawangan_nama'] = $cawangan->nama_cawangan;
|
|
||||||
$row['missing'] = empty($modal);
|
|
||||||
$rows[] = $row;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::warning('listToday modal_online skip ' . $cawangan['kodcaw'] . ': ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($rows, function ($a, $b) {
|
|
||||||
return strcmp((string) ($a['kodcaw'] ?? ''), (string) ($b['kodcaw'] ?? ''));
|
|
||||||
});
|
|
||||||
|
|
||||||
$open = 0;
|
|
||||||
$closed = 0;
|
|
||||||
$missing = 0;
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
if (!empty($row['missing'])) {
|
|
||||||
$missing++;
|
|
||||||
} elseif ((int) ($row['ditutup'] ?? 0) === 1) {
|
|
||||||
$closed++;
|
|
||||||
} else {
|
|
||||||
$open++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'tarikh' => $tarikh,
|
|
||||||
'bilangan' => count($rows),
|
|
||||||
'open' => $open,
|
|
||||||
'closed' => $closed,
|
|
||||||
'missing' => $missing,
|
|
||||||
'data' => $rows,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Operasi bulk EOD close for open branches today.
|
|
||||||
*
|
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
|
||||||
*/
|
|
||||||
public function closeAll($ditutupOleh, $zone = 'all')
|
|
||||||
{
|
|
||||||
$ditutupOleh = trim((string) $ditutupOleh);
|
|
||||||
if ($ditutupOleh === '') {
|
|
||||||
return [
|
|
||||||
'ok' => false,
|
|
||||||
'status' => 422,
|
|
||||||
'payload' => ['message' => 'ditutup_oleh diperlukan'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$list = $this->listToday($zone);
|
|
||||||
$closed = 0;
|
|
||||||
$skipped = 0;
|
|
||||||
$failed = [];
|
|
||||||
|
|
||||||
foreach ($list['payload']['data'] as $row) {
|
|
||||||
if (!empty($row['missing']) || (int) ($row['ditutup'] ?? 0) === 1) {
|
|
||||||
$skipped++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$res = $this->close($row['kodcaw'], $ditutupOleh);
|
|
||||||
if ($res['ok']) {
|
|
||||||
$closed++;
|
|
||||||
} else {
|
|
||||||
$failed[] = [
|
|
||||||
'kodcaw' => $row['kodcaw'],
|
|
||||||
'message' => $res['payload']['message'] ?? 'gagal',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'ok' => true,
|
|
||||||
'status' => 200,
|
|
||||||
'payload' => [
|
|
||||||
'closed' => $closed,
|
|
||||||
'skipped' => $skipped,
|
|
||||||
'failed' => $failed,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -377,8 +377,7 @@ class ImbangDugaService
|
|||||||
return $transaction->trans_type !== 'A';
|
return $transaction->trans_type !== 'A';
|
||||||
})->sum('keuntungan_rebet');
|
})->sum('keuntungan_rebet');
|
||||||
|
|
||||||
$backdate_keun_sebenar = isset($get_imbangduga['keun_sebenar']) ? $get_imbangduga['keun_sebenar'] : 0;
|
$total = $total_ansuran + $total_tebus + $get_imbangduga['keun_sebenar'];
|
||||||
$total = $total_ansuran + $total_tebus + $backdate_keun_sebenar;
|
|
||||||
|
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class LelonganService
|
|||||||
$marhun_lelongan = $this->getMarhunLelongan($total_lelongan, $cawangan_connection);
|
$marhun_lelongan = $this->getMarhunLelongan($total_lelongan, $cawangan_connection);
|
||||||
$cawangan_detail = $this->getCawanganDetail($cawangan_connection);
|
$cawangan_detail = $this->getCawanganDetail($cawangan_connection);
|
||||||
|
|
||||||
$total_lelongan = $total_lelongan->zip($customer_info, $marhun_lelongan)->map(function ($data) use ($total_lelongan) {
|
$total_lelongan = $total_lelongan->zip($customer_info, $marhun_lelongan)->map(function ($data) {
|
||||||
|
|
||||||
[$lelong, $customer_info, $marhun_lelongan] = $data;
|
[$lelong, $customer_info, $marhun_lelongan] = $data;
|
||||||
|
|
||||||
@@ -76,38 +76,31 @@ class LelonganService
|
|||||||
'bakipjm' => $lelong['bakipjm'],
|
'bakipjm' => $lelong['bakipjm'],
|
||||||
'keuntungan' => $lelong['bakiupah'],
|
'keuntungan' => $lelong['bakiupah'],
|
||||||
'cajlelong' => $lelong['cajlelong'],
|
'cajlelong' => $lelong['cajlelong'],
|
||||||
'hargaasas' => $lelong['hargaasas'],
|
|
||||||
'hargajual' => $lelong['hargajual'],
|
'hargajual' => $lelong['hargajual'],
|
||||||
'baki' => $lelong['baki'],
|
'baki' => $lelong['baki'],
|
||||||
'teller' => $lelong['teller'],
|
'teller' => $lelong['teller'],
|
||||||
];
|
];
|
||||||
|
dd($data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$total_lelongan = $total_lelongan->groupBy('teller');
|
$total_lelongan = $total_lelongan->groupBy('teller');
|
||||||
|
|
||||||
$result = [];
|
$lelongan_tellers = $total_lelongan->keys();
|
||||||
|
|
||||||
foreach ($total_lelongan as $teller => $lelongan) {
|
$total_lelongan = $total_lelongan
|
||||||
$result[$teller] = [
|
->zip($total_summary_lelongan_teller)
|
||||||
'lelongan' => $lelongan->values(),
|
->map(function ($data) {
|
||||||
'summary_lelongan_teller' => $total_summary_lelongan_teller[$teller] ?? [
|
|
||||||
'total_lelongan' => 0,
|
[$lelongan, $summary] = $data;
|
||||||
'total_berat' => 0,
|
|
||||||
'total_nilai_marhun' => 0,
|
return [
|
||||||
'total_pembiayaan' => 0,
|
'lelongan' => $lelongan,
|
||||||
'total_bakipjm' => 0,
|
'summary_lelongan_teller' => $summary,
|
||||||
'total_keuntungan' => 0,
|
|
||||||
'total_cajlelong' => 0,
|
|
||||||
'total_hargaasas' => 0,
|
|
||||||
'total_hargajual' => 0,
|
|
||||||
'total_baki' => 0,
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
});
|
||||||
|
|
||||||
$total_lelongan = collect($result);
|
|
||||||
|
|
||||||
|
$total_lelongan = $lelongan_tellers->combine($total_lelongan);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'query' => [
|
'query' => [
|
||||||
@@ -150,7 +143,6 @@ class LelonganService
|
|||||||
sum(gadai.bakipjm) as total_bakipjm,
|
sum(gadai.bakipjm) as total_bakipjm,
|
||||||
sum(lelong.bakiupah) as total_keuntungan,
|
sum(lelong.bakiupah) as total_keuntungan,
|
||||||
sum(lelong.cajlelong) as total_cajlelong,
|
sum(lelong.cajlelong) as total_cajlelong,
|
||||||
sum(lelong.hargaasas) as total_hargaasas,
|
|
||||||
sum(lelong.hargajual) as total_hargajual,
|
sum(lelong.hargajual) as total_hargajual,
|
||||||
sum(lelong.baki) as total_baki')
|
sum(lelong.baki) as total_baki')
|
||||||
->get()
|
->get()
|
||||||
@@ -163,54 +155,32 @@ class LelonganService
|
|||||||
'total_bakipjm' => $x['total_bakipjm'],
|
'total_bakipjm' => $x['total_bakipjm'],
|
||||||
'total_keuntungan' => $x['total_keuntungan'],
|
'total_keuntungan' => $x['total_keuntungan'],
|
||||||
'total_cajlelong' => $x['total_cajlelong'],
|
'total_cajlelong' => $x['total_cajlelong'],
|
||||||
'total_hargaasas' => $x['total_hargaasas'],
|
|
||||||
'total_hargajual' => $x['total_hargajual'],
|
'total_hargajual' => $x['total_hargajual'],
|
||||||
'total_baki' => $x['total_baki']
|
'total_baki' => $x['total_baki']
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
// dd($total_summary_lelongan);
|
||||||
|
|
||||||
return $total_summary_lelongan[0];
|
return $total_summary_lelongan[0];
|
||||||
}
|
}
|
||||||
// private function getTotalSummaryLelonganGroupByTeller(Builder $query_total_lelongan)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// $total_summary_lelongan_groupByTeller = (clone $query_total_lelongan)
|
|
||||||
// ->selectRaw('count(lelong.norujukan) as total_lelongan,
|
|
||||||
// sum(lelong.berat) as total_berat,
|
|
||||||
// sum(lelong.nilaimarhun) as total_nilai_marhun,
|
|
||||||
// sum(lelong.pinjaman) as total_pembiayaan,
|
|
||||||
// sum(gadai.bakipjm) as total_bakipjm,
|
|
||||||
// sum(lelong.bakiupah) as total_keuntungan,
|
|
||||||
// sum(lelong.cajlelong) as total_cajlelong,
|
|
||||||
// sum(lelong.hargaasas) as total_hargaasas,
|
|
||||||
// sum(lelong.hargajual) as total_hargajual,
|
|
||||||
// sum(lelong.baki) as total_baki')
|
|
||||||
// ->groupBy('lelong.teller')
|
|
||||||
// ->get();
|
|
||||||
// return $total_summary_lelongan_groupByTeller;
|
|
||||||
// }
|
|
||||||
private function getTotalSummaryLelonganGroupByTeller(Builder $query_total_lelongan)
|
private function getTotalSummaryLelonganGroupByTeller(Builder $query_total_lelongan)
|
||||||
{
|
{
|
||||||
return (clone $query_total_lelongan)
|
|
||||||
->selectRaw('
|
$total_summary_lelongan_groupByTeller = (clone $query_total_lelongan)
|
||||||
lelong.teller,
|
->selectRaw('count(lelong.norujukan) as total_lelongan,
|
||||||
count(lelong.norujukan) as total_lelongan,
|
|
||||||
sum(lelong.berat) as total_berat,
|
sum(lelong.berat) as total_berat,
|
||||||
sum(lelong.nilaimarhun) as total_nilai_marhun,
|
sum(lelong.nilaimarhun) as total_nilai_marhun,
|
||||||
sum(lelong.pinjaman) as total_pembiayaan,
|
sum(lelong.pinjaman) as total_pembiayaan,
|
||||||
sum(gadai.bakipjm) as total_bakipjm,
|
sum(gadai.bakipjm) as total_bakipjm,
|
||||||
sum(lelong.bakiupah) as total_keuntungan,
|
sum(lelong.bakiupah) as total_keuntungan,
|
||||||
sum(lelong.cajlelong) as total_cajlelong,
|
sum(lelong.cajlelong) as total_cajlelong,
|
||||||
sum(lelong.hargaasas) as total_hargaasas,
|
|
||||||
sum(lelong.hargajual) as total_hargajual,
|
sum(lelong.hargajual) as total_hargajual,
|
||||||
sum(lelong.baki) as total_baki
|
sum(lelong.baki) as total_baki')
|
||||||
')
|
|
||||||
->groupBy('lelong.teller')
|
->groupBy('lelong.teller')
|
||||||
->get()
|
->get();
|
||||||
->keyBy('teller'); // ⭐ PENTING
|
return $total_summary_lelongan_groupByTeller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getTotalLelongan(Builder $query_total_lelongan)
|
private function getTotalLelongan(Builder $query_total_lelongan)
|
||||||
{
|
{
|
||||||
$total_lelongan = (clone $query_total_lelongan)
|
$total_lelongan = (clone $query_total_lelongan)
|
||||||
@@ -229,7 +199,6 @@ class LelonganService
|
|||||||
'gadai.bakipjm',
|
'gadai.bakipjm',
|
||||||
'lelong.bakiupah',
|
'lelong.bakiupah',
|
||||||
'lelong.cajlelong',
|
'lelong.cajlelong',
|
||||||
'lelong.hargaasas',
|
|
||||||
'lelong.hargajual',
|
'lelong.hargajual',
|
||||||
'lelong.baki')
|
'lelong.baki')
|
||||||
->orderBy('lelong.teller')
|
->orderBy('lelong.teller')
|
||||||
@@ -342,7 +311,6 @@ class LelonganService
|
|||||||
'bakipjm' => $lelong['bakipjm'],
|
'bakipjm' => $lelong['bakipjm'],
|
||||||
'keuntungan' => $lelong['bakiupah'],
|
'keuntungan' => $lelong['bakiupah'],
|
||||||
'cajlelong' => $lelong['cajlelong'],
|
'cajlelong' => $lelong['cajlelong'],
|
||||||
'hargaasas' => $lelong['hargaasas'],
|
|
||||||
'hargajual' => $lelong['hargajual'],
|
'hargajual' => $lelong['hargajual'],
|
||||||
'baki' => $lelong['baki'],
|
'baki' => $lelong['baki'],
|
||||||
'teller' => $lelong['teller'],
|
'teller' => $lelong['teller'],
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ class OnePercentService
|
|||||||
$t_gadai = Carbon::parse($gadai->t_gadai);
|
$t_gadai = Carbon::parse($gadai->t_gadai);
|
||||||
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
||||||
|
|
||||||
if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) {
|
if (($t_gadai->month == $t_bayaran->month) && ($t_gadai->year == $t_bayaran->year)) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1322,7 +1322,7 @@ class RingkasanHarianService
|
|||||||
return floatval($totalSerahan);
|
return floatval($totalSerahan);
|
||||||
}
|
}
|
||||||
|
|
||||||
return floatval($serahanpkbTawarruq);
|
return floatval(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Support;
|
namespace App\Support;
|
||||||
|
|
||||||
use App\Cawangan;
|
|
||||||
use App\KadarUpah;
|
use App\KadarUpah;
|
||||||
use App\Pampasan;
|
|
||||||
use App\Support\v1\GadaiV1 as Version1Gadai;
|
use App\Support\v1\GadaiV1 as Version1Gadai;
|
||||||
|
|
||||||
use App\Services\MasterServices;
|
use App\Services\MasterServices;
|
||||||
use App\Support\v1\Penebusan;
|
use App\Support\v1\Penebusan;
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request as HttpRequest;
|
use Illuminate\Http\Request as HttpRequest;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ use App\KomuditiPurchase;
|
|||||||
use App\KomuditiTransaksi;
|
use App\KomuditiTransaksi;
|
||||||
use App\Marhun;
|
use App\Marhun;
|
||||||
use App\Moratorium;
|
use App\Moratorium;
|
||||||
use App\Palsu;
|
|
||||||
use App\Pampasan;
|
|
||||||
use App\Support\OnePercent;
|
use App\Support\OnePercent;
|
||||||
use App\Support\Tawarruq;
|
use App\Support\Tawarruq;
|
||||||
use App\Support\v1\Calculation as V1Calculation;
|
use App\Support\v1\Calculation as V1Calculation;
|
||||||
@@ -481,17 +479,6 @@ class Penebusan
|
|||||||
$upah_rebet_sebenar = $harga_tebus - $gadai['bakipjm'];
|
$upah_rebet_sebenar = $harga_tebus - $gadai['bakipjm'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$isPampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $request->norujukan)->exists();
|
|
||||||
|
|
||||||
if($isPampasan){
|
|
||||||
$barang_kes = Palsu::on($cawangan['mysql'])->where('norujukan', $norujukan)->first();
|
|
||||||
|
|
||||||
$harga_tebus = $barang_kes->untung + $barang_kes->pembiayaan;
|
|
||||||
$upah_tebus = $barang_kes->untung;
|
|
||||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
|
||||||
$upah_rebet_sebenar = $barang_kes->untung;
|
|
||||||
$rebet = $gadai['hargajualan'] - $harga_tebus;
|
|
||||||
}
|
|
||||||
|
|
||||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
||||||
'kodcaw'=> $kodcaw,
|
'kodcaw'=> $kodcaw,
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
namespace App\Support\v2;
|
namespace App\Support\v2;
|
||||||
|
|
||||||
use App\KadarUpah;
|
use App\KadarUpah;
|
||||||
|
use App\KadarRebet;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class Calculation
|
class Calculation
|
||||||
{
|
{
|
||||||
@@ -41,6 +43,16 @@ class Calculation
|
|||||||
return $onepercent;
|
return $onepercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function kiraanRebetAnnur (float $pembiayaan = 0.0){
|
||||||
|
|
||||||
|
$kadarrebet = KadarRebet::on('mysql7')
|
||||||
|
->where('pembiayaan_min', '<=', $pembiayaan)
|
||||||
|
->where('pembiayaan_max', '>=', $pembiayaan)
|
||||||
|
->sum('kadarrebet');
|
||||||
|
|
||||||
|
return $kadarrebet;
|
||||||
|
}
|
||||||
|
|
||||||
public function kiraanUjrahSebenar(float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
public function kiraanUjrahSebenar(float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||||
|
|
||||||
if($kadarujrah >= 1){
|
if($kadarujrah >= 1){
|
||||||
@@ -61,13 +73,17 @@ class Calculation
|
|||||||
|
|
||||||
$onepercent = $this->kiraanOnePercent($pembiayaan);
|
$onepercent = $this->kiraanOnePercent($pembiayaan);
|
||||||
$ujrah_sebenar = $this->kiraanUjrahSebenar($nilaimarhun,$kadarujrah,$margin);
|
$ujrah_sebenar = $this->kiraanUjrahSebenar($nilaimarhun,$kadarujrah,$margin);
|
||||||
|
$discount = $this->kiraanRebetAnnur($pembiayaan);
|
||||||
|
Log::debug('discount:' . $discount);
|
||||||
|
|
||||||
$onepercent = (!empty($onepercent)) ? $this->getRoundedMethod($onepercent) : 0;
|
$onepercent = (!empty($onepercent)) ? $this->getRoundedMethod($onepercent) : 0;
|
||||||
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
||||||
|
|
||||||
$keuntungan = $onepercent + $ujrah_sebenar;
|
$keuntungan = $onepercent + $ujrah_sebenar;
|
||||||
|
|
||||||
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar];
|
$kadar_diskaun = $this->getRoundedMethod($keuntungan * ($discount/100));
|
||||||
|
Log::debug('kadar_discount:' .$kadar_diskaun);
|
||||||
|
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar,'diskaun' => $kadar_diskaun];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||||
|
|||||||
+26
-17
@@ -58,9 +58,12 @@ class GadaiV2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getKadarUpahAnggota($nokp,$total_nilai_marhun = 0,$groupid = 2) : Float{
|
private function getKadarUpahAnggota($nokp, $total_nilai_marhun = 0, $groupid = 2): ?float
|
||||||
//Log::info('DEBUG NOKP:' . $nokp);
|
{
|
||||||
if($nokp){
|
if (!$nokp) {
|
||||||
|
return null; // tiada nokp = tak boleh tentukan kadar
|
||||||
|
}
|
||||||
|
|
||||||
$customer = Customer::on('mysql7')
|
$customer = Customer::on('mysql7')
|
||||||
->select('tag_anggota')
|
->select('tag_anggota')
|
||||||
->where(function ($q) use ($nokp) {
|
->where(function ($q) use ($nokp) {
|
||||||
@@ -68,19 +71,19 @@ class GadaiV2
|
|||||||
->orWhere('kplama', $nokp);
|
->orWhere('kplama', $nokp);
|
||||||
})
|
})
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$customer = $customer ? $customer->toArray() : [];
|
$customer = $customer ? $customer->toArray() : [];
|
||||||
if(isset($customer) && $customer['tag_anggota'] == 1){
|
|
||||||
return 0.16;
|
if (isset($customer['tag_anggota']) && $customer['tag_anggota'] == 1) {
|
||||||
}else{
|
return 0.00; // ahli — kadar 0.00 memang sah
|
||||||
return KadarUpah::where('min', '<=', $total_nilai_marhun)
|
}
|
||||||
|
|
||||||
|
$kadar = KadarUpah::where('min', '<=', $total_nilai_marhun)
|
||||||
->where('max', '>=', $total_nilai_marhun)
|
->where('max', '>=', $total_nilai_marhun)
|
||||||
->where('group_id', $groupid)
|
->where('group_id', $groupid)
|
||||||
->value('kadarujrah');
|
->value('kadarujrah');
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
|
return is_null($kadar) ? null : (float) $kadar; // tak jumpa row = null (block)
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createMarhun($norujukan,HttpRequest $request){
|
public function createMarhun($norujukan,HttpRequest $request){
|
||||||
@@ -110,17 +113,16 @@ class GadaiV2
|
|||||||
|
|
||||||
$kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']);
|
$kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']);
|
||||||
|
|
||||||
if (empty($kadar_raw) || $kadar_raw == 0) {
|
if (is_null($kadar_raw)) {
|
||||||
|
Log::error('[BLOCKED] Kadar upah tidak dijumpai', [
|
||||||
Log::error('[BLOCKED] Kadar upah kosong / 0', [
|
|
||||||
'nokp' => $request->nokp,
|
'nokp' => $request->nokp,
|
||||||
'total_nilai_marhun' => $total_nilai_marhun,
|
'total_nilai_marhun' => $total_nilai_marhun,
|
||||||
'group_id' => $cawangan['group_id'],
|
'group_id' => $cawangan['group_id'],
|
||||||
]);
|
]);
|
||||||
|
throw new \Exception("Kadar upah tidak dijumpai, transaksi dibatalkan!");
|
||||||
throw new \Exception("Kadar upah kosong / 0, transaksi dibatalkan!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $kadar_raw = 0.00 (ahli) akan lepas ke sini dan diteruskan
|
||||||
|
|
||||||
// query kadar upah lama
|
// query kadar upah lama
|
||||||
// $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first();
|
// $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first();
|
||||||
@@ -136,6 +138,9 @@ class GadaiV2
|
|||||||
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
||||||
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
||||||
|
|
||||||
|
$kadar_rebet = $request->input('kadar_rebate');
|
||||||
|
$diskaun = $request->input('rebate');
|
||||||
|
|
||||||
$hargajualan = $request->pinjaman + $upah12;
|
$hargajualan = $request->pinjaman + $upah12;
|
||||||
|
|
||||||
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
|
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
|
||||||
@@ -174,6 +179,8 @@ class GadaiV2
|
|||||||
'tagbaru' => 1,
|
'tagbaru' => 1,
|
||||||
'tunggakanujrah' => $akrual['ujrah'],
|
'tunggakanujrah' => $akrual['ujrah'],
|
||||||
'tunggakanonepercent' => $akrual['keuntungan'],
|
'tunggakanonepercent' => $akrual['keuntungan'],
|
||||||
|
'kadarrebet' => $kadar_rebet,
|
||||||
|
'diskaun' => $diskaun
|
||||||
));
|
));
|
||||||
|
|
||||||
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
@@ -245,6 +252,7 @@ class GadaiV2
|
|||||||
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
||||||
$upahrebet_raw = $onepercent + $ujrah;
|
$upahrebet_raw = $onepercent + $ujrah;
|
||||||
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
||||||
|
$upahrebet_raw = $upahrebet_raw - $upah['diskaun'];
|
||||||
|
|
||||||
return $upahrebet_raw;
|
return $upahrebet_raw;
|
||||||
}
|
}
|
||||||
@@ -282,7 +290,7 @@ class GadaiV2
|
|||||||
|
|
||||||
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
|
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
|
||||||
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
||||||
|
Log::debug($keuntungan);
|
||||||
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
||||||
$ujrahasal = $onepercent->getRoundedMethod($ujrahasal);
|
$ujrahasal = $onepercent->getRoundedMethod($ujrahasal);
|
||||||
$onepercentasal = $onepercent->getRoundedMethod($onepercentasal);
|
$onepercentasal = $onepercent->getRoundedMethod($onepercentasal);
|
||||||
@@ -331,6 +339,7 @@ class GadaiV2
|
|||||||
'tempoh' => $gadai['tempoh'],
|
'tempoh' => $gadai['tempoh'],
|
||||||
'beza_tempoh' => $bilang_bln,
|
'beza_tempoh' => $bilang_bln,
|
||||||
'margin_semasa' => $margin_semasa,
|
'margin_semasa' => $margin_semasa,
|
||||||
|
'kadardiskaun' => $keuntungan['diskaun']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ class Penebusan
|
|||||||
$this->cawangan_info = $cawangan_info;
|
$this->cawangan_info = $cawangan_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tebusTawarruq($kodcaw,$norujukan){
|
public function tebusTawarruq($kodcaw, $norujukan)
|
||||||
|
{
|
||||||
$onepercentservices = new Calculation();
|
$onepercentservices = new Calculation();
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')
|
$cawangan = Cawangan::on('mysql7')
|
||||||
@@ -53,20 +54,20 @@ class Penebusan
|
|||||||
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
||||||
|
|
||||||
$rebet = $this->rebetselepastawarruq($kodcaw, $norujukan, $jeniskeuntungan);
|
$rebet = $this->rebetselepastawarruq($kodcaw, $norujukan, $jeniskeuntungan);
|
||||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet;
|
|
||||||
|
|
||||||
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP);
|
// Ambil terus dari column 'diskaun'
|
||||||
// $hargatebus = bcdiv(round($harga_tebus,2),1,1);
|
$diskaun = $gadai_data['diskaun'] ?? 0;
|
||||||
// $hargatebus = number_format($hargatebus,2);
|
|
||||||
// if(strpos($hargatebus,',')){
|
|
||||||
// $hargatebus = str_replace(',','',$hargatebus);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
// Kira harga tebus selepas tolak rebet & diskaun
|
||||||
|
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet - $diskaun;
|
||||||
|
|
||||||
|
// Apply pembundaran
|
||||||
$hargatebus = $onepercentservices->getRoundedMethod($harga_tebus);
|
$hargatebus = $onepercentservices->getRoundedMethod($harga_tebus);
|
||||||
|
|
||||||
return response()->json($hargatebus);
|
return response()->json($hargatebus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function hargaTebusTawarruq($kodcaw,$norujukan){
|
public function hargaTebusTawarruq($kodcaw,$norujukan){
|
||||||
$onepercentservices = new Calculation();
|
$onepercentservices = new Calculation();
|
||||||
|
|
||||||
@@ -485,6 +486,9 @@ class Penebusan
|
|||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
|
|
||||||
|
// Ambil nilai diskaun
|
||||||
|
$diskaun = $gadai['diskaun'] ?? 0;
|
||||||
|
|
||||||
//check duplicate
|
//check duplicate
|
||||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
||||||
|
|
||||||
@@ -492,7 +496,7 @@ class Penebusan
|
|||||||
return response()->json('duplicate');
|
return response()->json('duplicate');
|
||||||
}
|
}
|
||||||
|
|
||||||
$ujrah=0;$onepercent=0;$rounded=0;
|
$ujrah=0;$onepercent=0;$rounded=0;$upah_rebet_sebenar=0;
|
||||||
if($gadai['hargajualan'] == null){
|
if($gadai['hargajualan'] == null){
|
||||||
$harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan);
|
$harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan);
|
||||||
$upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan);
|
$upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan);
|
||||||
@@ -502,7 +506,6 @@ class Penebusan
|
|||||||
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
||||||
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
||||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
|
||||||
|
|
||||||
if($request->jeniskeuntungan == 'onepercent'){
|
if($request->jeniskeuntungan == 'onepercent'){
|
||||||
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
||||||
@@ -514,8 +517,14 @@ class Penebusan
|
|||||||
$ujrah = $array_onepercent['ujrah'];
|
$ujrah = $array_onepercent['ujrah'];
|
||||||
$onepercent = $array_onepercent['onepercent'];
|
$onepercent = $array_onepercent['onepercent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIX: tolak diskaun DAHULU sebelum kira upah_rebet_sebenar
|
||||||
|
$harga_tebus['harga'] -= $diskaun;
|
||||||
|
|
||||||
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
||||||
'kodcaw'=> $kodcaw,
|
'kodcaw'=> $kodcaw,
|
||||||
@@ -543,6 +552,7 @@ class Penebusan
|
|||||||
'teller' => $request->teller,
|
'teller' => $request->teller,
|
||||||
'ujrah' => $ujrah_rebet,
|
'ujrah' => $ujrah_rebet,
|
||||||
'onepercent' => $onepercent_rebet,
|
'onepercent' => $onepercent_rebet,
|
||||||
|
'diskaun_rebate' => $diskaun, // Tambah kolum simpan diskaun
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||||
@@ -561,18 +571,28 @@ class Penebusan
|
|||||||
|
|
||||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran' => $current,
|
'tarikh_bayaran' => $current,
|
||||||
'kodcaw' => $kodcaw,
|
'kodcaw' => $kodcaw,
|
||||||
'ujrah' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['ujrah'] : 0,
|
'ujrah' => ($request->jeniskeuntungan == 'onepercent')
|
||||||
'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $ujrah_rebet : 0,
|
? $array_onepercent['ujrah']
|
||||||
'onepercent' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['onepercent'] : 0,
|
: 0,
|
||||||
'onepercent_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $onepercent_rebet : 0,
|
'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent')
|
||||||
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent') ? $margin_semasa : 0,
|
? $ujrah_rebet
|
||||||
|
: 0,
|
||||||
|
'onepercent' => ($request->jeniskeuntungan == 'onepercent')
|
||||||
|
? $array_onepercent['onepercent']
|
||||||
|
: 0,
|
||||||
|
'onepercent_rebet' => ($request->jeniskeuntungan == 'onepercent')
|
||||||
|
? $onepercent_rebet
|
||||||
|
: 0,
|
||||||
|
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent')
|
||||||
|
? $margin_semasa
|
||||||
|
: 0,
|
||||||
'tempoh' => $gadai['tempoh'],
|
'tempoh' => $gadai['tempoh'],
|
||||||
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
|
'beza_tempoh' => $gadai['tempoh'] - $gadai['tempohbayar'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($request->jenistebus == 'P'){
|
if($request->jenistebus == 'P'){
|
||||||
@@ -683,6 +703,8 @@ class Penebusan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
||||||
'sttebus' => "T",
|
'sttebus' => "T",
|
||||||
't_update' => $current->toDateString(),
|
't_update' => $current->toDateString(),
|
||||||
@@ -736,7 +758,7 @@ class Penebusan
|
|||||||
|
|
||||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran'=> $current,
|
'tarikh_bayaran'=> $current,
|
||||||
@@ -1133,10 +1155,12 @@ class Penebusan
|
|||||||
|
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
TransaksiKeuntungan::on('mysql7')->create([
|
TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran'=> $current,
|
'tarikh_bayaran'=> $current,
|
||||||
|
|||||||
+2
-1
@@ -52,7 +52,8 @@ class Tebus extends Model
|
|||||||
'pinjamanterkini',
|
'pinjamanterkini',
|
||||||
'tarikhbyrn',
|
'tarikhbyrn',
|
||||||
'ujrah',
|
'ujrah',
|
||||||
'onepercent'
|
'onepercent',
|
||||||
|
'diskaun_rebate'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TransaksiKeuntungan extends Model
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded'
|
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded','kadardiskaun'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class WTDSimulasi extends Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $connection = 'mysql7';
|
|
||||||
protected $table = 'wtd_simulasi';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'bulan',
|
|
||||||
'tahun',
|
|
||||||
'kodcaw',
|
|
||||||
'jumlah_sag',
|
|
||||||
'pembiayaan',
|
|
||||||
'baki',
|
|
||||||
'simulasi',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes excluded from the model's JSON form.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $hidden = [];
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/cache
|
|
||||||
+2
-30
@@ -23,33 +23,6 @@ $app = new Laravel\Lumen\Application(
|
|||||||
dirname(__DIR__)
|
dirname(__DIR__)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
| Laravel's storage_path() helper resolves app('path.storage'). Lumen does not
|
|
||||||
| register that binding by default; config files that call storage_path() at
|
|
||||||
| load time (e.g. config/logging.php) would fail without this.
|
|
||||||
*/
|
|
||||||
$app->instance('path.storage', $app->storagePath());
|
|
||||||
|
|
||||||
/*
|
|
||||||
| Laravel's Foundation helpers are loaded before Lumen's and win for names like
|
|
||||||
| response() and url(). Those helpers resolve Illuminate\Contracts\* from the
|
|
||||||
| container; Lumen only registers the "url" service, not the contracts. Map the
|
|
||||||
| contracts to Lumen's implementations so helpers work across the app.
|
|
||||||
*/
|
|
||||||
$app->singleton(
|
|
||||||
\Illuminate\Contracts\Routing\ResponseFactory::class,
|
|
||||||
function () {
|
|
||||||
return new \Laravel\Lumen\Http\ResponseFactory();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$app->singleton(
|
|
||||||
\Illuminate\Contracts\Routing\UrlGenerator::class,
|
|
||||||
function ($app) {
|
|
||||||
return $app->make('url');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$app->withFacades();
|
$app->withFacades();
|
||||||
|
|
||||||
$app->withEloquent();
|
$app->withEloquent();
|
||||||
@@ -87,12 +60,11 @@ $app->singleton(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$app->configure('app');
|
$app->configure('app');
|
||||||
$app->configure('logging');
|
|
||||||
$app->configure('tinker');
|
$app->configure('tinker');
|
||||||
$app->configure('tennant_database');
|
$app->configure('tennant_master');
|
||||||
$app->configure('report');
|
$app->configure('report');
|
||||||
$app->configure('app_parameter');
|
$app->configure('app_parameter');
|
||||||
$app->configure('parameter');
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Register Middleware
|
| Register Middleware
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'url' => env('APP_URL', 'http://localhost'),
|
'url' => env('APP_URL', url('/')),
|
||||||
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'),
|
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/')
|
||||||
'api_v3' => env('API_V3', 'http://apiv3.localhost/api/')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Monolog\Handler\NullHandler;
|
|
||||||
use Monolog\Handler\StreamHandler;
|
|
||||||
use Monolog\Handler\SyslogUdpHandler;
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Default Log Channel
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| This option defines the default log channel that gets used when writing
|
|
||||||
| messages to the logs. The name specified in this option should match
|
|
||||||
| one of the channels defined in the "channels" configuration array.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'default' => env('LOG_CHANNEL', 'stack'),
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Log Channels
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here you may configure the log channels for your application. Out of
|
|
||||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
|
||||||
| you a variety of powerful log handlers / formatters to utilize.
|
|
||||||
|
|
|
||||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
|
||||||
| "errorlog", "monolog", "custom", "stack"
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'channels' => [
|
|
||||||
'stack' => [
|
|
||||||
'driver' => 'stack',
|
|
||||||
'channels' => ['single'],
|
|
||||||
'ignore_exceptions' => false,
|
|
||||||
],
|
|
||||||
|
|
||||||
'single' => [
|
|
||||||
'driver' => 'single',
|
|
||||||
'path' => storage_path('logs/laravel.log'),
|
|
||||||
'level' => env('LOG_LEVEL', 'debug'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'daily' => [
|
|
||||||
'driver' => 'daily',
|
|
||||||
'path' => storage_path('logs/laravel.log'),
|
|
||||||
'level' => env('LOG_LEVEL', 'debug'),
|
|
||||||
'days' => 14,
|
|
||||||
],
|
|
||||||
|
|
||||||
'slack' => [
|
|
||||||
'driver' => 'slack',
|
|
||||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
|
||||||
'username' => 'Laravel Log',
|
|
||||||
'emoji' => ':boom:',
|
|
||||||
'level' => env('LOG_LEVEL', 'critical'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'papertrail' => [
|
|
||||||
'driver' => 'monolog',
|
|
||||||
'level' => env('LOG_LEVEL', 'debug'),
|
|
||||||
'handler' => SyslogUdpHandler::class,
|
|
||||||
'handler_with' => [
|
|
||||||
'host' => env('PAPERTRAIL_URL'),
|
|
||||||
'port' => env('PAPERTRAIL_PORT'),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
'stderr' => [
|
|
||||||
'driver' => 'monolog',
|
|
||||||
'handler' => StreamHandler::class,
|
|
||||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
|
||||||
'with' => [
|
|
||||||
'stream' => 'php://stderr',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
'syslog' => [
|
|
||||||
'driver' => 'syslog',
|
|
||||||
'level' => env('LOG_LEVEL', 'debug'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'errorlog' => [
|
|
||||||
'driver' => 'errorlog',
|
|
||||||
'level' => env('LOG_LEVEL', 'debug'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'null' => [
|
|
||||||
'driver' => 'monolog',
|
|
||||||
'handler' => NullHandler::class,
|
|
||||||
],
|
|
||||||
|
|
||||||
'emergency' => [
|
|
||||||
'path' => storage_path('logs/laravel.log'),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'max_mutuemas' => env('MAX_MUTUEMAS', true),
|
|
||||||
];
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'master_db' => env('TENNANT_MASTER_DB','online_arrahn'),
|
|
||||||
'kaunter_db' => env('TENNANT_KAUNTER_DB','kaunterpkb')
|
|
||||||
];
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'database' => env('TENNANT_MASTER_DB','master_erahn')
|
||||||
|
];
|
||||||
@@ -42,7 +42,7 @@ class AddColumnsToKomuditiTransaksi extends Migration
|
|||||||
{
|
{
|
||||||
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
||||||
|
|
||||||
if($connection['database'] === config('tennant_database.master_db')){
|
if($connection['database'] === 'online_arrahn' || $connection['database'] === 'master_annur' || $connection['database'] === config('tennant_master.database')){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class AddColumnsToKomuditiTransaksi extends Migration
|
|||||||
|
|
||||||
|
|
||||||
if(empty($online_arrahn_connection_array)){
|
if(empty($online_arrahn_connection_array)){
|
||||||
throw new Exception("Tennant master database (" . config('tennant_database.master_db') . ") doesn't exist in config.database.connections array");
|
throw new Exception("online_arrahn or master_krk doesn't exist in config.database.connections array");
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_keys($online_arrahn_connection_array)[0];
|
return array_keys($online_arrahn_connection_array)[0];
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateKadarRebetTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql7')->table('kadar_rebet', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->decimal('min');
|
||||||
|
$table->decimal('max');
|
||||||
|
$table->decimal('kadar_rebet');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('kadar_rebet');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class KadarRebet extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-16
@@ -69,10 +69,10 @@ class AddNmJbgUntungPembiayaanColumnsToPalsuTable extends Migration
|
|||||||
// Add index and foreign key constraint to existing norujukan column
|
// Add index and foreign key constraint to existing norujukan column
|
||||||
if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
||||||
// Add index to norujukan column for better performance
|
// Add index to norujukan column for better performance
|
||||||
// $table->index('norujukan');
|
$table->index('norujukan');
|
||||||
|
|
||||||
// Add foreign key constraint named 'norujukan'
|
// Add foreign key constraint named 'norujukan'
|
||||||
// $table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai');
|
$table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -87,21 +87,21 @@ class AddNmJbgUntungPembiayaanColumnsToPalsuTable extends Migration
|
|||||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||||
|
|
||||||
// Drop foreign key constraint and index from norujukan column
|
// Drop foreign key constraint and index from norujukan column
|
||||||
// if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
||||||
// try {
|
try {
|
||||||
// $table->dropForeign('norujukan');
|
$table->dropForeign('norujukan');
|
||||||
// echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n";
|
echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n";
|
||||||
// } catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||||
// }
|
}
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
// $table->dropIndex(['norujukan']);
|
$table->dropIndex(['norujukan']);
|
||||||
// echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n";
|
echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n";
|
||||||
// } catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Drop other columns if they exist
|
// Drop other columns if they exist
|
||||||
$columnsToCheck = ['nilaimarhun', 'jbg', 'untung','untungonepercent','untungcajlain', 'pembiayaan'];
|
$columnsToCheck = ['nilaimarhun', 'jbg', 'untung','untungonepercent','untungcajlain', 'pembiayaan'];
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class CreatePampasanTable extends Migration
|
|
||||||
{
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
$db_connection = array_filter($config_db, function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') return false; // ikut pattern sedia ada
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasTable('pampasan')) {
|
|
||||||
Schema::connection($dbase)->create('pampasan', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->string('norujukan', 50)->unique()->index();
|
|
||||||
$table->string('baucerno', 30)->index();
|
|
||||||
$table->string('kodcaw', 20)->index();
|
|
||||||
$table->decimal('jumlah_pampasan', 11, 2);
|
|
||||||
|
|
||||||
if (Schema::getConnection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION) >= '5.7') {
|
|
||||||
$table->json('denominasi')->nullable();
|
|
||||||
} else {
|
|
||||||
$table->longText('denominasi')->nullable();
|
|
||||||
}
|
|
||||||
$table->string('teller', 100);
|
|
||||||
$table->tinyInteger('status')
|
|
||||||
->default(0)
|
|
||||||
->comment('0 = belum dituntut, 1 = dituntut');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->dropIfExists('pampasan');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class AddJenisColumnToPalsuTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get active database connections
|
|
||||||
*/
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config("database.connections"));
|
|
||||||
|
|
||||||
$db_connection = array_filter($config_db, function($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection == 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasColumn('palsu', 'jenis')) {
|
|
||||||
$table->string('jenis', 50)->nullable()->comment('Jenis/Type classification');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (Schema::connection($dbase)->hasColumn('palsu', 'jenis')) {
|
|
||||||
$table->dropColumn('jenis');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class UpdateJenisToPampasanForSempornaRecords extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Semporna norujukan records to update
|
|
||||||
*/
|
|
||||||
private function getSempornaRecords(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'011237240808-0003',
|
|
||||||
'011237240719-0015',
|
|
||||||
'011237240806-0011',
|
|
||||||
'011237240828-0001',
|
|
||||||
'011237240904-0007',
|
|
||||||
'011237240904-0008',
|
|
||||||
'011237240904-0009',
|
|
||||||
'011237240719-0023',
|
|
||||||
'011237240719-0024',
|
|
||||||
'011237240719-0025',
|
|
||||||
'011237240618-0026',
|
|
||||||
'011237240719-0027',
|
|
||||||
'011237240719-0028',
|
|
||||||
'011237240618-0020',
|
|
||||||
'011237240719-0030',
|
|
||||||
'011237240618-0029',
|
|
||||||
'011237240731-0026',
|
|
||||||
'011237240912-0009'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
|
|
||||||
// Update jenis to 'pampasan' for Semporna records in mysql34 (Semporna branch)
|
|
||||||
try {
|
|
||||||
$updated = DB::connection('mysql34')->table('palsu')
|
|
||||||
->whereIn('norujukan', $semporna_records)
|
|
||||||
->update(['jenis' => 'pampasan']);
|
|
||||||
|
|
||||||
echo "Updated {$updated} Semporna records with jenis = 'pampasan'\n";
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error updating Semporna records: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
|
|
||||||
// Revert jenis to null for Semporna records
|
|
||||||
try {
|
|
||||||
$reverted = DB::connection('mysql34')->table('palsu')
|
|
||||||
->whereIn('norujukan', $semporna_records)
|
|
||||||
->update(['jenis' => null]);
|
|
||||||
|
|
||||||
echo "Reverted {$reverted} Semporna records jenis to null\n";
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error reverting Semporna records: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-130
@@ -1,130 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class UpdateNonSempornaRecordsJenisToHapuskira extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get active database connections
|
|
||||||
*/
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config("database.connections"));
|
|
||||||
|
|
||||||
$db_connection = array_filter($config_db, function($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection == 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Semporna norujukan records to exclude
|
|
||||||
*/
|
|
||||||
private function getSempornaRecords(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'011237240808-0003',
|
|
||||||
'011237240719-0015',
|
|
||||||
'011237240806-0011',
|
|
||||||
'011237240828-0001',
|
|
||||||
'011237240904-0007',
|
|
||||||
'011237240904-0008',
|
|
||||||
'011237240904-0009',
|
|
||||||
'011237240719-0023',
|
|
||||||
'011237240719-0024',
|
|
||||||
'011237240719-0025',
|
|
||||||
'011237240618-0026',
|
|
||||||
'011237240719-0027',
|
|
||||||
'011237240719-0028',
|
|
||||||
'011237240618-0020',
|
|
||||||
'011237240719-0030',
|
|
||||||
'011237240618-0029',
|
|
||||||
'011237240731-0026',
|
|
||||||
'011237240912-0009'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
try {
|
|
||||||
if ($dbase == 'mysql34') {
|
|
||||||
// For Semporna (mysql34), update only non-Semporna records to 'hapuskira'
|
|
||||||
$updated = DB::connection($dbase)->table('palsu')
|
|
||||||
->whereNotIn('norujukan', $semporna_records)
|
|
||||||
->update(['jenis' => 'hapuskira']);
|
|
||||||
|
|
||||||
if ($updated > 0) {
|
|
||||||
echo "Updated {$updated} non-Semporna records in {$dbase} to jenis = 'hapuskira'\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// For all other databases, update all records to 'hapuskira'
|
|
||||||
$updated = DB::connection($dbase)->table('palsu')
|
|
||||||
->update(['jenis' => 'hapuskira']);
|
|
||||||
|
|
||||||
if ($updated > 0) {
|
|
||||||
echo "Updated {$updated} records in {$dbase} to jenis = 'hapuskira'\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error updating {$dbase}: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
try {
|
|
||||||
// Revert all jenis values to null except Semporna records which should remain 'pampasan'
|
|
||||||
if ($dbase == 'mysql34') {
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
$reverted = DB::connection($dbase)->table('palsu')
|
|
||||||
->whereNotIn('norujukan', $semporna_records)
|
|
||||||
->update(['jenis' => null]);
|
|
||||||
|
|
||||||
if ($reverted > 0) {
|
|
||||||
echo "Reverted {$reverted} non-Semporna records in {$dbase} jenis to null\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$reverted = DB::connection($dbase)->table('palsu')
|
|
||||||
->update(['jenis' => null]);
|
|
||||||
|
|
||||||
if ($reverted > 0) {
|
|
||||||
echo "Reverted {$reverted} records in {$dbase} jenis to null\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error reverting {$dbase}: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class AddStatusColumnToPalsuTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get active database connections
|
|
||||||
*/
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config("database.connections"));
|
|
||||||
|
|
||||||
$db_connection = array_filter($config_db, function($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection == 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasColumn('palsu', 'status')) {
|
|
||||||
$table->unsignedSmallInteger('status')->default(0)->comment('Status value');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update existing rows to have status = 0
|
|
||||||
DB::connection($dbase)->table('palsu')
|
|
||||||
->whereNull('status')
|
|
||||||
->update(['status' => 0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (Schema::connection($dbase)->hasColumn('palsu', 'status')) {
|
|
||||||
$table->dropColumn('status');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class UpdateAllPalsuStatusToOne extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get active database connections
|
|
||||||
*/
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config("database.connections"));
|
|
||||||
|
|
||||||
$db_connection = array_filter($config_db, function($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection == 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
try {
|
|
||||||
// Update all status values to 1 in palsu table
|
|
||||||
$updated = DB::connection($dbase)->table('palsu')
|
|
||||||
->update(['status' => 1]);
|
|
||||||
|
|
||||||
if ($updated > 0) {
|
|
||||||
echo "Updated {$updated} records in {$dbase} palsu table to status = 1\n";
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error updating {$dbase}: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
try {
|
|
||||||
// Revert all status values back to 0 in palsu table
|
|
||||||
$reverted = DB::connection($dbase)->table('palsu')
|
|
||||||
->update(['status' => 0]);
|
|
||||||
|
|
||||||
if ($reverted > 0) {
|
|
||||||
echo "Reverted {$reverted} records in {$dbase} palsu table to status = 0\n";
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error reverting {$dbase}: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class UpdateSempornaRecordsStatusToZero extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Semporna norujukan records to update status to 0
|
|
||||||
*/
|
|
||||||
private function getSempornaRecords(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'011237240808-0003',
|
|
||||||
'011237240719-0015',
|
|
||||||
'011237240806-0011',
|
|
||||||
'011237240828-0001',
|
|
||||||
'011237240904-0007',
|
|
||||||
'011237240904-0008',
|
|
||||||
'011237240904-0009',
|
|
||||||
'011237240719-0023',
|
|
||||||
'011237240719-0024',
|
|
||||||
'011237240719-0025',
|
|
||||||
'011237240618-0026',
|
|
||||||
'011237240719-0027',
|
|
||||||
'011237240719-0028',
|
|
||||||
'011237240618-0020',
|
|
||||||
'011237240719-0030',
|
|
||||||
'011237240618-0029',
|
|
||||||
'011237240731-0026',
|
|
||||||
'011237240912-0009'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
|
|
||||||
// Update status to 0 for Semporna records in mysql34 (Semporna branch)
|
|
||||||
try {
|
|
||||||
$updated = DB::connection('mysql34')->table('palsu')
|
|
||||||
->whereIn('norujukan', $semporna_records)
|
|
||||||
->update(['status' => 0]);
|
|
||||||
|
|
||||||
echo "Updated {$updated} Semporna records with status = 0\n";
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error updating Semporna records status: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$semporna_records = $this->getSempornaRecords();
|
|
||||||
|
|
||||||
// Revert status to 1 for Semporna records
|
|
||||||
try {
|
|
||||||
$reverted = DB::connection('mysql34')->table('palsu')
|
|
||||||
->whereIn('norujukan', $semporna_records)
|
|
||||||
->update(['status' => 1]);
|
|
||||||
|
|
||||||
echo "Reverted {$reverted} Semporna records status to 1\n";
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "Error reverting Semporna records status: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class AddAgreementPrintedAtToPampasanTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get active database connections
|
|
||||||
*/
|
|
||||||
private function getActiveDB(): array
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config("database.connections"));
|
|
||||||
|
|
||||||
$db_connection = array_filter($config_db, function($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') return false; // ikut pattern sedia ada
|
|
||||||
DB::connection($connection)->select('SELECT 1');
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return $db_connection ? array_values($db_connection) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('pampasan', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasColumn('pampasan', 'agreement_printed_at')) {
|
|
||||||
$table->timestamp('agreement_printed_at')->nullable()->comment('Timestamp when agreement was printed');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('pampasan', function (Blueprint $table) use ($dbase) {
|
|
||||||
if (Schema::connection($dbase)->hasColumn('pampasan', 'agreement_printed_at')) {
|
|
||||||
$table->dropColumn('agreement_printed_at');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AddTHtrAgToSerahbakiTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $db_connection;
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
|
|
||||||
return array_filter($config_db, function ($connection) {
|
|
||||||
$config = config("database.connections.$connection");
|
|
||||||
|
|
||||||
// Skip if host is empty
|
|
||||||
if (empty($config['host'])) return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
$key = array_search('mysql7', $db_connection);
|
|
||||||
|
|
||||||
if ($key !== false) {
|
|
||||||
unset($db_connection[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('serahbaki', function (Blueprint $table) use ($dbase) {
|
|
||||||
|
|
||||||
if (!Schema::connection($dbase)->hasColumn('serahbaki', 't_htr_ag')) {
|
|
||||||
$table->date('t_htr_ag')->nullable()->after('aktif');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$db_connection = $this->getActiveDB();
|
|
||||||
|
|
||||||
$key = array_search('mysql7', $db_connection);
|
|
||||||
|
|
||||||
if ($key !== false) {
|
|
||||||
unset($db_connection[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($db_connection as $dbase) {
|
|
||||||
if (Schema::connection($dbase)->hasColumn('serahbaki', 't_htr_ag')) {
|
|
||||||
Schema::connection($dbase)->table('serahbaki', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('t_htr_ag');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateWtdSimulasiTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('wtd_simulasi', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
|
|
||||||
$table->string('bulan');
|
|
||||||
$table->string('tahun');
|
|
||||||
$table->string('kodcaw');
|
|
||||||
$table->integer('jumlah_sag');
|
|
||||||
$table->decimal('pembiayaan', 15, 2);
|
|
||||||
$table->decimal('baki', 15, 2);
|
|
||||||
$table->integer('simulasi');
|
|
||||||
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('wtd_simulasi');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class CreateMaxMutuemasTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('max_mutuemas', function (Blueprint $table) {
|
|
||||||
$table->id('recno');
|
|
||||||
$table->string('karat');
|
|
||||||
$table->string('keterangan');
|
|
||||||
$table->decimal('teller', 8, 2);
|
|
||||||
$table->decimal('pc', 8, 2);
|
|
||||||
$table->decimal('operasi', 8, 2);
|
|
||||||
$table->timestamp('tarikhupdate');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Insert data
|
|
||||||
DB::table('max_mutuemas')->insert([
|
|
||||||
[
|
|
||||||
'recno' => 1,
|
|
||||||
'karat' => '24.0Kgb',
|
|
||||||
'keterangan' => '999 gb',
|
|
||||||
'teller' => 75.00000,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 2,
|
|
||||||
'karat' => '24.0K',
|
|
||||||
'keterangan' => '999',
|
|
||||||
'teller' => 75.00000,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 3,
|
|
||||||
'karat' => '23.0K',
|
|
||||||
'keterangan' => '950',
|
|
||||||
'teller' => 74.00000,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 4,
|
|
||||||
'karat' => '22.0K',
|
|
||||||
'keterangan' => '916',
|
|
||||||
'teller' => 73.66667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 5,
|
|
||||||
'karat' => '21.0K',
|
|
||||||
'keterangan' => '900',
|
|
||||||
'teller' => 73.16667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 6,
|
|
||||||
'karat' => '20.0K',
|
|
||||||
'keterangan' => '835',
|
|
||||||
'teller' => 72.66667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 7,
|
|
||||||
'karat' => '18.0Kp',
|
|
||||||
'keterangan' => '750',
|
|
||||||
'teller' => 72.16667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 8,
|
|
||||||
'karat' => '18.0K',
|
|
||||||
'keterangan' => '750',
|
|
||||||
'teller' => 71.66667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 21,
|
|
||||||
'karat' => '14.0K',
|
|
||||||
'keterangan' => '585',
|
|
||||||
'teller' => 71.16667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 22,
|
|
||||||
'karat' => '14.0Kp',
|
|
||||||
'keterangan' => '585',
|
|
||||||
'teller' => 70.66667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'recno' => 23,
|
|
||||||
'karat' => '9.0K',
|
|
||||||
'keterangan' => '375',
|
|
||||||
'teller' => 70.16667,
|
|
||||||
'pc' => 80.00000,
|
|
||||||
'operasi' => 80.00000,
|
|
||||||
'tarikhupdate' => '2025-01-12 00:00:00',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('max_mutuemas');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class CreateModalOnlineTable extends Migration
|
|
||||||
{
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
|
|
||||||
return array_filter($config_db, function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasTable('modal_online')) {
|
|
||||||
Schema::connection($dbase)->create('modal_online', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->date('tarikh');
|
|
||||||
$table->string('kodcaw', 20);
|
|
||||||
$table->decimal('had', 12, 2)->default(100000.00);
|
|
||||||
$table->decimal('digunakan', 12, 2)->default(0.00);
|
|
||||||
$table->decimal('baki', 12, 2)->default(100000.00);
|
|
||||||
$table->decimal('tambah', 12, 2)->default(0.00);
|
|
||||||
$table->decimal('kurang', 12, 2)->default(0.00);
|
|
||||||
$table->timestamps();
|
|
||||||
$table->unique(['tarikh', 'kodcaw']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->dropIfExists('modal_online');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class CreateBatchPembiayaanOnlineTable extends Migration
|
|
||||||
{
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
|
|
||||||
return array_filter($config_db, function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasTable('batch_pembiayaan_online')) {
|
|
||||||
Schema::connection($dbase)->create('batch_pembiayaan_online', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->string('batch_no', 50);
|
|
||||||
$table->string('kodcaw', 20);
|
|
||||||
$table->date('tarikh');
|
|
||||||
$table->string('slot', 20)->nullable()->comment('BATCH1 / BATCH2');
|
|
||||||
$table->integer('bilangan')->default(0);
|
|
||||||
$table->decimal('jumlah_keseluruhan', 12, 2)->default(0.00);
|
|
||||||
$table->string('status', 30)->default('DRAFT');
|
|
||||||
$table->string('pc_submitted_by', 100)->nullable();
|
|
||||||
$table->timestamp('submitted_at')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
$table->index(['kodcaw', 'tarikh', 'status']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->dropIfExists('batch_pembiayaan_online');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class CreatePembiayaanOnlineTable extends Migration
|
|
||||||
{
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
|
|
||||||
return array_filter($config_db, function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (!Schema::connection($dbase)->hasTable('pembiayaan_online')) {
|
|
||||||
Schema::connection($dbase)->create('pembiayaan_online', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->string('norujukan', 50);
|
|
||||||
$table->string('nokp', 20);
|
|
||||||
$table->string('nopelanggan', 50)->nullable();
|
|
||||||
$table->string('nama_pelanggan', 150)->nullable();
|
|
||||||
$table->string('kodcaw', 20);
|
|
||||||
$table->decimal('pinjaman', 12, 2);
|
|
||||||
$table->string('kodbank', 20)->nullable();
|
|
||||||
$table->string('nama_bank', 100)->nullable();
|
|
||||||
$table->string('noakaun', 50)->nullable();
|
|
||||||
$table->string('nama_akaun', 150)->nullable();
|
|
||||||
$table->unsignedBigInteger('bukti_akaun_file_id')->nullable();
|
|
||||||
$table->unsignedBigInteger('borang_file_id')->nullable();
|
|
||||||
$table->string('status', 30)->default('PENDING_PC');
|
|
||||||
$table->text('reject_reason')->nullable();
|
|
||||||
$table->string('rejected_by', 100)->nullable();
|
|
||||||
$table->timestamp('rejected_at')->nullable();
|
|
||||||
$table->unsignedBigInteger('batch_id')->nullable();
|
|
||||||
$table->unsignedBigInteger('bukti_file_id')->nullable();
|
|
||||||
$table->string('no_rujukan_bayaran', 100)->nullable();
|
|
||||||
$table->date('tarikh_bayaran')->nullable();
|
|
||||||
$table->timestamp('paid_at')->nullable();
|
|
||||||
$table->string('created_by', 100)->nullable();
|
|
||||||
$table->string('pc_submitted_by', 100)->nullable();
|
|
||||||
$table->string('ops_by', 100)->nullable();
|
|
||||||
$table->text('nota')->nullable();
|
|
||||||
$table->tinyInteger('blast_sent')->default(0);
|
|
||||||
$table->timestamps();
|
|
||||||
$table->index(['kodcaw', 'status']);
|
|
||||||
$table->index('norujukan');
|
|
||||||
$table->index('batch_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->dropIfExists('pembiayaan_online');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class AddCaraTerimaToGadaiTable extends Migration
|
|
||||||
{
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
$config_db = array_keys(config('database.connections'));
|
|
||||||
|
|
||||||
return array_filter($config_db, function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (
|
|
||||||
Schema::connection($dbase)->hasTable('gadai')
|
|
||||||
&& !Schema::connection($dbase)->hasColumn('gadai', 'cara_terima')
|
|
||||||
) {
|
|
||||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
|
|
||||||
$table->string('cara_terima', 20)->nullable()->after('pinjaman');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
if (
|
|
||||||
Schema::connection($dbase)->hasTable('gadai')
|
|
||||||
&& Schema::connection($dbase)->hasColumn('gadai', 'cara_terima')
|
|
||||||
) {
|
|
||||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('cara_terima');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateRequestModalOnlineTable extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
if (!Schema::connection('mysql7')->hasTable('request_modal_online')) {
|
|
||||||
Schema::connection('mysql7')->create('request_modal_online', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->string('kodcaw', 20);
|
|
||||||
$table->date('tarikh');
|
|
||||||
$table->decimal('amaun', 12, 2);
|
|
||||||
$table->string('dimohon_oleh', 100)->nullable();
|
|
||||||
$table->string('status', 20)->default('PENDING');
|
|
||||||
$table->string('diluluskan_oleh', 100)->nullable();
|
|
||||||
$table->text('nota')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
$table->index(['kodcaw', 'tarikh', 'status']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::connection('mysql7')->dropIfExists('request_modal_online');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateArrahnFilesTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Master DB (mysql7) — shared file store for CIT / permohonan / bukti pembiayaan online.
|
|
||||||
* Matches App\ARFiles usage: data (base64), filename, type, tarikhmasa; id used as file reference.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
if (!Schema::connection('mysql7')->hasTable('arrahn_files')) {
|
|
||||||
Schema::connection('mysql7')->create('arrahn_files', function (Blueprint $table) {
|
|
||||||
$table->bigIncrements('id');
|
|
||||||
$table->unsignedBigInteger('files_id')->nullable()->index();
|
|
||||||
$table->longText('data')->nullable();
|
|
||||||
$table->string('filename', 255)->nullable();
|
|
||||||
$table->string('type', 100)->nullable();
|
|
||||||
$table->string('tarikhmasa', 50)->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::connection('mysql7')->dropIfExists('arrahn_files');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AddEodCloseColumnsToModalOnlineTable extends Migration
|
|
||||||
{
|
|
||||||
public function getActiveDB()
|
|
||||||
{
|
|
||||||
return array_filter(
|
|
||||||
array_keys(config('database.connections')),
|
|
||||||
function ($connection) {
|
|
||||||
try {
|
|
||||||
if ($connection === 'mysql7') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection($connection)->getPdo();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('modal_online', function (Blueprint $table) {
|
|
||||||
$table->tinyInteger('ditutup')
|
|
||||||
->default(0)
|
|
||||||
->after('kurang');
|
|
||||||
|
|
||||||
$table->string('ditutup_oleh', 100)
|
|
||||||
->nullable()
|
|
||||||
->after('ditutup');
|
|
||||||
|
|
||||||
$table->timestamp('ditutup_at')
|
|
||||||
->nullable()
|
|
||||||
->after('ditutup_oleh');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
foreach ($this->getActiveDB() as $dbase) {
|
|
||||||
Schema::connection($dbase)->table('modal_online', function (Blueprint $table) {
|
|
||||||
$table->dropColumn([
|
|
||||||
'ditutup',
|
|
||||||
'ditutup_oleh',
|
|
||||||
'ditutup_at',
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
# Staging stack — isolated from local docker-compose.yml (8080 / 3306)
|
|
||||||
# and from other apps on the server (unique project name + host ports).
|
|
||||||
#
|
|
||||||
# Local:
|
|
||||||
# docker compose --env-file .env.staging -f docker-compose.staging.yml up -d --build
|
|
||||||
#
|
|
||||||
# CI (image already in registry):
|
|
||||||
# APP_IMAGE=git.koppkb.com/KoPKB/api_arrahn IMAGE_TAG=<sha> \
|
|
||||||
# docker compose --env-file .env.staging -f docker-compose.staging.yml up -d --no-build
|
|
||||||
#
|
|
||||||
# Host nginx reverse-proxies the public domain to 127.0.0.1:${HTTP_PORT}.
|
|
||||||
# See docker/nginx/host-proxy.example.conf
|
|
||||||
#
|
|
||||||
# If 8090 or 3308 is already taken, set HTTP_PORT / MYSQL_PUBLISH_PORT in .env.staging.
|
|
||||||
|
|
||||||
name: api_arrahn_staging
|
|
||||||
|
|
||||||
services:
|
|
||||||
app:
|
|
||||||
image: ${APP_IMAGE:-api_arrahn}:${IMAGE_TAG:-staging}
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: docker/php/Dockerfile
|
|
||||||
target: staging
|
|
||||||
container_name: api_arrahn_staging_app
|
|
||||||
working_dir: /var/www/html
|
|
||||||
volumes:
|
|
||||||
- storage_staging:/var/www/html/storage
|
|
||||||
- ./.env.staging:/var/www/html/.env.staging:ro
|
|
||||||
env_file:
|
|
||||||
- .env.staging
|
|
||||||
environment:
|
|
||||||
APP_ENV: staging
|
|
||||||
USE_STAGING_ENV: "true"
|
|
||||||
extra_hosts:
|
|
||||||
- "host.docker.internal:host-gateway"
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
web:
|
|
||||||
image: nginx:1.25-alpine
|
|
||||||
container_name: api_arrahn_staging_web
|
|
||||||
ports:
|
|
||||||
- "${HTTP_PORT:-8090}:80"
|
|
||||||
volumes:
|
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
depends_on:
|
|
||||||
- app
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: api_arrahn_staging_mysql
|
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:${MYSQL_PUBLISH_PORT:-3308}:3306"
|
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: erahn_xtra
|
|
||||||
MYSQL_USER: xtrauser
|
|
||||||
MYSQL_PASSWORD: password
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
volumes:
|
|
||||||
- mysql_staging_data:/var/lib/mysql
|
|
||||||
- ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 30
|
|
||||||
start_period: 20s
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mysql_staging_data:
|
|
||||||
storage_staging:
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
services:
|
|
||||||
app:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: docker/php/Dockerfile
|
|
||||||
target: development
|
|
||||||
working_dir: /var/www/html
|
|
||||||
volumes:
|
|
||||||
- ./:/var/www/html:cached
|
|
||||||
environment:
|
|
||||||
APP_ENV: local
|
|
||||||
APP_DEBUG: "true"
|
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
|
|
||||||
web:
|
|
||||||
image: nginx:1.25-alpine
|
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
volumes:
|
|
||||||
- ./:/var/www/html:cached
|
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
depends_on:
|
|
||||||
- app
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: erahn_xtra
|
|
||||||
MYSQL_USER: xtrauser
|
|
||||||
MYSQL_PASSWORD: password
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
volumes:
|
|
||||||
- mysql_data:/var/lib/mysql
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mysql_data:
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS master_erahn;
|
|
||||||
CREATE DATABASE IF NOT EXISTS kaunter_erahn;
|
|
||||||
|
|
||||||
GRANT ALL PRIVILEGES ON master_erahn.* TO 'xtrauser'@'%';
|
|
||||||
GRANT ALL PRIVILEGES ON kaunter_erahn.* TO 'xtrauser'@'%';
|
|
||||||
GRANT ALL PRIVILEGES ON erahn_xtra.* TO 'xtrauser'@'%';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
root /var/www/html/public;
|
|
||||||
index index.php index.html;
|
|
||||||
|
|
||||||
charset utf-8;
|
|
||||||
client_max_body_size 50M;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
rewrite ^/(.*)/$ /$1 last;
|
|
||||||
try_files $uri @php;
|
|
||||||
}
|
|
||||||
|
|
||||||
location @php {
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
fastcgi_pass app:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_read_timeout 120s;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
fastcgi_pass app:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_read_timeout 120s;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ /\.(?!well-known).* {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
FROM php:7.4-fpm AS base
|
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
git \
|
|
||||||
pkg-config \
|
|
||||||
unzip \
|
|
||||||
libonig-dev \
|
|
||||||
libzip-dev \
|
|
||||||
libpng-dev \
|
|
||||||
libjpeg62-turbo-dev \
|
|
||||||
libfreetype6-dev \
|
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
||||||
&& docker-php-ext-install -j"$(nproc)" \
|
|
||||||
pdo_mysql \
|
|
||||||
mbstring \
|
|
||||||
bcmath \
|
|
||||||
zip \
|
|
||||||
exif \
|
|
||||||
gd \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
|
|
||||||
|
|
||||||
COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
|
|
||||||
COPY docker/php/zz-clear-env.conf /usr/local/etc/php-fpm.d/zz-clear-env.conf
|
|
||||||
COPY docker/php/entrypoint.sh /usr/local/bin/app-entrypoint.sh
|
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/app-entrypoint.sh \
|
|
||||||
&& usermod -u 1000 www-data && groupmod -g 1000 www-data
|
|
||||||
|
|
||||||
ENTRYPOINT ["app-entrypoint.sh"]
|
|
||||||
CMD ["php-fpm"]
|
|
||||||
|
|
||||||
FROM base AS staging
|
|
||||||
|
|
||||||
COPY --chown=www-data:www-data . /var/www/html
|
|
||||||
|
|
||||||
RUN composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader \
|
|
||||||
&& mkdir -p \
|
|
||||||
storage/logs \
|
|
||||||
storage/framework/cache/data \
|
|
||||||
storage/framework/views \
|
|
||||||
storage/framework/sessions \
|
|
||||||
storage/app/public \
|
|
||||||
bootstrap/cache \
|
|
||||||
&& chown -R www-data:www-data storage bootstrap/cache vendor
|
|
||||||
|
|
||||||
FROM base AS development
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd /var/www/html
|
|
||||||
|
|
||||||
if [ "${USE_STAGING_ENV:-false}" = "true" ] && [ -f .env.staging ]; then
|
|
||||||
cp .env.staging .env
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f composer.json ]; then
|
|
||||||
if [ -f vendor/autoload.php ] && [ "${USE_STAGING_ENV:-false}" = "true" ]; then
|
|
||||||
: # vendor is baked into the staging image
|
|
||||||
elif [ "${USE_STAGING_ENV:-false}" = "true" ]; then
|
|
||||||
composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader
|
|
||||||
else
|
|
||||||
composer install --no-interaction --prefer-dist
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p \
|
|
||||||
storage/logs \
|
|
||||||
storage/framework/cache/data \
|
|
||||||
storage/framework/views \
|
|
||||||
storage/framework/sessions \
|
|
||||||
storage/app/public \
|
|
||||||
bootstrap/cache
|
|
||||||
|
|
||||||
chown -R www-data:www-data storage bootstrap/cache
|
|
||||||
|
|
||||||
exec docker-php-entrypoint "$@"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
memory_limit=512M
|
|
||||||
upload_max_filesize=50M
|
|
||||||
post_max_size=50M
|
|
||||||
max_execution_time=120
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[www]
|
|
||||||
; Pass container env vars (from compose env_file) through to PHP workers.
|
|
||||||
clear_env = no
|
|
||||||
+1
-5
@@ -55,11 +55,7 @@ $router->group(['prefix' => 'api/reports'], function () use ($router) {
|
|||||||
$router->get('gadaitebus', ['uses' => 'GadaianController@getSummaryLaporanGadaiTebus']);
|
$router->get('gadaitebus', ['uses' => 'GadaianController@getSummaryLaporanGadaiTebus']);
|
||||||
$router->get('gadaitebusmasa', ['uses' => 'GadaianController@getSummaryLaporanGadaiTebusMasa']);
|
$router->get('gadaitebusmasa', ['uses' => 'GadaianController@getSummaryLaporanGadaiTebusMasa']);
|
||||||
$router->get('gadaitebusmasa/{kod_cawangan}', ['uses' => 'GadaianController@getLaporanGadaiTebusMasaCawangan']);
|
$router->get('gadaitebusmasa/{kod_cawangan}', ['uses' => 'GadaianController@getLaporanGadaiTebusMasaCawangan']);
|
||||||
$router->get('audit-trail', ['uses' => 'AuditTrailController@getAuditTrail']);
|
|
||||||
$router->get('audittrail/operasi',['uses'=>'AuditTrailController@AuditTrailOperasi']);
|
|
||||||
$router->get('saringan/gadaian', ['uses' => 'SaringanGadaianController@getLaporanGadai']);
|
|
||||||
|
|
||||||
$router->get('data-pelanggan', ['uses' => 'AnalisaController@getSummaryLaporanDataPelanggan']);
|
|
||||||
$router->get('data-pelanggan-bycaw', ['uses' => 'AnalisaController@getSummaryLaporanDataPelangganBycaw']);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-83
@@ -21,10 +21,6 @@ use App\Http\Controllers\TransactionOnlineTrailController;
|
|||||||
use App\Http\Controllers\Reports\RingkasanHarianController;
|
use App\Http\Controllers\Reports\RingkasanHarianController;
|
||||||
use App\Transaction;
|
use App\Transaction;
|
||||||
|
|
||||||
$router->get('/health', function () {
|
|
||||||
return response()->json(['status' => 'ok']);
|
|
||||||
});
|
|
||||||
|
|
||||||
$router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function() use ($router) {
|
$router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function() use ($router) {
|
||||||
$router->get('logs', 'LogViewerController@index');
|
$router->get('logs', 'LogViewerController@index');
|
||||||
});
|
});
|
||||||
@@ -60,17 +56,15 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->put('customers/update/khazanah/{nokp}', ['uses' => 'CustomerController@customerUpdateKhazanah']);
|
$router->put('customers/update/khazanah/{nokp}', ['uses' => 'CustomerController@customerUpdateKhazanah']);
|
||||||
$router->get('customers/laporan/{kodcaw}/{tarikh}',['uses'=>'CustomerController@getLaporanCustomers']);
|
$router->get('customers/laporan/{kodcaw}/{tarikh}',['uses'=>'CustomerController@getLaporanCustomers']);
|
||||||
$router->get('customers/latest/{kodcaw}',['uses'=>'CustomerController@getLatestCustomer']);
|
$router->get('customers/latest/{kodcaw}',['uses'=>'CustomerController@getLatestCustomer']);
|
||||||
$router->put('customers/information/update/admin', ['uses' => 'CustomerController@customerUpdateAdmin']); //blh refer sini izazi
|
$router->put('customers/information/update/admin', ['uses' => 'CustomerController@customerUpdateAdmin']);
|
||||||
$router->get('admin/customers/nokp/search',['uses'=>'CustomerController@showOneCustomerByICAdmin']);
|
$router->get('admin/customers/nokp/search',['uses'=>'CustomerController@showOneCustomerByICAdmin']);
|
||||||
$router->get('customer/blacklist',['uses'=>'CustomerController@blacklistCustomer']);
|
$router->get('customer/blacklist',['uses'=>'CustomerController@blacklistCustomer']);
|
||||||
$router->get('customer/anggota',['uses'=>'CustomerController@anggotaKoperasi']);
|
$router->get('customer/anggota',['uses'=>'CustomerController@anggotaKoperasi']);
|
||||||
$router->get('customer/eachcawangan/{ic}',['uses'=>'CustomerController@showCustomerByEachCawangan']);
|
$router->get('customer/eachcawangan/{ic}',['uses'=>'CustomerController@showCustomerByEachCawangan']);
|
||||||
$router->put('customers/{noic}/assign-anggota', ['uses' => 'CustomerController@assignAnggota']);
|
$router->put('customers/{noic}/assign-anggota', ['uses' => 'CustomerController@assignAnggota']);
|
||||||
$router->post('/customers/update-tag-pdpa', ['uses' => 'CustomerController@updateTagPdpa']);
|
|
||||||
|
|
||||||
//arcc
|
//arcc
|
||||||
$router->get('customer/searchbyname',['uses'=>'CustomerController@searchByName']);
|
$router->get('customer/searchbyname',['uses'=>'CustomerController@searchByName']);
|
||||||
$router->get('customer/searchbygadai/{kodcaw}/{norujukan}',['uses'=>'CustomerController@AdminsearchGadai']);
|
|
||||||
// Route::get('/api/customers/searchbyname', [CustomerController::class, 'searchByName']);
|
// Route::get('/api/customers/searchbyname', [CustomerController::class, 'searchByName']);
|
||||||
// $router->put('customers/update/{nokp}', ['uses' => 'CallCenterController@customerUpdate']); //kena tengok api ni
|
// $router->put('customers/update/{nokp}', ['uses' => 'CallCenterController@customerUpdate']); //kena tengok api ni
|
||||||
// $router->put('customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CallCenterController@customerUpdateKaunter']);
|
// $router->put('customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CallCenterController@customerUpdateKaunter']);
|
||||||
@@ -96,7 +90,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('gadai/cawangan/{kodcaw}/{tarikh}',['uses'=>'GadaiController@showOneGadaiByCawanganOnly']);
|
$router->get('gadai/cawangan/{kodcaw}/{tarikh}',['uses'=>'GadaiController@showOneGadaiByCawanganOnly']);
|
||||||
$router->get('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukan']);
|
$router->get('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukan']);
|
||||||
$router->get('gadai/norujukankodcaw/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukanKodcaw']);
|
$router->get('gadai/norujukankodcaw/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukanKodcaw']);
|
||||||
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukanAndCawangan']); // refer sini utk pass gadai
|
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukanAndCawangan']);
|
||||||
$router->post('gadai/{kodcaw}',['uses'=>'GadaiController@create']);
|
$router->post('gadai/{kodcaw}',['uses'=>'GadaiController@create']);
|
||||||
$router->post('gadaiold/{kodcaw}',['uses'=>'GadaiController@createold']);
|
$router->post('gadaiold/{kodcaw}',['uses'=>'GadaiController@createold']);
|
||||||
$router->get('gadai/{cawangan_code}/{date}',['uses'=>'GadaiController@gadaiTransactionByCawanganAndDay']);
|
$router->get('gadai/{cawangan_code}/{date}',['uses'=>'GadaiController@gadaiTransactionByCawanganAndDay']);
|
||||||
@@ -202,8 +196,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
|
|
||||||
$router->get('keluar/lelong',['uses'=>'LelongController@keluarLelong']);
|
$router->get('keluar/lelong',['uses'=>'LelongController@keluarLelong']);
|
||||||
|
|
||||||
$router->get('lelong/bakilelongbyteller/{kodcaw}',['uses' => 'LelongController@getBakiLelongByTeller']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Marhun API
|
//Marhun API
|
||||||
@@ -270,9 +262,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
|
|
||||||
|
|
||||||
$router->get('maxpinjaman',['uses'=>'MaxPinjamanController@getAllMaxPinjaman']);
|
$router->get('maxpinjaman',['uses'=>'MaxPinjamanController@getAllMaxPinjaman']);
|
||||||
$router->get('maxmutuemas',['uses'=>'MaxPinjamanController@getAllMaxMutuEmas']);
|
|
||||||
$router->get('maxmutuemas/specific',['uses'=>'MaxPinjamanController@getSpecificMaxMutuEmas']);
|
|
||||||
$router->post('maxmutuemas/update',['uses'=>'MaxPinjamanController@updateMaxMutuEmas']);
|
|
||||||
|
|
||||||
$router->get('transaksi_keuntungan/{norujukan}',['uses'=>'TransaksiKeuntunganController@getTransaksiKeuntunganByRujukan']);
|
$router->get('transaksi_keuntungan/{norujukan}',['uses'=>'TransaksiKeuntunganController@getTransaksiKeuntunganByRujukan']);
|
||||||
$router->get('transaksi_keuntungan_latest/{norujukan}',['uses'=>'TransaksiKeuntunganController@getTransaksiKeuntunganByRujukanLatest']);
|
$router->get('transaksi_keuntungan_latest/{norujukan}',['uses'=>'TransaksiKeuntunganController@getTransaksiKeuntunganByRujukanLatest']);
|
||||||
@@ -387,8 +376,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('laporanpetibesirange/{kodcaw}',['uses'=> 'VaultController@laporanPetiBesiRange']);
|
$router->get('laporanpetibesirange/{kodcaw}',['uses'=> 'VaultController@laporanPetiBesiRange']);
|
||||||
$router->get('laporanAuditTrail',['uses'=> 'LaporanController@LaporanAuditTrail']);
|
$router->get('laporanAuditTrail',['uses'=> 'LaporanController@LaporanAuditTrail']);
|
||||||
|
|
||||||
//Get Tunai By tarikh for Laporan Aliran Tunai Teller
|
|
||||||
$router->get('getTunaiByTarikh', ['uses' => 'TunaiController@getTunaiByTarikh']);
|
|
||||||
|
|
||||||
//API PANJAR KHAZANAH
|
//API PANJAR KHAZANAH
|
||||||
$router->get('SenaraiPanjar/{kodcaw}',['uses'=>'PanjarController@list']);
|
$router->get('SenaraiPanjar/{kodcaw}',['uses'=>'PanjarController@list']);
|
||||||
@@ -399,12 +386,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->post('CreatePanjar/{kodcaw}',['uses'=>'PanjarController@create']);
|
$router->post('CreatePanjar/{kodcaw}',['uses'=>'PanjarController@create']);
|
||||||
$router->post('DeletePanjar/{kodcaw}',['uses'=>'PanjarController@delete']);
|
$router->post('DeletePanjar/{kodcaw}',['uses'=>'PanjarController@delete']);
|
||||||
|
|
||||||
//API PAMPASAN GUNA PANJAR
|
|
||||||
$router->post('pampasan/initiatePampasan',['uses'=>'PampasanController@initiatePampasan']);
|
|
||||||
$router->post('pampasan/terimaPampasan',['uses'=>'PampasanController@terimaPampasan']);
|
|
||||||
$router->put('pampasan/updateStatusPampasan', ['uses' => 'PampasanController@updateStatusPampasan']);
|
|
||||||
$router->get('pampasan', ['uses' => 'PampasanController@getPampasan']);
|
|
||||||
|
|
||||||
|
|
||||||
//API KELULUSAN
|
//API KELULUSAN
|
||||||
$router->get('SenaraiKelulusan/{kodcaw}',['uses'=>'KelulusanController@list']);
|
$router->get('SenaraiKelulusan/{kodcaw}',['uses'=>'KelulusanController@list']);
|
||||||
@@ -487,14 +468,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
//laporanlelong adminportal
|
//laporanlelong adminportal
|
||||||
$router->get('laporan/lelong',['uses' => 'LelongController@LaporanLelong']);
|
$router->get('laporan/lelong',['uses' => 'LelongController@LaporanLelong']);
|
||||||
$router->get('lookupbatchlel/{kodcaw}',['uses' => 'LelongController@LookupBatchLel']);
|
$router->get('lookupbatchlel/{kodcaw}',['uses' => 'LelongController@LookupBatchLel']);
|
||||||
//barangkes
|
|
||||||
$router->get('palsu/laporan', ['uses' => 'BarangkesController@LaporanBarangKes']);
|
$router->get('palsu/laporan', ['uses' => 'BarangkesController@LaporanBarangKes']);
|
||||||
$router->get('barangkes', ['uses' => 'BarangkesController@index']); //
|
|
||||||
$router->post('barangkes/store', ['uses' => 'BarangkesController@store']);
|
|
||||||
|
|
||||||
// $router->post('/barangkes/{id}', ['uses' => 'BarangkesController@show']);
|
|
||||||
$router->put('barangkes/update/{recno}', ['uses' => 'BarangkesController@update']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//update tagterima Tebus
|
//update tagterima Tebus
|
||||||
@@ -575,6 +550,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']);
|
$router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']);
|
||||||
$router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']);
|
$router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']);
|
||||||
$router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']);
|
$router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']);
|
||||||
|
$router->get('RebetPromoCalculation/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculation']);
|
||||||
|
$router->get('PelarasanRebate/{kodcaw}',['uses'=>'TebusController@PelarasanRebate']);
|
||||||
|
|
||||||
//-- Harta Semasa --//
|
//-- Harta Semasa --//
|
||||||
$router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']);
|
$router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']);
|
||||||
@@ -604,6 +581,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('PendahuluanSerahanLejer/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahanLejer']);
|
$router->get('PendahuluanSerahanLejer/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahanLejer']);
|
||||||
$router->get('KeuntunganArRahnLejer/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntunganLejer']);
|
$router->get('KeuntunganArRahnLejer/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntunganLejer']);
|
||||||
$router->get('RebetCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetCalculationLejer']);
|
$router->get('RebetCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetCalculationLejer']);
|
||||||
|
$router->get('RebetPromoCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculationLejer']);
|
||||||
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
|
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
|
||||||
|
|
||||||
// //-- Harta Semasa --//
|
// //-- Harta Semasa --//
|
||||||
@@ -673,42 +651,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
|
|
||||||
//initiateTunai
|
//initiateTunai
|
||||||
$router->get('initiate/tunai',['uses'=>'TunaiController@initiateTunai']);
|
$router->get('initiate/tunai',['uses'=>'TunaiController@initiateTunai']);
|
||||||
|
|
||||||
// Modal Online (pembiayaan atas talian float)
|
|
||||||
// Operasi top-up routes before {kodcaw} catch-alls
|
|
||||||
$router->get('modal-online/operasi/topup/requests', ['uses' => 'ModalOnlineController@listTopUpOperasi']);
|
|
||||||
$router->post('modal-online/operasi/topup/{id}/approve', ['uses' => 'ModalOnlineController@approveTopUp']);
|
|
||||||
$router->post('modal-online/operasi/topup/{id}/reject', ['uses' => 'ModalOnlineController@rejectTopUp']);
|
|
||||||
$router->get('modal-online/operasi/eod', ['uses' => 'ModalOnlineController@listToday']);
|
|
||||||
$router->post('modal-online/operasi/eod/close-all', ['uses' => 'ModalOnlineController@closeAll']);
|
|
||||||
|
|
||||||
$router->get('modal-online/{kodcaw}', ['uses' => 'ModalOnlineController@get']);
|
|
||||||
$router->post('modal-online/{kodcaw}/reserve', ['uses' => 'ModalOnlineController@reserve']);
|
|
||||||
$router->post('modal-online/{kodcaw}/topup/request', ['uses' => 'ModalOnlineController@requestTopUp']);
|
|
||||||
$router->get('modal-online/{kodcaw}/topup/requests', ['uses' => 'ModalOnlineController@listTopUpByCawangan']);
|
|
||||||
$router->post('modal-online/{kodcaw}/close', ['uses' => 'ModalOnlineController@close']);
|
|
||||||
$router->get('initiate/modal-online', ['uses' => 'ModalOnlineController@initiate']);
|
|
||||||
|
|
||||||
// Operasi kelulusan pembiayaan online (must be before {kodcaw} routes)
|
|
||||||
$router->get('pembiayaan-online/operasi/batches', ['uses' => 'PembiayaanOnlineController@operasiListBatches']);
|
|
||||||
$router->get('pembiayaan-online/operasi/{kodcaw}/batches/{batchId}', ['uses' => 'PembiayaanOnlineController@operasiShowBatch']);
|
|
||||||
$router->post('pembiayaan-online/operasi/{kodcaw}/lines/{id}/approve', ['uses' => 'PembiayaanOnlineController@operasiApproveLine']);
|
|
||||||
$router->post('pembiayaan-online/operasi/{kodcaw}/lines/{id}/reject', ['uses' => 'PembiayaanOnlineController@operasiRejectLine']);
|
|
||||||
$router->post('pembiayaan-online/operasi/{kodcaw}/lines/{id}/paid', ['uses' => 'PembiayaanOnlineController@operasiMarkPaid']);
|
|
||||||
$router->post('pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/approve', ['uses' => 'PembiayaanOnlineController@operasiApproveBatch']);
|
|
||||||
$router->post('pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/paid', ['uses' => 'PembiayaanOnlineController@operasiMarkPaidBatch']);
|
|
||||||
|
|
||||||
// Pembiayaan Online (payout line + PC queue / batch)
|
|
||||||
$router->post('pembiayaan-online/{kodcaw}', ['uses' => 'PembiayaanOnlineController@store']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/queue', ['uses' => 'PembiayaanOnlineController@queue']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/paid', ['uses' => 'PembiayaanOnlineController@paidQueue']);
|
|
||||||
$router->post('pembiayaan-online/{kodcaw}/paid/blast', ['uses' => 'PembiayaanOnlineController@markBlastSent']);
|
|
||||||
$router->put('pembiayaan-online/{kodcaw}/lines/{id}', ['uses' => 'PembiayaanOnlineController@updateLine']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/lines/{id}/bukti', ['uses' => 'PembiayaanOnlineController@getBukti']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/batches', ['uses' => 'PembiayaanOnlineController@listBatches']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/batches/{batchId}', ['uses' => 'PembiayaanOnlineController@showBatch']);
|
|
||||||
$router->post('pembiayaan-online/{kodcaw}/batches/submit', ['uses' => 'PembiayaanOnlineController@submitBatch']);
|
|
||||||
$router->get('pembiayaan-online/{kodcaw}/by-norujukan/{norujukan}', ['uses' => 'PembiayaanOnlineController@show']);
|
|
||||||
//WTD
|
//WTD
|
||||||
$router->get('check/wtd',['uses'=>'WTDController@getDraftWTD']);
|
$router->get('check/wtd',['uses'=>'WTDController@getDraftWTD']);
|
||||||
$router->get('check/customer',['uses' => 'WTDController@getCustomerWTD']);
|
$router->get('check/customer',['uses' => 'WTDController@getCustomerWTD']);
|
||||||
@@ -857,7 +799,6 @@ $router->group(['prefix'=>'portal'], function () use ($router){
|
|||||||
$router->get('transaksipelanggan/upah',['uses'=>'TransactionController@TransaksiUpah']);
|
$router->get('transaksipelanggan/upah',['uses'=>'TransactionController@TransaksiUpah']);
|
||||||
$router->get('searchsagonline',['uses'=>'TransactionOnlineController@searchSAGOnline']);
|
$router->get('searchsagonline',['uses'=>'TransactionOnlineController@searchSAGOnline']);
|
||||||
$router->get('customer/info',['uses'=>'TransactionOnlineController@CustomerInfo']);
|
$router->get('customer/info',['uses'=>'TransactionOnlineController@CustomerInfo']);
|
||||||
$router->get('customer/info/lelong',['uses'=>'TransactionOnlineController@CustomerInfoLelong']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->group(['prefix'=>'admin'], function () use ($router){
|
$router->group(['prefix'=>'admin'], function () use ($router){
|
||||||
@@ -871,11 +812,9 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
|||||||
$router->get('TuntutBakiTarikhTeller/{kodcaw}',['uses'=>'AdminPageController@showTuntutBakiTarikhTeller']);
|
$router->get('TuntutBakiTarikhTeller/{kodcaw}',['uses'=>'AdminPageController@showTuntutBakiTarikhTeller']);
|
||||||
$router->get('lelong/tarikh/{kodcaw}',['uses'=>'AdminPageController@LelonganTarikh']);
|
$router->get('lelong/tarikh/{kodcaw}',['uses'=>'AdminPageController@LelonganTarikh']);
|
||||||
$router->post('updateTunaiGTByTarikh/{kodcaw}',['uses'=>'AdminPageController@UpdateTunaiByTarikh']);
|
$router->post('updateTunaiGTByTarikh/{kodcaw}',['uses'=>'AdminPageController@UpdateTunaiByTarikh']);
|
||||||
$router->get('searchByName',['uses'=>'CustomerController@AdminsearchCustomerByName']);
|
|
||||||
$router->get('searchByIC',['uses'=>'CustomerController@AdminsearchCustomerByIC']); //refer ni jugak
|
|
||||||
|
|
||||||
// sag
|
$router->get('searchByName',['uses'=>'CustomerController@AdminsearchCustomerByName']);
|
||||||
$router->get('searchBySag',['uses'=>'CustomerController@AdminsearchCustomerBySAG']); //refer ni jugak
|
$router->get('searchByIC',['uses'=>'CustomerController@AdminsearchCustomerByIC']);
|
||||||
|
|
||||||
$router->get('pembiayaanTahunan',['uses'=>'AdminPageController@TahunanGadai']);
|
$router->get('pembiayaanTahunan',['uses'=>'AdminPageController@TahunanGadai']);
|
||||||
$router->get('penebusanTahunan',['uses'=>'AdminPageController@TahunanTebus']);
|
$router->get('penebusanTahunan',['uses'=>'AdminPageController@TahunanTebus']);
|
||||||
@@ -943,20 +882,6 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
|||||||
$router->post('wtd/delete',['uses'=>'AdminPageController@RemoveDraftWTD']);
|
$router->post('wtd/delete',['uses'=>'AdminPageController@RemoveDraftWTD']);
|
||||||
$router->get('wtd/dalamproses',['uses'=>'AdminPageController@rekodWTDDalamProses']);
|
$router->get('wtd/dalamproses',['uses'=>'AdminPageController@rekodWTDDalamProses']);
|
||||||
|
|
||||||
//Aiman Ngube WTD
|
|
||||||
$router->get('wtd/janaSimulasi',['uses'=>'AdminPageController@JanaSimulasiWTD']);
|
|
||||||
$router->get('wtd/rekodSimulasi',['uses'=>'AdminPageController@RekodSimulasiWTD']);
|
|
||||||
$router->post('wtd/prosesSimulasi',['uses'=>'AdminPageController@ProsesSimulasiWTD']);
|
|
||||||
$router->post('wtd/pengesahanSimulasi',['uses'=>'AdminPageController@PengesahanSimulasiWTD']);
|
|
||||||
$router->post('wtd/simulasiToDraft',['uses'=>'AdminPageController@SimulasiToDraft']);
|
|
||||||
$router->post('wtd/simulasiBaru',['uses'=>'AdminPageController@SimulasiBaru']);
|
|
||||||
|
|
||||||
//laporan wtd
|
|
||||||
$router->get('wtd/summaryWtd', ['uses' => 'WTDController@getSummaryWtd']);
|
|
||||||
|
|
||||||
//debugwtd
|
|
||||||
$router->get('wtd/debugWtd', ['uses' => 'WTDController@getDebugWtd']);
|
|
||||||
|
|
||||||
$router->get('audit/keuntungansebenar',['uses'=>'AdminPageController@KeuntunganSebenarExport']);
|
$router->get('audit/keuntungansebenar',['uses'=>'AdminPageController@KeuntunganSebenarExport']);
|
||||||
$router->get('laporan/aging',['uses'=>'AdminPageController@LaporanAging']);
|
$router->get('laporan/aging',['uses'=>'AdminPageController@LaporanAging']);
|
||||||
$router->get('dashboard/aging',['uses'=>'AdminPageController@DashboardAging']);
|
$router->get('dashboard/aging',['uses'=>'AdminPageController@DashboardAging']);
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
/debugbar
|
|
||||||
/framework/sessions
|
|
||||||
@@ -11,7 +11,7 @@ $all_active_db_keys = array_filter(array_keys(config('database.connections')), f
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$non_cawangan_database = ['lelong', config('tennant_database.master_db'), config('tennant_database.kaunter_db')];
|
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
|
||||||
|
|
||||||
$all_cawangan_db = array_filter($all_active_db_keys, function($db_key) use($non_cawangan_database){
|
$all_cawangan_db = array_filter($all_active_db_keys, function($db_key) use($non_cawangan_database){
|
||||||
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
||||||
|
|||||||
Reference in New Issue
Block a user