Google Spreadsheet + JSON + Solve360 CRM

Here a sample code to get a JSON response using Google Apps Script from Solve360 CRM

Based on change some lines of code into the Solve360 Service library for Google Apps Scripts


/**
* Request to the Solve360 API server
* data should be an Array in Short Hand notation
*/
request : function(uri, restVerb, data) {
if (this._credentials == null) {
throw new Error(‘Solve360 credentials are not set’);
}
if (typeof(data) != ‘undefined’) {
data.unshift(‘request’);
data = Xml.parseJS(data).toXmlString();
} else {
data = ‘’;
}
var headers = {
“Authorization” : “Basic “ + this._credentials,
“Accept” : “application/json”,
};
var options = {
“contentType” : “application/xml”,
“method” : restVerb.toLowerCase(),
“payload” : data,
“headers” : headers
};
return UrlFetchApp.fetch(this._url + uri, options).getContentText(); //Xml.parse(UrlFetchApp.fetch(this._url + uri, options).getContentText()).getElement();
}

Making the calling from your own code


function getReport() {
// Loading Solve360Service library
// write here ..
var user = UserProperties.getProperty(USERPROPERTY_USER);
var token = UserProperties.getProperty(USERPROPERTY_TOKEN);
if (user == null || user.length == 0 || token == null || token.length == 0) {
throw new Error(‘Use Solve360 spreadsheet menu to set email and token first’);
}
// Configure service gateway object
Solve360Service.setCredentials(user, token);
var myContacts = Solve360Service.searchContacts([]);//getContactsCategories();
var myContactsJson = Utilities.jsonParse(myContacts);

….

Links

http://code.google.com/googleapps/appsscript/

http://norada.com/

http://static.solve360.com/gadgets/resources/js/Solve360Service.js

regards

Openbravo POS Cierre de Caja detallado por Categorias

 

Desarrollamos este requerimiento para un cliente y aqui lo comparto con ustedes, el codigo y el manual para su aplicación en tu instalación local.

1. Download the source code
https://docs.google.com/leaf?id=0B2UfTTLsYcx0MDk2MTMxNGMtOTg1ZS00N2FiLThlMTYtNDE1NTM2MTY4N2Rm&hl=en&authkey=CIGTsuYG

1.1 Apply diff files to your code

2. In Administration menu, Maintenance -> Resources
Update the Printer.PartialCash and Printer.CloseCash scripts using the next content:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!–
Openbravo POS is a point of sales application designed for touch screens.
Copyright (C) 2007-2009 Openbravo, S.L.

http://sourceforge.net/projects/openbravopos

This file is part of Openbravo POS.
Openbravo POS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Openbravo POS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
–>

<output>
<ticket>
<image>Printer.Ticket.Logo</image>
<line></line>
<line size=”1″>
<text align =”center” length=”42″ bold=”true”>Close cash report</text>
</line>
<line></line>
<line>
<text bold=”true”>Payments report</text>
</line>
<line>
<text align =”right” length=”42″>Total</text>
</line>
<line>
<text>——————————————</text>
</line>
#foreach ($line in $payments.getPaymentLines())
<line>
<text align =”left” length=”32″>${line.printType()}</text>
<text align =”right” length=”10″>${line.printValue()}</text>
</line>
#end
<line>
<text>——————————————</text>
</line>
<line>
<text align =”left” length=”32″>Payments:</text>
<text align =”right” length=”10″>${payments.printPayments()}</text>
</line>
<line></line>
<line size=”1″>
<text align =”left” length=”32″ bold=”true”>Total</text>
<text align =”right” length=”10″ bold=”true”>${payments.printPaymentsTotal()}</text>
</line>
<line></line>
<line>
<text bold=”true”>Taxes report</text>
</line>
<line>
<text align =”right” length=”42″>Total</text>
</line>
<line>
<text>——————————————</text>
</line>
#foreach ($line in $payments.getSaleLines())
<line>
<text align =”left” length=”32″>${line.printTaxName()}</text>
<text align =”right” length=”10″>${line.printTaxes()}</text>
</line>
#end
<line>
<text>——————————————</text>
</line>
<line>
<text align =”left” length=”32″>Receipts:</text>
<text align =”right” length=”10″>${payments.printSales()}</text>
</line>
<line></line>
<line size=”1″>
<text align =”left” length=”32″ bold=”true”>Subtotal</text>
<text align =”right” length=”10″ bold=”true”>${payments.printSalesBase()}</text>
</line>
<line size=”1″>
<text align =”left” length=”22″ bold=”true”>Total</text>
<text align =”right” length=”10″ bold=”true”>${payments.printSalesTaxes()}</text>
<text align =”right” length=”10″ bold=”true”>${payments.printSalesTotal()}</text>
</line>
<line></line>

<line>
<text bold=”true”>Sales By Category</text>
</line>
<line>
<text align =”right” length=”32″>Qty</text>
<text align =”right” length=”10″>Total</text>
</line>
<line>
<text>——————————————</text>
</line>
#foreach ($line in $payments.geCategoriesLines())
<line>
<text align =”left” length=”16″>${line.CategorieName()}</text>
<text align =”right” length=”16″>${line.getCategorieUnits()}</text>
<text align =”right” length=”10″>${line.getCategoriePrice()}</text>
</line>
#end
<line></line>
<line size=”1″>
<text align =”left” length=”32″ bold=”true”>Total</text>
<text align =”right” length=”10″ bold=”true”>${payments.printPaymentsTotal()}</text>
</line>
<line></line>

<line>
<text length=”18″>Machine:</text>
<text>${payments.printHost()}</text>
</line>
<line>
<text length=”18″>Sequence:</text>
<text length=”24″ align=”right”>${payments.printSequence()}</text>
</line>
<line>
<text length=”18″>Start date:</text>
<text length=”24″ align=”right”>${payments.printDateStart()}</text>
</line>
<line>
<text length=”18″>End date:</text>
<text length=”24″ align=”right”>${payments.printDateEnd()}</text>
</line>
</ticket>
</output>

Manual

https://docs.google.com/document/d/1ZOWgLvQLz40lC8q6qt_B86cRzPegsXPmTFZcw8ErhtQ/edit?hl=en&authkey=CLKazaQM

 

www.aesist.com/openbravopos

Espero les sea de utilidad

Seguir

Get every new post delivered to your Inbox.

Únete a otros 115 seguidores