Rev 20067 | Rev 21844 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.inventory.service;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.text.DateFormat;import java.util.Calendar;import java.util.Date;import java.util.Map;import org.apache.thrift.TException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.itextpdf.text.Document;import com.itextpdf.text.Element;import com.itextpdf.text.Font;import com.itextpdf.text.Font.FontFamily;import com.itextpdf.text.FontFactory;import com.itextpdf.text.Paragraph;import com.itextpdf.text.Phrase;import com.itextpdf.text.Rectangle;import com.itextpdf.text.pdf.PdfPCell;import com.itextpdf.text.pdf.PdfPTable;import com.itextpdf.text.pdf.PdfWriter;import in.shop2020.model.v1.catalog.CatalogServiceException;import in.shop2020.model.v1.inventory.StateInfo;import in.shop2020.model.v1.inventory.VatType;import in.shop2020.model.v1.order.BuyerInfo;import in.shop2020.model.v1.order.WarehouseAddress;import in.shop2020.purchase.PurchaseOrder;import in.shop2020.purchase.Supplier;import in.shop2020.purchase.TaxType;import in.shop2020.thrift.clients.CatalogClient;import in.shop2020.thrift.clients.InventoryClient;import in.shop2020.thrift.clients.TransactionClient;public class PdfPoSheetGenerator {private static Logger logger = LoggerFactory.getLogger(PdfPoSheetGenerator.class);// private static final Properties properties = readProperties();private static final String ourAddressDelhi = "Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";private static final String ourAddressBhiwandi = "Spice Online Retail Pvt. Ltd.\nC/O. FedEx Express Transportation and Supply Chain Services (India) Private Limited.\nC/O NDR WAREHOUSING, SURVEY NO.95, MUMBAI - NASIK HIGHWAY, WADAPE VILLAGE\nBHIWANDI (NR. SAI DHABA), Thane,Maharashtra -421302\n";private static final String ourAddressGoregaon = "Spice Online Retail Pvt. Ltd.\n93/743, Motilal Nagar-1, Goregaon(WEST),\nMotilal Nagar, Mumbai, Maharashtra-400062\n";private static final String ourAddressBangalore = "Spice Online Retail Pvt. Ltd.\n C/O.Drive India Enterprise Solutions Limited)\n Survey No. 86, Korulur Village, Kasab Hobli\n Hoskote Taluka\n Bangalore – 560067, Karnataka\n";private static final String ourAddressBangaloreSR = "Spice Online Retail Pvt. Ltd.\n Shop No. 320, Municipal 59th Cross,\n Next to Rammandir Ground,\n 3rd Block, Rajaji Nagar,\nBangalore - 560010, Karnataka\n";private static final String ourAddressGurgaon = "Spice Online Retail Private Limited,\n SHOP NO. 10 & 11,\n OLD DELHI ROAD,OPP SECTOR-14, GURGAON-122001 Haryana\n";private static final String ourAddressHyderabad = "Spice Online Retail Pvt. Ltd, Drive India Enterprise Solutions Limited, 16,17&18, Gundllapochampalli, Kompalli, Medchal Mandal, Secandrabad-500014, Dist- Hyderabad";private static final String ourAddressGurgaonS = "Spice Online Retail Pvt Ltd. \nC/O.Drive India Enterprise Solutions Ltd, \nKhasra No.2771,Main Sheetla Mata Mandir Road \nOpposite Sec-5,Petrol Pump(Bharat Petroliam) \nNear Anmol Vatika, Gurgaon- 122001";private static final String amazonAddress = "Spice Online Retail Pvt. Ltd. C/O Amazon Seller Services Pvt. Ltd.,\nBuilding H Prathmesh Complex, Saravali Village,\nOpp Hotel Vatika Kalyan, Bhivandi Junction,\nBhiwandi, Maharashtra\n";private static final String amazonAddreseBangalore = "Spice Online Retail Pvt. Ltd.\n C/O Amazon Seller Services Pvt. Ltd.\n 38 & 39, Soukya Road,\n kacherakanahalli,\n Hoskote Taluka,\n Bangalore -560067, Karnataka\n";private static final String amazonAddressMewat = "Spice Online Retail Pvt. Ltd.\n C/O AMAZON Seller Services Pvt. Limited,\n Gokaldas Warehousing Corporation, Unit No 1,\n Village Taoru, Tehsil Taoru, Distt Mewat - 122105";private static final String amazonAddressDelhi = "Spice Online Retail Pvt Ltd., \nC/O Amazon Seller Services Pvt. Ltd., \nA43 GF MOHAN COOPERATIVE IND, \nESTATE MAIN MATHURA ROAD, \nBADARPUR SOUTH DELHI, Delhi -110044";private static final String flipkartAddressGgn = "Spice Online Retail Pvt. Ltd.\n C/O. Flipkart Internet Pvt. Ltd, \n KILLA NO.219/15-16 25/1 220/11 12/1 12/2 13/1/113/1/2 20 21/1 21/2/1 22/1 23/1/1,\n Bohra Kalan, PATAUDI, GURGAON - 122001, Haryana\n";private static final String flipkartAddressDelhi = "Spice Online Retail Pvt. Ltd.\n C/O Flipkart Internet Pvt. Ltd.\n Khasra No. 435,Road No.# 04 ,Lal Dora Extension,\nMahipalpur, New Delhi- 110037\n";private static final String snapdealAddressDelhi = "Spice Online Retail Pvt. Ltd, \nC/O. Gati Kintetsu Express Pvt Ltd.,\nPlot In Khasra No. 15/17,24, G/F, \nVillage- Samalkha, New Delhi - 110037";private static final String tinNoDelhi = "07250399732";private static final String tinNoMum = "27450984008";private static final String tinNoBan = "29171183852";private static final String tinNoFkGgn = "06681944625";private static final String tinNoOurGgn = "06681944625";private static final String tinNoOurHyd = "36601220768";private static final String tinNoFkDelhi = "07720408834";private static final Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);private static final Font helveticaBold8 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8);private static final Font helveticaBold12 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12);public static Map<Long, StateInfo> stateIdMap = null;static{try{in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();stateIdMap = inventoryClient.getStateMaster();} catch(Exception e){logger.error("Unable to get State Info Map", e);}}public static String generatePdfSheet(PurchaseOrder purchaseOrder,Supplier supplier) throws IOException {ByteArrayOutputStream baosPDF = null;try {baosPDF = new ByteArrayOutputStream();Document document = new Document();PdfWriter.getInstance(document, baosPDF);document.addAuthor("shop2020");document.addTitle("Purchase Order No: "+ purchaseOrder.getPoNumber());document.open();PdfPTable poTable = getPoTable(purchaseOrder, supplier);poTable.setSpacingAfter(10.0f);poTable.setWidthPercentage(90.0f);document.add(poTable);document.close();baosPDF.close();} catch (Exception e) {logger.error("Error while generating Invoice: ", e);e.printStackTrace();}String tmpDir = System.getProperty("java.io.tmpdir");String filename = tmpDir + "/po-" + purchaseOrder.getId() + ".pdf";File f = new File(filename);FileOutputStream fos = new FileOutputStream(f);baosPDF.writeTo(fos);return filename;}private static PdfPTable getPoTable(PurchaseOrder purchaseOrder,Supplier supplier) throws Exception {PdfPTable poTable = new PdfPTable(1);poTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);poTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);PdfPCell poTitleCell = new PdfPCell(new Phrase("Purchase Order",helveticaBold12));poTitleCell.setHorizontalAlignment(Element.ALIGN_CENTER);poTitleCell.setBorder(Rectangle.NO_BORDER);long poValidityLimit = supplier.getPoValidityLimit();Calendar cal1 = Calendar.getInstance();cal1.setTimeInMillis(purchaseOrder.getCreatedAt());cal1.add(Calendar.DAY_OF_MONTH, (int)poValidityLimit);Date poDate = new Date(purchaseOrder.getCreatedAt());Date poExpiryDate = new Date(cal1.getTimeInMillis());PdfPTable poSummaryTable = new PdfPTable(new float[] { 0.3f, 0.3f, 0.4f });poSummaryTable.addCell(new PdfPCell(new Phrase("PO No: "+ purchaseOrder.getPoNumber())));poSummaryTable.addCell(new PdfPCell(new Phrase("Date: "+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(poDate))));poSummaryTable.addCell(new PdfPCell(new Phrase("PO Valid for delivery by: "+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(poExpiryDate))));poSummaryTable.setSpacingBefore(10.0f);poTable.addCell(poTitleCell);poTable.addCell(getAddressCell(purchaseOrder));poTable.addCell(poSummaryTable);poTable.addCell(getSalutationTable(supplier));poTable.addCell(getPoDetailsTable(purchaseOrder, supplier));poTable.addCell(getBillToTable(purchaseOrder));//poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));return poTable;}/*private static PdfPCell getCFormCell(TaxType taxType) {PdfPCell cFormCell = null;if(taxType == TaxType.CFORM) {cFormCell = new PdfPCell(new Paragraph("*To be billed on CST Against C-Form ", new Font(FontFamily.TIMES_ROMAN, 8f)));} else {cFormCell = new PdfPCell();}cFormCell.setBorder(Rectangle.NO_BORDER);cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT);return cFormCell;}*/private static PdfPTable getAddressCell(PurchaseOrder purchaseOrder) {//TODO Write this code in a proper configurable wayBuyerInfo binfo = null;String address = "";String tinNo = "";String shippingAddress = "";try {in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();binfo = tClient.getBuyerByWarehouse(purchaseOrder.getWarehouseId());WarehouseAddress addr = tClient.getWarehouseAddress(purchaseOrder.getWarehouseAddressId());tinNo = binfo.getTin();address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();} catch (Exception e) {logger.error("This should not happen", e);}PdfPTable billToShipToTable = new PdfPTable(2);Paragraph addressParagraph = new Paragraph(address + "\nTIN NO. "+ tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));PdfPCell addressCell = new PdfPCell();if(purchaseOrder.getWarehouseId() != purchaseOrder.getShippingWarehouseId()) {addressParagraph = new Paragraph("Bill To :\n" + address + "\n\nTIN NO. "+ tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));}addressCell.addElement(addressParagraph);//addressCell.setHorizontalAlignment(Element.ALIGN_CENTER);addressCell.setBorder(Rectangle.NO_BORDER);if(purchaseOrder.getWarehouseId() != purchaseOrder.getShippingWarehouseId()) {try {in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();WarehouseAddress addr = tClient.getWarehouseAddress(purchaseOrder.getShippingWarehouseAddressId());address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();} catch (Exception e) {logger.error("This should not happen", e);}/* if(shippingWarehouseId ==7) {shippingAddress = ourAddressDelhi;shippingTinNo = tinNoDelhi;} else if(shippingWarehouseId == 12) {shippingAddress = ourAddressGoregaon;shippingTinNo = tinNoMum;} else if(shippingWarehouseId == 13) {shippingAddress = ourAddressBhiwandi;shippingTinNo = tinNoMum;} else if(shippingWarehouseId ==16) {shippingAddress = amazonAddress;shippingTinNo = tinNoMum;} else if(shippingWarehouseId ==1765){shippingAddress = ourAddressBangalore;shippingTinNo = tinNoBan;} else if(shippingWarehouseId ==1768){shippingAddress = ourAddressBangaloreSR;shippingTinNo = tinNoBan;} else if(shippingWarehouseId ==1771){shippingAddress = amazonAddreseBangalore;shippingTinNo = tinNoBan;} else if(shippingWarehouseId == 2854){shippingAddress = flipkartAddressGgn;shippingTinNo = tinNoFkGgn;} else if(shippingWarehouseId == 2857){shippingAddress = ourAddressGurgaon;shippingTinNo = tinNoOurGgn;} else if(shippingWarehouseId == 3295){shippingAddress = amazonAddressMewat;shippingTinNo = tinNoOurGgn;} else if(shippingWarehouseId == 3298){shippingAddress = ourAddressHyderabad;shippingTinNo = tinNoOurHyd;} else if(shippingWarehouseId == 3931){shippingAddress = ourAddressGurgaonS;shippingTinNo = tinNoOurGgn;} else if(shippingWarehouseId == 4699){shippingAddress = flipkartAddressDelhi;shippingTinNo = tinNoFkDelhi;} else if(shippingWarehouseId == 5314){shippingAddress = snapdealAddressDelhi;shippingTinNo = tinNoFkDelhi;} else if(shippingWarehouseId == 5623){shippingAddress = amazonAddressDelhi;shippingTinNo = tinNoDelhi;}*/PdfPCell billToShipToCell = new PdfPCell();billToShipToCell.setHorizontalAlignment(Element.ALIGN_LEFT);billToShipToCell.setBorder(Rectangle.NO_BORDER);PdfPCell shippingAddressCell = new PdfPCell();shippingAddressCell.addElement(new Paragraph("Ship To :\n" +shippingAddress + "\nTIN NO. "+ tinNo, new Font(FontFamily.TIMES_ROMAN, 8f)));shippingAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);shippingAddressCell.setBorder(Rectangle.LEFT);billToShipToTable.addCell(addressCell);billToShipToTable.addCell(shippingAddressCell);billToShipToCell.addElement(billToShipToTable);return billToShipToTable;}billToShipToTable.addCell(addressCell);PdfPCell placeHolderCell = new PdfPCell();placeHolderCell.setBorder(Rectangle.NO_BORDER);billToShipToTable.addCell(placeHolderCell);return billToShipToTable;}private static PdfPTable getSalutationTable(Supplier supplier)throws Exception {PdfPTable salutationTable = new PdfPTable(1);salutationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);salutationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);salutationTable.addCell(new Phrase("To", helvetica8));if(supplier.getName().equals("Smobility Ltd.")) {salutationTable.addCell(new Phrase("Spice Retail Ltd.", helvetica8));} else if(supplier.getName().equals("Smobility Ltd. - Mumbai")) {salutationTable.addCell(new Phrase("Spice Retail Ltd. Mumbai", helvetica8));} else {salutationTable.addCell(new Phrase(supplier.getName(), helvetica8));}salutationTable.addCell(new Paragraph(supplier.getCommunicationAddress(), helvetica8));salutationTable.addCell(new Phrase("Dear Sir/Madam", helveticaBold8));salutationTable.addCell(new Phrase("Please supply the following stocks as per the details given below:",helvetica8));salutationTable.addCell(new Phrase(" "));return salutationTable;}private static PdfPTable getPoDetailsTable(PurchaseOrder purchaseOrder,Supplier supplier) throws CatalogServiceException, TException {PdfPTable detailsTable = new PdfPTable(new float[] { 0.1f, 0.3f, 0.1f,0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f });detailsTable.addCell(new Phrase("Sl. No.", helveticaBold8));detailsTable.addCell(new Phrase("Description", helveticaBold8));detailsTable.addCell(new Phrase("Quantity", helveticaBold8));detailsTable.addCell(new Phrase("Mrp", helveticaBold8));if(purchaseOrder.getTaxType()==TaxType.CFORM){detailsTable.addCell(new Phrase("Rate Excl CST(Rs)", helveticaBold8));detailsTable.addCell(new Phrase("CST%",helveticaBold8));detailsTable.addCell(new Phrase("CST Amount",helveticaBold8));detailsTable.addCell(new Phrase("Rate Incl CST(Rs)", helveticaBold8));} else {detailsTable.addCell(new Phrase("Rate Excl VAT(Rs)", helveticaBold8));detailsTable.addCell(new Phrase("VAT%",helveticaBold8));detailsTable.addCell(new Phrase("VAT Amount",helveticaBold8));detailsTable.addCell(new Phrase("Rate Incl VAT(Rs)", helveticaBold8));}detailsTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));int slNo = 0;double total = 0;double vatFactor = 0;double totalUnits = 0;boolean isMRPVat = false;CatalogClient cClient = new CatalogClient();in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = cClient.getClient();if(stateIdMap.get(supplier.getStateId()).getVatType().equals(VatType.MRP)) {isMRPVat = true;}for (in.shop2020.purchase.LineItem lineitem : purchaseOrder.getLineitems()) {slNo++;detailsTable.addCell(new Phrase(slNo + "", helvetica8));detailsTable.addCell(getProductNameCell(lineitem));detailsTable.addCell(new Phrase(String.format("%.0f", lineitem.getQuantity()),helvetica8));if(lineitem.isSetMrp() && lineitem.getMrp()>0){detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getMrp()),helvetica8));} else {detailsTable.addCell(new Phrase(" ",helvetica8));}if(purchaseOrder.getTaxType()==TaxType.CFORM){vatFactor = 2.0;} else {if(!catalogClient.isAlive()){catalogClient = cClient.getClient();}if(isMRPVat){vatFactor = catalogClient.getVatPercentageForItem(lineitem.getItemId(), supplier.getStateId(), lineitem.getMrp());}else{vatFactor = catalogClient.getVatPercentageForItem(lineitem.getItemId(), supplier.getStateId(), lineitem.getUnitPrice());}}double preVatPrice = lineitem.getUnitPrice()/(1+(vatFactor/100));double taxAmount = preVatPrice * (vatFactor/100);detailsTable.addCell(new Phrase(String.format("%.2f", preVatPrice), helvetica8));detailsTable.addCell(new Phrase(String.format("%.2f", vatFactor), helvetica8));detailsTable.addCell(new Phrase(String.format("%.2f", taxAmount), helvetica8));detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getUnitPrice()), helvetica8));double lineTotal = lineitem.getQuantity() * lineitem.getUnitPrice();totalUnits += lineitem.getQuantity();total += lineTotal;detailsTable.addCell(new Phrase(String.format("%.2f", lineTotal), helvetica8));}detailsTable.addCell(getTotalCell(2));detailsTable.addCell(new Phrase(String.format("%.0f", totalUnits), helvetica8));detailsTable.addCell(getTotalAmountCell(6,total));return detailsTable;}private static PdfPTable getBillToTable(PurchaseOrder po) {//TODO Write this code in a proper configurable wayString address = "";String tinNo = "";String contactPerson = "";BuyerInfo binfo = new BuyerInfo();try {in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();binfo = tClient.getBuyerByWarehouse(po.getWarehouseId());WarehouseAddress addr = tClient.getWarehouseAddress(po.getWarehouseAddressId());tinNo = binfo.getTin();address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();} catch (Exception e) {logger.error("This should not happen", e);}if(po.getWarehouseId()==7) {contactPerson = "Mr. Varun Patiyal, Contact No. +91 8860488282, +91 9711178101";} else if(po.getWarehouseId() == 12) {contactPerson = "Mr. Avinash Sambhaji Lavange, Contact No. +91 9004049589";} else if(po.getWarehouseId() == 13) {contactPerson = "Mr. Vishal Tayade, Contact No. +91 9819231651";} else if(po.getWarehouseId() ==16) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";} else if(po.getWarehouseId() ==1765) {contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";}else if(po.getWarehouseId() ==1768) {contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";}else if(po.getWarehouseId() ==1771) {contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";}else if(po.getWarehouseId() ==2854) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() ==2857) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() == 3295) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() == 3298) {contactPerson = "Mr. Achyuta Ramaiah A, Contact No. +91 9246581582";}else if(po.getWarehouseId() == 3931) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() == 4699) {contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() == 5314){contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}else if(po.getWarehouseId() == 5623){contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";}PdfPTable billToTable = new PdfPTable(new float[] { 0.2f, 0.8f });billToTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);billToTable.addCell(new Phrase("Bill To :", helvetica8));billToTable.addCell(new PdfPCell(new Paragraph(address+ "\nTIN NO. " + tinNo, helvetica8)));billToTable.addCell(new Phrase("Contact Person:", helvetica8));billToTable.addCell(new Phrase(contactPerson, helvetica8));billToTable.addCell(new Phrase("Taxes:", helvetica8));if(po.getTaxType() == TaxType.CFORM) {billToTable.addCell(new Phrase("Prices inclusive of all taxes (To be billed on CST Against C-Form)",helvetica8));} else {billToTable.addCell(new Phrase("Prices inclusive of all taxes",helvetica8));}return billToTable;}private static PdfPCell getProductNameCell(in.shop2020.purchase.LineItem lineitem) {String itemName = getItemDisplayName(lineitem);PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);return productNameCell;}private static String getItemDisplayName(in.shop2020.purchase.LineItem lineitem) {StringBuffer itemName = new StringBuffer();if (lineitem.getBrand() != null)itemName.append(lineitem.getBrand() + " ");if (lineitem.getModelName() != null)itemName.append(lineitem.getModelName() + " ");if (lineitem.getModelNumber() != null)itemName.append(lineitem.getModelNumber() + " ");if (lineitem.getColor() != null&& !lineitem.getColor().trim().equals("NA"))itemName.append("(" + lineitem.getColor() + ")");return itemName.toString();}private static PdfPCell getTotalCell(int colspan) {PdfPCell totalCell = new PdfPCell(new Phrase("Total", helveticaBold8));totalCell.setColspan(colspan);totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);return totalCell;}private static PdfPCell getTotalAmountCell(int colspan, double totalAmount){PdfPCell totalCell = new PdfPCell(new Phrase(String.format("%.2f", totalAmount), helvetica8));totalCell.setColspan(colspan);totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);return totalCell;}}