Skip to content

Commit

Permalink
Merge pull request #10872 from hmislk/10857-create-supplier-payment-v…
Browse files Browse the repository at this point in the history
…oucher

10857 create supplier payment voucher
  • Loading branch information
buddhika75 authored Mar 3, 2025
2 parents 92efbcd + 901c6ad commit 928c868
Show file tree
Hide file tree
Showing 169 changed files with 8,923 additions and 2,787 deletions.
6 changes: 3 additions & 3 deletions .github/scripts/db_export_import_scheduler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ if [[ ! -f "$CONFIG_FILE" ]]; then
exit 1
fi

# Ensure TO_ENV is QA
if [[ "$TO_ENV" != "QA" ]]; then
echo "Error: TO_ENV must be QA for now."
# Ensure TO_ENV is either QA or COOP_Test
if [[ "$TO_ENV" != "QA" && "$TO_ENV" != "COOP_Test" ]]; then
echo "Error: TO_ENV must be QA or COOP_Test for now."
exit 1
fi

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/database_export_import_scheduler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ on:
- COOP_Prod
- Ruhunu_Prod
- MP_Prod
- RMH_Prod
- SLH_Prod
toEnv:
description: 'Select Environment to Import'
required: true
type: choice
options:
- QA
- COOP_Test
date:
description: 'Select Scheduling Date (YYYY-MM-DD)'
required: true
Expand Down
141 changes: 141 additions & 0 deletions .github/workflows/southernlanka_prod_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Southernlanka-PROD Build & Deployment Pipeline

on:
push:
branches:
- southernlanka-prod

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven Packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Update JDBC Data Sources in persistence.xml
run: |
sed -i 's|<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/SouthernLanka</jta-data-source>|' src/main/resources/META-INF/persistence.xml
sed -i 's|<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/SouthernLankaAudit</jta-data-source>|' src/main/resources/META-INF/persistence.xml
- name: Verify JDBC Data Sources in persistence.xml
run: |
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
- name: Build with Maven
run: mvn clean package -DskipTests

- name: Archive Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: target/*.war
overwrite: true

# - name: Run Tests
# run: mvn test

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./

- name: Deploy to Payara
env:
SERVER_IP: ${{ secrets.SOUTHERNLANKA_PROD_SERVER_IP }}
SERVER_USER: ${{ secrets.SOUTHERNLANKA_PROD_SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SOUTHERNLANKA_PROD_SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.SOUTHERNLANKA_PROD_PAYARA_ADMIN_PASS }}
run: |
# Add SSH private key to the SSH agent
echo "$SSH_PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
# Variables
WAR_NAME="southernlanka.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="southernlanka"
SUBDOMAIN="southernlanka"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
mkdir -p $WAR_DIR
chown -R appuser:appuser $WAR_DIR
cd $WAR_DIR
# Remove old backup if it exists
if [ -f $WAR_NAME.old ]; then
rm $WAR_NAME.old
fi
# If the current WAR file exists, back it up
if [ -f $WAR_NAME ]; then
mv $WAR_NAME $WAR_NAME.old
fi
"
# Copy new WAR file to the server
rsync -aL --progress -e "ssh -i private_key.pem" ./*.war $SERVER_USER@$SERVER_IP:$WAR_DIR/$WAR_NAME
# Set the WAR file permission
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
chown appuser:appuser $WAR_DIR/$WAR_NAME
"
# Deploy the WAR using asadmin
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy $APP_NAME || true
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force=true --contextroot $APP_NAME $WAR_DIR/$WAR_NAME
rm /tmp/payara-admin-pass.txt
"
# Validate if the application is running
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q '$APP_NAME'; then
echo 'Application is running.'
else
echo 'Application failed to start.'
fi
rm /tmp/payara-admin-pass.txt
"
# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
if [ "$RESPONSE_CODE" == "200" ]; then
echo "Application is reachable and healthy."
break
elif [ "$i" == "5" ]; then
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
done
# Cleanup
rm -f private_key.pem
141 changes: 141 additions & 0 deletions .github/workflows/southernlanka_stg_ci_cd .yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Southernlanka-STG Build & Deployment Pipeline

on:
push:
branches:
- southernlanka-stg

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven Packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Update JDBC Data Sources in persistence.xml
run: |
sed -i 's|<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/SouthernlankaStg</jta-data-source>|' src/main/resources/META-INF/persistence.xml
sed -i 's|<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>|<jta-data-source>jdbc/SouthernlankaStgAudit</jta-data-source>|' src/main/resources/META-INF/persistence.xml
- name: Verify JDBC Data Sources in persistence.xml
run: |
grep '<jta-data-source>' src/main/resources/META-INF/persistence.xml
- name: Build with Maven
run: mvn clean package -DskipTests

- name: Archive Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: target/*.war
overwrite: true

# - name: Run Tests
# run: mvn test

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./

- name: Deploy to Payara
env:
SERVER_IP: ${{ secrets.SOUTHERNLANKA_STG_SERVER_IP }}
SERVER_USER: ${{ secrets.SOUTHERNLANKA_STG_SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SOUTHERNLANKA_STG_SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.SOUTHERNLANKA_STG_PAYARA_ADMIN_PASS }}
run: |
# Add SSH private key to the SSH agent
echo "$SSH_PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
# Variables
WAR_NAME="southernlanka.war"
WAR_DIR="/home/appuser/app/latest"
APP_NAME="southernlanka"
SUBDOMAIN="stg"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
mkdir -p $WAR_DIR
chown -R appuser:appuser $WAR_DIR
cd $WAR_DIR
# Remove old backup if it exists
if [ -f $WAR_NAME.old ]; then
rm $WAR_NAME.old
fi
# If the current WAR file exists, back it up
if [ -f $WAR_NAME ]; then
mv $WAR_NAME $WAR_NAME.old
fi
"
# Copy new WAR file to the server
rsync -aL --progress -e "ssh -i private_key.pem" ./*.war $SERVER_USER@$SERVER_IP:$WAR_DIR/$WAR_NAME
# Set the WAR file permission
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
chown appuser:appuser $WAR_DIR/$WAR_NAME
"
# Deploy the WAR using asadmin
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy $APP_NAME || true
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force=true --contextroot $APP_NAME $WAR_DIR/$WAR_NAME
rm /tmp/payara-admin-pass.txt
"
# Validate if the application is running
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=$PAYARA_ADMIN_PASS' > /tmp/payara-admin-pass.txt
if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q '$APP_NAME'; then
echo 'Application is running.'
else
echo 'Application failed to start.'
fi
rm /tmp/payara-admin-pass.txt
"
# Check if the application is reachable
for i in {1..5}; do
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://$SUBDOMAIN.carecode.org/$APP_NAME/faces/index1.xhtml)
if [ "$RESPONSE_CODE" == "200" ]; then
echo "Application is reachable and healthy."
break
elif [ "$i" == "5" ]; then
echo "Application is not reachable or unhealthy at https://$SUBDOMAIN.carecode.org/$APP_NAME (HTTP $RESPONSE_CODE)"
break
fi
sleep 10
done
# Cleanup
rm -f private_key.pem
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@
<type>jar</type>
</dependency>

<!-- MySQL Connector -->
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.4.0</version>
</dependency>


<!-- OpenPDF -->
<dependency>
<groupId>com.github.librepdf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ public String navigateToFinancialTransactionIndex() {
return "/cashier/index?faces-redirect=true;";
}

public String navigateToPaymentManagement() {
if (sessionController.getPaymentManagementAfterShiftStart()) {
findNonClosedShiftStartFundBillIsAvailable();
if (getNonClosedShiftStartFundBill() != null) {
return "/payments/pay_index?faces-redirect=true";
} else {
JsfUtil.addErrorMessage("Start Your Shift First !");
return "/cashier/index?faces-redirect=true";
}
} else {
return "/payments/pay_index?faces-redirect=true";
}
}

public String navigateToNewIncomeBill() {
resetClassVariables();
currentBill = new Bill();
Expand Down Expand Up @@ -3688,7 +3702,7 @@ public List<Payment> fetchAllPaymentInMyHold(Bill shiftStartBill, WebUser wu) {
}
return finalOtherPayments;
}

public List<Payment> fetchAllPaymentInMyHold(Date paramFromDate, Date paramToDate, WebUser wu) {
WebUser paymentUser = wu;
StringBuilder jpqlBuilder = new StringBuilder("SELECT p ")
Expand Down Expand Up @@ -4712,6 +4726,7 @@ public String settleHandoverStartBill() {
}

billController.save(currentBill);
bundle.setHandoverBill(currentBill);

return "/cashier/handover_creation_bill_print?faces-redirect=true";
}
Expand Down Expand Up @@ -5023,6 +5038,10 @@ public String acceptHandoverBillAndWriteToCashbook() {
currentBill.setBillClassType(BillClassType.PreBill);
currentBill.setReferenceBill(selectedBill);

String deptId = billNumberGenerator.departmentBillNumberGeneratorYearly(sessionController.getDepartment(), BillTypeAtomic.FUND_SHIFT_HANDOVER_ACCEPT);

currentBill.setDeptId(deptId);
currentBill.setInsId(deptId);
currentBill.setDepartment(sessionController.getDepartment());
currentBill.setFromDepartment(cashbookDepartment);
currentBill.setToDepartment(sessionController.getDepartment());
Expand Down Expand Up @@ -5111,6 +5130,8 @@ public String acceptHandoverBillAndWriteToCashbook() {

billController.save(currentBill);

bundle.setHandoverBill(currentBill);

selectedBill.setCompleted(true);
selectedBill.setCompletedAt(new Date());
selectedBill.setCompletedBy(sessionController.getLoggedUser());
Expand Down
Loading

0 comments on commit 928c868

Please sign in to comment.