Skip to content

Commit

Permalink
fix: None
Browse files Browse the repository at this point in the history
refactor: None
feat: TailPOS Language Translation
  • Loading branch information
jiloysss authored and jiloysss committed Jul 5, 2019
1 parent 1815900 commit 2fdab21
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 400 deletions.
114 changes: 58 additions & 56 deletions src/container/ShiftReportsContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,23 @@ export default class ShiftReportsContainer extends React.Component {
loading: false,
visibility: false,
visibilityCommission: false,
bluetoothConnection: false
bluetoothConnection: false,
};
}
componentWillMount() {
this.getBluetoothState();
for (let i = 0; i < this.props.printerStore.rows.length; i += 1) {
if (this.props.printerStore.rows[i].defaultPrinter) {

BluetoothSerial.connect(this.props.printerStore.rows[i].macAddress)
.then(() => {
this.setState({
bluetoothConnection: true
bluetoothConnection: true,
});
})
.catch(() => {
this.setState({
bluetoothConnection: false
});
this.setState({
bluetoothConnection: false,
});
});
}
}
Expand Down Expand Up @@ -117,60 +116,63 @@ export default class ShiftReportsContainer extends React.Component {
}, 10000);
}
printItemSalesReports(dates) {
for (let i = 0; i < this.props.printerStore.rows.length; i += 1) {
if (this.props.printerStore.rows[i].defaultPrinter) {

BluetoothSerial.connect(this.props.printerStore.rows[i].macAddress)
.then(async () => {
let itemArray = [];
let date1 = new Date(dates.dateFrom);
let date2 = new Date(dates.dateTo);
for (let i = 0; i < this.props.printerStore.rows.length; i += 1) {
if (this.props.printerStore.rows[i].defaultPrinter) {
BluetoothSerial.connect(this.props.printerStore.rows[i].macAddress)
.then(async () => {
let itemArray = [];
let date1 = new Date(dates.dateFrom);
let date2 = new Date(dates.dateTo);

if (date1.getTime() <= date2.getTime()) {
for (let v = 0; v < 1 && new Date(date1).getTime() <= date2; v = 0) {
await this.props.receiptStore
.getReceiptsForItemSalesReport(moment(date1).format("YYYY-MM-DD"))
.then(result => {
if (result) {
for (let x = 0; x < result.length; x += 1) {
itemArray.push(result[x]);
}
}
});
date1 = moment(date1)
.add(1, "day")
.format("YYYY-MM-DD");
}
//
} else {
Toast.show({
text: "(From) date must be greater than or equal (To) date",
duration: 3000,
type: "danger",
});
}
if (itemArray.length > 0){
printReport(itemArray, this.props);
} else {
Toast.show({
text: "No Item Sales from" + dates.dateFrom + "to" + dates.dateTo,
duration: 2000,
type: "danger",
});
if (date1.getTime() <= date2.getTime()) {
for (
let v = 0;
v < 1 && new Date(date1).getTime() <= date2;
v = 0
) {
await this.props.receiptStore
.getReceiptsForItemSalesReport(
moment(date1).format("YYYY-MM-DD"),
)
.then(result => {
if (result) {
for (let x = 0; x < result.length; x += 1) {
itemArray.push(result[x]);
}

})
.catch(() => {
Toast.show({
text: "Bluetooth Connection Failed",
duration: 2000,
type: "danger",
});

}
});
}
date1 = moment(date1)
.add(1, "day")
.format("YYYY-MM-DD");
}
//
} else {
Toast.show({
text: "(From) date must be greater than or equal (To) date",
duration: 3000,
type: "danger",
});
}
if (itemArray.length > 0) {
printReport(itemArray, this.props);
} else {
Toast.show({
text:
"No Item Sales from" + dates.dateFrom + "to" + dates.dateTo,
duration: 2000,
type: "danger",
});
}
})
.catch(() => {
Toast.show({
text: "Bluetooth Connection Failed",
duration: 2000,
type: "danger",
});
});
}

}
}
itemSalesReport() {
return (
Expand Down
6 changes: 4 additions & 2 deletions src/stories/components/ItemSalesReportModalComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export default class ItemSalesReportModalComponent extends React.Component {

const fullYear = new Date(dateNow).getFullYear();
const fullMonth = new Date(dateNow).getMonth() + 1;
const checkMonth = (new Date(dateNow).getMonth() + 1).toString().length === 1 ? "-0" : "-";
const checkDate = new Date(dateNow).getDate().toString().length === 1 ? "-0" : "-";
const checkMonth =
(new Date(dateNow).getMonth() + 1).toString().length === 1 ? "-0" : "-";
const checkDate =
new Date(dateNow).getDate().toString().length === 1 ? "-0" : "-";
const fullDate = new Date(dateNow).getDate();

this.setState({
Expand Down
3 changes: 1 addition & 2 deletions src/stories/components/TotalLineComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const TotalLineComponent = props => (
</View>
<View style={styles.viewInner}>
<Text style={styles.text}>
{strings.Tax}{" "}

{strings.Tax}{" "}
{parseFloat(props.receipt.taxesValue) > 0
? "(" + props.receipt.taxesValue.toString() + "%)"
: ""}
Expand Down
115 changes: 59 additions & 56 deletions src/stories/screens/ShiftReports/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { TouchableOpacity, View, StyleSheet,Dimensions } from "react-native";
import { TouchableOpacity, View, StyleSheet, Dimensions } from "react-native";
import {
Container,
Header,
Expand Down Expand Up @@ -41,14 +41,14 @@ class ShiftReports extends React.PureComponent {
const shiftReportCardComponents = this.props.shiftReportsStore.map(
this.reports,
);
const ShiftRerorts =
this.props.shiftReportsStore.length === 0 ? (
<CardItem>
<Text>No shift report available</Text>
</CardItem>
) : (
shiftReportCardComponents
);
const ShiftRerorts =
this.props.shiftReportsStore.length === 0 ? (
<CardItem>
<Text>No shift report available</Text>
</CardItem>
) : (
shiftReportCardComponents
);
return (
<Container>
<Header style={styles.header}>
Expand All @@ -64,58 +64,62 @@ class ShiftReports extends React.PureComponent {
</Button>
</Left>
<Body style={styles.headerBody}>

<Title>Shift Reports</Title>
</Body>
<Right />
</Header>
<Content padder>
<Card>
<CardItem bordered >
<CardItem bordered>
<Text style={styles.cardItemText}>
<Icon name="file-document-box" size={21} /> Shift Reports
</Text>
<View style={styles.cardItemTop}>
{this.props.attendant.role === "Owner" ? (

<Button onPress={this.props.itemSales} style={styles.buttonMargin}>
<Text>Item Sales Report</Text>
</Button>
) : null}
{this.props.attendant.role === "Owner" ? (

<Button onPress={this.props.commission} style={styles.buttonMargin}>
<Text>Commission Report</Text>
</Button>
) : null}
{this.props.attendant.role === "Owner" ? (
<Button onPress={this.props.ZReading} >
<Text>Generate Z Reading</Text>
</Button>
) : null}
{this.props.attendant.role === "Owner" ? (
<Button
onPress={this.props.itemSales}
style={styles.buttonMargin}
>
<Text>Item Sales Report</Text>
</Button>
) : null}
{this.props.attendant.role === "Owner" ? (
<Button
onPress={this.props.commission}
style={styles.buttonMargin}
>
<Text>Commission Report</Text>
</Button>
) : null}
{this.props.attendant.role === "Owner" ? (
<Button onPress={this.props.ZReading}>
<Text>Generate Z Reading</Text>
</Button>
) : null}
</View>
</CardItem>
{this.props.attendant.role === "Owner" ? (
this.props.loading ? (
<Spinner color="#427ec6" />
) : this.props.zReading ? (
<TouchableOpacity onPress={this.zReadingOnClick}>
<CardItem bordered style={styles.cardItem}>
<View>
<Text style={styles.reportText}>Z Reading</Text>
</View>
<Text style={styles.shiftText}>
{this.props.zReading.shift_beginning !== null
? this.props.zReading.shift_beginning.toLocaleDateString()
: ""}
</Text>
</CardItem>
{this.props.attendant.role === "Owner" ? (
this.props.loading ? (
<Spinner color="#427ec6" />
) : this.props.zReading ? (
<TouchableOpacity onPress={this.zReadingOnClick}>
<CardItem bordered style={styles.cardItem}>
<View>
<Text style={styles.reportText}>Z Reading</Text>
</View>
<Text style={styles.shiftText}>
{this.props.zReading.shift_beginning !== null
? this.props.zReading.shift_beginning.toLocaleDateString()
: ""}
</Text>
</CardItem>
</TouchableOpacity>
) : (
<CardItem bordered>
<Text>No Z Reading Generated</Text>
</CardItem>
</TouchableOpacity>
) : (
<CardItem bordered>
<Text >No Z Reading Generated</Text>
</CardItem>
)) : null}
)
) : null}
{ShiftRerorts}
</Card>
</Content>
Expand All @@ -133,18 +137,17 @@ const styles = StyleSheet.create({
cardItem: {
justifyContent: "space-between",
},
cardItemTop: {
cardItemTop: {
alignSelf: "flex-end",
width: Dimensions.get("window").width * 0.82,
width: Dimensions.get("window").width * 0.82,
justifyContent: "flex-end",
flexDirection: "row"
flexDirection: "row",
},

cardItemText: {
fontSize: 21,
fontWeight: "bold",
justifyContent: "flex-start",

justifyContent: "flex-start",
},
reportText: {
fontSize: 21,
Expand All @@ -160,8 +163,8 @@ const styles = StyleSheet.create({
alignItems: "center",
justifyContent: "center",
},
buttonMargin: {
marginRight: 5
buttonMargin: {
marginRight: 5,
},
});

Expand Down
Loading

0 comments on commit 2fdab21

Please sign in to comment.