question

liju avatar image
liju asked tg commented

Urgent - Issue - StaticOrderPrintJob prints same order multiple times

I am using the below code to print an Order to the order printer. Multiple merchants using my app are having an issue of same order printing multiple times. Following are the scenarios:

Merchant 1: Has 6 different Clover Stations in their Store with one receipt printer each and 3 shared order printers When my app tries to print with below code. The order is printed 6 times on the receipt printer attached to one of the Stations (i.e. all 6 prints are coming out on the one & the same printer).

Merchant 2: Has 2 different Clover Stations in their Store with one receipt printer each. When my app tries to print with below code. The order is printed 2 times on the receipt printer attached to one of the Stations (i.e. all 2 prints are coming out on the one & the same printer).

// To get orderPrinter

List<printer> printers = mPrinterConnector.getPrinters();

                    if (printers != null && !printers.isEmpty()) {
                        orderPrinter = printers.get(0);
                    }

orderSet = mPrinterConnector.isPrinterSet(Category.ORDER);

Order order = mOrderConnector.getOrder(orderId); if(null !=order){ PrintJob printJob = new StaticOrderPrintJob.Builder().markPrinted(true).order(order).build(); new PrintJobsConnector(DbInit.this).print(orderPrinter, printJob); }

The app uses ContentObserver to watch for changes to the Order table. When new order is in it queries the orders to get the new order and fires the print.

OrderContract.Summaries.contentUriWithAccount(mCloverAccount)

Please help me understand why it is happening and whats the fix for this? Is there some configuration in the merchants end that doing this or something else?

We need to fix this situation asap for our merchants, please help!

6 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

What's your app? What triggers your app to print? What is "orderPrinter" in your example and how'd you obtain it?

0 Likes 0 ·
liju avatar image liju commented ·

Clavo Online Order

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

I'd need more information about how your app works to help. Is it possible your app is being triggered on multiple times to perform the print? Can you give me the merchant names?

0 Likes 0 ·
liju avatar image liju commented ·

Hi Jeff - details as follows: The app name is 'Clavo Online Order'. The merchants are 'Kora Restaurant | Bar | Lounge' and 'L Taco' . The app triggers a print when a new order is created. We get to know it from the content provider & observable uri mechanism. Please see original post for code to obtain the printer. Merchant has installed the app and they mentioned it is on all their Clover stations automatically once they installed.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

How do you prevent your app on each Clover device from detecting an order created and printing a receipt, resulting multiple receipts printed? The order is synced to each Clover device for the merchant, and your observable will be notified on each device.

0 Likes 0 ·
Show more comments

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered tg commented

Marking printed is just a flag. An app (like yours) can print an order any number of times nothing will stop it. If your app chooses to ignore the flag, the job will be printed. It seems like you could iterate over the order and check the line items to see if they are printed, and then only print the line items that aren't printed (which should be none if it was printed on another device previously). However, I believe there could be a lag between seeing the order created and seeing the line items as marked printed. Those things don't happen atomically.

Another approach would be to check the Order.getDevice() and see if it equals the current device, and ignore the change otherwise. I don't think there's a way to get "this" device ID, so you'd need to get the Merchant object, call getDevices(), and find where Device.getSerial().equals(Build.SERIAL), then use the ID from that Device.

4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

liju avatar image liju commented ·

Thanks for the answer Jeff. We found the issue at our end, as you had mentioned, with the observable getting triggered multiple times and hence triggering prints for same order many times. While investigating we also found a flag called reprintAllowed on StaticOrderPrintJob class. What does this stand for?

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

reprintAllowed is used to allow a reprint of an order receipt when it wouldn't otherwise be allowed. If you try to print an order receipt that's already been printed, the owner or manager must authenticate, unless you set reprintAllowed.

0 Likes 0 ·
tg avatar image tg commented ·

hey @jeff from what I can see there is a .getDeviceId() method and not a .getDevices() method for the merchant object -- is the only way to get the list of devices to go through the web api?

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

We don't have an Android SDK wrapper around the /v3/merchant/.../devices endpoint.

0 Likes 0 ·

Welcome to the
Clover Developer Community