Skip to content

Commit

Permalink
Fix: Tax Issue
Browse files Browse the repository at this point in the history
Refactor: None
Feat: None
  • Loading branch information
jiloysss authored and jiloysss committed Jul 23, 2019
1 parent fa8d1c0 commit ec2b20b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/boot/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import getTheme from "../theme/components";
import variables from "../theme/variables/platform";

const stores2 = config();
BackgroundJob.cancel({jobKey: "AutomaticSync"});
const backgroundJob = {
jobKey: "myJob",
job: () => syncObjectValues("sync", stores2, true),
Expand Down
1 change: 0 additions & 1 deletion src/services/tailorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exports.sendOrder = function(origin, order) {
method: "POST",
body: JSON.stringify(order),
};

return fetch(url, fetchData).then(response => response.json());
};

Expand Down
84 changes: 46 additions & 38 deletions src/store/PosStore/DbFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { unformat } from "accounting-js";
import FrappeFetch from "react-native-frappe-fetch";
import { Toast } from "native-base";
var validUrl = require("valid-url");
import BackgroundJob from "react-native-background-job";

export function openAndSyncDB(dbName, withSync = false) {
const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
Expand Down Expand Up @@ -37,49 +38,56 @@ export function sync(
store,
) {
// if (credentials.url !== undefined && credentials.user_name !== undefined && credentials.password !== undefined) {
if (validUrl.isWebUri(credentials.url.toLowerCase())) {
return FrappeFetch.createClient({
url: credentials.url.toLowerCase(),
username: credentials.user_name,
password: credentials.password,
})
if (credentials.url) {

.then(responseLog => {
const { Client } = FrappeFetch;
return Client.postApi(
"tailpos_sync.sync_pos.sync_data",
// "frappe.handler.ping",
{
tailposData: JSON.parse(jsonObject),
trashObject: JSON.parse(trashObj),
deviceId: credentials.deviceId,
typeOfSync: type,
},
);
})
.catch(error => {
store.stateStore.setIsNotSyncing();
if (validUrl.isWebUri(credentials.url.toLowerCase())) {
return FrappeFetch.createClient({
url: credentials.url.toLowerCase(),
username: credentials.user_name,
password: credentials.password,
})

if (!jobStatus) {
.then(responseLog => {
const {Client} = FrappeFetch;
return Client.postApi(
"tailpos_sync.sync_pos.sync_data",
// "frappe.handler.ping",
{
tailposData: JSON.parse(jsonObject),
trashObject: JSON.parse(trashObj),
deviceId: credentials.deviceId,
typeOfSync: type,
},
);
})
.catch(error => {
store.stateStore.setIsNotSyncing();
BackgroundJob.cancel({ jobKey: "AutomaticSync" });
if (!jobStatus) {
Toast.show({
text: "Unable to sync",
type: "danger",
duration: 5000,
});

}
})

.then(response => response.json())
.then(responseJson => {
return responseJson.message.data;
});
} else {
store.stateStore.setIsNotSyncing();
Toast.show({
text: "Unable to sync",
type: "danger",
duration: 5000,
text: "Invalid URL",
type: "danger",
duration: 5000,
});
}
})

.then(response => response.json())
.then(responseJson => {
return responseJson.message.data;
});
BackgroundJob.cancel({ jobKey: "AutomaticSync" });
}
} else {
store.stateStore.setIsNotSyncing();
Toast.show({
text: "Invalid URL",
type: "danger",
duration: 5000,
});
BackgroundJob.cancel({ jobKey: "AutomaticSync" });
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/store/PosStore/ReceiptStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ export const Receipt = types
ReceiptStore.delete(self); // Reference
},
clear() {
self.discount = "";
self.discountValue = 0;
self.taxesValue = "0";

// Yay!
self.lines.splice(0, self.lines.length);
Expand Down
2 changes: 1 addition & 1 deletion src/stories/components/ConfirmOrderModalComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export default class ConfirmOrderModalComponent extends React.Component {
<Picker.Item label="Dine In" value="Dine-in" />
<Picker.Item label="Delivery" value="Delivery" />
<Picker.Item label="Online" value="Online" />
<Picker.Item label="Family" value="Family" />
</Picker>
</Form>

<View
style={{
flexDirection: "row",
Expand Down

0 comments on commit ec2b20b

Please sign in to comment.