package w.soulofpluto.posstock;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;

import com.squareup.okhttp.MediaType;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.security.MessageDigest;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/*
Create by Ramesh Babu
*/

 public class Constants {
    //public static String BASE_URL         = "https://49588a.emporter.eu/";
    //public static String BASE_URL         = "https://30ad04.emporter.eu/";
    //public static String BASE_URL         = "http://192.168.34.14/";
    //20009  13022020
    //public static String BASE_URL         = "http://192.168.34.16/";
    //public static String BASE_URL         = "http://182.18.167.139/";
    public static String         BASE_URL = "http://posapi.plutokm.com/";
    public static String         MenuBar = BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp";
    public static String         Logout = BASE_URL + "/login/doLogout/";
    public static String         Login = BASE_URL + "/login/doLogin";
    public static String         StoreId = BASE_URL + "login/getStoresMappedToUser/";
    public static String         Dashboard = BASE_URL + "/stockaudit/listOfStockAuditsOfLoginStore";
    public static String         BarcodeUpload = BASE_URL + "/stockaudit/validateStockAuditBarcode";
    public static String         BarcodeDelete = BASE_URL + "/stockaudit/deleteBarcodeAndQuantityFromStockAudit";
    public static String         BarcodeComplete = BASE_URL + "/stockaudit/batchScanningCompleted";
    public static String         RackWiseQty = BASE_URL + "/stockaudit/stockAuditPlanBarcodesScannedInformation";
    public static String         BarcodeSearch = BASE_URL + "/stockaudit/stockAuditBarcodeRackInformation";
    public static String         GenerateSlip = BASE_URL + "/Sales/generateDeliverySlip";
    public static String         GetInfoWithTFS = BASE_URL + "Tfs/getInfoWithTfsNumber";
    public static String         GetTFSBoxNumbers = BASE_URL + "/Tfs/getTfsBoxesNumbers/";
    public static String         GetTFSBoxDetailsByBarcode = BASE_URL + "/Tfs/getTfsBoxDetailsBybarcode/";
    public static String         StockReceiving = BASE_URL + "Tfs/stockReceiving";
    public static String         ToState = BASE_URL + "Stores/getActiveStoreStates";
    public static String         ToFormat = BASE_URL + "Stores/getDistinctActiveStoreForamtsOfGivenState/";
    public static String         ToStoreFormat = BASE_URL + "Stores/getActiveStoresInGivenStoreAndFormat/";
    public static String         StockPointId = BASE_URL + "/stockpoint/getGivenStoreSaleStockPointId/";
    public static String         CheckBarcodeQty = BASE_URL + "Inventory/checkBarcodeQuantityInGivenStockPoint";
    public static String         StockTransfer = BASE_URL + "/Tfs/stockTransfer";
    public static String         Type = "Content-Type";
    public static String         App_json = "application/json";
    public static String         Access_Token = "Pos-Access-Token";
    public static String         Access_StoreId = "Pos-User-Access-Store-Id";
    public static MediaType      JSON = MediaType.parse("application/json; charset=utf-8");
    public static String         Sec = "<font color=#3700B3><b>SECTION      : </b></font>";
    public static String         div = "<font color=#3700B3><b>DIVISION     : </b></font>";
    public static String         Id = "<font color=#3700B3><b>RACK ID      : </b></font>";
    public static String         Qty = "<font color=#3700B3><b>QTY          : </b></font>";
    public static String         User = "<font color=#3700B3><b>UserId       : </b></font>";
    public static String         From = "<font color=#3700B3><b>Start time   : </b></font>";
    public static String         To = "<font color=#3700B3><b>End time     : </b></font>";
    public static String         Count = "<font color=#3700B3><b>TOTAL SCANNED ITEMS     : </b></font>";
    public static String         Barcode = "<font color=#3700B3><b>Barcode      : </b></font>";
    public static String         Ver_Text = "<font color=#ee4d35><b>Version      : </b></font>";
    public static String         Plan_Id = "<font color=#3700B3><b>PLAN ID      : </b></font>";
    public static String         Name = "<font color=#3700B3><b>NAME         : </b></font>";
    public static String         VERSION = "1.1";
    public static int            Value = 14;
    public static final String   dashed = "------------------------------------------------" + "\n";
    public static ProgressDialog progressDialog;
    public static StringBuilder  stringBuilder;

    public static void getToast(Context context, String data) {
        Toast toast = Toast.makeText(context, data, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    public static String getVal(int count) {
       return "<font color=#3700B3><b>TOTAL SCANNED ITEMS     : </b></font>" + "<font color=#3700B3><b>" + count + "</b></font>";
    }

    public static String getTotalItems(String count) {
       return "<font color=#ee4d35><b>Items     : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getTotalMRP(String count) {
       return "<font color=#ee4d35><b>Total MRP  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getTotalDisc(String count) {
       return "<font color=#ee4d35><b> Disc &nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getTotalNetPayable(String count) {
       return "<font color=#ee4d35><b>NetPayable : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getBarcode(String count) {
       return "<font color=#797979><b>Barcode     : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getCode(String count) {
       return "<font color=#797979><b>Disc    : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getMRP(String count) {
       return "<font color=#797979><b>MRP  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getEmpId(String count) {
       return "<font color=#797979><b>SM   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
    }

    public static String getNetPayable(String count) {
       return "<font color=#797979><b>NetPayable     : </b></font>" + "<font color=#4caa4c><b>" + count + "</b></font>";
    }

    public static boolean isNetworkAvailable(Context context) {
       ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
       NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
       return activeNetworkInfo != null;
    }

    public static String IndianRupeesFormat(String amount) {
       NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
       String moneyString = formatter.format(Double.valueOf(amount));
       return moneyString;
    }
    public static void ProgressDialogShow(Context context) {
       progressDialog = new ProgressDialog(context);
       progressDialog.setMessage("Loading Please wait ...");
       progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
       progressDialog.show();
    }

    public static void ProgressDialogDismiss() {
       if (progressDialog != null) {
           progressDialog.dismiss();
       }
    }

    public static String PrintData(String Id) {
       return ",{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
    }

    public static String PrintData1(String Id) {
       return "{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
    }

    public static String getSHA256(String data) {
       StringBuffer sb = new StringBuffer();
       try {
           MessageDigest md = MessageDigest.getInstance("SHA-256");
           md.update(data.getBytes());
           byte byteData[] = md.digest();
           for (int i = 0; i < byteData.length; i++) {
               sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
       return sb.toString();
    }

    public static String convertString(String data) {
       StringBuilder stringBuilder = new StringBuilder();
       try {
           JSONArray jsonArray = new JSONArray(data);
           for (int i = 0; i < jsonArray.length(); i++) {
               stringBuilder.append(jsonArray.get(i) + ",");
           }
       } catch (JSONException e) {
           e.printStackTrace();
       }
       return stringBuilder.toString().substring(0, stringBuilder.toString().length() - 1);
    }

    public static Boolean Existing(ArrayList<Plans> plans, String barcode) {
       for (Plans plan : plans) {
           if (plan.getBarcode().contains(barcode)) {
             return true;
           }
       }
       return false;
    }

    public static Boolean ExistingStockWord(ArrayList<StockBarcode> plans, String barcode) {
       for (StockBarcode plan : plans) {
           Log.e("barcode ===>", plan.barcode);
           Log.e("barcode ===>", barcode);
           if (plan.getBarcode().contains(barcode)) {
               return true;
           }
       }
       return false;
    }

    public static Date getDateWithOffset(int offset, Date date) {
       Calendar calendar = Calendar.getInstance();
       calendar.setTime(date);
       calendar.add(Calendar.DAY_OF_MONTH, offset);
       return calendar.getTime();
    }

    protected static void hideSoftKeyboard(EditText input, Context context) {
       InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
    }

    public static String SL(String len) {
       if (len.length() == 3) {
           return len;
       } else if (len.length() == 2) {
           return len + " ";
       } else if (len.length() == 1) {
           return len + "  ";
       }
       return null;
    }

    public static String Qty(String len) {
       if (len.length() == 3) {
           return len + " ";
       } else if (len.length() == 2) {
           return len + "  ";
       } else if (len.length() == 1) {
           return len + "   ";
       }
       return null;
    }

    public static String Barcode(String mrp) {
       if (mrp.length() == 11) {
          return mrp;
       } else if (mrp.length() == 10) {
          return mrp + " ";
       } else if (mrp.length() == 9) {
          return mrp + "  ";
       } else if (mrp.length() == 8) {
          return mrp + "   ";
       } else if (mrp.length() == 7) {
          return mrp + "    ";
       } else if (mrp.length() == 6) {
          return mrp + "     ";
       } else if (mrp.length() == 5) {
          return mrp + "      ";
       } else if (mrp.length() == 4) {
          return mrp + "       ";
       } else if (mrp.length() == 3) {
          return mrp + "        ";
       } else if (mrp.length() == 2) {
          return mrp + "         ";
       } else if (mrp.length() == 1) {
          return mrp + "          ";
       }
        return null;
    }

    public static String Mrp(String mrp) {
        if (mrp.length() == 9) {
            return mrp;
        } else if (mrp.length() == 9) {
            return mrp + " ";
        } else if (mrp.length() == 8) {
            return mrp + "  ";
        } else if (mrp.length() == 7) {
            return mrp + "   ";
        } else if (mrp.length() == 6) {
            return mrp + "    ";
        } else if (mrp.length() == 5) {
            return mrp + "     ";
        } else if (mrp.length() == 4) {
            return mrp + "      ";
        } else if (mrp.length() == 3) {
            return mrp + "       ";
        } else if (mrp.length() == 2) {
            return mrp + "        ";
        } else if (mrp.length() == 1) {
            return mrp + "         ";
        }
        return null;
    }

    public static String Dis(String dis) {
        if (dis.length() == 9) {
            return dis;
        } else if (dis.length() == 8) {
            return dis + " ";
        } else if (dis.length() == 7) {
            return dis + "  ";
        } else if (dis.length() == 6) {
            return dis + "   ";
        } else if (dis.length() == 5) {
            return dis + "    ";
        } else if (dis.length() == 4) {
            return dis + "     ";
        } else if (dis.length() == 3) {
            return dis + "      ";
        } else if (dis.length() == 2) {
            return dis + "       ";
        } else if (dis.length() == 1) {
            return dis + "        ";
        }
        return null;
    }

    public static String Total(String mrp) {
        if (mrp.length() == 11) {
            return mrp;
        } else if (mrp.length() == 10) {
            return mrp + " ";
        } else if (mrp.length() == 9) {
            return mrp + "  ";
        } else if (mrp.length() == 8) {
            return mrp + "   ";
        } else if (mrp.length() == 7) {
            return mrp + "    ";
        } else if (mrp.length() == 6) {
            return mrp + "     ";
        } else if (mrp.length() == 5) {
            return mrp + "      ";
        } else if (mrp.length() == 4) {
            return mrp + "       ";
        } else if (mrp.length() == 3) {
            return mrp + "        ";
        } else if (mrp.length() == 2) {
            return mrp + "         ";
        } else if (mrp.length() == 1) {
            return mrp + "          ";
        }
        return null;
    }

    public static String Taxable(String tax) {
        if (tax.length() == 13) {
            return tax;
        } else if (tax.length() == 12) {
            return tax + " ";
        } else if (tax.length() == 11) {
            return tax + "  ";
        } else if (tax.length() == 10) {
            return tax + "   ";
        } else if (tax.length() == 9) {
            return tax + "    ";
        } else if (tax.length() == 8) {
            return tax + "     ";
        } else if (tax.length() == 7) {
            return tax + "      ";
        } else if (tax.length() == 6) {
            return tax + "       ";
        } else if (tax.length() == 5) {
            return tax + "        ";
        } else if (tax.length() == 4) {
            return tax + "         ";
        } else if (tax.length() == 3) {
            return tax + "          ";
        } else if (tax.length() == 2) {
            return tax + "           ";
        } else if (tax.length() == 1) {
            return tax + "            ";
        }
        return null;
    }

    public static String CGST(String dis) {
        if (dis.length() == 9) {
            return dis;
        } else if (dis.length() == 8) {
            return dis + " ";
        } else if (dis.length() == 7) {
            return dis + "  ";
        } else if (dis.length() == 6) {
            return dis + "   ";
        } else if (dis.length() == 5) {
            return dis + "    ";
        } else if (dis.length() == 4) {
            return dis + "     ";
        } else if (dis.length() == 3) {
            return dis + "      ";
        } else if (dis.length() == 2) {
            return dis + "       ";
        } else if (dis.length() == 1) {
            return dis + "        ";
        }
        return null;
    }

    public static String SGST(String dis) {
        if (dis.length() == 7) {
            return dis + " ";
        } else if (dis.length() == 6) {
            return dis + " ";
        } else if (dis.length() == 5) {
            return dis + "  ";
        } else if (dis.length() == 4) {
            return dis + "   ";
        } else if (dis.length() == 3) {
            return dis + "    ";
        } else if (dis.length() == 2) {
            return dis + "     ";
        } else if (dis.length() == 1) {
            return dis + "      ";
        }
        return null;
    }

    public static String IGST(String dis) {
        if (dis.length() == 8) {
            return dis;
        } else if (dis.length() == 7) {
            return dis + " ";
        } else if (dis.length() == 6) {
            return dis + " ";
        } else if (dis.length() == 5) {
            return dis + "  ";
        } else if (dis.length() == 4) {
            return dis + "   ";
        } else if (dis.length() == 3) {
            return dis + "    ";
        } else if (dis.length() == 2) {
            return dis + "     ";
        } else if (dis.length() == 1) {
            return dis + "      ";
        }
        return null;
    }

    public static String GST(String dis) {
        if (dis.length() == 7) {
            return dis;
        } else if (dis.length() == 6) {
            return dis + " ";
        } else if (dis.length() == 5) {
            return dis + "  ";
        } else if (dis.length() == 4) {
            return dis + "   ";
        } else if (dis.length() == 3) {
            return dis + "    ";
        } else if (dis.length() == 2) {
            return dis + "     ";
        } else if (dis.length() == 1) {
            return dis + "      ";
        }
        return null;
    }

    public static String Gross(String dis) {
        if (dis.length() == 10) {
            return "                     " + dis;
        } else if (dis.length() == 9) {
            return "                      " + dis;
        } else if (dis.length() == 8) {
            return "                       " + dis;
        } else if (dis.length() == 7) {
            return "                        " + dis;
        } else if (dis.length() == 6) {
            return "                         " + dis;
        } else if (dis.length() == 5) {
            return "                          " + dis;
        } else if (dis.length() == 4) {
            return "                           " + dis;
        } else if (dis.length() == 3) {
            return "                            " + dis;
        } else if (dis.length() == 2) {
            return "                             " + dis;
        } else if (dis.length() == 1) {
            return "                              " + dis;
        }
        return null;
    }

    public static String RecievedCashText(String dis) {
        if (dis.length() == 13) {
            return dis + "     ";
        } else if (dis.length() == 14) {
            return dis + "    ";
        } else if (dis.length() == 15) {
            return dis + "   ";
        } else if (dis.length() == 16) {
            return dis + "  ";
        } else if (dis.length() == 17) {
            return dis + " ";
        } else if (dis.length() == 18) {
            return dis;
        }
        return null;
    }

    public static String Deliveryslipnumber(String dev) {
        if (dev.length() == 16) {
            return dev + "    ";
        } else if (dev.length() == 15) {
            return dev + "     ";
        } else if (dev.length() == 14) {
            return dev + "      ";
        } else if (dev.length() == 13) {
            return dev + "       ";
        } else if (dev.length() == 12) {
            return dev + "        ";
        } else if (dev.length() == 11) {
            return dev + "         ";
        }
        return null;
    }

    public static String DeliveryslipQty(String dev) {
        if (dev.length() == 7) {
            return dev + "      ";
        } else if (dev.length() == 6) {
            return dev + "       ";
        } else if (dev.length() == 5) {
            return dev + "        ";
        } else if (dev.length() == 4) {
            return dev + "         ";
        } else if (dev.length() == 3) {
            return dev + "          ";
        } else if (dev.length() == 2) {
            return dev + "           ";
        } else if (dev.length() == 1) {
            return dev + "            ";
        }
        return null;
    }

    public static String DeliveryslipAmt(String dev) {
        if (dev.length() == 11) {
            return dev + "    ";
        } else if (dev.length() == 10) {
            return dev + "    ";
        } else if (dev.length() == 9) {
            return dev + "     ";
        } else if (dev.length() == 8) {
            return dev + "      ";
        } else if (dev.length() == 7) {
            return dev + "       ";
        } else if (dev.length() == 6) {
            return dev + "        ";
        } else if (dev.length() == 5) {
            return dev + "          ";
        } else if (dev.length() == 4) {
            return dev + "          ";
        } else if (dev.length() == 3) {
            return dev + "           ";
        } else if (dev.length() == 2) {
            return dev + "            ";
        } else if (dev.length() == 1) {
            return dev + "             ";
        }
        return null;
    }

    public static String RecievedCash(String dis) {
        if (dis.length() == 10) {
            return "                   " + dis;
        } else if (dis.length() == 9) {
            return "                    " + dis;
        } else if (dis.length() == 8) {
            return "                     " + dis;
        } else if (dis.length() == 7) {
            return "                      " + dis;
        } else if (dis.length() == 6) {
            return "                       " + dis;
        } else if (dis.length() == 5) {
            return "                        " + dis;
        } else if (dis.length() == 4) {
            return "                         " + dis;
        } else if (dis.length() == 3) {
            return "                          " + dis;
        } else if (dis.length() == 2) {
            return "                           " + dis;
        } else if (dis.length() == 1) {
            return "                            " + dis;
        }
        return null;
    }

    public static String TotalSavings(String dis) {
        if (dis.length() == 10) {
            return "                     " + dis;
        } else if (dis.length() == 9) {
            return "                      " + dis;
        } else if (dis.length() == 8) {
            return "                       " + dis;
        } else if (dis.length() == 7) {
            return "                        " + dis;
        } else if (dis.length() == 6) {
            return "                         " + dis;
        } else if (dis.length() == 5) {
            return "                          " + dis;
        } else if (dis.length() == 4) {
            return "                           " + dis;
        } else if (dis.length() == 3) {
            return "                            " + dis;
        } else if (dis.length() == 2) {
            return "                             " + dis;
        } else if (dis.length() == 1) {
            return "                              " + dis;
        }
        return null;
    }

    public static String IndianRupeesformat(String amount) {
        NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
        String moneyString = formatter.format(Double.valueOf(amount));
        return moneyString;
    }

    public static void hideKeyboard(Activity activity) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        View view = activity.getCurrentFocus();
        if (view == null) {
            view = new View(activity);
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    public static void hideSoftKeyBoardOnTabClicked(View v, Context context) {
        if (v != null && context != null) {
            InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    public static String formData(String builder, String name, String phone) {
        stringBuilder = new StringBuilder();
        stringBuilder.append("{" + '"' + "approval_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
        stringBuilder.append('"' + "from_mobile" + '"' + ":" + '"' + "yes" + '"' + ",");
        stringBuilder.append('"' + "incharge_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
        stringBuilder.append('"' + "bill_level_manual_discount" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "transaction_type" + '"' + ":" + '"' + "presale_check" + '"' + ",");
        stringBuilder.append('"' + "clear_promotion" + '"' + ":" + '"' + "N" + '"' + ",");
        stringBuilder.append('"' + "delivery_slips" + '"' + ":" + "[" + builder + "]" + ",");
        stringBuilder.append('"' + "actual_received_cash" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "return_cash_amount" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "mop" + '"' + ":" + "{");
        stringBuilder.append('"' + "cash" + '"' + ":" + '"' + 0 + '"' + ",");
        stringBuilder.append('"' + "credit_card" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "return_slips" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "pkt_pending" + '"' + ":" + '"' + 0 + '"' + ",");
        stringBuilder.append('"' + "pkt_advance_used" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "gv_ids" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "loyalty_points" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "km_gvs" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "online_gvs" + '"' + ":" + "[]" + "}" + ",");
        stringBuilder.append('"' + "customer_info" + '"' + ":" + "{");
        stringBuilder.append('"' + "customer_phone" + '"' + ":" + '"' + phone + '"' + ",");
        stringBuilder.append('"' + "customer_name" + '"' + ":" + '"' + name + '"' + "},");
        stringBuilder.append('"' + "otp" + '"' + ":" + '"' + '"' + "}");
        return stringBuilder.toString();
    }

    public static String formData1(String builder, String name, String phone, JSONObject obj) {
        stringBuilder = new StringBuilder();
        stringBuilder.append("{" + '"' + "approval_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
        stringBuilder.append('"' + "from_mobile" + '"' + ":" + '"' + "yes" + '"' + ",");
        stringBuilder.append('"' + "incharge_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
        stringBuilder.append('"' + "bill_level_manual_discount" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "transaction_type" + '"' + ":" + '"' + "sale" + '"' + ",");
        stringBuilder.append('"' + "clear_promotion" + '"' + ":" + '"' + "N" + '"' + ",");
        stringBuilder.append('"' + "delivery_slips" + '"' + ":" + "[" + builder + "]" + ",");
        stringBuilder.append('"' + "actual_received_cash" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "return_cash_amount" + '"' + ":" + '"' + "0" + '"' + ",");
        stringBuilder.append('"' + "mop" + '"' + ":" + "{");
        stringBuilder.append('"' + "cash" + '"' + ":" + '"' + 0 + '"' + ",");
        stringBuilder.append('"' + "credit_card" + '"' + ":" + "[" + obj + "]" + ",");
        stringBuilder.append('"' + "return_slips" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "pkt_pending" + '"' + ":" + '"' + 0 + '"' + ",");
        stringBuilder.append('"' + "pkt_advance_used" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "gv_ids" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "loyalty_points" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "km_gvs" + '"' + ":" + "[]" + ",");
        stringBuilder.append('"' + "online_gvs" + '"' + ":" + "[]" + "}" + ",");
        stringBuilder.append('"' + "customer_info" + '"' + ":" + "{");
        stringBuilder.append('"' + "customer_phone" + '"' + ":" + '"' + phone + '"' + ",");
        stringBuilder.append('"' + "customer_name" + '"' + ":" + '"' + name + '"' + "},");
        stringBuilder.append('"' + "otp" + '"' + ":" + '"' + '"' + "}");
        return stringBuilder.toString();
    }

    public static String JsonFormatData(String TFS, String Box, ArrayList<BoxInfo> arrayList, String Store_Id) throws JSONException {
        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i < arrayList.size(); i++) {
            BoxInfo boxInfo = arrayList.get(i);
            JSONObject jsonObject = new JSONObject();
            if (boxInfo.getStatus()) {
                jsonObject.put("barcode", boxInfo.getBarcode());
                jsonObject.put("box_id", Box);
                jsonObject.put("pending_qty", boxInfo.getPending_qty());
                jsonObject.put("quantity", boxInfo.getReceive_qty());
                jsonObject.put("received_qty", boxInfo.getReceive_qty());
                jsonObject.put("transfered_qty", boxInfo.getTransfer_qty());
                jsonObject.put("uom", "units");
            } else {
                jsonObject.put("barcode", boxInfo.getBarcode());
                jsonObject.put("box_id", Box);
                jsonObject.put("pending_qty", boxInfo.getPending_qty());
                jsonObject.put("quantity", "0.00");
                jsonObject.put("received_qty", boxInfo.getReceive_qty());
                jsonObject.put("transfered_qty", boxInfo.getTransfer_qty());
                jsonObject.put("uom", "units");
            }
            jsonArray.put(jsonObject);
        }
        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("tfs_id", TFS);
        jsonObject1.put("receiving_store_id", Store_Id);
        jsonObject1.put("received_items", jsonArray);
        return jsonObject1.toString();
    }
 }
