@controleonline/ui-common 1.2.119 → 1.2.120
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.119",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.2.
|
|
5
|
-
"baseMaster": "
|
|
4
|
+
"branch": "rc/1.2.119-rc.1",
|
|
5
|
+
"baseMaster": "d88e3ddf8397cc22b4dac04522cb000cf43cfeb8",
|
|
6
6
|
"tasks": [
|
|
7
|
-
|
|
7
|
+
128
|
|
8
8
|
],
|
|
9
9
|
"frozen": true,
|
|
10
10
|
"repositories": {
|
|
11
|
-
"ControleOnline/ui-common": "
|
|
11
|
+
"ControleOnline/ui-common": "6bb419444fabf184d89c7738795617cb7b527246"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
TouchableOpacity,
|
|
10
10
|
View,
|
|
11
11
|
} from 'react-native';
|
|
12
|
-
import {useFocusEffect} from '@react-navigation/native';
|
|
12
|
+
import {useFocusEffect, useNavigation} from '@react-navigation/native';
|
|
13
13
|
import {useStore} from '@store';
|
|
14
14
|
import {api} from '@controleonline/ui-common/src/api';
|
|
15
15
|
import Formatter from '@controleonline/ui-common/src/utils/formatter';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
buildCashDrilldownNavigation,
|
|
18
|
+
buildCashSummaryParams,
|
|
19
|
+
} from '@controleonline/ui-common/src/react/utils/cashRegisterSummary';
|
|
17
20
|
|
|
18
21
|
const PERIOD_OPTIONS = [
|
|
19
22
|
{key: 'today', label: 'Hoje'},
|
|
@@ -34,6 +37,7 @@ const ERROR_MESSAGES = {
|
|
|
34
37
|
* Refs: ControleOnline/ui-common#128
|
|
35
38
|
*/
|
|
36
39
|
export default function CashRegisterSummary() {
|
|
40
|
+
const navigation = useNavigation();
|
|
37
41
|
const peopleStore = useStore('people');
|
|
38
42
|
const {currentCompany} = peopleStore.getters || {};
|
|
39
43
|
const [period, setPeriod] = useState('today');
|
|
@@ -141,15 +145,26 @@ export default function CashRegisterSummary() {
|
|
|
141
145
|
<Text style={styles.empty}>Nenhuma movimentação no período.</Text>
|
|
142
146
|
)}
|
|
143
147
|
|
|
144
|
-
{payments.map(item =>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
{payments.map(item => {
|
|
149
|
+
const target = buildCashDrilldownNavigation(item, data);
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<TouchableOpacity
|
|
153
|
+
key={`${item.paymentTypeId}-${item.paymentType}`}
|
|
154
|
+
testID={`cash-payment-${item.paymentTypeId}`}
|
|
155
|
+
style={styles.row}
|
|
156
|
+
disabled={!target}
|
|
157
|
+
activeOpacity={0.8}
|
|
158
|
+
onPress={() => target && navigation.navigate(target.routeName, target.params)}>
|
|
159
|
+
<View style={styles.rowInfo}>
|
|
160
|
+
<Text style={styles.rowTitle}>{item.paymentType}</Text>
|
|
161
|
+
<Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
|
|
162
|
+
</View>
|
|
163
|
+
<Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
|
|
164
|
+
{!!target && <Text style={styles.rowChevron}>›</Text>}
|
|
165
|
+
</TouchableOpacity>
|
|
166
|
+
);
|
|
167
|
+
})}
|
|
153
168
|
</>
|
|
154
169
|
)}
|
|
155
170
|
</ScrollView>
|
|
@@ -181,4 +196,5 @@ const styles = StyleSheet.create({
|
|
|
181
196
|
rowTitle: {fontWeight: '700', color: '#0F172A'},
|
|
182
197
|
rowSub: {color: '#64748B', fontSize: 12},
|
|
183
198
|
rowValue: {fontWeight: '700', color: '#0F172A'},
|
|
199
|
+
rowChevron: {marginLeft: 8, fontSize: 22, color: '#94A3B8'},
|
|
184
200
|
});
|
|
@@ -27,4 +27,19 @@ const buildCashSummaryParams = ({companyId, period, from, to, device}) => {
|
|
|
27
27
|
return {params};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Params for navigating from a payment-type row to FinancialHubPage, keeping the
|
|
32
|
+
* period shown on the Caixa screen. Returns null for rows without payment type.
|
|
33
|
+
*/
|
|
34
|
+
const buildCashDrilldownNavigation = (item, summary) => {
|
|
35
|
+
const paymentTypeId = Number(item?.paymentTypeId);
|
|
36
|
+
if (!Number.isInteger(paymentTypeId) || paymentTypeId <= 0) return null;
|
|
37
|
+
if (!isValidDate(summary?.from) || !isValidDate(summary?.to)) return null;
|
|
38
|
+
|
|
39
|
+
const cashFilter = {paymentTypeId, from: summary.from, to: summary.to};
|
|
40
|
+
if (summary.scope === 'user' && summary.userId) cashFilter.userId = summary.userId;
|
|
41
|
+
|
|
42
|
+
return {routeName: 'FinancialHubPage', params: {cashFilter}};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = {PERIODS, isValidDate, buildCashSummaryParams, buildCashDrilldownNavigation};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const test = require('node:test');
|
|
2
2
|
const assert = require('node:assert/strict');
|
|
3
|
-
const {buildCashSummaryParams, isValidDate} = require('../../../react/utils/cashRegisterSummary');
|
|
3
|
+
const {buildCashSummaryParams, buildCashDrilldownNavigation, isValidDate} = require('../../../react/utils/cashRegisterSummary');
|
|
4
4
|
|
|
5
5
|
test('requires company and a known period', () => {
|
|
6
6
|
assert.deepEqual(buildCashSummaryParams({period: 'today'}), {error: 'company'});
|
|
@@ -21,3 +21,21 @@ test('custom period validates dates and order', () => {
|
|
|
21
21
|
});
|
|
22
22
|
assert.equal(isValidDate('2026-10-01'), true);
|
|
23
23
|
});
|
|
24
|
+
|
|
25
|
+
test('drill-down keeps payment type and period from the summary', () => {
|
|
26
|
+
const summary = {from: '2026-11-01', to: '2026-11-30', scope: 'company'};
|
|
27
|
+
assert.deepEqual(buildCashDrilldownNavigation({paymentTypeId: 63}, summary), {
|
|
28
|
+
routeName: 'FinancialHubPage',
|
|
29
|
+
params: {cashFilter: {paymentTypeId: 63, from: '2026-11-01', to: '2026-11-30'}},
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('drill-down carries the user when the scope is the user', () => {
|
|
34
|
+
const nav = buildCashDrilldownNavigation({paymentTypeId: 1}, {from: '2026-11-07', to: '2026-11-07', scope: 'user', userId: 6});
|
|
35
|
+
assert.equal(nav.params.cashFilter.userId, 6);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('drill-down is disabled without payment type or valid period', () => {
|
|
39
|
+
assert.equal(buildCashDrilldownNavigation({paymentTypeId: null}, {from: '2026-11-01', to: '2026-11-30'}), null);
|
|
40
|
+
assert.equal(buildCashDrilldownNavigation({paymentTypeId: 1}, {from: 'x', to: '2026-11-30'}), null);
|
|
41
|
+
});
|