Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/08/2011, 09:14
acse
 
Fecha de Ingreso: agosto-2010
Ubicación: mexico
Mensajes: 125
Antigüedad: 14 años, 7 meses
Puntos: 0
Exclamación problema en progrmacion o consulta

Hola la progrmacion es de un punto de venta llamado mybussines, por lo que mi intencion es modificar la programacion o la consulta para que me de dos columnas mas en las cuales debe de salir lo que son venta al 16% y ventas al 0%. y la idea es hacerlo dentrod e la misma consulta esas divicion y las restas pero generando un as con dos columnas.

ejemplo lo que quiero es lo siguiente:

Código PHP:
p.ej:
 
         
Ventas Totales        $135,931.18
                         IVA         
$15,739.00
                Importe            
$120,192.18
El iva no corresponde
,  ya que hay ventas al cero de cafe o de Teo chocolatePor lo cual a partir del IVA calculamos el importe.
 
         $
15,739 .16  =  $98,368.75
   
El resto es venta al cero 
%   135931.18 15,739 98368.75 = $21,823.43  
 
La factura Quedaria asi
:
 
 
               
Ventas 16%                         98,368.75
               Ventas  0
%                         21,823.43
 
 
                Subtotal                            120
,192.18
                     IVA   0
%                                    0
                     IVA 16
%                         15,739.00
 
                          TOTAL                 
$  135,931.18 
La programacion es la siguiente.

Código PHP:
Public Sub Main()

    
' Colocamos los datos del rango
    ParamData.ParametrosRequeridos ,,,,,,,,True 

    ' 
Mostramos la ventana de rangos
    Rangos Ambiente
False

    
' Si se presiono el boton cancelado detenemos la operación
    if Cancelado Then
       Exit Sub
    end if

    if Not ParamData.TodasLasFechas Then
       cCondicion = " AND ventas.f_emision >= " & FechaSQL(ParamData.FechaInicial, Ambiente.Connection) & " AND ventas.f_emision <= " & FechaSQL( ParamData.FechaFinal, Ambiente.Connection )
       Reporte.Titulo2 = "Del día " & Formato(ParamData.FechaInicial, "dd-MM-yyyy") & " al día " & Formato(ParamData.FechaFinal, "dd-MM-yyyy")
    End if

    IniciaDocumento()       

        ' 
SELECT ventas.caja AS 'CAJA'ventas.f_emision AS 'FECHA'ventas.estado AS 'ESTATUS'
        
' sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end ) AS 'IMPORTE'
        ' 
FROM ventas WHERE ventas.estado 'CO' AND ventas.concepto2 <> 'COR'  
        ' AND ventas.f_emision >= '
20091201' AND ventas.f_emision <= '20091209
        ' 
GROUP BY ventas.caja,ventas.estado,ventas.f_emision ORDER BY ventas.f_emision
  

          strSQL 
"" 
          
strSQL strSQL "SELECT "
          
strSQL strSQL "ventas.caja AS 'CAJA', "
          
strSQL strSQL "ventas.f_emision AS 'FECHA', "
          
strSQL strSQL "ventas.estado AS 'ESTATUS', "   
          
strSQL strSQL "round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) AS 'IMPORTE', "
          
strSQL strSQL "round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then impuesto else 0 end ) - sum(case when (tipo_doc = 'DEV') then impuesto else 0 end),0) AS 'IVA', "
          
strSQL strSQL "round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) + (round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then impuesto else 0 end ) - sum(case when (tipo_doc = 'DEV') then impuesto else 0 end),0)) AS 'TOTAL',"
          
strSQL strSQL "round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) * 0.06 AS 'IMP REG', "
          
strSQL strSQL "(round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) * 0.06) * 0.16 AS 'IVA REGALIAS', "
          
strSQL strSQL "round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) * 0.06 + (round(sum(case when (tipo_doc = 'FAC' or tipo_doc = 'REM' ) then importe else 0 end )- sum(case when (tipo_doc = 'DEV') then importe else 0 end ),0) * 0.06) * 0.15 AS 'REGALIAS'"
          
strSQL strSQL "FROM ventas "                     
          
strSQL strSQL "WHERE ventas.estado = 'CO' AND ventas.concepto2 <> 'COR' " 
          
strSQL strSQL &  cCondicion       
          strSQL 
strSQL "GROUP BY ventas.caja,ventas.estado,ventas.f_emision "
          
strSQL strSQL "ORDER BY ventas.f_emision "    
          
       ' MyMessage (strSQL = strSQL("IMPORTE"))  
                                 
                        
                                      
          Reporte.SQL = strSQL 
                  
          Reporte.Titulo = "Total de Cobro de regalías (no incluye tickets cancelados, Devoluciones y cortesías en totales)"
          Reporte.RetrieveColumns 
          


          For n = 1 to Reporte.Columns.Count
              Reporte.Columns(n).EColor = RGB( 100,100,100 )
              Reporte.Columns(n).EColorCondition = Prepara("ResultSet('
Estatus') = 'CO'")
          Next
          
              

          Reporte.Columns("caja").Visible = False
          '
Reporte.Columns("caja").Ancho 8
          
          Reporte
.Columns("IMPORTE").Acumulado true
          Reporte
.Columns("IMPORTE").Formato Ambiente.FDinero 
          Reporte
.Columns("IMPORTE").Font "Courier New"
          
Reporte.Columns("IMPORTE").FontSize 7      
          Reporte
.Columns("IMPORTE").Anchocelda 11     
          Reporte
.Columns("IMPORTE").Ancho 8
          Reporte
.Columns("IMPORTE").Econdition Prepara("ResultSet('ESTATUS') = 'CO'"
          
Reporte.Columns("IVA").Acumulado True
          Reporte
.Columns("IVA").Formato Ambiente.FDinero 
          Reporte
.Columns("IVA").Font "Courier New"
          
Reporte.Columns("IVA").FontSize 7      
          Reporte
.Columns("IVA").Anchocelda 11     
          Reporte
.Columns("IVA").Ancho 8
          Reporte
.Columns("IVA").Econdition Prepara("ResultSet('ESTATUS') = 'CO'"
         
          
Reporte.Columns("TOTAL").Acumulado True
          Reporte
.Columns("TOTAL").Formato "###,###,###.00"
          
Reporte.Columns("TOTAL").Font "Courier New"
          
Reporte.Columns("TOTAL").FontSize 7      
          Reporte
.Columns("TOTAL").Anchocelda 11     
          Reporte
.Columns("TOTAL").Ancho 8                 
 
          
          Reporte
.Columns("IMP REG").Visible True 
          Reporte
.Columns("IMP REG").Acumulado True
          Reporte
.Columns("IMP REG").Formato "###,###,###.00"
          
Reporte.Columns("IMP REG").Font "Courier New"
          
Reporte.Columns("IMP REG").FontSize 7      
          Reporte
.Columns("IMP REG").Anchocelda 11     
          Reporte
.Columns("IMP REG").Ancho 8              
           
         
          Reporte
.Columns("IVA REGALIAS").Acumulado True 
          Reporte
.Columns("IVA REGALIAS").Formato "###,###,###.00"
          
Reporte.Columns("IVA REGALIAS").Font "Courier New"
          
Reporte.Columns("IVA REGALIAS").FontSize 7      
          Reporte
.Columns("IVA REGALIAS").Anchocelda 11     
          Reporte
.Columns("IVA REGALIAS").Ancho 8         
          
          Reporte
.Columns("REGALIAS").Acumulado True 
          Reporte
.Columns("REGALIAS").Formato "###,###,###.00"
          
Reporte.Columns("REGALIAS").Font "Courier New"
          
Reporte.Columns("REGALIAS").FontSize 7      
          Reporte
.Columns("REGALIAS").Anchocelda 11     
          Reporte
.Columns("REGALIAS").Ancho 8
          

          Reporte
.Columns("fecha").Formato "dd-MM-yyyy"
          
          
Reporte.Columns("Estatus").Visible False
          Reporte
.Columns("Estatus").Ancho 5


          Reporte
.ImprimeReporte

    FinDocumento
()

End Sub