Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline Online Sync #3941

Open
1 task done
muhibstore opened this issue Mar 8, 2024 · 9 comments
Open
1 task done

Offline Online Sync #3941

muhibstore opened this issue Mar 8, 2024 · 9 comments

Comments

@muhibstore
Copy link

Background information

IMPORTANT: If you choose to ignore this issue report template, your issue will be closed as we cannot help without the requested information.

Please make sure you tick (add an x between the square brackets with no spaces) the following check boxes:

  • Reporting an issue of an unmodified OSPOS installation
  • [] Checked open and closed issues and no similar issue was already reported (please make sure you searched!)
  • [] Read README, WHATS_NEW, INSTALL.md and UPGRADE
  • [] Read the FAQ for any known install and/or upgrade gotchas (in specific PHP extensions installed)
  • [] Read the wiki
  • [] Executed any database upgrade scripts if an upgrade pre 3.0.0 (e.g. database/2.4_to_3.0.sql)
  • [] Aware the installation code that GitHub master is for developers only and therefore not complete nor stable.

Installation information

  • OSPOS version is:
  • OSPOS git commit hash is:
  • PHP version is:
  • MySQL or MariaDB version is:
  • OS and version is:
  • WebServer is:
  • Selected language is:
  • (If applicable) Docker installation:
  • (If applicable) Installation package for the LAMP/LEMP stack is:

Issue / Bug / Question / New Feature

  1. I want to use ospos in 3 Stores in different geographic locations.
  2. But I do not have a reliable internet connection, its off some times.
  3. I want to host OSPOS on Cloud to access from all three cash register linux desktop computers.
  4. How can I store my transactions locally when I do not have internet connection.
  5. How can I update to the Cloud server when I am online again.
@objecttothis
Copy link
Member

Currently this feature is not present. In order to make this work, we would need a way of locally storing the database and keep a transaction log to replay transactions for the server once connection is re-established. PHP doesn't lend itself to doing this as easily as other languages. This would be quite an undertaking to do, but it's doable. Further complicating this is the fact that you have three locations. Care would have to be taken to prevent race conditions and stale data. Currently, the only way is to have one local installation per geographic location. This way you won't have requirement for internet connection. The downside is that your locations wouldn't be talking with each other then.

@codify-anand
Copy link

codify-anand commented Mar 20, 2024

Our client had a similar requirement wherein he had a book store but he needed to take a laptop to book fairs/exhibitions where Internet access would be unreliable. So he wanted a way to load book stock information onto the laptop and bill offline at the book fairs. Later his employee should be able to come back to the office and sync the book fair bills with his office system (Or he can sync as and when Internet is available).

We gave him a solution involving an ERP system hosted on our server (FrontAccounting ERP), the office would bill using a hosted copy of OSPoS and the book fair laptops would have a local (laragon) hosted OSPoS.
We modified the PoS software with a custom sync button that would:

  1. Export the customers, item list and stock info. from central ERP to the PoS
  2. Import the stock information, sales information and Expenses information from the PoS to the central ERP
  3. Some validation logic to check the data, preventing double imports, etc.
  4. Display some basic status info in the PoS screen like total items imported, no. of sales left to sync, etc.

Overall, the client is happy with the solution provided. Let me know if you require clarifications and I will try to explain as much as I can.

@objecttothis
Copy link
Member

Our client had a similar requirement wherein he had a book store but he needed to take a laptop to book fairs/exhibitions where Internet access would be unreliable. So he wanted a way to load book stock information onto the laptop and bill offline at the book fairs. Later his employee should be able to come back to the office and sync the book fair bills with his office system (Or he can sync as and when Internet is available).

We gave him a solution involving an ERP system hosted on our server (FrontAccounting ERP), the office would bill using a hosted copy of OSPoS and the book fair laptops would have a local (laragon) hosted OSPoS. We modified the PoS software with a custom sync button that would:

1. Export the customers, item list and stock info. from central ERP to the PoS

2. Import the stock information, sales information and Expenses information from the PoS to the central ERP

3. Some validation logic to check the data, preventing double imports, etc.

4. Display some basic status info in the PoS screen like total items imported, no. of sales left to sync, etc.

Overall, the client is happy with the solution provided. Let me know if you require clarifications and I will try to explain as much as I can.

This is a useful solution. I use Laragon myself on my development box. It's quite useful. From your post, it sounds like implementing the ability for two instances of OpensourcePOS to sync in a Server/Client relationship would be a good way to accomplish the desired effect. To make that happen in the codebase we would need to sort out a few aspects:

  • API endpoints to receive/send data such as sales, customer/supplier changes, etc (planned).
  • Authorization system to prevent unauthorized API access/encryption in transmission (planned).
  • Configuration capabilities to configure an install as a client and server information necessary to knowing where to get data from and where to send it.
  • Buttons and business logic to sync with server.

A big consideration that needs to be sorted is how to keep data from getting stale. For example if you have server A send the data to Client 1, then while offline Client 1 sells item 1, 2 and 3 and server A makes a change to any of those items, it's possible for problems to be produced. The problems are magnified if you have more than one offline client, such as a large book event requiring more than one client. Also, if a long time goes by without syncing data from client to server, we risk even further exacerbating the situation.

@codify-anand
Copy link

codify-anand commented Mar 21, 2024

A big consideration that needs to be sorted is how to keep data from getting stale. For example if you have server A send the data to Client 1, then while offline Client 1 sells item 1, 2 and 3 and server A makes a change to any of those items, it's possible for problems to be produced. The problems are magnified if you have more than one offline client, such as a large book event requiring more than one client. Also, if a long time goes by without syncing data from client to server, we risk even further exacerbating the situation.
We manage this using the following strategy in our solution:

  1. Each location is given a location name and one location will be managed by one PoS system only.
  2. Stock transfers are done both physically and in ERP (and pushed to PoS via sync) to each locations. Hence only the PoS in that location will sell that stock.
  3. Book fairs are also treated as separate locations inside the system. Hence there's no chance of double billing.
  4. Only limitation so far is that OSPOS has support for only 4 locations internally while the ERP supports creation of any number of locations. We have been able to avoid any issues with this limitation so far because the client very rarely uses more than one laptop for book fair billing.

From your post, it sounds like implementing the ability for two instances of OpensourcePOS to sync in a Server/Client relationship would be a good way to accomplish the desired effect.

Good to know API endpoints are planned. Right now we are finding and calling each model's functions for data querying and updation.

@objecttothis
Copy link
Member

@codify-anand. Once we have the CodeIgniter4 rework completed we can move toward third party integrations. The idea is that we will be exposing API endpoints so that no one using unmodified releases are directly modifying data in the tables. The layer of abstraction provides security and stability. The CI4 rework is going pretty slow though because there aren't a lot of devs available to be working on it.

@objecttothis
Copy link
Member

Yeah, if each client is treated as it's own stock location, then you don't have an issue of overlap. An easy-to-use interface will be needed to facilitate stock transfer. I'm sure we can figure something out, but will need to take into account that there is an optional setting to allow duplicate barcode numbers, so it would likely need to be a scan and select system rather than just feed it a list of barcode numbers. Although you could feed it a list of item_id's since those are unique.

I will say that if we can get this sorted out and in the codebase, that will open up a lot of possibilities. I know of a number of Africans who would love it.

@objecttothis
Copy link
Member

I'm surprised OSPOS has a limit of 4 stock locations. I'll have to look at that part of the code but I imagine it shouldn't take too much work to correct that. One thing to note is that stock locations was developed with locations within a single physical storefront in mind, even if it bends pretty easily to be used to represent multiple storefronts. Ideally we would be adding a layer to have both multiple shop locations and multiple stock locations within shops. The reason for this is that you want a shop location to be able to sell product from more than one stock location and let the stock location tell you better where to find the item. Generally though you don't want to allow shop locations to sell each other's items without a stock transfer though.

@jekkos
Copy link
Member

jekkos commented Mar 23, 2024

the stock transfer is already there, you can do it in receivings I believe. There used to be a special mode that activates once you have more then one location that allows you to do the transfer from one location to another. It was developed by someone a long time ago and then integrated, but I never touched it after.

@hoststatic
Copy link

the requisition in receiving, when you have multiple locations and you can transfer goods from one location to other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants