def render_border(self, borders_dict, rect_dict): """Renders a border in the coordinates setted in the rect.""" b_all = borders_dict.get('all', None) if b_all: graphic = isinstance(b_all, Graphic) and b_all or Rect() graphic.set_rect( left=rect_dict['left'], top=rect_dict['top'] - rect_dict['height'], width=rect_dict['right'] - rect_dict['left'], height=rect_dict['height'], ) self._rendered_pages[-1].elements.append(graphic) b_left = borders_dict.get('left', None) if b_left: graphic = isinstance(b_left, Graphic) and b_left or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['top'], right=rect_dict['left'], bottom=rect_dict['bottom']) self._rendered_pages[-1].elements.append(graphic) b_top = borders_dict.get('top', None) if b_top: graphic = isinstance(b_top, Graphic) and b_top or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['top'], right=rect_dict['right'], bottom=rect_dict['top']) self._rendered_pages[-1].elements.append(graphic) b_right = borders_dict.get('right', None) if b_right: graphic = isinstance(b_right, Graphic) and b_right or Line() graphic.set_rect(left=rect_dict['right'], top=rect_dict['top'], right=rect_dict['right'], bottom=rect_dict['bottom']) self._rendered_pages[-1].elements.append(graphic) b_bottom = borders_dict.get('bottom', None) if b_bottom: graphic = isinstance(b_right, Graphic) and b_right or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['bottom'], right=rect_dict['right'], bottom=rect_dict['bottom']) self._rendered_pages[-1].elements.append(graphic)
def __init__(self): super(Observacoes, self).__init__() self.elements = [] self.elements.append( Line(top=0.1 * cm, bottom=0.1 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = Label(text='Observações', top=0.2 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 11, 'alignment': TA_CENTER, 'leading': 11 } self.elements.append(txt) txt = ObjectValue(attribute_name='observacoes', top=0.8 * cm, left=0.5 * cm, width=19.4 * cm, height=2 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 9, 'leading': 9} self.elements.append(txt) self.height = 2 * cm
def __init__(self): super(BandaPagamento, self).__init__() self.elements = [] self.elements.append(Line(top=0.1 * cm, bottom=0.1 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = Label(text='Pagamento', top=0.2 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 11, 'alignment': TA_CENTER, 'leading': 11} self.elements.append(txt) # Condicao de pagamento txt = ObjectValue(attribute_name='cond_pagamento.get_forma_display', display_format='Forma: %s', top=1 * cm, left=0.5 * cm, width=4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 9, 'leading': 9} self.elements.append(txt) txt = ObjectValue(attribute_name='cond_pagamento.n_parcelas', display_format='Nº de parcelas: %s', top=1 * cm, left=5 * cm, width=3 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 9, 'leading': 9} self.elements.append(txt) self.height = 2 * cm
def __init__(self): super(DadosProdutos.band_header, self).__init__() self.elements = [] self.elements.append(Line( top=0.1 * cm, bottom=0.1 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = Label(text='Produtos', top=0.2 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 11, 'alignment': TA_CENTER, 'leading': 11} self.elements.append(txt) txt = Label(text='Cód.', top=1.1 * cm, left=0 * cm, width=2.1 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'alignment': TA_CENTER, 'fontSize': 9, 'leading': 9} self.elements.append(txt) txt = Label(text='Descrição', top=1.1 * cm, left=2.1 * cm, width=4.8 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) txt = Label(text='Un.', top=1.1 * cm, left=6.9 * cm, width=1.5 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) txt = Label(text='Qtde.', top=1.1 * cm, left=8.4 * cm, width=1.9 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) txt = Label(text='Vl. Unit. (R$)', top=1.1 * cm, left=10.3 * cm, width=3.5 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) txt = Label(text='Desconto (R$)', top=1.1 * cm, left=13.8 * cm, width=2.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) txt = Label(text='Total (R$)', top=1.1 * cm, left=16.2 * cm, width=3.2 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 9, 'alignment': TA_CENTER, 'leading': 9} self.elements.append(txt) self.height = 1.8 * cm
def inserir_vendedor(self): self.elements.append( Line(top=2.5 * cm, bottom=2.5 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = ObjectValue(attribute_name='vendedor', display_format='Vendedor: %s', top=2.6 * cm, left=0.5 * cm, width=19.4 * cm, height=2 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 9, 'leading': 9} self.elements.append(txt)
class band_summary(ReportBand): margin_top = 3 * cm height = 0.5 * cm elements = [ ObjectValue(attribute_name='neto', top=0.1 * cm, left=16.9 * cm, width=2 * cm, \ action=FIELD_ACTION_SUM, get_value=lambda instance: float( "%.2f" % (instance.neto * -1) if instance.tipo.startswith("NC") else "%.2f" % instance.neto), style={'alignment': TA_RIGHT}), ObjectValue(attribute_name='iva21', top=0.1 * cm, left=21.4 * cm, width=2 * cm, \ action=FIELD_ACTION_SUM, get_value=lambda instance: float( "%.2f" % (instance.iva21 * -1) if instance.tipo.startswith("NC") else "%.2f" % instance.iva21), style={'alignment': TA_RIGHT}), ObjectValue(attribute_name='total', top=0.1 * cm, left=26 * cm, width=2 * cm, \ action=FIELD_ACTION_SUM, get_value=lambda instance: float( "%.2f" % (instance.total * -1) if instance.tipo.startswith("NC") else "%.2f" % instance.total), style={'alignment': TA_RIGHT}), ] borders = {'top': Line()}
def __init__(self): super(TopoPagina, self).__init__() self.elements = [] txt = SystemField(expression='%(report_title)s', top=0.65 * cm, left=0 * cm, width=19.4 * cm, height=0.8 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 15, 'alignment': TA_CENTER, 'leading': 15} self.elements.append(txt) txt = SystemField(expression='Página %(page_number)s de %(last_page_number)s', top=3.1 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 8.5, 'alignment': TA_RIGHT, 'leading': 8.5} self.elements.append(txt) self.elements.append(Line(top=3.6 * cm, bottom=3.6 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) self.height = 3.65 * cm
def __init__(self): super(BandaFoot, self).__init__() self.ender_info = False self.elements = [] self.elements.append(Line(top=1.5 * cm, bottom=1.5 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = Label(text='Gerado por SGEO', top=1.5 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT_BOLD, 'fontSize': 8, 'alignment': TA_LEFT, 'leading': 8} self.elements.append(txt) txt = SystemField(expression='Data da impressão: %(now:%d/%m/%Y)s', top=1.5 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = {'fontName': REPORT_FONT, 'fontSize': 8, 'alignment': TA_RIGHT, 'leading': 8} self.elements.append(txt) self.height = 2 * cm
def render_border(self, borders_dict, rect_dict): """Renders a border in the coordinates setted in the rect.""" b_all = borders_dict.get('all', None) if b_all: graphic = isinstance(b_all, Graphic) and b_all or Rect() graphic.set_rect( left=rect_dict['left'], top=rect_dict['top'] - rect_dict['height'], width=rect_dict['right'] - rect_dict['left'], height=rect_dict['height'], ) # If border is a number, it is recognized as the stroke width if isinstance(b_all, (int, float)): graphic.stroke_width = b_all self._rendered_pages[-1].add_element(graphic) b_left = borders_dict.get('left', None) if b_left: graphic = isinstance(b_left, Graphic) and b_left or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['top'], right=rect_dict['left'], bottom=rect_dict['bottom']) # If border is a number, it is recognized as the stroke width if isinstance(b_left, (int, float)): graphic.stroke_width = b_left self._rendered_pages[-1].add_element(graphic) b_top = borders_dict.get('top', None) if b_top: graphic = isinstance(b_top, Graphic) and b_top or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['top'], right=rect_dict['right'], bottom=rect_dict['top']) # If border is a number, it is recognized as the stroke width if isinstance(b_top, (int, float)): graphic.stroke_width = b_top self._rendered_pages[-1].add_element(graphic) b_right = borders_dict.get('right', None) if b_right: graphic = isinstance(b_right, Graphic) and b_right or Line() graphic.set_rect(left=rect_dict['right'], top=rect_dict['top'], right=rect_dict['right'], bottom=rect_dict['bottom']) # If border is a number, it is recognized as the stroke width if isinstance(b_right, (int, float)): graphic.stroke_width = b_right self._rendered_pages[-1].add_element(graphic) b_bottom = borders_dict.get('bottom', None) if b_bottom: graphic = isinstance(b_right, Graphic) and b_right or Line() graphic.set_rect(left=rect_dict['left'], top=rect_dict['bottom'], right=rect_dict['right'], bottom=rect_dict['bottom']) # If border is a number, it is recognized as the stroke width if isinstance(b_bottom, (int, float)): graphic.stroke_width = b_bottom self._rendered_pages[-1].add_element(graphic)
def __init__(self): super(TotaisVenda, self).__init__() self.elements = [] self.elements.append( Line(top=0.1 * cm, bottom=0.1 * cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3)) txt = Label(text='Totais', top=0.2 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 11, 'alignment': TA_CENTER, 'leading': 11 } self.elements.append(txt) txt = Label(text='Frete', top=1 * cm, left=0 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_frete', display_format='R$ %s', top=1.5 * cm, left=0 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = Label(text='Seguro', top=1 * cm, left=4 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_seguro', display_format='R$ %s', top=1.5 * cm, left=4 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = Label(text='Despesas', top=1 * cm, left=8 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_despesas', display_format='R$ %s', top=1.5 * cm, left=8 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = Label(text='Desconto', top=1 * cm, left=12 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_desconto', display_format='R$ %s', top=1.5 * cm, left=12 * cm, width=4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = Label(text='Impostos', top=1 * cm, left=16 * cm, width=3.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_impostos', display_format='R$ %s', top=1.5 * cm, left=16 * cm, width=3.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_CENTER, 'leading': 10 } self.elements.append(txt) # Totais self.elements.append( Line(top=2.3 * cm, bottom=2.3 * cm, left=0.4 * cm, right=19 * cm, stroke_width=0.3)) txt = Label(text='Total sem impostos:', top=2.4 * cm, left=0 * cm, width=13.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_RIGHT, 'leading': 10 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_total_sem_imposto', display_format='R$ %s', top=2.4 * cm, left=13.4 * cm, width=5.6 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT, 'fontSize': 10, 'alignment': TA_RIGHT, 'leading': 10 } self.elements.append(txt) self.elements.append( Line(top=2.9 * cm, bottom=2.9 * cm, left=9.7 * cm, right=19 * cm, stroke_width=0.3)) txt = Label(text='Total:', top=3 * cm, left=0 * cm, width=13.4 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 11, 'alignment': TA_RIGHT, 'leading': 11 } self.elements.append(txt) txt = ObjectValue(attribute_name='format_valor_total', display_format='R$ %s', top=3 * cm, left=13.4 * cm, width=5.6 * cm, height=0.5 * cm) txt.style = { 'fontName': REPORT_FONT_BOLD, 'fontSize': 10, 'alignment': TA_RIGHT, 'leading': 10 } self.elements.append(txt) self.height = 3.6 * cm
class band_page_header(ReportBand): height = 4 * cm elements = [ SystemField(expression='%(report_title)s', top=0.1 * cm, left=0, width=BAND_WIDTH, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 14, 'alignment': TA_CENTER }), Label(text="RAZON SOCIAL: %s" % RAZON_SOCIAL_EMPRESA, top=0.8 * cm, width=BAND_WIDTH, style={ 'fontName': 'Helvetica', 'fontSize': 10 }), Label(text="CUIT: %s" % CUIT, top=1.2 * cm, width=BAND_WIDTH, style={ 'fontName': 'Helvetica', 'fontSize': 10 }), Label(text="DOMICILIO COMERCIAL: %s" % DOMICILIO_COMERCIAL, top=1.5 * cm, width=BAND_WIDTH, style={ 'fontName': 'Helvetica', 'fontSize': 10 }), SystemField(expression='Periodo: %(var:periodo)s', top=1.5 * cm, left=23 * cm, style={ 'fontName': 'Helvetica', 'fontSize': 10 }), SystemField(expression='Fecha emisión: %(now:%d/%m/%Y)s', top=2 * cm, width=8 * cm), SystemField(expression='Folio N°: %(page_number)s', top=2 * cm, left=23 * cm, style={ 'fontName': 'Helvetica', 'fontSize': 10 }), Line(left=0, top=2.7 * cm, right=29.7 * cm, bottom=2.7 * cm), # Encabezado de tabla Label(text="Fecha", top=2.9 * cm, left=0, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="Comprobante", top=2.9 * cm, left=2.1 * cm, width=3.5 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="Razón Social", top=2.9 * cm, left=5.7 * cm, width=7 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="CUIT", top=2.9 * cm, left=13.7 * cm, width=2.5 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="Imp. Neto", top=2.9 * cm, left=17.2 * cm, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="IVA(10.5%)", top=2.9 * cm, left=20.2 * cm, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="IVA(21%)", top=2.9 * cm, left=22.2 * cm, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="Exento", top=2.9 * cm, left=23.7 * cm, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Label(text="Imp. Total", top=2.9 * cm, left=26 * cm, width=2 * cm, style={ 'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER }), Line(left=0, top=3.5 * cm, right=29.7 * cm, bottom=3.5 * cm), ]