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 90f84a8 commit 1815900
Show file tree
Hide file tree
Showing 14 changed files with 518 additions and 66 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ android {
}

dependencies {
compile project(':react-native-localization')
compile project(':react-native-background-job')
compile project(':react-native-bluetooth-status')
compile project(':react-native-device-info')
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/java/com/tailpos/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.solinor.bluetoothstatus.RNBluetoothManagerPackage;
import com.facebook.react.ReactApplication;
import com.babisoft.ReactNativeLocalization.ReactNativeLocalizationPackage;
import com.pilloxa.backgroundjob.BackgroundJobPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
Expand Down Expand Up @@ -36,6 +37,7 @@ protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new RNBluetoothManagerPackage(),
new MainReactPackage(),
new ReactNativeLocalizationPackage(),
new BackgroundJobPackage(),
new RNDeviceInfo(),
new SplashScreenReactPackage(),
Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rootProject.name = 'TailPOS'
include ':react-native-localization'
project(':react-native-localization').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localization/android')
include ':react-native-background-job'
project(':react-native-background-job').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-job/android')
include ':react-native-bluetooth-status'
Expand Down
14 changes: 14 additions & 0 deletions ios/TailPOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
C9FF7F18951F4D28ABFA15A7 /* libRNDeviceInfo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FEE29440B4E34568A40EDE64 /* libRNDeviceInfo-tvOS.a */; };
43FFBF74D0094DD8866DD727 /* libRNBluetoothManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 114C3F4566DC4AAFBF009FFF /* libRNBluetoothManager.a */; };
51F0F7BBE5C142D4B8521808 /* libRNBackgroundJob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 030627CBACC14D929C0207BD /* libRNBackgroundJob.a */; };
520D4F11F21A4CEEB05724EB /* libReactNativeLocalization.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A5548395195745ED8AFFDEBB /* libReactNativeLocalization.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -410,6 +411,8 @@
114C3F4566DC4AAFBF009FFF /* libRNBluetoothManager.a */ = {isa = PBXFileReference; name = "libRNBluetoothManager.a"; path = "libRNBluetoothManager.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
2140AF7DBD7F486D8BC7E6D1 /* RNBackgroundJob.xcodeproj */ = {isa = PBXFileReference; name = "RNBackgroundJob.xcodeproj"; path = "../node_modules/react-native-background-job/ios/RNBackgroundJob.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
030627CBACC14D929C0207BD /* libRNBackgroundJob.a */ = {isa = PBXFileReference; name = "libRNBackgroundJob.a"; path = "libRNBackgroundJob.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
D5BF8BC30E324943AB843FEB /* ReactNativeLocalization.xcodeproj */ = {isa = PBXFileReference; name = "ReactNativeLocalization.xcodeproj"; path = "../node_modules/react-native-localization/ReactNativeLocalization.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
A5548395195745ED8AFFDEBB /* libReactNativeLocalization.a */ = {isa = PBXFileReference; name = "libReactNativeLocalization.a"; path = "libReactNativeLocalization.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -451,6 +454,7 @@
150FBD971C734294B008FA4E /* libRNDeviceInfo.a in Frameworks */,
43FFBF74D0094DD8866DD727 /* libRNBluetoothManager.a in Frameworks */,
51F0F7BBE5C142D4B8521808 /* libRNBackgroundJob.a in Frameworks */,
520D4F11F21A4CEEB05724EB /* libReactNativeLocalization.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -467,6 +471,7 @@
2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */,
2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */,
C9FF7F18951F4D28ABFA15A7 /* libRNDeviceInfo-tvOS.a in Frameworks */,
B1072CF6C1704DF8A28F80E5 /* libRNI18n-tvOS.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -651,6 +656,7 @@
042ECB823A744F6C8E3E8785 /* RNDeviceInfo.xcodeproj */,
0FC20227933C497CB2330EEF /* RNBluetoothManager.xcodeproj */,
2140AF7DBD7F486D8BC7E6D1 /* RNBackgroundJob.xcodeproj */,
D5BF8BC30E324943AB843FEB /* ReactNativeLocalization.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
Expand Down Expand Up @@ -1329,6 +1335,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Debug;
Expand Down Expand Up @@ -1364,6 +1371,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Release;
Expand Down Expand Up @@ -1397,6 +1405,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Debug;
Expand Down Expand Up @@ -1429,6 +1438,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Release;
Expand Down Expand Up @@ -1473,6 +1483,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Debug;
Expand Down Expand Up @@ -1517,6 +1528,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Release;
Expand Down Expand Up @@ -1560,6 +1572,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Debug;
Expand Down Expand Up @@ -1603,6 +1616,7 @@
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)/../node_modules/react-native-bluetooth-status/ios",
"$(SRCROOT)/../node_modules/react-native-background-job/ios",
"$(SRCROOT)/../node_modules/react-native-localization",
);
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^0.21.5",
"react-native-frappe-fetch": "^0.9.1",
"react-native-localization": "^2.1.2",
"react-native-maps": "^0.21.0",
"react-native-modal": "^6.0.0",
"react-native-orientation": "^3.1.3",
Expand Down
94 changes: 58 additions & 36 deletions src/container/ShiftReportsContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,24 @@ export default class ShiftReportsContainer extends React.Component {
loading: false,
visibility: false,
visibilityCommission: 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) {
this.setState({
currentAddress: this.props.printerStore.rows[i].macAddress,
connectionStatus: "Connecting...",
checkBoxValue: this.props.printerStore.rows[i]._id,
});

BluetoothSerial.connect(this.props.printerStore.rows[i].macAddress)
.then(() => {
this.setState({
connected: this.props.printerStore.rows[i].macAddress,
checkBoxValue: this.props.printerStore.rows[i]._id,
bluetoothConnection: true
});
})
.catch(() => {
this.setState({ connectionStatus: "Not Connected" });
this.setState({
bluetoothConnection: false
});
});
}
}
Expand Down Expand Up @@ -119,36 +116,61 @@ export default class ShiftReportsContainer extends React.Component {
this.setState({ loading: false });
}, 10000);
}
async printItemSalesReports(dates) {
let itemArray = [];
let date1 = new Date(dates.dateFrom);
let date2 = new Date(dates.dateTo);
printItemSalesReports(dates) {
for (let i = 0; i < this.props.printerStore.rows.length; i += 1) {
if (this.props.printerStore.rows[i].defaultPrinter) {

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");
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",
});
}

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

});
}
}
//
} else {
Toast.show({
text: "(From) date must be greater than or equal (To) date",
duration: 3000,
type: "danger",
});
}

printReport(itemArray, this.props);
}
itemSalesReport() {
return (
Expand Down Expand Up @@ -420,7 +442,7 @@ export default class ShiftReportsContainer extends React.Component {
}
attendant={
this.props.attendantStore.defaultAttendant
? this.props.attendantStore.defaultAttendant.user_name
? this.props.attendantStore.defaultAttendant
: ""
}
ZReading={() => this.ZReading()}
Expand Down
8 changes: 4 additions & 4 deletions src/stories/components/ItemSalesReportModalComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default class ItemSalesReportModalComponent extends React.Component {

const fullYear = new Date(dateNow).getFullYear();
const fullMonth = new Date(dateNow).getMonth() + 1;
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({
dateFrom: fullYear + "-" + fullMonth + checkDate + fullDate,
dateTo: fullYear + "-" + fullMonth + checkDate + fullDate,
dateFrom: fullYear + checkMonth + fullMonth + checkDate + fullDate,
dateTo: fullYear + checkMonth + fullMonth + checkDate + fullDate,
});
}
render() {
Expand Down
1 change: 1 addition & 0 deletions src/stories/components/PrintItemSalesReportComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function printReport(arrayOfObjects, store) {
}
}
}

printReportFinal(store);
arrayOfItems = [];
}
Expand Down
9 changes: 6 additions & 3 deletions src/stories/components/TotalLineComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import * as React from "react";
import { View, StyleSheet } from "react-native";
import { Text } from "native-base";
import { formatNumber } from "accounting-js";
import translation from "../../translations/translation";
import LocalizedStrings from "react-native-localization";

let MoneyCurrency = require("money-currencies");

let strings = new LocalizedStrings(translation);
const TotalLineComponent = props => (
<View style={styles.viewOuter}>
<View style={styles.viewInner}>
<Text style={styles.text}>Subtotal</Text>
<Text style={styles.text}>{strings.Subtotal}</Text>
<Text>
{new MoneyCurrency(props.currency ? props.currency : "PHP").moneyFormat(
formatNumber(props.subtotal),
Expand All @@ -17,7 +19,8 @@ const TotalLineComponent = props => (
</View>
<View style={styles.viewInner}>
<Text style={styles.text}>
Tax{" "}
{strings.Tax}{" "}

{parseFloat(props.receipt.taxesValue) > 0
? "(" + props.receipt.taxesValue.toString() + "%)"
: ""}
Expand Down
Loading

0 comments on commit 1815900

Please sign in to comment.