This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogisticService: | |
def is_serviceable(self, postal_code) -> bool: | |
mn, mx = self.get_postal_code_range() | |
# use exception list here | |
if mn <= postal_code <= mx and postal_code not in self.get_exception_postal_codes(): | |
return True | |
return False | |
... | |
def get_exception_postal_codes(self) -> list: | |
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assign_logistic_service(order): | |
for logistic in logistic_services: | |
if logistic.is_serviceable(order.postal_code): | |
# if hack | |
if logistic.__class__.__name__ == 'DoneTodayLogisticService': | |
if order.postal_code in [690040, 690041]: | |
continue | |
logistic.make_shipping_request() | |
return logistic.__class__.__name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogisticService: | |
def is_serviceable(self, postal_code) -> bool: | |
mn, mx = self.get_postal_code_range() | |
if mn <= postal_code <= mx: | |
return True | |
return False | |
@abstractmethod | |
def get_postal_code_range(self) -> Tuple(int, int): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if 690034 <= postal_code <= 695000: | |
return "DoneTodayLogistics" | |
elif ...: | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Script to generate templates and merge with docs to sign them""" | |
import io | |
from fpdf import Template | |
from PyPDF2 import PdfFileWriter, PdfFileReader | |
def create_elements(el_dict): | |
"""Creates a elements dict to customize the template""" | |
final_dict = [] |