22 createColumnHelper ,
33 flexRender ,
44 getCoreRowModel ,
5- useReactTable
5+ useReactTable ,
66} from "@tanstack/react-table" ;
77import clsx from "clsx" ;
88import { format } from "date-fns" ;
@@ -294,6 +294,13 @@ export default function BalanceDetails() {
294294 . map ( ( account ) => Math . abs ( account . debit - account . credit ) )
295295 . reduce ( ( a , b ) => a + b , 0 ) ;
296296
297+ console . log (
298+ flatAccounts
299+ . filter ( ( account ) => account . debit < account . credit )
300+ . map ( ( acount ) => Math . abs ( acount . debit - acount . credit ) )
301+ . reduce ( ( a , b ) => a + b , 0 )
302+ ) ;
303+
297304 return (
298305 < >
299306 < Head >
@@ -621,7 +628,7 @@ export default function BalanceDetails() {
621628 { flatAccounts
622629 . filter (
623630 ( account ) =>
624- account . debit >= account . credit
631+ account . debit > account . credit
625632 )
626633 . map ( ( acount ) =>
627634 Math . abs ( acount . debit - acount . credit )
@@ -634,9 +641,12 @@ export default function BalanceDetails() {
634641 { flatAccounts
635642 . filter (
636643 ( account ) =>
637- account . debit <= account . credit
644+ account . debit < account . credit
638645 )
639- . reduce ( ( a , b ) => a + b . credit , 0 ) }
646+ . map ( ( acount ) =>
647+ Math . abs ( acount . debit - acount . credit )
648+ )
649+ . reduce ( ( a , b ) => a + b , 0 ) }
640650 </ span >
641651 </ td >
642652 </ tr >
@@ -757,8 +767,8 @@ export default function BalanceDetails() {
757767 className = "flex flex-row justify-between"
758768 >
759769 < span >
760- { formatAccount ( account . accountNumber ) } . { " " }
761- { account . accountName }
770+ { formatAccount ( account . accountNumber ) }
771+ . { account . accountName }
762772 </ span >
763773 { Math . abs (
764774 account . debit - account . credit
@@ -780,8 +790,8 @@ export default function BalanceDetails() {
780790 className = "flex flex-row justify-between"
781791 >
782792 < span >
783- { formatAccount ( account . accountNumber ) } . { " " }
784- { account . accountName }
793+ { formatAccount ( account . accountNumber ) }
794+ . { account . accountName }
785795 </ span >
786796 { Math . abs (
787797 account . debit - account . credit
@@ -812,8 +822,8 @@ export default function BalanceDetails() {
812822 className = "flex flex-row justify-between"
813823 >
814824 < span >
815- { formatAccount ( account . accountNumber ) } . { " " }
816- { account . accountName }
825+ { formatAccount ( account . accountNumber ) }
826+ . { account . accountName }
817827 </ span >
818828 { Math . abs (
819829 account . debit - account . credit
@@ -835,9 +845,12 @@ export default function BalanceDetails() {
835845 { flatAccounts
836846 . filter (
837847 ( account ) =>
838- ( account . accountNumber . startsWith (
848+ ( ( account . accountNumber . startsWith (
839849 "4"
840- ) ||
850+ ) &&
851+ ! account . accountNumber . startsWith (
852+ "445"
853+ ) ) ||
841854 account . accountNumber . startsWith (
842855 "16"
843856 ) ) &&
@@ -849,8 +862,8 @@ export default function BalanceDetails() {
849862 className = "flex flex-row justify-between"
850863 >
851864 < span >
852- { formatAccount ( account . accountNumber ) } . { " " }
853- { account . accountName }
865+ { formatAccount ( account . accountNumber ) }
866+ . { account . accountName }
854867 </ span >
855868 { Math . abs (
856869 account . debit - account . credit
@@ -899,6 +912,9 @@ export default function BalanceDetails() {
899912 . filter (
900913 ( account ) =>
901914 account . accountNumber . startsWith ( "4" ) &&
915+ ! account . accountNumber . startsWith (
916+ "445"
917+ ) &&
902918 account . credit > account . debit
903919 )
904920 . map ( ( account ) =>
@@ -934,16 +950,18 @@ function LedgerTable({
934950} : LedgerTableProps ) {
935951 const maxDebit = Math . max (
936952 0 ,
937- ... transactions
953+ transactions
938954 . filter ( ( item ) => item . type === "DEBIT" )
939955 . map ( ( item ) => item . amount )
956+ . reduce ( ( a , b ) => a + b , 0 )
940957 ) ;
941958
942959 const maxCredit = Math . max (
943960 0 ,
944- ... transactions
961+ transactions
945962 . filter ( ( item ) => item . type === "CREDIT" )
946963 . map ( ( item ) => item . amount )
964+ . reduce ( ( a , b ) => a + b , 0 )
947965 ) ;
948966
949967 const difference = Math . abs ( maxDebit - maxCredit ) ;
0 commit comments