Skip to content

Commit

Permalink
Merge pull request #154 from icefoganalytics/test
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
datajohnson authored Sep 19, 2023
2 parents 1d46b4e + 0755264 commit d499f8a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 113 deletions.
3 changes: 1 addition & 2 deletions db/4_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4023,8 +4023,7 @@ BEGIN
INNER JOIN sfa.assessment a ON fr.id = a.funding_request_id
INNER JOIN sfa.disbursement d ON a.id = d.assessment_id
INNER JOIN sfa.person p ON p.id = s.person_id
LEFT JOIN sfa.person_address pa ON pa.person_id = p.id AND pa.address_type_id = 1
LEFT JOIN sfa.person_address pam ON pa.person_id = p.id AND pa.address_type_id = 2
LEFT JOIN sfa.person_address pa ON pa.person_id = p.id AND pa.id = app.primary_address_id
LEFT JOIN sfa.msfaa m ON s.id = m.student_id
WHERE fr.request_type_id IN (4, 5)
AND d.csl_cert_seq_number = @CSL_CERT_SEQ_P
Expand Down
214 changes: 104 additions & 110 deletions src/api/repositories/disbursement/disbursement-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,146 +5,140 @@ import { IMainTable } from "../i-main-table";
import { PortalStatusDTO } from "models/dto/PortalStatusDTO";

export class DisbursementRepository extends BaseRepository implements IMainTable {
protected mainTable: string = "sfa.disbursement";

private disbursement: Partial<DisbursementDTO> = {};

constructor(maindb: Knex<any, unknown>) {
super(maindb);
}

getMainTable(): string {
return this.mainTable;
}

getDisbursementTable(disbursement: DisbursementDTO): DisbursementTable {
return Object.keys(disbursement)
.filter((key) => disbursementColumns.includes(key as keyof DisbursementTable))
.reduce((obj: any, key) => {
obj[key as keyof DisbursementTable] = disbursement[key as keyof DisbursementTable];
return obj as DisbursementTable;
}, {});
}

async getByAssessmentId(assessment_id: number | undefined): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];

if (assessment_id) {
const query = await this.mainDb(this.mainTable)
.select("*")
.where({ assessment_id: assessment_id })
.orderBy("id", "asc");

query.forEach((x: DisbursementDTO) => {
x.delete_flag = false;
result.push(x);
});
}

protected mainTable: string = "sfa.disbursement";

private disbursement: Partial<DisbursementDTO> = {};
return result;
}

constructor(maindb: Knex<any, unknown>) {
super(maindb);
}
async getECertificateList(assessment_id: number | undefined): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];

getMainTable(): string {
return this.mainTable;
}
if (assessment_id) {
const query = await this.mainDb(this.mainTable)
.select("*")
.where({ assessment_id: assessment_id })
.whereNotNull("csl_cert_seq_number")
.orderBy("id", "asc");

getDisbursementTable(disbursement: DisbursementDTO): DisbursementTable {
return Object.keys(disbursement)
.filter(key => disbursementColumns.includes(key as keyof DisbursementTable))
.reduce((obj: any, key) => {
obj[key as keyof DisbursementTable] = disbursement[key as keyof DisbursementTable];
return obj as DisbursementTable;
}, {});
query.forEach((x: DisbursementDTO) => result.push(x));
}

async getByAssessmentId(assessment_id: number | undefined): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];

if (assessment_id) {
const query = await this.mainDb(this.mainTable)
.select(
"*"
)
.where({ assessment_id: assessment_id })
.orderBy("id", "asc");

query.forEach((x: DisbursementDTO) => {
x.delete_flag = false;
result.push(x);
});
}

return result;
}
return result;
}

async getECertificateList(assessment_id: number | undefined): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];

if (assessment_id) {
const query = await this.mainDb(this.mainTable)
.select(
"*"
)
.where({ assessment_id: assessment_id })
.whereNull("financial_batch_id")
.orderBy("id", "asc");

query.forEach((x: DisbursementDTO) => result.push(x));
}

return result;
}
async getPortalStatusList(): Promise<Array<Partial<PortalStatusDTO>>> {
let result: Array<Partial<PortalStatusDTO>> = [];

async getPortalStatusList(): Promise<Array<Partial<PortalStatusDTO>>> {
let result: Array<Partial<PortalStatusDTO>> = [];

const query = await this.mainDb("sfa.portal_status")
.select(
"*"
)
.orderBy("id", "asc");

query.forEach((x: PortalStatusDTO) => result.push(x));

return result;
}
const query = await this.mainDb("sfa.portal_status").select("*").orderBy("id", "asc");

query.forEach((x: PortalStatusDTO) => result.push(x));

async getTotalGrantAmount(application_id?: number): Promise<number> {
let result = 0;
return result;
}

if (application_id) {
result = await this.getScalarValue<number>("fn_get_total_grant_amount", [application_id]);
}
async getTotalGrantAmount(application_id?: number): Promise<number> {
let result = 0;

return result;
if (application_id) {
result = await this.getScalarValue<number>("fn_get_total_grant_amount", [application_id]);
}

async getGrantAmount(application_id?: number, request_type_id?: number): Promise<number> {
let result = 0;
return result;
}

if (application_id && request_type_id) {
result = await this.getScalarValue<number>("fn_get_grant_amount", [application_id, request_type_id]);
}
async getGrantAmount(application_id?: number, request_type_id?: number): Promise<number> {
let result = 0;

return result;
if (application_id && request_type_id) {
result = await this.getScalarValue<number>("fn_get_grant_amount", [application_id, request_type_id]);
}

async getDisbursedAmount(funding_request_id?: number, assessment_id?: number): Promise<number> {
let result = 0;
return result;
}

if (funding_request_id && assessment_id) {
result = await this.getScalarValue<number>("fn_get_disbursed_amount_fct", [funding_request_id, assessment_id]);
}
async getDisbursedAmount(funding_request_id?: number, assessment_id?: number): Promise<number> {
let result = 0;

return result;
if (funding_request_id && assessment_id) {
result = await this.getScalarValue<number>("fn_get_disbursed_amount_fct", [funding_request_id, assessment_id]);
}

async getPreviousDisbursedAmount(funding_request_id?: number, assessment_id?: number): Promise<number> {
let result = 0;
return result;
}

if (funding_request_id && assessment_id) {
result = await this.getScalarValue<number>("fn_get_previous_disbursed_amount", [funding_request_id, assessment_id]);
}
async getPreviousDisbursedAmount(funding_request_id?: number, assessment_id?: number): Promise<number> {
let result = 0;

return result;
if (funding_request_id && assessment_id) {
result = await this.getScalarValue<number>("fn_get_previous_disbursed_amount", [
funding_request_id,
assessment_id,
]);
}

async getMaxTransaction(funding_request_id?: number): Promise<string> {
let result = 0;
return result;
}

if (funding_request_id) {
result = await this.getScalarValue<number>("fn_get_disbursement_max_transaction", [funding_request_id]);
}
async getMaxTransaction(funding_request_id?: number): Promise<string> {
let result = 0;

return result.toString();
if (funding_request_id) {
result = await this.getScalarValue<number>("fn_get_disbursement_max_transaction", [funding_request_id]);
}

async getNextTransactionSequenceValue(): Promise<string> {
const query = await this.mainDb.raw("SELECT NEXT VALUE FOR sfa.CSL_TRANSACTION_SEQ as nextVal;");
const result: Partial<{ nextVal?: number }> = this.singleResult(query);
return result.nextVal?.toString() ?? '0';
}
return result.toString();
}

async getTopDisbursements(application_id?: number): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];
async getNextTransactionSequenceValue(): Promise<string> {
const query = await this.mainDb.raw("SELECT NEXT VALUE FOR sfa.CSL_TRANSACTION_SEQ as nextVal;");
const result: Partial<{ nextVal?: number }> = this.singleResult(query);
return result.nextVal?.toString() ?? "0";
}

if (application_id) {
result = await this.mainDb.raw(`SELECT * FROM sfa.fn_get_top_disbursements(${application_id})`);
if (!Array.isArray(result)) {
result = [];
}
}
async getTopDisbursements(application_id?: number): Promise<Array<Partial<DisbursementDTO>>> {
let result: Array<Partial<DisbursementDTO>> = [];

return result;
if (application_id) {
result = await this.mainDb.raw(`SELECT * FROM sfa.fn_get_top_disbursements(${application_id})`);
if (!Array.isArray(result)) {
result = [];
}
}
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<v-card-title>E-Certificate</v-card-title>
<div class="col-xs-12 col-sm-12 col-lg-12 d-flex noppading-bottom">
<div class="col-xs-2 col-sm-2 col-lg-2 nopadding d-flex align-center justify-center">
<p class="nomargin">Cart #</p>
<p class="nomargin">Cert #</p>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2 nopadding d-flex align-center justify-center">
<p class="nomargin">Sent Date</p>
Expand Down

0 comments on commit d499f8a

Please sign in to comment.