diff --git a/README.md b/README.md index af80d11..0f9f358 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,11 @@ Roulier will get a label + tracking number to your carrier for you. * Roulier runs on your server and call each carrier API directly. * You have to use your own credentials provided by each carriers. * Roulier is Open Source software, AGPL-3 -* Roulier integrate a multitude of carriers : Laposte, Geodis, DPD, K&N... more to come. +* Roulier integrate a multitude of carriers + * French La Poste + * French DPD + * French Geodis + * French Chronopost ### Installation @@ -65,6 +69,11 @@ from roulier import roulier print(roulier.get_carriers_action_available()) ``` +### Known Issues +#### French GLS carrier : +* The glsbox webservice only manage Basic products : BP, EBP, GBP +* In the rest webservice, the incoterms don't work + ### Contributors @@ -73,6 +82,7 @@ print(roulier.get_carriers_action_available()) * [@damdam-s](https://github.com/damdam-s) ([Camp2Camp.com](http://camptocamp.com)) * [@bealdav](https://github.com/bealdav) ([Akretion.com](https://akretion.com)) * [@DylannCordel](https://github.com/DylannCordel) ([Webu.coop](https://www.webu.coop)) +* [@florian-dacosta](https://github.com/florian-dacosta) ([Webu.coop](https://akretion.com)) ### Dependencies diff --git a/roulier/carriers/gls_fr/glsbox/decoder.py b/roulier/carriers/gls_fr/glsbox/decoder.py index 45d38bf..ff0ef47 100644 --- a/roulier/carriers/gls_fr/glsbox/decoder.py +++ b/roulier/carriers/gls_fr/glsbox/decoder.py @@ -40,7 +40,9 @@ def decode(self, response, input_payload): def exotic_serialization_to_dict(self, data): res = {} - for val in data.split("|")[1:-1]: + # remove start of string + data = re.sub(r"\\*GLS\\*", "", data) + for val in data.split("|")[0:-1]: key, value = val.split(":", 1) res[key] = value return res @@ -107,7 +109,7 @@ def create_exception(self, result, exception, ctx_except, data_request): def validate_template(self, template_string, available_keys): keys2match = [] - for match in re.findall(r"\$(T[0-9].*) ", template_string): + for match in re.findall(r"\$\{(T[0-9].*)\}", template_string): keys2match.append(match) unmatch = list(set(keys2match) - set(available_keys)) not_in_tmpl_but_known_case = ["T8900", "T8901", "T8717", "T8911"] diff --git a/roulier/carriers/gls_fr/glsbox/encoder.py b/roulier/carriers/gls_fr/glsbox/encoder.py index 29f229b..1ff05a8 100644 --- a/roulier/carriers/gls_fr/glsbox/encoder.py +++ b/roulier/carriers/gls_fr/glsbox/encoder.py @@ -64,8 +64,23 @@ def merge_dict(mydict): class GlsEncoder(Encoder): """Transform input to gls compatible format.""" + def _extra_input_data_processing(self, input_payload, data): + # Manage origin_reference from Destination and custom_sequence + country_code = data.get("to_address", {}).get("country") + seq = data.get("parcels") and data["parcels"][0].get("custom_sequence") + if country_code and seq: + product_code = country_code == "FR" and "02" or "01" + origin_ref = "%s%s%s%s" % (product_code, seq, "0000", country_code) + data["service"]["gls_origin_reference"] = origin_ref + return data + def transform_input_to_carrier_webservice(self, data): merged_data = self.merge_data(data) + # Manage some mandatory constants... + merged_data["T090"] = "NOSAVE" + # not in documentation but comes from GLS support... + # T100 is destination country + merged_data["T082"] = merged_data["T100"] == "FR" and "UNIQUENO" or "GPDEL" exotic_data = self.dict_to_exotic_serialization(merged_data) return exotic_data diff --git a/roulier/carriers/gls_fr/glsbox/templates/zpl.zpl b/roulier/carriers/gls_fr/glsbox/templates/zpl.zpl index 920586a..ff6ebd4 100644 --- a/roulier/carriers/gls_fr/glsbox/templates/zpl.zpl +++ b/roulier/carriers/gls_fr/glsbox/templates/zpl.zpl @@ -1,96 +1,100 @@ ^XA ^CI28 -^FWN -^FO50,80^GB825,0,15^FS -^FO50,102^AE,90,37^FD$T110 ^FS -^FO360,95^GB30,105,82,^FS -^FO375,102^AG,90,22^FR^FD$T310 ^FS -^FO475,102^AE,90,45^FD$T100 ^FS -^FO645,95^GB195,105,105,^FS -^FO650,102^AE,90,30^FR^FD$T101 ^FS -^FO50,194^GB825,0,5^FS - -^FO50,203^A0,90,65^FD$T320 ^FS -^FO213,203^AB,8,10^FD$T8951 ^FS -^FO375,203^AB,8,10^FD$T8952 ^FS -^FO675,203^AB,8,10^FDPRODUIT^FS -^FO210,233^A0,60,50^FD$T330 ^FS -^FO330,222^AB,12,15^FD$T8911 ^FS -^FO520,222^AB,12,15^FD$T8912 ^FS -^FO390,252^AB,20,15^FD$T8913 ^FS -^FO675,233^A0,60,50^FD$T8900 ^FS -^FO780,233^A0,60,50^FD$T8901 ^FS -^FO50,279^GB8250,0,5^FS - -^FO50,282^GB30,0,6^FS -^FO255,282^GB30,0,6^FS -^FO50,282^GB0,30,6^FS -^FO285,282^GB0,30,6^FS - -^FO90,320^BX,4,200^FD$T8902 ^FS - -^FO50,510^GB30,0,6^FS -^FO255,510^GB30,0,6^FS -^FO50,480^GB0,30,6^FS -^FO285,480^GB0,31,6^FS - -^FO650,320^BX,4,200^FD$T8903 ^FS - -^FO50,515^GB825,0,5^FS -^FO50,530^A0,60,40^FD$T500 ^FS -^FO180,545^A0,30,20^FD$T510 ^FS -^FO210,545^A0,30,20^FD$T540 ^FS -^FO310,545^A0,30,20^FD$T541 ^FS -^FO370,530^A0,60,45^FD$T530 ^FS -^FO480,530^A0,60,45^FDKG^FS -^FO540,545^A0,30,20^FD$T8904 ^FS -^FO570,545^A0,30,20^FD/^FS -^FO580,545^A0,30,20^FD$T8905 ^FS -^FO610,545^A0,30,20^FDRTG^FS -^FO650,545^A0,30,20^FD$T520 ^FS -^FO740,545^A0,30,20^FDV02-00^FS - -^FO50,590^GB825,0,5^FS -^FO55,620^B2N,70^FD$T8717 ^FS - -^FO55,740^GB640,0,5^FS -^FO55,762^A0,30,45^FD$T860 ^FS -^FO55,800^A0,30,30^FD$T861 ^FS -^FO55,845^A0,30,30^FD$T862 ^FS -^FO55,890^A0,30,45^FD$T863 ^FS -^FO55,930^A0,30,45^FD$T864 ^FS -^FO55,970^A0,30,30^FD$T100 ^FS -^FO150,970^A0,30,30^FD$T330 ^FS - -^FO55,1000^GB640,0,5^FS -^FO55,1007^A0,20,20^FD$T8958 ^FS -^FO150,1007^A0,20,20^FD$T8906 ^FS -^FO560,1007^A0,20,20^FDColisage^FS -^FO55,1035^A0,20,20^FDTel:^FS -^FO150,1035^A0,20,20^FD$T871 ^FS -^FO555,1035^A0,20,20^FD$T8904 ^FS -^FO590,1035^A0,20,20^FD/^FS -^FO600,1035^A0,20,20^FD$T8905 ^FS -^FO55,1060^A0,20,20^FDRef:^FS -^FO150,1060^A0,20,20^FD$T8977 ^FS -^FO55,1090^A0,20,20^FD$T8907 ^FS -^FO230,1090^A0,20,20^FD/^FS -^FO240,1090^A0,20,20^FD$T8908 ^FS -^FO525,1063^GB160,0,5^FS -^FO525,1000^GB0,63,5^FS -^FO55,1125^GB825,0,5^FS -^FO690,740^GB0,390,5^FS -^FO50,740^GB0,390,5^FS -^FO870,535^GB0,585,5^FS - -^FO775,600^A0,30,20^FWR^FDExpediteur^FS^ -^FO750,600^A0,20,20^FDClient^FS^ -^FO750,750^A0,20,20^FD$T805 ^FS^ -^FO750,870^A0,20,20^FDContactId^FS^ -^FO750,970^A0,20,20^FD$T8914 ^FS^ -^FO722,600^A0,20,20^FD$T810 ^FS^ -^FO695,600^A0,20,20^FD$T821 ^FS^ -^FO695,675^A0,20,20^FD$T822 ^FS^ -^FO695,825^A0,20,20^FD$T823 ^FS^ - -^XZ= +^LH15,0 +^PR6 +^JMA +^FO10,946,^GB616,137,0^FS +^FO10,703,^GB616,244,0^FS +^FO24,712,^A0N,24^FR^FD${T859}^FS +^FO24,743,^A0N,43^FR^FD${T860}^FS +^FO24,790,^A0N,31^FR^FD${T861}^FS +^FO24,824,^A0N,31^FR^FD${T862}^FS +^FO24,857,^A0N,43^FR^FD${T863}^FS +^FO24,903,^A0N,31^FR^FD${T100}^FS +^FO256,716,^A0N,18^FR^FD${T851}^FS +^FO379,716,^A0N,18^FR^FD${T852}^FS +^FO112,1052,^A0N,24^FR^FD${T854}^FS +^FO18,953,^A0N,24^FR^FD${T8958}^FS +^FO18,978,^A0N,24^FR^FD${T8959}^FS +^FO18,1003,^A0N,24^FR^FD${T8960}^FS +^FO112,953,^A0N,24^FR^FD${T759}^FS +^FO112,978,^A0N,24^FR^FD${T758}^FS +^FO112,1003,^A0N,24^FR^FD${T920}^FS +^FO112,1028,^A0N,24^FR^FD${T921}^FS +^FO10,444,^GB616,260,0^FS +^FO18,1028,^A0N,24^FR^FD${T8960}^FS +^FO18,1052,^A0N,24^FR^FD${T853}^FS +^FO625,444,^GB162,639,0^FS +^FO24,453,^A0N,42^FR^FD${T750}^FS +^FO24,502,^A0N,24^FR^FD${T751}^FS +^FO24,527,^A0N,24^FR^FD${T752}^FS +^FO24,556,^A0N,24^FR^FD${T753}^FS +^FO24,580,^A0N,32^FR^FD${T754}^FS +^FO24,628,^A0N,24^FR^FD${T755}^FS +^FO24,653,^A0N,24^FR^FD${T756}^FS +^FO24,678,^A0N,24^FR^FD${T757}^FS +^FO100,903,^A0N,31^FR^FD${T330}^FS +^FO280,903,^A0N,31^FR^FD${T864}^FS +^FO630,514,^A0R,18^FR^FD${T822}^FS +^FO630,607,^A0R,18^FR^FD${T823}^FS +^FO754,451,^A0R,18^FR^FD${T800}^FS +^FO727,451,^A0R,24^FR^FD${T810}^FS +^FO754,572,^A0R,18^FR^FD${T8957}^FS +^FO754,692,^A0R,18^FR^FD${T8915}^FS +^FO754,840,^A0R,18^FR^FD${T8965}^FS +^FO754,946,^A0R,18^FR^FD${T8914}^FS +^FO701,451,^A0R,18^FR^FD${T811}^FS +^FO677,451,^A0R,18^FR^FD${T812}^FS +^FO654,451,^A0R,18^FR^FD${T820}^FS +^FO630,451,^A0R,18^FR^FD${T821}^FS +^FO570,12,^GB224,90,90^FS +^FO248,13,^GB71,89,71^FS +^FO4,5,^GB790,9,9^FS +^FO27,120,^A0N,62^FR^FD${T320}^FS +^FO183,139,^A0N,43^FR^FD${T330}^FS +^FO25,28,^A0N,74^FR^FD${T110}^FS +^FO450,30,^A0N,74^FR^FD${T105}^FS +^FO7,102,^GB787,6,6^FS +^FO263,25,^A0N,80^FR^FD${T310}^FS +^FO216,110,^A0N,18^FR^FD${T8951}^FS +^FO384,110,^A0N,18^FR^FD${T8952}^FS +^FO387,147,^A0N,34^FR^FD${T8913}^FS +^FO8,184,^GB787,6,6^FS +^FO8,395,^GB783,9,9^FS +^FO50,217,^BY4^BXN,4,200^FR^FD${T8902}^FS +^FO595,214,^BY4^BXN,4,200^FR^FD${T8903}^FS +^FO8,190,^GB24,8,8^FS +^FO8,196,^GB8,16,8^FS +^FO8,372,^GB8,16,8^FS +^FO8,387,^GB24,8,8^FS +^FO229,387,^GB24,8,8^FS +^FO244,196,^GB8,16,8^FS +^FO228,190,^GB24,8,8^FS +^FO245,372,^GB8,16,8^FS +^FO580,28,^A0N,80^FR^FD${T101}^FS +^FO303,352,^A0N,37^FR^FD${T400}^FS +^FO720,416,^A0N,18^FR^FDB2.00.0^FS +^FO616,416,^A0N,18^FR^FD${T520}^FS +^FO168,416,^A0N,18^FR^FD${T540}^FS +^FO32,408,^A0N,31^FR^FD${T500}^FS +^FO342,408,^A0N,37^FR^FD${T530}^FS +^FO131,407,^A0N,31^FR^FD${T510}^FS +^FO273,416,^A0N,18^FR^FD${T541}^FS +^FO481,416,^A0N,18^FR^FD${T8904}^FS +^FO525,416,^A0N,18^FR^FD${T8905}^FS +^FO510,416,^A0N,18^FR^FD/^FS +^FO572,416,^A0N,18^FR^FDRTG^FS +^FO268,221,^BY3,2.0,125,^B2N,125,N,N^FR^FD${T8916}^FS +^FO624,135,^A0N,43^FR^FD${T202}^FS +^FO735,135,^A0N,43^FR^FD${T205}^FS +^FO579,135,^A0N,43^FR^FD${T204}^FS +^FO763,135,^A0N,43^FR^FD${T201}^FS +^FO670,135,^A0N,43^FR^FD${T200}^FS +^FO577,135,^A0N,43^FR^FD${T203}^FS +^FO425,407,^A0N,37^FR^FDkg^FS +^FO18,1090,^A0N,20^FR^FD${T1945}^FS +^FO18,1115,^A0N,20^FR^FD${T1946}^FS +^FO18,1140,^A0N,20^FR^FD${T1947}^FS +^FO18,1165,^A0N,20^FR^FD${T1948}^FS +^PQ1 +^XZ