Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void afterTextChanged(Editable s) {
- textwatcheritem = clicked-1 ;
- int i = 0;
- if(s == etproduct[textwatcheritem].getEditableText()){
- i = 1;
- }else if(s == etquantity[textwatcheritem].getEditableText()){
- i = 2 ;
- }
- switch(i)
- {
- case 1:
- String clientname = edclientname.getText().toString();
- if(TextUtils.isEmpty(clientname)){
- etproduct[textwatcheritem].clearFocus();
- edclientname.requestFocus();
- Toast.makeText(getActivity(), getResources().getString(R.string.strgetclient), Toast.LENGTH_LONG).show();
- } else{
- clientname = edclientname.getText().toString();
- customerid = String.valueOf(Customers.getCustomerid(getActivity(), clientname));
- }
- break;
- case 2:
- String productname = etproduct[textwatcheritem].getText().toString();
- if(TextUtils.isEmpty(productname)){
- etproduct[0].requestFocus() ;
- Toast.makeText(getActivity(), getResources().getString(R.string.strfilldata), Toast.LENGTH_LONG).show();
- } else{
- productname = etproduct[textwatcheritem].getText().toString();
- if(Validating.areSet(productname)) {
- int qu = Stock.getAllStockQuantity(getActivity(), productname);
- if(qu < 1){
- Toast.makeText(getActivity(), "this product is sold out", Toast.LENGTH_LONG).show();
- etproduct[textwatcheritem].findFocus();
- } else {
- int userquantity = 0;
- String qt = etquantity[textwatcheritem].getText().toString();
- if(Validating.areSet(qt)) {
- userquantity = Integer.parseInt(qt) ;
- if(userquantity > qu)
- {
- Toast.makeText(getActivity(), productname +" "+getResources().getString(R.string.strsalesquantityerror1)+
- " "+qu+" "+getResources().getString(R.string.strsalesquantityerror2), Toast.LENGTH_LONG).show();
- etquantity[textwatcheritem].setText("");
- etproduct[textwatcheritem].findFocus();
- return;
- } else {
- // price and taxes of the respective product chosen
- double pr = Stock.getUnitPrice(getActivity(), productname);
- double tx = Stock.getTax(getActivity(), productname);
- int proid = Stock.getStockid(getActivity(), productname);
- //getting the final price tax inc/exclusive times quantity
- double grandtotal = Double.parseDouble(Constants.getPriceAfterBeforeTax(pr, tx, 0)) * userquantity ;
- double grandtotalwithnotax = Double.parseDouble(Constants.getPriceAfterBeforeTax(pr, tx, 1))* userquantity;
- if(userquantity == 0){
- etprice[textwatcheritem].setText("0.0") ;
- }else{
- //set the price of the current item
- String totalp = String.format("%.02f", grandtotal);
- etprice[textwatcheritem].setText(totalp) ;
- //this shit works
- double item_sale_price = pr * userquantity ;
- orderQuantity.add(userquantity);
- String orderdetails = proid+"-"+ userquantity+"-" + item_sale_price+"-"+tx+"-"+grandtotal+ "-"+productname+ "-"+grandtotalwithnotax;
- orderDetailsList.add(orderdetails);
- }
- double reportdata = 0 ;
- String strfinalprice = txreportdata.getText().toString() ;
- if(TextUtils.isEmpty(strfinalprice)) {
- reportdata = 0 ;
- } else {
- reportdata = Double.parseDouble(strfinalprice) ;
- }
- double total = grandtotal + reportdata ;
- String totals = String.format("%.02f", total);
- txreportdata.setText(totals) ;
- }
- } else {
- etprice[textwatcheritem].setText("0.0");
- }
- }
- }
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement