customer use case : tones - cug-benelux.becug-benelux.be/downloads/130617/cug_danny.pdf · tones...

30
Customer use case : Tones Real-life tips & tricks : sharing of coding tips, tricks and ideas based on a customer use case Danny Wijnschenk – [email protected]

Upload: others

Post on 24-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Customer use case : TonesReal-life tips & tricks : sharing of coding tips, tricks and ideas

based on a customer use case

Danny Wijnschenk – [email protected]

Page 2: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Tones

Retail - Computer shops

Specialised in tailor-made configurations

Game PC’s

Desktops – Laptops – Tablets – Monitors – Printers – Projectors - Pc parts - Peripherals

Page 3: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Tones

4 computer stores + webshop

Page 4: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Tones & Caché

Caché server on Windows, 30 users

Terminal application for management of articles, stock, order, invoice, accounting

Website (www.tones.be) written outside Caché, communication via Soap (new website : via

REST)

Website for distributors written in CSP

Much communication with other systems

Developed by Pierre Op de Beeck & Hilde Vervoort (Arco bvba)

Page 5: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Communication with Suppliers

(ftp, http(s), soap)

%Net.FtpSession

%Net.HttpRequest

%XML.Reader Correlate

%SOAP.WebRequest

Page 6: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Connecting websites, delivery, catalogs, CRM

(soap, rest, tcp/ip)

Websites

CRM

Catalog & Prices

Delivery

Page 7: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Tips & TricksHow we do it @Tones

Interactive discussion on alternatives

Page 8: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Output

Label printers

Direct ZPL output to Zebra label printers

Excel (.XLS)

All reporting is done in Excel (.xls)

PDF

Invoices are directly formatted to PDF and mailed to customer

E-Invoice to government – PEPPOL (in development)

Page 9: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Caché & Excel

Application generates text file with data

Application uses Terminal emulation to call Excel on the client + VBA macro

VBA macro reads text file & copies data into cells

.XLS (macro) .XLS

.TXT (data)

VBA

.XLS (layout

template)

Page 10: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Excel VBA MacroWorkbooks.Open Filename:=path & "Sjablonen\Applicatie\SJATRABEWGLSZL.xls"

Workbooks.OpenText Filename:=path & "TRABEWGLSZL.TXT", Origin :=xlWindows, StartRow:=1, DataType:=xlDelimited,_

TextQualifier:= xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _

Comma:=False,Space:=False,Other:=False,FieldInfo:=Array(Array(1, 1),Array(2, 1)),TrailingMinusNumbers:=True

Cells.Select

Selection.Copy

Windows("SJATRABEWGLSZL.xls").Activate

Cells.Select

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Range("A1").Select

Windows("TRABEWGLSZL.TXT").Activate

Application.CutCopyMode = False

ActiveWorkbook.Close SaveChanges:=False

Windows("SJATRABEWGLSZL.xls").Activate

ActiveWorkbook.SaveAs Filename:=naamfile , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _

ReadOnlyRecommended:=False, CreateBackup:=False

Page 11: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Excel : Advantages

User can sort, resize columns, ... without developer intervention

Better than generating CSV : you can add Layout elements like Font properties, Images,

Graphs, ... directly in template

No server processing

Need to install ms-office on each client pc !

None yet

Page 12: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Invoices in PDF

Application generates data in XML file

Application calls Apache FOP with XSLT layout file which generates PDF

PDF is emailed to customer with %Net.SMTP and %Net.MailMessage

XML Data

XSLT Layout Apache FOP

Page 13: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

XML Data

<invoice-record>

<invoice-title>Factuur</invoice-title>

<invoice-number>17100740</invoice-number>

<invoice-our-reference> 50191506/00</invoice-our-reference>

<invoice-date>21/04/2017</invoice-date>

<invoice-due-date>29/04/2017</invoice-due-date>

<invoice-shipped-date>21/04/2017</invoice-shipped-date>

<invoice-currency>EUR</invoice-currency>

<customer-number>5052585</customer-number>

<customer-vat>BE0448046562</customer-vat>

<customer-name>WINFO BVBA</customer-name>

<line-item-records>

<line-item-record>

<type>ARTICLE</type>

<description>EWENT-EW7015 USB 3.0 DUAL DOCKING STATION</description>

<quantity>1 Stuk</quantity>

</line-item-record>

</line-item-records>

</invoice-record>

Page 14: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

XSL file<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/invoice-record">

<fo:root>

<fo:layout-master-set>

<fo:simple-page-master master-name="A4_NOTLAST" page-height="29.7cm" page-width="21cm" margin-top="5mm" margin-bottom="2cm">

<fo:region-body margin-top="95mm" margin-bottom="42mm"/>

<fo:region-before region-name="invoice-header" extent="95mm"/>

<fo:region-after region-name="invoice-footer" extent="42mm"/>

</fo:simple-page-master>

...

<fo:table-cell text-align="left">

<fo:block>Onze referentie</fo:block>

<fo:block>Documentdatum</fo:block>

</fo:table-cell>

<fo:table-cell text-align="left">

<fo:block><xsl:value-of select="invoice-our-reference"/></fo:block>

<fo:block><xsl:value-of select="invoice-date"/></fo:block>

</fo:table-cell>

<xsl:for-each select="line-item-records/line-item-record">

Page 15: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

FOP Apache

Set cmd = "C:/Intersystems/Cache/fop/fop.bat –xml xmlFile –xsl xslFile –pdf pdfFile"

;;no response

Set x = $ZF(-1, cmd)

Or

;;SEVERE in response means pdf is not generated

Open cmd: "RQ"

Try {

Use cmd

For loop=1:1 Read response(loop) If $ZEOF=-1 Quit ;in case SetZEOF is set

} Catch {

;manage errors other than <ENDOFFILE>

}

Close cmd

Page 16: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

PDF using XSLT : Advantages

Apache FOP is aready installed with Caché

Plenty of XSLT examples on internet

GUI tools available (but we prefer to edit in notepad)

• Do not forget to install Java Server JRE on the Caché server !

• Needs %System.CallOut privilege

• Read Apache log for FATAL errors (e.g. Non-unicode characters)

Page 17: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Security

Users have minimal privileges

%Service_Login, %Service_Telnet, %DB

Special privileges thru Role escalation

New $Roles

Do $System.Security.AddRoles("CallOut")

Page 18: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Discussion : How do you Print or Export Data ?

Write ! Report

Generator

ODBC

ZEN

reportsHTML

CSV

DeepSee

I want to

go home!

Page 19: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Communication with other applications

Website

Build by external partners (non-Caché)

Communication via Soap / REST

Bol Marketplace

Product offer send to Bol every morning

Upates in stock and prices send in real time

Orders received (polling) every minute

TeamLeader CRM

in development

Communication via REST

Page 20: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Marketplace

Page 21: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Order process : upload products

<UpsertRequest>

<RetailerOffer>

<EAN>4712900142501</EAN>

<Condition>NEW</Condition>

<Price>1017.69</Price>

<DeliveryCode>3-5d</DeliveryCode>

<QuantityInStock>16</QuantityInStock>

<Publish>true</Publish>

<ReferenceCode>121047</ReferenceCode>

</RetailerOffer>

</UpsertRequest>

PUT /offers/v2

Page 22: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Order process : receive orders

GET /orders/v2

<Orders>

<Order>

<OrderId>4243683280</OrderId>

<DateTimeCustomer>2017-06-01T10:31:18.000+02:00</DateTimeCustomer>

<DateTimeDropShipper>2017-06-01T10:31:18.000+02:00</DateTimeDropShipper>

<CustomerDetails>

<ShipmentDetails>

<SalutationCode>01</SalutationCode>

<Firstname>sander</Firstname>

<Surname>anoniem</Surname>

<Streetname>Grote Baan</Streetname>

<Housenumber>123</Housenumber>

<ZipCode>6414 PH</ZipCode>

<City>HEERLEN</City>

<CountryCode>NL</CountryCode>

<Email>[email protected]</Email>

</ShipmentDetails>

<BillingDetails> ... </BillingDetails>

</CustomerDetails>

<OrderItems>

<OrderItem>

<OrderItemId>2047270369</OrderItemId>

<EAN>0713228142703</EAN>

<OfferReference>119281</OfferReference>

<Title>AKRACING Premium Carbon Black Edition Racestoel-Zwart</Title>

<Quantity>1</Quantity>

<OfferPrice>299.99</OfferPrice>

<TransactionFee>17.35</TransactionFee>

<PromisedDeliveryDate>2017-06-02+02:00</PromisedDeliveryDate>

</OrderItem>

</OrderItems>

</Order>

</Orders>

Page 23: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Order process : request shipment

\\\\\GLS\\\\\

T050:CACHE GLS.UTILS.SEND|T051:V1.0.0|T090:|T100:BE|T330:3000|T400:612402644042

|T530:1,2|T545:22.05.2017|T805:560000051|T810:Tones BVBA|T820:Zemstbaan 1

|T821:BE|T822:2800|T823:Mechelen|T854:123456/00|T860:De Klant N.V.|T863:Straat,

1|T864:Leuven|T8700:BE 610|T8748:|T8904:001|T8905:001|T8914:050abcdbLQ

|T8915:0500000123|

/////GLS/////

TCP

Page 24: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Order process : receive shipment track&trace

\\\\\GLS\\\\\

T8915:050000972|T920:|T921:|T080:V90_11_0004|T520:08062017|T510:hb|T500:BE 610|T560:BE

01|T8797:IBOXCUS|T540:09.06.2017|T541:15:03|T8749:S|T100:BE|CTRA2:BE|T210:|ARTNO:Standard|T5

30:0.50|T206:BP|ALTZIP:1910|FLOCCODE:BE610|TOURNO:6599|T320:6599|TOURTYPE:21102|SORT1:0|T310

:0|T331:1910|T890:9056|ROUTENO:0 |FLOCNO:777|T101: 610|T105:BE|T300:05661007|T20 2:F

|T207:FDF;CD|NDI:|T8970:A|T8971:A|T8975:100613436|T8980:AA|T8974:eq|T8950:Tour

|T8951:ZipCode|T8952:Your GLS Track ID|T8953:Product|T8954:Service Code|T8955:Delivery

address|T8956:Contact|T8958:Contact|T8957:CustomerID|T8959:Phone|T8960:Note|T8961:Parcel|T89

62:Weight|T8965:Contact ID|T8913:ZI7PA0I8|T8972:ZI7PA0I8|T8902:ABE 610BE6100560009

872056aaacwBtZI7PA0I8AAeq 0 65991910 00050001001100613436

|T8903:A¬VANDEREET MAARTEN¬Bosstraat 1 bus A¬KAMPENHOUT¬¬17006828/00¬¬ |T102:BE

10|PRINTINFO:|PRINT1:|RESULT:E000:612836388000|T565:150353|PRINT0:xxGLSzebrazpl200.int01|

/////GLS/////

TCP

Page 25: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Order process : confirm shipment

<ShipmentRequest>

<OrderItemId>44012354</OrderItemId>

<ShipmentReference>812314/00</ShipmentReference>

<DateTime>2017-06-01T10:32:12.000+02:00</DateTime>

<ExpectedDeliveryDate>2017-06-02T18:00:00.000+02:00</ExpectedDeliveryDate>

<Transport>

<TransporterCode>GLS</TransporterCode>

<TrackAndTrace>aortert4565645</TrackAndTrace>

</Transport>

</ShipmentRequest>

POST /shipments/v2

Page 26: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Communication via http/REST

set body = "<UpsertRequest xmlns=""https://plazaapi.bol.com/offers/xsd/api-2.0.xsd"">"

set body = body _ " <RetailerOffer>"

set body = body _ " <EAN>"_$P(XART3,D,10)_"</EAN>"

...

Set objHttp = ##class(%Net.HttpRequest).%New()

Set objHttp.Server=“plazaapi.bol.com"

Set objHttp.Https=1

Set objHttp.SSLConfiguration = “BOL” ;add BOL in SSL

Set hash = ..Encrypt(header, privateKey)

Set objHttp.SetHeader(“X-Bol-Authorization”,hash)

Set status = objHttp.Send(“GET”, “/offers/v2/”)

...

Set response = objHttp.HttpResponse.Data

...

}

Classmethod Encrypt(s as %String, key as %String) as %String

{

Quit $system.Encryption.Base64Encode($system.Encryption.HMACSHA(256, s, key)

}

Page 27: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Communication with Bol uses

REST

%Net.HttpRequest

Https (Define SSL Configuration in portal!)

Content-Type header with GET method

Encryption

$system.Encryption.HMACSHA(256, string, privateKey)

$system.Encryption.Base64Encode

Page 28: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Other marketplaces to consider

Amazon

Vanden Borre (Mirakl)

Storesquare

eBay

Page 29: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Discussion : How do you Communicate ?

REST TCP/IP

ODBC

SoapEnsemble

CSVFTP

Where is

the food?

Page 30: Customer use case : Tones - cug-benelux.becug-benelux.be/downloads/130617/CUG_Danny.pdf · Tones & Caché Caché server on Windows, 30 users Terminal application for management of

Next time it is your turn !

Please consider doing a presentation of one of your applications

Interesting tools you use

Special COS or other code that works with Caché

Any tips & tricks you use