Skip to content

Commit

Permalink
RAHUL AUTO AGENCY parsing problem fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
subhranshuchoudhury committed Mar 8, 2024
1 parent 35dc16f commit f0a0df5
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions renderer/validation-new/modules/RAHUL_AUTO_AGENCY.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export const MAIN = (excelData: any) => {
console.log("RAHUL_AUTO_AGENCY", (excelData));
const closingBalanceIndex = getClosingBalanceIndex(excelData);
const OB = getOpeningBalance(excelData);
const CB = getClosingBalance(excelData);
const CB = getClosingBalance(excelData, closingBalanceIndex);
// const LD = getLedgerDuration(excelData);
const LT = getTransactionDetails(excelData);
const LT = getTransactionDetails(excelData, closingBalanceIndex);
const TCD = getTotalCreditAndDebit(LT);
return {
account: {
Expand All @@ -28,11 +29,11 @@ function getOpeningBalance(excelData: any): number {
return openingBalance;
}

function getClosingBalance(excelData: any): number {
const closingBalanceRow = excelData.length - 2;
function getClosingBalance(excelData: any, closingBalanceIndex: number): number {
const closingBalanceRow = closingBalanceIndex;
const fieldName = "__EMPTY_4";
const closingBalance = Number(excelData[closingBalanceRow][fieldName]);
console.log("Closing Balance", closingBalance);
console.log("--> Closing Balance", closingBalance);
return closingBalance;
}

Expand Down Expand Up @@ -63,10 +64,10 @@ function getLedgerDuration(excelData: any): { startDate: Date, endDate: Date } {

}

function getTransactionDetails(excelData: any): any[] {
function getTransactionDetails(excelData: any, closingBalanceIndex: number): any[] {
const transactionDetails = [];
const transactionStartRow = 7;
const transactionEndRow = excelData.length - 3;
const transactionEndRow = closingBalanceIndex - 1;
const creditFieldName = "__EMPTY_3";
const debitFieldName = "__EMPTY_2";
const dateFieldName = "RAHUL AUTO AGENCY PVT. LTD.";
Expand Down Expand Up @@ -116,5 +117,16 @@ function excelSerialToJSDate(serial: number): Date {
return resultDate;
}

function getClosingBalanceIndex(excelData: any) { // may not work for others
let closingBalanceIndex = 0;
for (let i = 0; i < excelData.length; i++) {
if (excelData[i].__EMPTY_1 === "Closing Balance") {
closingBalanceIndex = i;
break;
}
}
return closingBalanceIndex;
}



0 comments on commit f0a0df5

Please sign in to comment.