Skip to content

Commit

Permalink
ver 2.0.2 - Download report (beta), missMatchReport Enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
subhranshuchoudhury committed Feb 16, 2024
1 parent fd36ac1 commit b590f8e
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Jyeshtha",
"JYESTHA",
"MAHAVIR",
"nextron",
"officedocument",
"openxmlformats",
"otherdata",
Expand All @@ -13,6 +14,7 @@
"Pymt",
"RAHUL",
"spreadsheetml",
"tailwindcss",
"TOPSEL",
"xslx"
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "jyeshtha-motors",
"description": "Ledger bill calculation application for Jyestha Motors",
"version": "2.0.1",
"version": "2.0.2",
"author": "Jyeshtha Motors <[email protected]>",
"main": "app/background.js",
"scripts": {
Expand All @@ -16,6 +16,7 @@
"daisyui": "^4.5.0",
"electron-serve": "^1.1.0",
"electron-store": "^8.1.0",
"json-as-xlsx": "^2.5.6",
"prop-types": "^15.8.1",
"react-dropdown-select": "^4.11.1",
"react-hot-toast": "^2.4.1",
Expand Down
30 changes: 26 additions & 4 deletions renderer/pages/components/Analyzer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useEffect, useState } from 'react'
import { compareCreditDebitCounts, compareCreditDebitCountsReverse } from '../../validation-new/analyze'
import { missMatchEnhance } from '../../validation-new/utils/missMatchEnhance';
import { generateReport } from '../../validation-new/utils/generateReport';
export default function Analyzer(props: any) {
const { ownLedger, creditorsLedger, toggleViewer } = props;

Expand All @@ -23,7 +25,9 @@ export default function Analyzer(props: any) {

compareCreditDebitCounts(ownLedger?.transactions, creditorsLedger?.transactions).then((res) => {
// console.log("Mismatch", res);
setMismatchData(res);
const finalResult = missMatchEnhance(res);
// generateReport(finalResult, [], ownLedger, creditorsLedger);
setMismatchData(finalResult);
if (!res) {
setIsPass(true);
} else {
Expand All @@ -33,7 +37,10 @@ export default function Analyzer(props: any) {

compareCreditDebitCountsReverse(ownLedger?.transactions, creditorsLedger?.transactions).then((res) => {
// console.log("Mismatch", res);
setMismatchDataTwo(res);
const finalResult = missMatchEnhance(res);
// generateReport([], finalResult, ownLedger, creditorsLedger);

setMismatchDataTwo(finalResult);
if (!res) {
setIsPass(true);
} else {
Expand All @@ -50,6 +57,15 @@ export default function Analyzer(props: any) {

</div>

{
MismatchDataTwo?.length > 0 || MismatchData?.length > 0 ? <div>
<div className='flex justify-between items-center bg-gray-700 p-4 rounded-md m-10'>
<p>DOWNLOAD REPORT</p>
<button onClick={() => generateReport(MismatchData, MismatchDataTwo, ownLedger, creditorsLedger)} className='btn btn-primary'>Download</button>
</div>
</div> : null
}

{
MismatchData?.length > 0 ? <div className='flex justify-center mb-8 mt-14'>
<MissMatchStats isReverse={false} Data={MismatchData} ownTransactions={ownLedger?.transactions} creditorsTransactions={creditorsLedger?.transactions} />
Expand Down Expand Up @@ -126,7 +142,7 @@ const LedgerStats = (props: any) => {

<div className="stat place-items-center">
<div className="stat-title">{isOwn ? "Bills" : "Payments"}</div>
<div className="stat-value text-blue-600">{Data?.totalCredit?.toLocaleString('en-IN', {
<div className="stat-value text-blue-600">{Data?.[isOwn ? "totalCredit" : "totalDebit"]?.toLocaleString('en-IN', {
maximumFractionDigits: 2,
style: 'currency',
currency: 'INR'
Expand All @@ -136,7 +152,7 @@ const LedgerStats = (props: any) => {

<div className="stat place-items-center">
<div className="stat-title">{isOwn ? "Payments" : "Bills"}</div>
<div className="stat-value text-blue-600">{Data?.totalDebit?.toLocaleString('en-IN', {
<div className="stat-value text-blue-600">{Data?.[isOwn ? "totalDebit" : "totalCredit"]?.toLocaleString('en-IN', {
maximumFractionDigits: 2,
style: 'currency',
currency: 'INR'
Expand All @@ -149,6 +165,7 @@ const LedgerStats = (props: any) => {

const MissMatchStats = (props: any) => {
const { Data, ownTransactions, creditorsTransactions, isReverse } = props;
console.log("MISSMATCH", isReverse, Data)
return <ul data-theme="dark" className="timeline timeline-snap-icon max-md:timeline-compact timeline-vertical">

{
Expand Down Expand Up @@ -182,6 +199,7 @@ const MissMatchStats = (props: any) => {
<th>Date</th>
<th>Credit</th>
<th>Debit</th>
<th>Type</th>
</tr>
</thead>
<tbody>
Expand All @@ -199,6 +217,7 @@ const MissMatchStats = (props: any) => {
<td>{ownTransactions[idx]?.date.toDateString()}</td>
<td>{ownTransactions[idx]?.credit}</td>
<td>{ownTransactions[idx]?.debit}</td>
<td>{ownTransactions[idx]?.type}</td>
</tr>
})
}
Expand All @@ -212,6 +231,7 @@ const MissMatchStats = (props: any) => {
<td>{creditorsTransactions[idx]?.date.toDateString()}</td>
<td>{creditorsTransactions[idx]?.credit}</td>
<td>{creditorsTransactions[idx]?.debit}</td>
<td>{creditorsTransactions[idx]?.type}</td>
</tr>
})
}
Expand All @@ -225,6 +245,7 @@ const MissMatchStats = (props: any) => {
<td>{creditorsTransactions[idx]?.date.toDateString()}</td>
<td>{creditorsTransactions[idx]?.credit}</td>
<td>{creditorsTransactions[idx]?.debit}</td>
<td>{creditorsTransactions[idx]?.type}</td>
</tr>
})
}
Expand All @@ -238,6 +259,7 @@ const MissMatchStats = (props: any) => {
<td>{ownTransactions[idx]?.date.toDateString()}</td>
<td>{ownTransactions[idx]?.credit}</td>
<td>{ownTransactions[idx]?.debit}</td>
<td>{ownTransactions[idx]?.type}</td>
</tr>
})
}
Expand Down
29 changes: 16 additions & 13 deletions renderer/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Head from 'next/head'
import Link from 'next/link'
import Image from 'next/image'


export default function HomePage() {
return (
<React.Fragment>
Expand All @@ -16,7 +15,11 @@ export default function HomePage() {
<main className='flex flex-col h-screen'>
<div data-theme="forest" className="navbar bg-base-100">
<div className="flex-1">
<a className="btn btn-ghost text-xl">JYESHTHA MOTORS</a>
<div className='flex-col'>

<p className="btn btn-ghost text-xl font-mono">LEDGER ANALYZER</p>
<p className='ml-4 text-xs font-mono mb-3'>Jyestha Motors</p>
</div>
</div>
<div className="flex-none">
<div className="dropdown dropdown-end">
Expand All @@ -29,20 +32,20 @@ export default function HomePage() {
</div>
<ul tabIndex={0} className="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52">
<li>
<a className="justify-between">
Profile
<a target='_blank' href='https://github.com/subhranshuchoudhury/Ledger-Analyzer/releases' className="justify-between">
Download
<span className="badge">New</span>
</a>
</li>
<li><a>Settings</a></li>

</ul>
</div>
</div>
</div>
</div >
</div >

{/* Middle Buttons */}

<div className='flex justify-center items-center h-screen'>
< div className='flex justify-center items-center h-screen' >

{/* <Link href={"/menu/calculate"}>
<div className='flex flex-col h-56 w-56 rounded-md shadow-2xl justify-center items-center cursor-pointer hover:bg-gray-600'>
Expand All @@ -53,18 +56,18 @@ export default function HomePage() {
</div>
</Link> */}

<Link href={"/menu/calculate-new"}>
< Link href={"/menu/calculate-new"} >
<div className='flex flex-col h-56 w-56 rounded-md shadow-2xl justify-center items-center cursor-pointer hover:bg-gray-600'>
<div className='bg-blue-500 hover:bg-pink-400 justify-center flex items-center h-32 w-52 rounded-md p-10'>
<Image width={90} height={90} alt="Jm Logo" src="/images/calculate-budget.png" />
</div>
<p className='flex justify-center items-end mt-5 uppercase font-bold text-white'>Analyze Files</p>
</div>
</Link>
</Link >

</div>
</div >

</main>
</React.Fragment>
</main >
</React.Fragment >
)
}
2 changes: 1 addition & 1 deletion renderer/pages/menu/calculate-new/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function CalculatePage() {
<div data-theme="dark">
<div className="navbar mt-2">

<div className="flex-1">
<div className="flex-1 mt-2">
<div onClick={() => router.back()} className='hover:cursor-pointer'>
<Image width={40} height={40} alt="back button" src="/images/back.png" />
</div>
Expand Down
20 changes: 20 additions & 0 deletions renderer/test/LedgerMissmatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const missMatchSchemaDemo = [
{
amount: 4000,
creditCount: 1,
debitCount: 2,
indexes: {
ledgerOne: [28, 87],
ledgerTwo: [28]
}
},
{
amount: 4000,
creditCount: 1,
debitCount: 2,
indexes: {
ledgerOne: [28, 87],
ledgerTwo: [28]
}
}
]
Loading

0 comments on commit b590f8e

Please sign in to comment.