simba-mobile-cud/app/screens/wallet/HistoricScreen.js

1235 lines
66 KiB
JavaScript
Raw Normal View History

2025-01-07 09:47:45 +00:00
/**
* Project iLinkWorld
* File HistoricNanoSanteUserScreen
* Path screens/wallet/user
* Created by BRICE ZELE
* Date: 26/01/2022
*/
import React, {useEffect, useState} from 'react';
import {
ActivityIndicator, Alert,
Dimensions,
FlatList,
Platform,
ProgressBarAndroid,
ScrollView,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';
import isNil from 'lodash/isNil';
import {connect, useDispatch} from 'react-redux';
import {Color} from "../../config/Color";
import I18n from 'react-native-i18n';
import {ScreenComponent} from "../../components/ScreenComponent";
import {createStructuredSelector} from "reselect";
import {readUser} from "../../webservice/AuthApi";
import Text from '../../components/Text';
import * as Utils from "../../utils/UtilsFunction";
import {uppercaseFirstLetter} from "../../utils/UtilsFunction";
import Dialog from "react-native-dialog";
import {Typography} from "../../config/typography";
import Tag from "../../components/Tag";
import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
import {store} from "../../redux/store";
import AccordionComponent from "../../components/AccordionComponent";
import {selectHistoric} from "../../redux/historic/historic.selector";
import {fetchGeHistoricReset, fetchGetHistoric, fetchGetHistoricPending} from "../../redux/historic/historic.actions";
let moment = require('moment-timezone');
const {width, height} = Dimensions.get('window');
const HistoricScreen = ({
navigation,
fetchGetHistoric,
historic
}) => {
const dispatch = useDispatch();
const [user, setUser] = useState(null);
const [displayModalHistory, setDisplayModalHistory] = useState(false);
const [historyItemDetail, setHistoryItemDetail] = useState({});
const [displaySuperHyperModalHistory, setDisplaySuperHyperModalHistory] = useState(false);
const [page, setPage] = useState(1);
const [historiqueDetailLabel, setHistoriqueDetailLabel] = useState(I18n.t('AVIS_IMPOSITION'));
const [loadMore, setLoadMore] = useState(false);
const [historyResult, setHistoryResult] = useState([]);
const [isDisplayHistoryOrdreRecette, setIsDisplayHistoryOrdreRecette]= useState(false);
const [isDisplayHistoryDeclaration, setIsDisplayHistoryDeclaration]= useState(false);
const [isDisplayHistoryReceipt, setIsDisplayHistoryReceipt]= useState(false);
const [wallet] = useState(store.getState().walletDetailReducer.result.response);
function useForceUpdate() {
const [value, setValue] = useState(0); // integer state
return () => setValue(value => value + 1); // update the state to force render
}
const forceUpdate = useForceUpdate();
useEffect(() => {
dispatch(fetchGeHistoricReset());
readUser().then((user) => {
setUser(user);
console.log("User", user);
switch (user.category) {
case "super":
console.log("ON est pas superviseur nous");
fetchGetHistoric(`${user.agentId}?page=1&perPage=40`, false, 1);
break;
case "hyper":
fetchGetHistoric(`${user.network_id}?page=1&perPage=20`, true, 1);
break;
case "geolocated":
fetchGetHistoric(`${user.agentId}?page=1&perPage=20`, null, 0);
break;
}
});
}, []);
useEffect(() => {
if (historic.result !== null) {
if (page < historic.result.response.last_page)
setHistoryResult(historyResult.concat(historic.result.response.data));
if (page === historic.result.response.last_page) {
console.log("Page", page === historic.result.response.last_page);
setPage(page + 1);
console.log("historyResult.concat", historyResult.concat(historic.result.response.data));
setHistoryResult(historyResult.concat(historic.result.response.data));
}
}
if (historic.error) {
Alert.alert(
I18n.t("ERROR_LABLE"),
Utils.getErrorMsg(historic),
[
{
text: I18n.t("OK"), onPress: () => {
dispatch(fetchGeHistoricReset());
}
}
],
{ cancelable: false }
);
}
//forceUpdate();
}, [historic]);
useEffect(() => {
console.log("historyResult", historyResult);
}, [historyResult]);
const handleLoadMore = () => {
dispatch(fetchGeHistoricReset());
switch (user.category) {
case "super":
console.log("ON est pas superviseur nous");
fetchGetHistoric(`${user.agentId}?pagination=true&pagination=true&page=${page + 1}`, false, 1);
break;
case "hyper":
fetchGetHistoric(`${user.network_id}?pagination=true&pagination=true&page=${page + 1}`, true, 1);
break;
case "geolocated":
fetchGetHistoric(`${user.agentId}?pagination=true&pagination=true&page=${page + 1}`, null, 0);
break;
}
setPage(page + 1);
}
const renderLoader = () => (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
{Platform.OS === 'android'
?
(
<>
<ProgressBarAndroid/>
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
) :
<>
<ActivityIndicator size="large" color={'#ccc'}/>
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
}
</View>
);
const renderFooterLoader = () => {
return (
<View
style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}
>
{Platform.OS === 'android'
?
(
<>
<ProgressBarAndroid/>
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
) :
<>
<ActivityIndicator size="small" color={'#ccc'}/>
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
}
</View>
);
};
const renderModalSuperHyperHistoryDetail = () => (
<Dialog.Container useNativeDriver={true} visible={displaySuperHyperModalHistory}>
<Dialog.Title>{I18n.t('HISTORY_DETAIL')}</Dialog.Title>
{
isDisplayHistoryOrdreRecette ?
<ScrollView persistentScrollbar={true}>
<View style={[styles.blockView, {borderBottomColor: Color.borderColor}]}>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>Type</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{(historyItemDetail.type)}</Text>
</View>
</View>
{
user !== null ?
user.category !== "geolocated" &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ACTION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.history_action === "M" ? I18n.t('UPDATE') : I18n.t('ADD')}</Text>
</View>
</View>
: null
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('EMAIL')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.email}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ISSUER_LASTNAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.issuer_lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ISSUER_PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.issuer_phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('OLD_VALUE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.old_data_id}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NEW_VALUE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.new_data_id}</Text>
</View>
</View>
{
historyItemDetail.hasOwnProperty("revenue_orders") &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('ORDRE_DE_RECETTE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.revenue_orders.map((ordreRecette) => {
let message = "";
message = ordreRecette.tax_name + " | " + ordreRecette.amount + " | " + ordreRecette.payment_deadline_date + "\n\n";
return message;
}
)
}
</Text>
</View>
</View>
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PRINCIPAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('TOTAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('DATE_AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.created_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('UPDATE_DATE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.updated_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PAYMENT_DEADLINE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.payment_deadline_date}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('YEAR')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.year}</Text>
</View>
</View>
</View>
</ScrollView>
:
<ScrollView persistentScrollbar={true}>
<View style={[styles.blockView, {borderBottomColor: Color.borderColor}]}>
{
user !== null ?
user.category !== "geolocated" &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ACTION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.history_action === "M" ? I18n.t('UPDATE') : I18n.t('ADD')}</Text>
</View>
</View>
: null
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ID_TAX_NOTICE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.id_tax_notice}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('STATUS')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.status}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('EMAIL')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.email}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ARRONDISSEMENT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.district}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NEIGHTBORHOOD')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.neighborhood}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NOM_RESPONSABLE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.responsable_name}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('TECHNICAL_AGREMENT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.technical_approval}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PRINCIPAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('OFFICE_PENALITIES')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.office_penalties}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('MONTH_DELAY_PENALTIES')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.month_delay_penalties}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('TOTAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
{
historyItemDetail.hasOwnProperty("penalties") ?
historyItemDetail.penalties.length > 0 ?
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PENALITE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.penalties.map((penalite) => {
let message = "";
message = penalite.name + " \n " + (penalite.n_order === 2 ? penalite.tax_amount : penalite.amount) + (penalite.n_order === 1 ? ` | ${penalite.rate} %` : "") + "\n\n";
return message;
}
)
}
</Text>
</View>
</View> : null : null
}
{
historyItemDetail.hasOwnProperty("taxes") &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.taxes.map((taxe) => {
let message = "";
if (taxe.hasOwnProperty('new_quantity'))
message = taxe.name + " | " + taxe.unit_price + " | (" + taxe.old_quantity + ", " + taxe.old_quantity + ")\n\n";
else
message = taxe.name + " | " + taxe.quantity + " | " + taxe.amount + "\n\n";
return message;
}
)
}
</Text>
</View>
</View>
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('DATE_AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.created_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('UPDATE_DATE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.updated_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PAYMENT_DEADLINE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.payment_deadline_date}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('YEAR')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.year}</Text>
</View>
</View>
</View>
</ScrollView>
}
<Dialog.Button bold={true} label={I18n.t('OK')} onPress={() => {
setDisplaySuperHyperModalHistory(!displaySuperHyperModalHistory);
}}/>
</Dialog.Container>
);
const renderModalHistoryDetail = () => (
<Dialog.Container useNativeDriver={true} visible={displayModalHistory}>
<Dialog.Title>{I18n.t('HISTORY_DETAIL')}</Dialog.Title>
{historiqueDetailLabel === I18n.t('AVIS_IMPOSITION') ?
<ScrollView persistentScrollbar={true}>
<View style={[styles.blockView, {borderBottomColor: Color.borderColor}]}>
{
user !== null ?
user.category !== "geolocated" &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ACTION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.history_action === "M" ? I18n.t('UPDATE') : I18n.t('ADD')}</Text>
</View>
</View>
: null
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ID_TAX_NOTICE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.id_tax_notice}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('STATUS')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.status}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('EMAIL')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.email}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ARRONDISSEMENT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.district}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NEIGHTBORHOOD')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.neighborhood}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NOM_RESPONSABLE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.responsable_name}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('TECHNICAL_AGREMENT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.technical_approval}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PRINCIPAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('OFFICE_PENALITIES')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.office_penalties}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('MONTH_DELAY_PENALTIES')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.month_delay_penalties}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('TOTAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
{
historyItemDetail.hasOwnProperty("penalties") ?
historyItemDetail.penalties.length > 0 ?
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PENALITE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.penalties.map((penalite) => {
let message = "";
message = penalite.name + " \n " + (penalite.n_order === 2 ? penalite.tax_amount : penalite.amount) + (penalite.n_order === 1 ? ` | ${penalite.rate} %` : "") + "\n\n";
return message;
}
)
}
</Text>
</View>
</View> : null : null
}
{
historyItemDetail.hasOwnProperty("taxes") &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.taxes.map((taxe) => {
let message = "";
if (taxe.hasOwnProperty('new_quantity'))
message = taxe.name + " | " + taxe.unit_price + " | (" + taxe.old_quantity + ", " + taxe.old_quantity + ")\n\n";
else
message = taxe.name + " | " + taxe.quantity + " | " + taxe.amount + "\n\n";
return message;
}
)
}
</Text>
</View>
</View>
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('DATE_AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.created_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('UPDATE_DATE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.updated_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PAYMENT_DEADLINE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.payment_deadline_date}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('YEAR')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.year}</Text>
</View>
</View>
</View>
</ScrollView>
:
<ScrollView persistentScrollbar={true}>
<View style={[styles.blockView, {borderBottomColor: Color.borderColor}]}>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>Type</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{(historyItemDetail.type)}</Text>
</View>
</View>
{
user !== null ?
user.category !== "geolocated" &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ACTION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.history_action === "M" ? I18n.t('UPDATE') : I18n.t('ADD')}</Text>
</View>
</View>
: null
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('EMAIL')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.email}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ISSUER_LASTNAME')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.issuer_lastname}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('ISSUER_PHONE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.issuer_phone}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('OLD_VALUE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.old_data_id}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('NEW_VALUE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.new_data_id}</Text>
</View>
</View>
{
historyItemDetail.hasOwnProperty("revenue_orders") &&
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('ORDRE_DE_RECETTE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>
{
historyItemDetail.revenue_orders.map((ordreRecette) => {
let message = "";
message = ordreRecette.tax_name + " | " + ordreRecette.amount + " | " + ordreRecette.payment_deadline_date + "\n\n";
return message;
}
)
}
</Text>
</View>
</View>
}
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PRINCIPAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('TOTAL_AMOUNT')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.amount}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('DATE_AVIS_IMPOSITION')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.created_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text style={[styles.body2]}>{I18n.t('UPDATE_DATE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.updated_at}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('PAYMENT_DEADLINE')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.payment_deadline_date}</Text>
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 10}}>
<View style={{flex: 1}}>
<Text tyle={[Typography.body2]}>{I18n.t('YEAR')}</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
style={[Typography.caption1, Color.grayColor]}>{historyItemDetail.year}</Text>
</View>
</View>
</View>
</ScrollView>
}
<Dialog.Button bold={true} label={I18n.t('OK')} onPress={() => {
setDisplayModalHistory(!displayModalHistory)
}}/>
</Dialog.Container>
)
const renderItem = (item) => (
historiqueDetailLabel !== I18n.t('AVIS_IMPOSITION') ?
<TouchableOpacity
style={[styles.content, {backgroundColor: Color.cardBackgroundColor}]}
onPress={() => {
setHistoryItemDetail(item);
setDisplayModalHistory(true);
/*navigation.navigate('validateConsultationDetailScreen', {
item
});*/
}}>
<View style={[styles.contentTop, {borderColor: Color.borderColor}]}>
<View style={{flex: 1, alignItems: 'flex-start'}}>
<Text caption1>{`${I18n.t('AMOUNT')}: ${item.amount}`}</Text>
<Text footnote light numberOfLines={1}>
{`${I18n.t('NAME')}: ${item.lastname}`}
</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-start'}}>
<Text
caption1>{`${I18n.t('ID')}: ${item.id_tax_notice}`}</Text>
<Text footnote light numberOfLines={1}>
{`${I18n.t('NAME')}: ${item.lastname}`}
</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
caption1>{`${I18n.t('PHONE')}: ${item.phone}`}</Text>
<Text footnote light numberOfLines={1}>
{`${I18n.t('STATUS')}: ${item?.status?.toLowerCase()}`}
</Text>
</View>
</View>
<View style={styles.contentBottom}>
<View style={{flexDirection: 'row', alignItems: 'flex-start'}}>
<Text caption1 semibold primaryColor>
{item.created_at ? `Date: ${moment(item.created_at).format('YYYY-MM-DD')}` : I18n.t('AVIS_NON_EMIS')}
</Text>
</View>
</View>
</TouchableOpacity>
:
<TouchableOpacity
style={[styles.content, {backgroundColor: Color.cardBackgroundColor}]}
onPress={() => {
setDisplayModalHistory(true);
setHistoryItemDetail(item);
/*navigation.navigate('validateConsultationDetailScreen', {
item
});*/
}}>
<View style={{borderColor: Color.borderColor, flexDirection: "row",paddingBottom: 10, borderBottomWidth: 0.5}}>
<View style={{flex: 1, alignItems: 'flex-start'}}>
<Text caption1>{`${I18n.t('AMOUNT')}: ${item.amount}`}</Text>
</View>
</View>
<View style={[styles.contentTop, {borderColor: Color.borderColor}]}>
<View style={{flex: 1, alignItems: 'flex-start'}}>
<Text
caption1>{`${I18n.t('ID')}: ${item.id_tax_notice}`}</Text>
<Text footnote light numberOfLines={1}>
{`${I18n.t('NAME')}: ${item.lastname}`}
</Text>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<Text
caption1>{`${I18n.t('PHONE')}: ${item.phone}`}</Text>
<Text footnote light numberOfLines={1}>
{`${I18n.t('STATUS')}: ${item?.status?.toLowerCase()}`}
</Text>
</View>
</View>
<View style={styles.contentBottom}>
<View style={{flexDirection: 'row', alignItems: 'flex-start'}}>
<Text caption1 semibold primaryColor>
{item.created_at ? `Date: ${moment(item.created_at).format('YYYY-MM-DD')}` : I18n.t('AVIS_NON_EMIS')}
</Text>
</View>
</View>
</TouchableOpacity>
);
return (
<ScreenComponent>
<View style={styles.contain}>
<View style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingBottom: 10}}>
<Tag primary
icon={<FontAwesome5 name='file' size={20} color={Color.whiteColor}
style={{marginLeft: 15}}/>}
style={{
paddingRight: 10,
width: 120,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
borderRightWidth: 1,
borderRightColor: Color.whiteColor
}}
onPress={() => {
dispatch(fetchGeHistoricReset());
setPage(1);
setLoadMore(false);
setHistoryResult([]);
setHistoriqueDetailLabel(I18n.t('AVIS_IMPOSITION'));
switch (user.category) {
case "super":
console.log("ON est pas superviseur nous");
fetchGetHistoric(`${user.agentId}?page=1&perPage=20`, false, 1);
break;
case "hyper":
fetchGetHistoric(`${user.network_id}?page=1&perPage=20`, true, 1);
break;
case "geolocated":
fetchGetHistoric(`${user.agentId}?page=1&perPage=20`, null, 0);
break;
}
}}>
{` ${I18n.t('AVIS_IMPOSITION')}`}
</Tag>
{
user ?
user.category !== "geolocated" && (
<Tag icon={<MaterialCommunityIcons name='file' size={20} color={Color.whiteColor}/>}
style={{width: 110, borderTopLeftRadius: 0, borderBottomLeftRadius: 0,}}
primary
onPress={() => {
dispatch(fetchGeHistoricReset());
setPage(1);
setLoadMore(false);
setHistoryResult([]);
setHistoriqueDetailLabel(I18n.t('ORDRE_RECETTE_QUITANCE'));
fetchGetHistoric(`${user.agentId}?page=1&perPage=40`, false, 2);
//fetchGetInvoiceHistory(`?network_id=${wallet.id_network}&page=1&perPage=20`);
}}>
{` ${I18n.t('ORDRE_RECETTE_QUITANCE')}`}
</Tag>
)
: null
}
</View>
{historic.loading && !loadMore
? renderLoader()
: (
<FlatList
style={{flex: 1}}
ListEmptyComponent={() => {
return (
<Text>{I18n.t('NO_WALLET_HISTORY')}</Text>
)
}}
data={historyResult}
keyExtractor={(item, index) => item.id}
renderItem={({item, index}) => (
renderItem(item)
)}
onEndReached={() => {
if (historic.result !== null) {
if (page < historic.result.response.last_page) {
setLoadMore(true);
handleLoadMore();
}
}
}}
onEndReachedThreshold={0.5}
ListFooterComponent={historic.result !== null ? page < historic.result.response.last_page ? renderFooterLoader() : null : null}
/>
)}
{displayModalHistory && renderModalHistoryDetail()}
</View>
</ScreenComponent>
)
};
const mapStateToProps = createStructuredSelector({
historic: selectHistoric
});
export default connect(mapStateToProps, {
fetchGetHistoric
})(
HistoricScreen,
);
const styles = StyleSheet.create({
textInput: {
height: 46,
backgroundColor: Color.fieldColor,
borderRadius: 5,
marginTop: 10,
padding: 10,
width: '100%',
},
contentService: {
paddingVertical: 10,
borderBottomWidth: 0.5,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
},
lineRow: {
flexDirection: 'row',
justifyContent: 'space-between',
paddingBottom: 20,
},
contain: {
marginTop: 20,
paddingBottom: 20,
paddingLeft: 10,
paddingRight: 10,
flex: 1,
},
content: {
padding: 10,
marginBottom: 10,
borderRadius: 8
},
contentTop: {
flexDirection: "row",
paddingBottom: 10,
borderBottomWidth: 1
},
contentBottom: {
flexDirection: "row",
marginTop: 10,
justifyContent: "space-between"
},
bottomLeft: {flexDirection: "row", alignItems: "center"},
image: {width: 32, height: 32, marginRight: 10, borderRadius: 16},
blockView: {
paddingVertical: 10,
borderBottomWidth: 0.5,
},
});