Please provide the following:
- SDK Version:Expo 39.0.2
- Platforms:Android
I have created a point of sale system using expo and sqlite/prepopulated database problem is that it runs smoothly in development mode but in production some tables work but others do not yet they exist which is the same problem in the apk. This is the github repo of the project https://github.com/16isaac89/point-of-sale.git Expected behaviour is that it is supposed to save the sale,reduce that item and save the transaction into the database, below is the code that is supposed to do that. I have tested this in development environment and it works using expo but when i use bare react native,apk or production mode it does not work and does not produce any errors
return async(dispatch)=>{
cartItems.forEach(item => {
let amounts = item.price * item.quantity;
let paid = 'now';
let id = item.id
let qty = item.quantity
let balance = '0000'
db.transaction(tx => {
tx.executeSql('INSERT INTO salesssssss (name,price,amount,quantity,date,seller_id,txid,product_id,paid,balance,customer_id)values (?,?,?,?,?,?,?,?,?,?,?)', [item.name,item.price,amounts,item.quantity,dateTime,seller,txid,item.id,paid,balance,customername],
(txObj, result) =>{
if (result.rowsAffected > 0) {
dispatch({type:SALE_SAVED})
} else alert('Failed Saving sale');
},
(txObj, error) => console.log('Error', error))
})
db.transaction(tx => {
tx.executeSql('UPDATE products SET stock = stock - ? WHERE id =? ', [qty, id],
(txObj, resultSet) =>{
dispatch({type:QTY_SAVED})
console.log('data ireduced')},
(txObj, error) => console.log('Error', error))
})
});
db.transaction(tx => {
tx.executeSql('INSERT INTO transactions (customername,total,paid,date,seller_id,txid,datechanged ) values (?,?,?,?,?,?,?)', [customername,total,moneypaid,dateTime,seller,txid,dateTime],
(txObj, resultSet) =>{
dispatch({type:TX_SAVED})
console.log('data inserted')},
(txObj, error) => console.log('Error', error))
})
}
the item gets reduced but the sale and transaction is not saved this is the structure of the sales table
CREATE TABLE "sales" (
"id" INTEGER,
"name" TEXT,
"price" INTEGER,
"amount" INTEGER,
"quantity" INTEGER,
"date" TEXT,
"seller_id" INTEGER,
"txid" TEXT,
"product_id" INTEGER,
"paid" INTEGER,
"balance" INTEGER,
"customer_id" INTEGER,
"ptmethod" TEXT,
PRIMARY KEY("id" AUTOINCREMENT)
)
this is the transactions table
CREATE TABLE "transactions" (
"id" INTEGER,
"customername" TEXT,
"paid" TEXT,
"total" INTEGER,
"balance" INTEGER,
"date" INTEGER,
"seller_id" TEXT,
"txid" TEXT,
"datechanged" TEXT,
PRIMARY KEY("id" AUTOINCREMENT)
)
your help is greatly appreciated, thank you in advance