(self, cancel=False)
return inv_dict
Build dict with data to send to AEAT WS for invoice types:
        in_invoice and in_refund.

        :param cancel: It indicates if the dictionary if for sending a
          cancellation of the invoice.
        :return: invoices (dict) : Dict XML with data for this invoice.
Build dict with data to send to AEAT WS for invoice types:
        in_invoice and in_refund.
Build dict with data to send to AEAT WS for invoice types : in_invoice and in_refund .
def _get_sii_invoice_dict_in(self, cancel=False):
        """Build dict with data to send to AEAT WS for invoice types:
        in_invoice and in_refund.

        :param cancel: It indicates if the dictionary if for sending a
          cancellation of the invoice.
        :return: invoices (dict) : Dict XML with data for this invoice.
        """
        self.ensure_one()
        invoice_date = self._change_date_format(self.invoice_date)
        reg_date = self._change_date_format(self._get_account_registration_date())
        ejercicio = fields.Date.to_date(self.date).year
        periodo = "%02d" % fields.Date.to_date(self.date).month
        partner = self._sii_get_partner()
        desglose_factura, tax_amount, not_in_amount_total = self._get_sii_in_taxes()
        inv_dict = {
            "IDFactura": {
                "IDEmisorFactura": {},
                "NumSerieFacturaEmisor": ((self.ref or "")[:60]),
                "FechaExpedicionFacturaEmisor": invoice_date,
            },
            "PeriodoLiquidacion": {"Ejercicio": ejercicio, "Periodo": periodo},
        }
        # Uso condicional de IDOtro/NIF
        ident = self._get_sii_identifier()
        inv_dict["IDFactura"]["IDEmisorFactura"].update(ident)
        if cancel:
            inv_dict["IDFactura"]["IDEmisorFactura"].update(
                {"NombreRazon": partner.name[0:120]}
            )
        else:
            amount_total = -self.amount_total_signed - not_in_amount_total
            inv_dict["FacturaRecibida"] = {
                # TODO: Incluir los 5 tipos de facturas rectificativas
                "TipoFactura": self._get_sii_invoice_type(),
                "ClaveRegimenEspecialOTrascendencia": self.sii_registration_key.code,
                "DescripcionOperacion": self.sii_description,
                "DesgloseFactura": desglose_factura,
                "Contraparte": {"NombreRazon": partner.name[0:120]},
                "FechaRegContable": reg_date,
                "ImporteTotal": amount_total,
                "CuotaDeducible": tax_amount,
            }
            if self.sii_macrodata:
                inv_dict["FacturaRecibida"].update(Macrodato="S")
            if self.sii_registration_key_additional1:
                inv_dict["FacturaRecibida"].update(
                    {
                        "ClaveRegimenEspecialOTrascendenciaAdicional1": (
                            self.sii_registration_key_additional1.code
                        )
                    }
                )
            if self.sii_registration_key_additional2:
                inv_dict["FacturaRecibida"].update(
                    {
                        "ClaveRegimenEspecialOTrascendenciaAdicional2": (
                            self.sii_registration_key_additional2.code
                        )
                    }
                )
            # Uso condicional de IDOtro/NIF
            inv_dict["FacturaRecibida"]["Contraparte"].update(ident)
            if self.move_type == "in_refund":
                rec_dict = inv_dict["FacturaRecibida"]
                rec_dict["TipoRectificativa"] = self.sii_refund_type
                if self.sii_refund_type == "S":
                    refund_tax_amount = self.refund_invoice_id._get_sii_in_taxes()[1]
                    rec_dict["ImporteRectificacion"] = {
                        "BaseRectificada": abs(
                            self.refund_invoice_id.amount_untaxed_signed
                        ),
                        "CuotaRectificada": refund_tax_amount,
                    }
        return inv_dict
def _get_sii_invoice_dict_in ( self , cancel = False ) : self . ensure_one ( ) invoice_date = self . _change_date_format ( self . invoice_date ) reg_date = self . _change_date_format ( self . _get_account_registration_date ( ) ) ejercicio = fields . Date . to_date ( self . date ) . year periodo = "%02d" % fields . Date . to_date ( self . date ) . month partner = self . _sii_get_partner ( ) desglose_factura , tax_amount , not_in_amount_total = self . _get_sii_in_taxes ( ) inv_dict = { "IDFactura" : { "IDEmisorFactura" : { } , "NumSerieFacturaEmisor" : ( ( self . ref or "" ) [ : 60 ] ) , "FechaExpedicionFacturaEmisor" : invoice_date , } , "PeriodoLiquidacion" : { "Ejercicio" : ejercicio , "Periodo" : periodo } , } # Uso condicional de IDOtro/NIF ident = self . _get_sii_identifier ( ) inv_dict [ "IDFactura" ] [ "IDEmisorFactura" ] . update ( ident ) if cancel : inv_dict [ "IDFactura" ] [ "IDEmisorFactura" ] . update ( { "NombreRazon" : partner . name [ 0 : 120 ] } ) else : amount_total = - self . amount_total_signed - not_in_amount_total inv_dict [ "FacturaRecibida" ] = { # TODO: Incluir los 5 tipos de facturas rectificativas "TipoFactura" : self . _get_sii_invoice_type ( ) , "ClaveRegimenEspecialOTrascendencia" : self . sii_registration_key . code , "DescripcionOperacion" : self . sii_description , "DesgloseFactura" : desglose_factura , "Contraparte" : { "NombreRazon" : partner . name [ 0 : 120 ] } , "FechaRegContable" : reg_date , "ImporteTotal" : amount_total , "CuotaDeducible" : tax_amount , } if self . sii_macrodata : inv_dict [ "FacturaRecibida" ] . update ( Macrodato = "S" ) if self . sii_registration_key_additional1 : inv_dict [ "FacturaRecibida" ] . update ( { "ClaveRegimenEspecialOTrascendenciaAdicional1" : ( self . sii_registration_key_additional1 . code ) } ) if self . sii_registration_key_additional2 : inv_dict [ "FacturaRecibida" ] . update ( { "ClaveRegimenEspecialOTrascendenciaAdicional2" : ( self . sii_registration_key_additional2 . code ) } ) # Uso condicional de IDOtro/NIF inv_dict [ "FacturaRecibida" ] [ "Contraparte" ] . update ( ident ) if self . move_type == "in_refund" : rec_dict = inv_dict [ "FacturaRecibida" ] rec_dict [ "TipoRectificativa" ] = self . sii_refund_type if self . sii_refund_type == "S" : refund_tax_amount = self . refund_invoice_id . _get_sii_in_taxes ( ) [ 1 ] rec_dict [ "ImporteRectificacion" ] = { "BaseRectificada" : abs ( self . refund_invoice_id . amount_untaxed_signed ) , "CuotaRectificada" : refund_tax_amount , } return inv_dict