@controleonline/ui-common 1.2.120 → 1.2.121
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,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.120",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.2.
|
|
4
|
+
"branch": "rc/1.2.120-rc.1",
|
|
5
5
|
"baseMaster": "d88e3ddf8397cc22b4dac04522cb000cf43cfeb8",
|
|
6
6
|
"tasks": [
|
|
7
|
-
128
|
|
7
|
+
128,
|
|
8
|
+
131
|
|
8
9
|
],
|
|
9
10
|
"frozen": true,
|
|
10
11
|
"repositories": {
|
|
11
|
-
"ControleOnline/ui-common": "
|
|
12
|
+
"ControleOnline/ui-common": "7998dc134d7be0e72c864ff0cb6408fd109c561c"
|
|
12
13
|
}
|
|
13
14
|
}
|
package/package.json
CHANGED
|
@@ -16,6 +16,8 @@ import Formatter from '@controleonline/ui-common/src/utils/formatter';
|
|
|
16
16
|
import {
|
|
17
17
|
buildCashDrilldownNavigation,
|
|
18
18
|
buildCashSummaryParams,
|
|
19
|
+
resolveDeviceLabel,
|
|
20
|
+
sumDeviceBalances,
|
|
19
21
|
} from '@controleonline/ui-common/src/react/utils/cashRegisterSummary';
|
|
20
22
|
|
|
21
23
|
const PERIOD_OPTIONS = [
|
|
@@ -80,6 +82,8 @@ export default function CashRegisterSummary() {
|
|
|
80
82
|
);
|
|
81
83
|
|
|
82
84
|
const payments = data?.payments || [];
|
|
85
|
+
const devices = data?.devices || [];
|
|
86
|
+
const devicesTotal = sumDeviceBalances(devices);
|
|
83
87
|
|
|
84
88
|
return (
|
|
85
89
|
<ScrollView
|
|
@@ -165,6 +169,34 @@ export default function CashRegisterSummary() {
|
|
|
165
169
|
</TouchableOpacity>
|
|
166
170
|
);
|
|
167
171
|
})}
|
|
172
|
+
|
|
173
|
+
<Text style={styles.sectionTitle}>Por dispositivo</Text>
|
|
174
|
+
|
|
175
|
+
{devices.length === 0 && !loading && (
|
|
176
|
+
<Text style={styles.empty}>Nenhuma movimentação por dispositivo no período.</Text>
|
|
177
|
+
)}
|
|
178
|
+
|
|
179
|
+
{devices.map(item => (
|
|
180
|
+
<View
|
|
181
|
+
key={`device-${item.deviceId ?? 'none'}`}
|
|
182
|
+
testID={`cash-device-${item.deviceId ?? 'none'}`}
|
|
183
|
+
style={styles.row}>
|
|
184
|
+
<View style={styles.rowInfo}>
|
|
185
|
+
<Text style={styles.rowTitle}>{resolveDeviceLabel(item)}</Text>
|
|
186
|
+
<Text style={styles.rowSub}>{item.quantity} lançamentos</Text>
|
|
187
|
+
</View>
|
|
188
|
+
<Text style={styles.rowValue}>{Formatter.formatMoney(item.balance)}</Text>
|
|
189
|
+
</View>
|
|
190
|
+
))}
|
|
191
|
+
|
|
192
|
+
{devices.length > 0 && (
|
|
193
|
+
<View style={styles.row}>
|
|
194
|
+
<View style={styles.rowInfo}>
|
|
195
|
+
<Text style={styles.rowTitle}>Total por dispositivo</Text>
|
|
196
|
+
</View>
|
|
197
|
+
<Text style={styles.rowValue}>{Formatter.formatMoney(devicesTotal)}</Text>
|
|
198
|
+
</View>
|
|
199
|
+
)}
|
|
168
200
|
</>
|
|
169
201
|
)}
|
|
170
202
|
</ScrollView>
|
|
@@ -190,6 +222,7 @@ const styles = StyleSheet.create({
|
|
|
190
222
|
totalLabel: {color: '#64748B', fontSize: 12},
|
|
191
223
|
totalValue: {fontSize: 26, fontWeight: '800', color: '#0F766E'},
|
|
192
224
|
totalSub: {color: '#64748B', fontSize: 12, marginTop: 4},
|
|
225
|
+
sectionTitle: {marginTop: 8, fontSize: 15, fontWeight: '800', color: '#0F172A'},
|
|
193
226
|
empty: {textAlign: 'center', color: '#64748B', marginTop: 16},
|
|
194
227
|
row: {flexDirection: 'row', alignItems: 'center', backgroundColor: '#FFFFFF', borderRadius: 10, padding: 14, borderWidth: 1, borderColor: '#E2E8F0'},
|
|
195
228
|
rowInfo: {flex: 1},
|
|
@@ -42,4 +42,21 @@ const buildCashDrilldownNavigation = (item, summary) => {
|
|
|
42
42
|
return {routeName: 'FinancialHubPage', params: {cashFilter}};
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/** Label of a device row; rows without device are grouped as "Sem dispositivo". */
|
|
46
|
+
const resolveDeviceLabel = item => {
|
|
47
|
+
if (item?.deviceId === null || item?.deviceId === undefined) return 'Sem dispositivo';
|
|
48
|
+
return String(item?.label || item?.device || `#${item.deviceId}`);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Sum of the device balances, rounded to cents (must equal the payment block total). */
|
|
52
|
+
const sumDeviceBalances = devices =>
|
|
53
|
+
Math.round((devices || []).reduce((sum, item) => sum + Number(item?.balance || 0), 0) * 100) / 100;
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
PERIODS,
|
|
57
|
+
isValidDate,
|
|
58
|
+
buildCashSummaryParams,
|
|
59
|
+
buildCashDrilldownNavigation,
|
|
60
|
+
resolveDeviceLabel,
|
|
61
|
+
sumDeviceBalances,
|
|
62
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const test = require('node:test');
|
|
2
2
|
const assert = require('node:assert/strict');
|
|
3
|
-
const {buildCashSummaryParams, buildCashDrilldownNavigation, isValidDate} = require('../../../react/utils/cashRegisterSummary');
|
|
3
|
+
const {buildCashSummaryParams, buildCashDrilldownNavigation, isValidDate, resolveDeviceLabel, sumDeviceBalances} = require('../../../react/utils/cashRegisterSummary');
|
|
4
4
|
|
|
5
5
|
test('requires company and a known period', () => {
|
|
6
6
|
assert.deepEqual(buildCashSummaryParams({period: 'today'}), {error: 'company'});
|
|
@@ -39,3 +39,16 @@ test('drill-down is disabled without payment type or valid period', () => {
|
|
|
39
39
|
assert.equal(buildCashDrilldownNavigation({paymentTypeId: null}, {from: '2026-11-01', to: '2026-11-30'}), null);
|
|
40
40
|
assert.equal(buildCashDrilldownNavigation({paymentTypeId: 1}, {from: 'x', to: '2026-11-30'}), null);
|
|
41
41
|
});
|
|
42
|
+
|
|
43
|
+
test('device label uses the backend label with fallbacks and groups rows without device', () => {
|
|
44
|
+
assert.equal(resolveDeviceLabel({deviceId: 4, label: 'Balcao (123456)'}), 'Balcao (123456)');
|
|
45
|
+
assert.equal(resolveDeviceLabel({deviceId: 4, device: 'web-6'}), 'web-6');
|
|
46
|
+
assert.equal(resolveDeviceLabel({deviceId: 4}), '#4');
|
|
47
|
+
assert.equal(resolveDeviceLabel({deviceId: null}), 'Sem dispositivo');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('device balances sum matches the payment total without float drift', () => {
|
|
51
|
+
assert.equal(sumDeviceBalances([{balance: 1140.01}, {balance: 2}]), 1142.01);
|
|
52
|
+
assert.equal(sumDeviceBalances([{balance: 0.1}, {balance: 0.2}]), 0.3);
|
|
53
|
+
assert.equal(sumDeviceBalances(undefined), 0);
|
|
54
|
+
});
|