digikhata-mashreq-sdk 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/lib/module/App.js +41 -0
- package/lib/module/App.js.map +1 -0
- package/lib/module/app/assets/Icons/Bill.png +0 -0
- package/lib/module/app/assets/Icons/Cash.png +0 -0
- package/lib/module/app/assets/Icons/Expense.png +0 -0
- package/lib/module/app/assets/Icons/Staff.png +0 -0
- package/lib/module/app/assets/Icons/Stock.png +0 -0
- package/lib/module/app/assets/images/bill.png +0 -0
- package/lib/module/app/assets/images/book.png +0 -0
- package/lib/module/app/assets/images/digiKhataSolo256.png +0 -0
- package/lib/module/app/assets/images/money.png +0 -0
- package/lib/module/app/assets/images/staff.png +0 -0
- package/lib/module/app/assets/images/stock.png +0 -0
- package/lib/module/app/assets/images/svgviewer-png-output-white.png +0 -0
- package/lib/module/app/components/Balance.js +153 -0
- package/lib/module/app/components/Balance.js.map +1 -0
- package/lib/module/app/components/CountryPhoneInput.js +271 -0
- package/lib/module/app/components/CountryPhoneInput.js.map +1 -0
- package/lib/module/app/components/Entries.js +89 -0
- package/lib/module/app/components/Entries.js.map +1 -0
- package/lib/module/app/components/SearchBar.js +70 -0
- package/lib/module/app/components/SearchBar.js.map +1 -0
- package/lib/module/app/components/Transaction.js +108 -0
- package/lib/module/app/components/Transaction.js.map +1 -0
- package/lib/module/app/components/User.js +109 -0
- package/lib/module/app/components/User.js.map +1 -0
- package/lib/module/app/components/index.js +10 -0
- package/lib/module/app/components/index.js.map +1 -0
- package/lib/module/app/database/clients.js +149 -0
- package/lib/module/app/database/clients.js.map +1 -0
- package/lib/module/app/database/database.js +9 -0
- package/lib/module/app/database/database.js.map +1 -0
- package/lib/module/app/database/schema.js +525 -0
- package/lib/module/app/database/schema.js.map +1 -0
- package/lib/module/app/navigation/BottomTabs/BottomTabs.js +29 -0
- package/lib/module/app/navigation/BottomTabs/BottomTabs.js.map +1 -0
- package/lib/module/app/navigation/Drawer/Drawer.js +13 -0
- package/lib/module/app/navigation/Drawer/Drawer.js.map +1 -0
- package/lib/module/app/navigation/HomeStack/HomeStack.js +36 -0
- package/lib/module/app/navigation/HomeStack/HomeStack.js.map +1 -0
- package/lib/module/app/navigation/Root.js +26 -0
- package/lib/module/app/navigation/Root.js.map +1 -0
- package/lib/module/app/navigation/index.js +7 -0
- package/lib/module/app/navigation/index.js.map +1 -0
- package/lib/module/app/redux/Store.js +10 -0
- package/lib/module/app/redux/Store.js.map +1 -0
- package/lib/module/app/redux/reducers/client/client_actions.js +2 -0
- package/lib/module/app/redux/reducers/client/client_actions.js.map +1 -0
- package/lib/module/app/redux/reducers/client/client_reducers.js +26 -0
- package/lib/module/app/redux/reducers/client/client_reducers.js.map +1 -0
- package/lib/module/app/redux/reducers/client/client_types.js +7 -0
- package/lib/module/app/redux/reducers/client/client_types.js.map +1 -0
- package/lib/module/app/screens/AddScreen.js +200 -0
- package/lib/module/app/screens/AddScreen.js.map +1 -0
- package/lib/module/app/screens/Banks.js +126 -0
- package/lib/module/app/screens/Banks.js.map +1 -0
- package/lib/module/app/screens/CustomerEntries.js +475 -0
- package/lib/module/app/screens/CustomerEntries.js.map +1 -0
- package/lib/module/app/screens/Customers.js +233 -0
- package/lib/module/app/screens/Customers.js.map +1 -0
- package/lib/module/app/screens/Entry.js +696 -0
- package/lib/module/app/screens/Entry.js.map +1 -0
- package/lib/module/app/screens/HomeScreen.js +176 -0
- package/lib/module/app/screens/HomeScreen.js.map +1 -0
- package/lib/module/app/screens/SelectBusiness.js +201 -0
- package/lib/module/app/screens/SelectBusiness.js.map +1 -0
- package/lib/module/app/screens/Splash.js +51 -0
- package/lib/module/app/screens/Splash.js.map +1 -0
- package/lib/module/app/screens/Suppliers.js +222 -0
- package/lib/module/app/screens/Suppliers.js.map +1 -0
- package/lib/module/app/screens/TransactionDetails.js +301 -0
- package/lib/module/app/screens/TransactionDetails.js.map +1 -0
- package/lib/module/app/screens/index.js +14 -0
- package/lib/module/app/screens/index.js.map +1 -0
- package/lib/module/app/themes/config.js +156 -0
- package/lib/module/app/themes/config.js.map +1 -0
- package/lib/module/app/utils/countries.json +1930 -0
- package/lib/module/declarations.d.js +2 -0
- package/lib/module/declarations.d.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/babel.config.d.ts +10 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/eslint.config.d.mts +3 -0
- package/lib/typescript/eslint.config.d.mts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/App.d.ts +2 -0
- package/lib/typescript/src/App.d.ts.map +1 -0
- package/lib/typescript/src/app/components/Balance.d.ts +8 -0
- package/lib/typescript/src/app/components/Balance.d.ts.map +1 -0
- package/lib/typescript/src/app/components/CountryPhoneInput.d.ts +6 -0
- package/lib/typescript/src/app/components/CountryPhoneInput.d.ts.map +1 -0
- package/lib/typescript/src/app/components/Entries.d.ts +4 -0
- package/lib/typescript/src/app/components/Entries.d.ts.map +1 -0
- package/lib/typescript/src/app/components/SearchBar.d.ts +6 -0
- package/lib/typescript/src/app/components/SearchBar.d.ts.map +1 -0
- package/lib/typescript/src/app/components/Transaction.d.ts +11 -0
- package/lib/typescript/src/app/components/Transaction.d.ts.map +1 -0
- package/lib/typescript/src/app/components/User.d.ts +10 -0
- package/lib/typescript/src/app/components/User.d.ts.map +1 -0
- package/lib/typescript/src/app/components/index.d.ts +8 -0
- package/lib/typescript/src/app/components/index.d.ts.map +1 -0
- package/lib/typescript/src/app/database/clients.d.ts +9 -0
- package/lib/typescript/src/app/database/clients.d.ts.map +1 -0
- package/lib/typescript/src/app/database/database.d.ts +3 -0
- package/lib/typescript/src/app/database/database.d.ts.map +1 -0
- package/lib/typescript/src/app/database/schema.d.ts +2 -0
- package/lib/typescript/src/app/database/schema.d.ts.map +1 -0
- package/lib/typescript/src/app/navigation/BottomTabs/BottomTabs.d.ts +2 -0
- package/lib/typescript/src/app/navigation/BottomTabs/BottomTabs.d.ts.map +1 -0
- package/lib/typescript/src/app/navigation/Drawer/Drawer.d.ts +2 -0
- package/lib/typescript/src/app/navigation/Drawer/Drawer.d.ts.map +1 -0
- package/lib/typescript/src/app/navigation/HomeStack/HomeStack.d.ts +2 -0
- package/lib/typescript/src/app/navigation/HomeStack/HomeStack.d.ts.map +1 -0
- package/lib/typescript/src/app/navigation/Root.d.ts +2 -0
- package/lib/typescript/src/app/navigation/Root.d.ts.map +1 -0
- package/lib/typescript/src/app/navigation/index.d.ts +5 -0
- package/lib/typescript/src/app/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/app/redux/Store.d.ts +2 -0
- package/lib/typescript/src/app/redux/Store.d.ts.map +1 -0
- package/lib/typescript/src/app/redux/reducers/client/client_actions.d.ts +1 -0
- package/lib/typescript/src/app/redux/reducers/client/client_actions.d.ts.map +1 -0
- package/lib/typescript/src/app/redux/reducers/client/client_reducers.d.ts +3 -0
- package/lib/typescript/src/app/redux/reducers/client/client_reducers.d.ts.map +1 -0
- package/lib/typescript/src/app/redux/reducers/client/client_types.d.ts +5 -0
- package/lib/typescript/src/app/redux/reducers/client/client_types.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/AddScreen.d.ts +5 -0
- package/lib/typescript/src/app/screens/AddScreen.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/Banks.d.ts +2 -0
- package/lib/typescript/src/app/screens/Banks.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/CustomerEntries.d.ts +5 -0
- package/lib/typescript/src/app/screens/CustomerEntries.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/Customers.d.ts +4 -0
- package/lib/typescript/src/app/screens/Customers.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/Entry.d.ts +5 -0
- package/lib/typescript/src/app/screens/Entry.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/HomeScreen.d.ts +4 -0
- package/lib/typescript/src/app/screens/HomeScreen.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/SelectBusiness.d.ts +4 -0
- package/lib/typescript/src/app/screens/SelectBusiness.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/Splash.d.ts +4 -0
- package/lib/typescript/src/app/screens/Splash.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/Suppliers.d.ts +4 -0
- package/lib/typescript/src/app/screens/Suppliers.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/TransactionDetails.d.ts +5 -0
- package/lib/typescript/src/app/screens/TransactionDetails.d.ts.map +1 -0
- package/lib/typescript/src/app/screens/index.d.ts +12 -0
- package/lib/typescript/src/app/screens/index.d.ts.map +1 -0
- package/lib/typescript/src/app/themes/config.d.ts +63 -0
- package/lib/typescript/src/app/themes/config.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +154 -0
- package/src/App.js +41 -0
- package/src/app/assets/Icons/Bill.png +0 -0
- package/src/app/assets/Icons/Cash.png +0 -0
- package/src/app/assets/Icons/Expense.png +0 -0
- package/src/app/assets/Icons/Staff.png +0 -0
- package/src/app/assets/Icons/Stock.png +0 -0
- package/src/app/assets/images/bill.png +0 -0
- package/src/app/assets/images/book.png +0 -0
- package/src/app/assets/images/digiKhataSolo256.png +0 -0
- package/src/app/assets/images/money.png +0 -0
- package/src/app/assets/images/staff.png +0 -0
- package/src/app/assets/images/stock.png +0 -0
- package/src/app/assets/images/svgviewer-png-output-white.png +0 -0
- package/src/app/components/Balance.js +122 -0
- package/src/app/components/CountryPhoneInput.js +286 -0
- package/src/app/components/Entries.js +75 -0
- package/src/app/components/SearchBar.js +64 -0
- package/src/app/components/Transaction.js +91 -0
- package/src/app/components/User.js +85 -0
- package/src/app/components/index.js +15 -0
- package/src/app/database/clients.js +207 -0
- package/src/app/database/database.js +9 -0
- package/src/app/database/schema.js +525 -0
- package/src/app/navigation/BottomTabs/BottomTabs.js +27 -0
- package/src/app/navigation/Drawer/Drawer.js +10 -0
- package/src/app/navigation/HomeStack/HomeStack.js +43 -0
- package/src/app/navigation/Root.js +32 -0
- package/src/app/navigation/index.js +9 -0
- package/src/app/redux/Store.js +9 -0
- package/src/app/redux/reducers/client/client_actions.js +0 -0
- package/src/app/redux/reducers/client/client_reducers.js +30 -0
- package/src/app/redux/reducers/client/client_types.js +5 -0
- package/src/app/screens/AddScreen.js +185 -0
- package/src/app/screens/Banks.js +151 -0
- package/src/app/screens/CustomerEntries.js +402 -0
- package/src/app/screens/Customers.js +240 -0
- package/src/app/screens/Entry.js +658 -0
- package/src/app/screens/HomeScreen.js +146 -0
- package/src/app/screens/SelectBusiness.js +177 -0
- package/src/app/screens/Splash.js +43 -0
- package/src/app/screens/Suppliers.js +228 -0
- package/src/app/screens/TransactionDetails.js +199 -0
- package/src/app/screens/index.js +23 -0
- package/src/app/themes/config.js +185 -0
- package/src/app/utils/countries.json +1930 -0
- package/src/declarations.d.ts +1 -0
- package/src/index.tsx +3 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { View, Text, StyleSheet, TouchableOpacity, FlatList } from 'react-native'
|
|
2
|
+
import React, { useState, useEffect } from 'react'
|
|
3
|
+
import LinearGradient from 'react-native-linear-gradient'
|
|
4
|
+
import Ionicons from "react-native-vector-icons/Ionicons"
|
|
5
|
+
import { COLORS, FONT_MEDIUM, FONT_NORMAL, formatDateTime, HP, WP } from '../themes/config'
|
|
6
|
+
import { useSelector } from "react-redux";
|
|
7
|
+
import { getClientTransactions } from '../database/clients'
|
|
8
|
+
import { SearchBar, Transaction } from '../components'
|
|
9
|
+
|
|
10
|
+
export default function CustomerEntries({ navigation, route }) {
|
|
11
|
+
|
|
12
|
+
const ClientDetails = useSelector(state => state.client.client_details);
|
|
13
|
+
const homeDetails = route?.params?.homeDetails;
|
|
14
|
+
|
|
15
|
+
let amount = homeDetails?.total_subamount - homeDetails?.total_amount;
|
|
16
|
+
|
|
17
|
+
let type = "none";
|
|
18
|
+
if (amount > 0) {
|
|
19
|
+
type = "receivable";
|
|
20
|
+
} else if (amount < 0) {
|
|
21
|
+
type = "payable";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
amount = Math.abs(amount);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const [Entries, setEntries] = useState([]);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const unsubscribe = navigation.addListener('focus', () => {
|
|
31
|
+
getClientTransactions(ClientDetails.id).then((res) => {
|
|
32
|
+
setEntries(res)
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
return () => unsubscribe();
|
|
36
|
+
}, [navigation]);
|
|
37
|
+
|
|
38
|
+
const options = [
|
|
39
|
+
{
|
|
40
|
+
name: "Report",
|
|
41
|
+
icon: "document-outline",
|
|
42
|
+
disabled: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "Set Date",
|
|
46
|
+
icon: "calendar-outline",
|
|
47
|
+
disabled: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "Reminder",
|
|
51
|
+
icon: "logo-whatsapp",
|
|
52
|
+
disabled: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "SMS",
|
|
56
|
+
icon: "chatbox-ellipses-outline",
|
|
57
|
+
disabled: true,
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
const calculateBalances = (transactions) => {
|
|
62
|
+
let balance = 0
|
|
63
|
+
const reversed = [...transactions].reverse()
|
|
64
|
+
|
|
65
|
+
const withBalances = reversed.map((t) => {
|
|
66
|
+
const amount = parseFloat(t.amount) || 0
|
|
67
|
+
const subamount = parseFloat(t.subamount) || 0
|
|
68
|
+
balance += (subamount - amount)
|
|
69
|
+
return { ...t, balance }
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return withBalances.reverse()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const balancesData = calculateBalances(Entries)
|
|
76
|
+
|
|
77
|
+
// console.log(Entries)
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View style={Styles._mainContainer}>
|
|
81
|
+
<LinearGradient
|
|
82
|
+
style={Styles._headerMain}
|
|
83
|
+
start={{ x: 0, y: 0 }}
|
|
84
|
+
end={{ x: 1, y: 0 }}
|
|
85
|
+
colors={[COLORS.primaryColor, COLORS.secondaryColor]}
|
|
86
|
+
>
|
|
87
|
+
<TouchableOpacity
|
|
88
|
+
activeOpacity={0.8}
|
|
89
|
+
onPress={() => navigation?.goBack()}
|
|
90
|
+
>
|
|
91
|
+
<Ionicons
|
|
92
|
+
name={"chevron-back"}
|
|
93
|
+
color={COLORS.whiteColor}
|
|
94
|
+
size={25}
|
|
95
|
+
/>
|
|
96
|
+
</TouchableOpacity>
|
|
97
|
+
|
|
98
|
+
<View style={Styles._dataMain}>
|
|
99
|
+
<View style={Styles._nameMain}>
|
|
100
|
+
<Text style={Styles._nameTxt}>{ClientDetails?.name}</Text>
|
|
101
|
+
<View style={Styles._badge}>
|
|
102
|
+
<Text style={Styles._badgeText}>{ClientDetails.type == 0 ? "Customer" : "Supplier"}</Text>
|
|
103
|
+
</View>
|
|
104
|
+
</View>
|
|
105
|
+
<Text style={Styles._clickText}>Click here to view settings</Text>
|
|
106
|
+
</View>
|
|
107
|
+
|
|
108
|
+
<Ionicons
|
|
109
|
+
name={"ellipsis-vertical"}
|
|
110
|
+
color={COLORS.whiteColor}
|
|
111
|
+
size={25}
|
|
112
|
+
/>
|
|
113
|
+
</LinearGradient>
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
!Entries?.length &&
|
|
117
|
+
<View style={Styles._privacyMain}>
|
|
118
|
+
<Ionicons
|
|
119
|
+
name={"lock-closed"}
|
|
120
|
+
color={"green"}
|
|
121
|
+
size={20}
|
|
122
|
+
/>
|
|
123
|
+
|
|
124
|
+
<Text style={Styles._privacyText}>Only you can see these entries</Text>
|
|
125
|
+
</View>
|
|
126
|
+
}
|
|
127
|
+
{
|
|
128
|
+
!!Entries.length &&
|
|
129
|
+
<View style={Styles._contentMain}>
|
|
130
|
+
<LinearGradient
|
|
131
|
+
style={[Styles._headerMain, { height: 40 }]}
|
|
132
|
+
start={{ x: 0, y: 0 }}
|
|
133
|
+
end={{ x: 1, y: 0 }}
|
|
134
|
+
colors={[COLORS.primaryColor, COLORS.secondaryColor]}
|
|
135
|
+
/>
|
|
136
|
+
<View style={Styles._calculationMain}>
|
|
137
|
+
<Text style={{ color: type == "receivable" ? "green" : type == "payable" ? "red" : COLORS.blackColor, fontFamily: FONT_MEDIUM, fontSize: 14 }}>Rs {amount}</Text>
|
|
138
|
+
<Text style={{ color: COLORS.blackColor, opacity: 0.6, fontFamily: FONT_NORMAL, fontSize: 12 }}>{type == "receivable" ? "You'll Give" : type == "payable" ? (ClientDetails.type == 0 ? "You'll Get" : "Received") : "Settled Up"}</Text>
|
|
139
|
+
</View>
|
|
140
|
+
|
|
141
|
+
<View style={Styles._optionsMain}>
|
|
142
|
+
<FlatList
|
|
143
|
+
data={options}
|
|
144
|
+
horizontal
|
|
145
|
+
showsHorizontalScrollIndicator={false}
|
|
146
|
+
scrollEnabled={false}
|
|
147
|
+
keyExtractor={(item, index) => index.toString()}
|
|
148
|
+
contentContainerStyle={{ justifyContent: "space-between", width: "100%" }}
|
|
149
|
+
renderItem={({ item, index }) => (
|
|
150
|
+
<TouchableOpacity activeOpacity={0.8} style={Styles._listItem} key={index}>
|
|
151
|
+
<Ionicons name={item.icon} size={25} color={COLORS.yellowColor} />
|
|
152
|
+
<Text style={{ color: COLORS.blackColor, fontSize: 11, fontFamily: FONT_NORMAL, textAlign: "center" }}>{item.name}</Text>
|
|
153
|
+
</TouchableOpacity>
|
|
154
|
+
)}
|
|
155
|
+
/>
|
|
156
|
+
</View>
|
|
157
|
+
|
|
158
|
+
<View style={Styles._entriesMain}>
|
|
159
|
+
<SearchBar />
|
|
160
|
+
<View style={Styles._tableHeader}>
|
|
161
|
+
<View style={[Styles._headerCell, { width: "50%" }]}>
|
|
162
|
+
<Text style={Styles._headerCellText}>Entries</Text>
|
|
163
|
+
</View>
|
|
164
|
+
|
|
165
|
+
<View style={[Styles._headerCell, { alignItems: "flex-end" }]}>
|
|
166
|
+
<Text style={Styles._headerCellText}>{ClientDetails.type == 0 ? "You Gave" : "Payment"}</Text>
|
|
167
|
+
</View>
|
|
168
|
+
|
|
169
|
+
<View style={[Styles._headerCell, { alignItems: "flex-end" }]}>
|
|
170
|
+
<Text style={Styles._headerCellText}>{ClientDetails.type == 0 ? "You Got" : "Purchase"}</Text>
|
|
171
|
+
</View>
|
|
172
|
+
</View>
|
|
173
|
+
|
|
174
|
+
<FlatList
|
|
175
|
+
data={balancesData}
|
|
176
|
+
keyExtractor={(item, index) => index.toString()}
|
|
177
|
+
scrollEnabled
|
|
178
|
+
contentContainerStyle={{ paddingBottom: 150 }}
|
|
179
|
+
renderItem={({ item, index }) => (
|
|
180
|
+
<Transaction
|
|
181
|
+
balance={item.balance}
|
|
182
|
+
isAttachment={item?.attachments?.length ? true : false}
|
|
183
|
+
notes={item?.notes}
|
|
184
|
+
date={formatDateTime(item?.date)}
|
|
185
|
+
firstCell={item?.amount}
|
|
186
|
+
secondCell={item?.subamount}
|
|
187
|
+
onPress={() => navigation.navigate("TransactionDetails", { item })}
|
|
188
|
+
/>
|
|
189
|
+
)}
|
|
190
|
+
/>
|
|
191
|
+
</View>
|
|
192
|
+
</View>
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
<View style={Styles._btnsMain}>
|
|
196
|
+
<TouchableOpacity
|
|
197
|
+
style={Styles._btn}
|
|
198
|
+
activeOpacity={0.8}
|
|
199
|
+
onPress={() => navigation.navigate("Entry", { type: "red" })}
|
|
200
|
+
>
|
|
201
|
+
<LinearGradient
|
|
202
|
+
colors={["darkred", "red"]}
|
|
203
|
+
style={{ width: "100%", height: "100%", justifyContent: "center", alignItems: "center" }}
|
|
204
|
+
start={{ x: 0, y: 0 }}
|
|
205
|
+
end={{ x: 1, y: 0 }}
|
|
206
|
+
>
|
|
207
|
+
<Text style={Styles._btnTitle}>{ClientDetails.type == 0 ? "YOU GAVE" : "PAYMENT"} Rs</Text>
|
|
208
|
+
</LinearGradient>
|
|
209
|
+
</TouchableOpacity>
|
|
210
|
+
|
|
211
|
+
<TouchableOpacity
|
|
212
|
+
style={Styles._btn}
|
|
213
|
+
activeOpacity={0.8}
|
|
214
|
+
onPress={() => navigation.navigate("Entry", { type: "green" })}
|
|
215
|
+
>
|
|
216
|
+
<LinearGradient
|
|
217
|
+
colors={["darkgreen", "green"]}
|
|
218
|
+
style={{ width: "100%", height: "100%", justifyContent: "center", alignItems: "center" }}
|
|
219
|
+
start={{ x: 0, y: 0 }}
|
|
220
|
+
end={{ x: 1, y: 0 }}
|
|
221
|
+
>
|
|
222
|
+
<Text style={Styles._btnTitle}>{ClientDetails.type == 0 ? "YOU GOT" : "PURCHASE"} Rs</Text>
|
|
223
|
+
</LinearGradient>
|
|
224
|
+
</TouchableOpacity>
|
|
225
|
+
</View>
|
|
226
|
+
</View>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const Styles = StyleSheet.create({
|
|
231
|
+
_mainContainer: {
|
|
232
|
+
flex: 1,
|
|
233
|
+
backgroundColor: COLORS.backgroundColor,
|
|
234
|
+
},
|
|
235
|
+
_headerMain: {
|
|
236
|
+
width: WP(100),
|
|
237
|
+
height: 60,
|
|
238
|
+
flexDirection: "row",
|
|
239
|
+
alignItems: "center",
|
|
240
|
+
justifyContent: "space-between"
|
|
241
|
+
},
|
|
242
|
+
_dataMain: {
|
|
243
|
+
width: "80%",
|
|
244
|
+
height: "100%",
|
|
245
|
+
// backgroundColor: "red",
|
|
246
|
+
justifyContent: "center"
|
|
247
|
+
},
|
|
248
|
+
_nameMain: {
|
|
249
|
+
width: "100%",
|
|
250
|
+
height: "50%",
|
|
251
|
+
// backgroundColor: "pink",
|
|
252
|
+
flexDirection: "row",
|
|
253
|
+
alignItems: "center",
|
|
254
|
+
gap: 10
|
|
255
|
+
},
|
|
256
|
+
_badge: {
|
|
257
|
+
// height:10,
|
|
258
|
+
backgroundColor: COLORS.whiteColor,
|
|
259
|
+
paddingVertical: 2,
|
|
260
|
+
paddingHorizontal: 5,
|
|
261
|
+
justifyContent: "center",
|
|
262
|
+
alignItems: "center",
|
|
263
|
+
borderRadius: 50
|
|
264
|
+
},
|
|
265
|
+
_badgeText: {
|
|
266
|
+
fontFamily: FONT_NORMAL,
|
|
267
|
+
fontSize: 10,
|
|
268
|
+
color: COLORS.primaryColor
|
|
269
|
+
},
|
|
270
|
+
_nameTxt: {
|
|
271
|
+
color: COLORS.whiteColor,
|
|
272
|
+
fontFamily: FONT_MEDIUM,
|
|
273
|
+
fontSize: 15
|
|
274
|
+
},
|
|
275
|
+
_clickText: {
|
|
276
|
+
color: COLORS.whiteColor,
|
|
277
|
+
fontFamily: FONT_NORMAL,
|
|
278
|
+
fontSize: 13
|
|
279
|
+
},
|
|
280
|
+
_btnsMain: {
|
|
281
|
+
width: WP(100),
|
|
282
|
+
height: 60,
|
|
283
|
+
backgroundColor: COLORS.whiteColor,
|
|
284
|
+
position: "absolute",
|
|
285
|
+
bottom: 0,
|
|
286
|
+
flexDirection: "row",
|
|
287
|
+
justifyContent: "space-between",
|
|
288
|
+
alignItems: "center",
|
|
289
|
+
paddingHorizontal: 25
|
|
290
|
+
},
|
|
291
|
+
_btn: {
|
|
292
|
+
width: "47%",
|
|
293
|
+
height: "75%",
|
|
294
|
+
overflow: "hidden",
|
|
295
|
+
borderRadius: 100,
|
|
296
|
+
},
|
|
297
|
+
_btnTitle: {
|
|
298
|
+
color: COLORS.whiteColor,
|
|
299
|
+
fontFamily: FONT_MEDIUM,
|
|
300
|
+
fontSize: 14
|
|
301
|
+
},
|
|
302
|
+
_privacyMain: {
|
|
303
|
+
// width: "70%",
|
|
304
|
+
// height: 40,
|
|
305
|
+
backgroundColor: COLORS.whiteColor,
|
|
306
|
+
alignSelf: "center",
|
|
307
|
+
marginTop: 15,
|
|
308
|
+
borderRadius: 10,
|
|
309
|
+
flexDirection: "row",
|
|
310
|
+
alignItems: "center",
|
|
311
|
+
paddingHorizontal: 10,
|
|
312
|
+
paddingVertical: 10,
|
|
313
|
+
gap: 10
|
|
314
|
+
},
|
|
315
|
+
_privacyText: {
|
|
316
|
+
color: COLORS.blackColor,
|
|
317
|
+
opacity: 0.6,
|
|
318
|
+
fontFamily: FONT_NORMAL,
|
|
319
|
+
fontSize: 13
|
|
320
|
+
},
|
|
321
|
+
_contentMain: {
|
|
322
|
+
flex: 1,
|
|
323
|
+
width: "100%",
|
|
324
|
+
// height: "85%",
|
|
325
|
+
// backgroundColor: "red",
|
|
326
|
+
alignItems: "center"
|
|
327
|
+
},
|
|
328
|
+
_calculationMain: {
|
|
329
|
+
width: "95%",
|
|
330
|
+
height: 80,
|
|
331
|
+
backgroundColor: COLORS.whiteColor,
|
|
332
|
+
position: "absolute",
|
|
333
|
+
top: 10,
|
|
334
|
+
borderRadius: 12,
|
|
335
|
+
shadowColor: "#000",
|
|
336
|
+
shadowOffset: {
|
|
337
|
+
width: 0,
|
|
338
|
+
height: 2,
|
|
339
|
+
},
|
|
340
|
+
shadowOpacity: 0.2,
|
|
341
|
+
shadowRadius: 3.84,
|
|
342
|
+
elevation: 5,
|
|
343
|
+
justifyContent: "center",
|
|
344
|
+
paddingLeft: 20,
|
|
345
|
+
gap: 2,
|
|
346
|
+
},
|
|
347
|
+
_optionsMain: {
|
|
348
|
+
width: "95%",
|
|
349
|
+
// height: 80,
|
|
350
|
+
// backgroundColor: "red",
|
|
351
|
+
marginTop: 60,
|
|
352
|
+
},
|
|
353
|
+
_listItem: {
|
|
354
|
+
width: HP(9),
|
|
355
|
+
height: 65,
|
|
356
|
+
backgroundColor: COLORS.whiteColor,
|
|
357
|
+
justifyContent: "center",
|
|
358
|
+
alignItems: "center",
|
|
359
|
+
shadowColor: "#000",
|
|
360
|
+
shadowOffset: {
|
|
361
|
+
width: 0,
|
|
362
|
+
height: 2,
|
|
363
|
+
},
|
|
364
|
+
shadowOpacity: 0.2,
|
|
365
|
+
shadowRadius: 3.84,
|
|
366
|
+
elevation: 5,
|
|
367
|
+
margin: 5,
|
|
368
|
+
borderRadius: 12,
|
|
369
|
+
gap: 5,
|
|
370
|
+
},
|
|
371
|
+
_entriesMain: {
|
|
372
|
+
flex: 1,
|
|
373
|
+
width: "100%",
|
|
374
|
+
// height: 40,
|
|
375
|
+
backgroundColor: COLORS.whiteColor,
|
|
376
|
+
paddingHorizontal: 10,
|
|
377
|
+
marginTop: 10,
|
|
378
|
+
paddingTop: 10,
|
|
379
|
+
},
|
|
380
|
+
_tableHeader: {
|
|
381
|
+
width: "100%",
|
|
382
|
+
height: 30,
|
|
383
|
+
// backgroundColor: "red",
|
|
384
|
+
flexDirection: "row",
|
|
385
|
+
marginTop: 10,
|
|
386
|
+
borderBottomColor: COLORS.darkGrey,
|
|
387
|
+
borderBottomWidth: 0.7,
|
|
388
|
+
},
|
|
389
|
+
_headerCell: {
|
|
390
|
+
width: "25%",
|
|
391
|
+
height: "100%",
|
|
392
|
+
// backgroundColor: "pink",
|
|
393
|
+
justifyContent: "center",
|
|
394
|
+
paddingLeft: 5,
|
|
395
|
+
},
|
|
396
|
+
_headerCellText: {
|
|
397
|
+
color: COLORS.blackColor,
|
|
398
|
+
opacity: 0.5,
|
|
399
|
+
fontFamily: FONT_MEDIUM,
|
|
400
|
+
fontSize: 12
|
|
401
|
+
},
|
|
402
|
+
})
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'
|
|
2
|
+
import React, { useEffect } from 'react'
|
|
3
|
+
import { COLORS, FONT_NORMAL, formatDateTime, HP, WP } from '../themes/config'
|
|
4
|
+
import { Balance, Entries, SearchBar, User } from '../components'
|
|
5
|
+
import Ionicons from "react-native-vector-icons/Ionicons"
|
|
6
|
+
import FontAwesome6 from "react-native-vector-icons/FontAwesome6"
|
|
7
|
+
import LinearGradient from 'react-native-linear-gradient'
|
|
8
|
+
import { getAllClients, getClientDetails, getClientsByType } from '../database/clients';
|
|
9
|
+
import { useSelector, useDispatch } from "react-redux";
|
|
10
|
+
import { CLIENT_DETAILS, HOME_CUSTOMERS } from '../redux/reducers/client/client_types'
|
|
11
|
+
|
|
12
|
+
export default function Customers({ navigation }) {
|
|
13
|
+
|
|
14
|
+
const dispatch = useDispatch()
|
|
15
|
+
const clients = useSelector(state => state.client.home_customers);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const unsubscribe = navigation.addListener('focus', () => {
|
|
19
|
+
getClientsByType(0).then(clients => {
|
|
20
|
+
dispatch({ type: HOME_CUSTOMERS, payload: clients });
|
|
21
|
+
console.log("Clients:", clients);
|
|
22
|
+
}).catch(err => console.error(err));
|
|
23
|
+
});
|
|
24
|
+
return () => unsubscribe();
|
|
25
|
+
}, [navigation]);
|
|
26
|
+
|
|
27
|
+
const processed = clients.map((item) => {
|
|
28
|
+
let amount = (parseFloat(item?.total_subamount) || 0) - (parseFloat(item?.total_amount) || 0);
|
|
29
|
+
|
|
30
|
+
let type = "none";
|
|
31
|
+
if (amount > 0) {
|
|
32
|
+
type = "receivable";
|
|
33
|
+
} else if (amount < 0) {
|
|
34
|
+
type = "payable";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
type,
|
|
39
|
+
amount: Math.abs(amount),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const totals = processed.reduce(
|
|
44
|
+
(acc, item) => {
|
|
45
|
+
if (item.type === "receivable") {
|
|
46
|
+
acc.receivable += item.amount;
|
|
47
|
+
} else if (item.type === "payable") {
|
|
48
|
+
acc.payable += item.amount;
|
|
49
|
+
}
|
|
50
|
+
return acc;
|
|
51
|
+
},
|
|
52
|
+
{ receivable: 0, payable: 0 }
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<View style={Styles._mainContainer}>
|
|
59
|
+
<ScrollView
|
|
60
|
+
contentContainerStyle={{ alignItems: "center", paddingBottom: 60 }}
|
|
61
|
+
showsVerticalScrollIndicator={false}
|
|
62
|
+
>
|
|
63
|
+
<Balance
|
|
64
|
+
greenTitle={"You will give"}
|
|
65
|
+
greenValue={totals?.receivable}
|
|
66
|
+
redTitle={"You will get"}
|
|
67
|
+
redValue={totals?.payable}
|
|
68
|
+
/>
|
|
69
|
+
{/* <View style={{height:HP(7)}}></View> */}
|
|
70
|
+
<Entries marginTop={70} />
|
|
71
|
+
|
|
72
|
+
<View style={Styles._contentMain}>
|
|
73
|
+
<View style={Styles._searchMain}>
|
|
74
|
+
<View style={Styles._inputMain}>
|
|
75
|
+
<SearchBar />
|
|
76
|
+
</View>
|
|
77
|
+
|
|
78
|
+
<View style={Styles._filterMain}>
|
|
79
|
+
<TouchableOpacity
|
|
80
|
+
activeOpacity={0.8}
|
|
81
|
+
style={Styles._filterBtn}
|
|
82
|
+
>
|
|
83
|
+
<Ionicons
|
|
84
|
+
name={"funnel-outline"}
|
|
85
|
+
color={COLORS.primaryColor}
|
|
86
|
+
size={27}
|
|
87
|
+
/>
|
|
88
|
+
</TouchableOpacity>
|
|
89
|
+
|
|
90
|
+
<TouchableOpacity
|
|
91
|
+
activeOpacity={0.8}
|
|
92
|
+
style={Styles._filterBtn}
|
|
93
|
+
>
|
|
94
|
+
<FontAwesome6
|
|
95
|
+
name={"file-pdf"}
|
|
96
|
+
color={COLORS.primaryColor}
|
|
97
|
+
size={23}
|
|
98
|
+
/>
|
|
99
|
+
</TouchableOpacity>
|
|
100
|
+
</View>
|
|
101
|
+
</View>
|
|
102
|
+
|
|
103
|
+
<View>
|
|
104
|
+
{
|
|
105
|
+
clients.map((item, index) => {
|
|
106
|
+
let amount = item?.total_subamount - item?.total_amount;
|
|
107
|
+
|
|
108
|
+
let type = "none";
|
|
109
|
+
if (amount > 0) {
|
|
110
|
+
type = "receivable";
|
|
111
|
+
} else if (amount < 0) {
|
|
112
|
+
type = "payable";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
amount = Math.abs(amount);
|
|
116
|
+
|
|
117
|
+
// console.log({amount,type})
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<User
|
|
121
|
+
key={index}
|
|
122
|
+
name={item?.name}
|
|
123
|
+
addedAt={formatDateTime(item?.latest_updated_at)}
|
|
124
|
+
amount={amount}
|
|
125
|
+
type={type}
|
|
126
|
+
avatarColor={item?.avatarColor}
|
|
127
|
+
clientType={item?.type}
|
|
128
|
+
onPress={() => {
|
|
129
|
+
getClientDetails(item?.id).then((res) => {
|
|
130
|
+
dispatch({
|
|
131
|
+
type: CLIENT_DETAILS,
|
|
132
|
+
payload: res
|
|
133
|
+
})
|
|
134
|
+
navigation.navigate("CustomerEntries", { homeDetails: item })
|
|
135
|
+
})
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
</View>
|
|
143
|
+
</View>
|
|
144
|
+
</ScrollView>
|
|
145
|
+
|
|
146
|
+
<TouchableOpacity
|
|
147
|
+
style={Styles._floatingBtn}
|
|
148
|
+
activeOpacity={0.8}
|
|
149
|
+
onPress={() => {
|
|
150
|
+
navigation.navigate("AddScreen", { type: 0 });
|
|
151
|
+
}}
|
|
152
|
+
|
|
153
|
+
>
|
|
154
|
+
<LinearGradient
|
|
155
|
+
start={{ x: 0, y: 0 }}
|
|
156
|
+
end={{ x: 1, y: 0 }}
|
|
157
|
+
colors={[COLORS.secondaryColor, COLORS.primaryColor]}
|
|
158
|
+
style={Styles._linearGradient}
|
|
159
|
+
>
|
|
160
|
+
<Ionicons
|
|
161
|
+
name={"person-add-outline"}
|
|
162
|
+
color={COLORS.whiteColor}
|
|
163
|
+
size={22}
|
|
164
|
+
style={{ paddingLeft: 10 }}
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<Text style={Styles._fabTxt}>ADD CUSTOMER</Text>
|
|
168
|
+
</LinearGradient>
|
|
169
|
+
</TouchableOpacity>
|
|
170
|
+
</View>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const Styles = StyleSheet.create({
|
|
175
|
+
_mainContainer: {
|
|
176
|
+
flex: 1,
|
|
177
|
+
backgroundColor: COLORS.backgroundColor,
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
},
|
|
180
|
+
_contentMain: {
|
|
181
|
+
width: WP(100),
|
|
182
|
+
// height: 30,
|
|
183
|
+
backgroundColor: COLORS.whiteColor,
|
|
184
|
+
paddingHorizontal: 15,
|
|
185
|
+
marginTop: 6
|
|
186
|
+
},
|
|
187
|
+
_searchMain: {
|
|
188
|
+
width: "100%",
|
|
189
|
+
flexDirection: "row",
|
|
190
|
+
// height:40,
|
|
191
|
+
paddingVertical: 20,
|
|
192
|
+
},
|
|
193
|
+
_inputMain: {
|
|
194
|
+
width: "75%"
|
|
195
|
+
},
|
|
196
|
+
_filterMain: {
|
|
197
|
+
flexDirection: "row",
|
|
198
|
+
alignItems: "center",
|
|
199
|
+
justifyContent: "center",
|
|
200
|
+
gap: 11,
|
|
201
|
+
paddingLeft: 10
|
|
202
|
+
},
|
|
203
|
+
_filterBtn: {
|
|
204
|
+
width: 35,
|
|
205
|
+
height: 35,
|
|
206
|
+
justifyContent: "center",
|
|
207
|
+
alignItems: "center"
|
|
208
|
+
// backgroundColor:"red"
|
|
209
|
+
},
|
|
210
|
+
_floatingBtn: {
|
|
211
|
+
width: WP(38),
|
|
212
|
+
height: 42,
|
|
213
|
+
position: "absolute",
|
|
214
|
+
right: 12,
|
|
215
|
+
bottom: 70,
|
|
216
|
+
borderRadius: 40,
|
|
217
|
+
overflow: "hidden",
|
|
218
|
+
shadowColor: "#000",
|
|
219
|
+
shadowOffset: {
|
|
220
|
+
width: 0,
|
|
221
|
+
height: 2,
|
|
222
|
+
},
|
|
223
|
+
shadowOpacity: 0.2,
|
|
224
|
+
shadowRadius: 3.84,
|
|
225
|
+
elevation: 5,
|
|
226
|
+
},
|
|
227
|
+
_linearGradient: {
|
|
228
|
+
width: "100%",
|
|
229
|
+
height: "100%",
|
|
230
|
+
flexDirection: "row",
|
|
231
|
+
justifyContent: "space-between",
|
|
232
|
+
alignItems: "center",
|
|
233
|
+
},
|
|
234
|
+
_fabTxt: {
|
|
235
|
+
color: COLORS.whiteColor,
|
|
236
|
+
fontSize: 12,
|
|
237
|
+
fontFamily: FONT_NORMAL,
|
|
238
|
+
paddingRight: 10,
|
|
239
|
+
},
|
|
240
|
+
})
|