Se adapata para que cuando se cree una factura a partir de todos los detalles de un presupuesto, se copie el precio neto (calculado) en el importe unidad ya que las facturas no tienen habilitado el campo descuento en los detalles

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@1021 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
roberto 2010-08-19 14:36:55 +00:00
parent cd7f1c5147
commit c1e3d5faaf
6 changed files with 21 additions and 339 deletions

View File

@ -142,58 +142,6 @@ uses
uROXMLIntf;
{procedure CopiarArticulosPedido(AOrigen: IBizDetallesPedidoCliente;
ADestino : IBizDetallesFacturaCliente);
var
i : integer;
ADetallesController : IDetallesFacturaClienteController;
begin
if not Assigned(AOrigen) then
raise Exception.Create ('Origen no asignado (CopiarArticulosPedido)');
if not Assigned(ADestino) then
raise Exception.Create ('Destino no asignado (CopiarArticulosPedido)');
if not AOrigen.DataTable.Active then
AOrigen.DataTable.Active := True;
if not ADestino.DataTable.Active then
ADestino.DataTable.Active := True;
ADetallesController := TDetallesFacturaClienteController.Create;
try
//OJO IMPORTANTE
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
//obligarle siempre a recalcular los detalles una sola vez
ADetallesController.BeginUpdate(ADestino);
AOrigen.DataTable.First;
for i := 0 to AOrigen.DataTable.RecordCount - 1 do
begin
ADetallesController.Add(ADestino, TIPO_DETALLE_CONCEPTO);
ADestino.Edit;
ADestino.REFERENCIA := AOrigen.REFERENCIA;
if AOrigen.ID_ARTICULO > 0 then
ADestino.ID_ARTICULO := AOrigen.ID_ARTICULO;
ADestino.CONCEPTO := AOrigen.CONCEPTO;
ADestino.CANTIDAD := AOrigen.CANTIDAD;
ADestino.IMPORTE_UNIDAD := AOrigen.IMPORTE_UNIDAD;
ADestino.IMPORTE_TOTAL := AOrigen.IMPORTE_TOTAL;
ADestino.DESCUENTO := AOrigen.DESCUENTO;
ADestino.IMPORTE_PORTE := AOrigen.IMPORTE_PORTE;
ADestino.VISIBLE := AOrigen.VISIBLE;
ADestino.REFERENCIA_PROVEEDOR := AOrigen.REFERENCIA_PROVEEDOR;
ADestino.Post;
AOrigen.Next;
end;
finally
ADetallesController.EndUpdate(ADestino);
ADetallesController := NIL;
end;
end;}
{ TFacturasClienteController }
function TFacturasClienteController.Anadir(AFactura: IBizFacturaCliente) : Boolean;

View File

@ -77,14 +77,6 @@ inherited frViewDetallesFacturaCliente: TfrViewDetallesFacturaCliente
Height = 205
ExplicitTop = 99
ExplicitHeight = 205
inherited cxGridView: TcxGridDBTableView
inherited cxGridViewDESCUENTO: TcxGridDBColumn
Visible = True
end
inherited cxGridViewIMPORTENETO: TcxGridDBColumn
Visible = True
end
end
end
inherited TBXDock1: TTBXDock
Top = 73

View File

@ -107,12 +107,12 @@ inherited frViewDetallesPedidoProveedor: TfrViewDetallesPedidoProveedor
end
inherited cxGridViewIMPORTENETO: TcxGridDBColumn
Caption = 'Importe coste'
Visible = True
end
end
end
inherited TBXDock1: TTBXDock
Top = 73
ExplicitTop = 73
inherited TBXToolbar1: TTBXToolbar
inherited TBXSubmenuItem1: TTBXSubmenuItem
Visible = False

View File

@ -35,103 +35,13 @@ var
// AProveedoresController : IProveedoresController;
{ Métodos auxiliares }
{procedure CopiarPedidoAPedido(APedido: IBizPedidoCliente;
APedido : IBizFacturaProveedor);
begin
if not Assigned(APedido) then
raise Exception.Create ('Presupuesto no asignado (CopiarPedidoAPedido)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarPedidoAPedido)');
if not APedido.DataTable.Active then
APedido.DataTable.Active := True;
// El presupuesto tiene que venir ya abierto y posicionado donde hay que copiar
APedido.ID_CLIENTE := APedido.ID_CLIENTE;
APedido.ID_PEDIDO := APedido.ID;
APedido.CALLE := APedido.CALLE;
APedido.CODIGO_POSTAL := APedido.CODIGO_POSTAL;
APedido.POBLACION := APedido.POBLACION;
APedido.PROVINCIA := APedido.PROVINCIA;
APedido.PERSONA_CONTACTO := APedido.PERSONA_CONTACTO;
APedido.TELEFONO := APedido.TELEFONO;
APedido.IMPORTE_NETO := APedido.IMPORTE_NETO;
APedido.IMPORTE_PORTE := APedido.IMPORTE_PORTE;
APedido.DESCUENTO := APedido.DESCUENTO;
APedido.IMPORTE_DESCUENTO := APedido.IMPORTE_DESCUENTO;
APedido.BASE_IMPONIBLE := APedido.BASE_IMPONIBLE;
APedido.IVA := APedido.IVA;
APedido.IMPORTE_IVA := APedido.IMPORTE_IVA;
APedido.IMPORTE_TOTAL := APedido.IMPORTE_TOTAL;
APedido.DataTable.FieldByName(fld_PedidosClienteOBSERVACIONES).AsVariant := APedido.DataTable.FieldByName(fld_PedidosClienteOBSERVACIONES).AsVariant;
APedido.ID_FORMA_PAGO := APedido.ID_FORMA_PAGO;
end;
procedure CopiarArticulosPendAPedido(
APedido: IBizPedidoCliente;
APedido: IBizFacturaProveedor;
AArticulosPendientes: IBizPedidoClienteArticulosPend);
var
i : integer;
ADetalles : IBizDetallesFacturaProveedor;
ADetallesController : IDetallesFacturaProveedorController;
begin
if not Assigned(APedido) then
raise Exception.Create ('Presupuesto no asignado (CopiarArticulosPendAPedido)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarArticulosPendAPedido)');
if not Assigned(AArticulosPendientes) then
raise Exception.Create ('Artículos pendientes no asignado (CopiarArticulosPendAPedido)');
if not AArticulosPendientes.DataTable.Active then
AArticulosPendientes.DataTable.Active := True;
// El presupuesto tiene que venir ya abierto y posicionado donde hay que copiar
ADetalles := APedido.Detalles;
ADetallesController := TDetallesFacturaProveedorController.Create;
try
//OJO IMPORTANTE
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
//obligarle siempre a recalcular los detalles una sola vez
ADetallesController.BeginUpdate(ADetalles);
AArticulosPendientes.DataTable.First;
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
begin
APedido.Detalles.First;
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
begin
ADetallesController.Add(ADetalles, TIPO_DETALLE_CONCEPTO);
ADetalles.Edit;
ADetalles.REFERENCIA := APedido.Detalles.REFERENCIA;
ADetalles.ID_ARTICULO := APedido.Detalles.ID_ARTICULO;
ADetalles.CONCEPTO := APedido.Detalles.CONCEPTO;
ADetalles.CANTIDAD := AArticulosPendientes.CANTIDAD_PENDIENTE;
ADetalles.IMPORTE_UNIDAD := APedido.Detalles.IMPORTE_UNIDAD;
ADetalles.IMPORTE_TOTAL := APedido.Detalles.IMPORTE_TOTAL;
ADetalles.DESCUENTO := APedido.Detalles.DESCUENTO;
ADetalles.IMPORTE_PORTE := APedido.Detalles.IMPORTE_PORTE;
ADetalles.VISIBLE := APedido.Detalles.VISIBLE;
ADetalles.REFERENCIA_PROVEEDOR := APedido.Detalles.REFERENCIA_PROVEEDOR;
ADetalles.Post;
AArticulosPendientes.Next;
end;
end;
finally
ADetallesController.EndUpdate(ADetalles);
ADetallesController := NIL;
end;
end; }
procedure CopiarArticulosPresupuesto(AOrigen: IBizDetallesPresupuestoCliente;
ADestino : IBizDetallesFacturaCliente);
var
i : integer;
ImporteDescuento: Double;
ImporteDescuentoAux: Double;
ADetallesController : IDetallesFacturaClienteController;
begin
if not Assigned(AOrigen) then
@ -163,9 +73,25 @@ begin
ADestino.ID_ARTICULO := AOrigen.ID_ARTICULO;
ADestino.CONCEPTO := AOrigen.CONCEPTO;
ADestino.CANTIDAD := AOrigen.CANTIDAD;
ADestino.IMPORTE_UNIDAD := AOrigen.IMPORTE_UNIDAD;
ADestino.IMPORTE_TOTAL := AOrigen.IMPORTE_TOTAL;
ADestino.DESCUENTO := AOrigen.DESCUENTO;
//SE adapta para que el descuento no se tenga en cuenta en el paso de presupuesto a factura
// ADestino.IMPORTE_UNIDAD := AOrigen.IMPORTE_UNIDAD;
// ADestino.DESCUENTO := AOrigen.DESCUENTO;
if (AOrigen.DESCUENTOIsNull) then
ADestino.IMPORTE_UNIDAD := AOrigen.IMPORTE_UNIDAD
else
begin
//Importe descuento con todos los decimales
ImporteDescuentoAux := AOrigen.IMPORTE_UNIDAD * (AOrigen.DESCUENTO/100);
//Importe descuento redondeado a solo dos decimales, porque en grandes cantidades hay fluctuación
//(importe unidad - 0,6732 no es lo mismo que importe unidad - 0,67 sobre todo cuando trabajamos con grandes cantidades)
ImporteDescuento := round(ImporteDescuentoAux*100)/100;
ADestino.IMPORTE_UNIDAD := AOrigen.IMPORTE_UNIDAD - ImporteDescuento;
end;
ADestino.IMPORTE_PORTE := AOrigen.IMPORTE_PORTE;
ADestino.VISIBLE := AOrigen.VISIBLE;
ADestino.REFERENCIA_PROVEEDOR := AOrigen.REFERENCIA_PROVEEDOR;

View File

@ -40,98 +40,6 @@ var
// AProveedoresController : IProveedoresController;
{ Métodos auxiliares }
{procedure CopiarPedidoAPedido(APedido: IBizPedidoCliente;
APedido : IBizFacturaProveedor);
begin
if not Assigned(APedido) then
raise Exception.Create ('Albarán no asignado (CopiarPedidoAPedido)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarPedidoAPedido)');
if not APedido.DataTable.Active then
APedido.DataTable.Active := True;
// El albarán tiene que venir ya abierto y posicionado donde hay que copiar
APedido.ID_CLIENTE := APedido.ID_CLIENTE;
APedido.ID_PEDIDO := APedido.ID;
APedido.CALLE := APedido.CALLE;
APedido.CODIGO_POSTAL := APedido.CODIGO_POSTAL;
APedido.POBLACION := APedido.POBLACION;
APedido.PROVINCIA := APedido.PROVINCIA;
APedido.PERSONA_CONTACTO := APedido.PERSONA_CONTACTO;
APedido.TELEFONO := APedido.TELEFONO;
APedido.IMPORTE_NETO := APedido.IMPORTE_NETO;
APedido.IMPORTE_PORTE := APedido.IMPORTE_PORTE;
APedido.DESCUENTO := APedido.DESCUENTO;
APedido.IMPORTE_DESCUENTO := APedido.IMPORTE_DESCUENTO;
APedido.BASE_IMPONIBLE := APedido.BASE_IMPONIBLE;
APedido.IVA := APedido.IVA;
APedido.IMPORTE_IVA := APedido.IMPORTE_IVA;
APedido.IMPORTE_TOTAL := APedido.IMPORTE_TOTAL;
APedido.DataTable.FieldByName(fld_PedidosClienteOBSERVACIONES).AsVariant := APedido.DataTable.FieldByName(fld_PedidosClienteOBSERVACIONES).AsVariant;
APedido.ID_FORMA_PAGO := APedido.ID_FORMA_PAGO;
end;
procedure CopiarArticulosPendAPedido(
APedido: IBizPedidoCliente;
APedido: IBizFacturaProveedor;
AArticulosPendientes: IBizPedidoClienteArticulosPend);
var
i : integer;
ADetalles : IBizDetallesFacturaProveedor;
ADetallesController : IDetallesFacturaProveedorController;
begin
if not Assigned(APedido) then
raise Exception.Create ('Albarán no asignado (CopiarArticulosPendAPedido)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarArticulosPendAPedido)');
if not Assigned(AArticulosPendientes) then
raise Exception.Create ('Artículos pendientes no asignado (CopiarArticulosPendAPedido)');
if not AArticulosPendientes.DataTable.Active then
AArticulosPendientes.DataTable.Active := True;
// El albarán tiene que venir ya abierto y posicionado donde hay que copiar
ADetalles := APedido.Detalles;
ADetallesController := TDetallesFacturaProveedorController.Create;
try
//OJO IMPORTANTE
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
//obligarle siempre a recalcular los detalles una sola vez
ADetallesController.BeginUpdate(ADetalles);
AArticulosPendientes.DataTable.First;
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
begin
APedido.Detalles.First;
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
begin
ADetallesController.Add(ADetalles, TIPO_DETALLE_CONCEPTO);
ADetalles.Edit;
ADetalles.REFERENCIA := APedido.Detalles.REFERENCIA;
ADetalles.ID_ARTICULO := APedido.Detalles.ID_ARTICULO;
ADetalles.CONCEPTO := APedido.Detalles.CONCEPTO;
ADetalles.CANTIDAD := AArticulosPendientes.CANTIDAD_PENDIENTE;
ADetalles.IMPORTE_UNIDAD := APedido.Detalles.IMPORTE_UNIDAD;
ADetalles.IMPORTE_TOTAL := APedido.Detalles.IMPORTE_TOTAL;
ADetalles.DESCUENTO := APedido.Detalles.DESCUENTO;
ADetalles.IMPORTE_PORTE := APedido.Detalles.IMPORTE_PORTE;
ADetalles.VISIBLE := APedido.Detalles.VISIBLE;
ADetalles.REFERENCIA_PROVEEDOR := APedido.Detalles.REFERENCIA_PROVEEDOR;
ADetalles.Post;
AArticulosPendientes.Next;
end;
end;
finally
ADetallesController.EndUpdate(ADetalles);
ADetallesController := NIL;
end;
end; }
procedure Inicializar;
begin

View File

@ -40,98 +40,6 @@ var
// AProveedoresController : IProveedoresController;
{ Métodos auxiliares }
{procedure CopiarPedidoAAlbaran(APedido: IBizPedidoCliente;
AAlbaran : IBizFacturaProveedor);
begin
if not Assigned(AAlbaran) then
raise Exception.Create ('Albarán no asignado (CopiarPedidoAAlbaran)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarPedidoAAlbaran)');
if not APedido.DataTable.Active then
APedido.DataTable.Active := True;
// El albarán tiene que venir ya abierto y posicionado donde hay que copiar
AAlbaran.ID_CLIENTE := APedido.ID_CLIENTE;
AAlbaran.ID_PEDIDO := APedido.ID;
AAlbaran.CALLE := APedido.CALLE;
AAlbaran.CODIGO_POSTAL := APedido.CODIGO_POSTAL;
AAlbaran.POBLACION := APedido.POBLACION;
AAlbaran.PROVINCIA := APedido.PROVINCIA;
AAlbaran.PERSONA_CONTACTO := APedido.PERSONA_CONTACTO;
AAlbaran.TELEFONO := APedido.TELEFONO;
AAlbaran.IMPORTE_NETO := APedido.IMPORTE_NETO;
AAlbaran.IMPORTE_PORTE := APedido.IMPORTE_PORTE;
AAlbaran.DESCUENTO := APedido.DESCUENTO;
AAlbaran.IMPORTE_DESCUENTO := APedido.IMPORTE_DESCUENTO;
AAlbaran.BASE_IMPONIBLE := APedido.BASE_IMPONIBLE;
AAlbaran.IVA := APedido.IVA;
AAlbaran.IMPORTE_IVA := APedido.IMPORTE_IVA;
AAlbaran.IMPORTE_TOTAL := APedido.IMPORTE_TOTAL;
AAlbaran.DataTable.FieldByName(fld_AlbaranesClienteOBSERVACIONES).AsVariant := APedido.DataTable.FieldByName(fld_PedidosClienteOBSERVACIONES).AsVariant;
AAlbaran.ID_FORMA_PAGO := APedido.ID_FORMA_PAGO;
end;
procedure CopiarArticulosPendAAlbaran(
APedido: IBizPedidoCliente;
AAlbaran: IBizFacturaProveedor;
AArticulosPendientes: IBizPedidoClienteArticulosPend);
var
i : integer;
ADetalles : IBizDetallesFacturaProveedor;
ADetallesController : IDetallesFacturaProveedorController;
begin
if not Assigned(AAlbaran) then
raise Exception.Create ('Albarán no asignado (CopiarArticulosPendAAlbaran)');
if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (CopiarArticulosPendAAlbaran)');
if not Assigned(AArticulosPendientes) then
raise Exception.Create ('Artículos pendientes no asignado (CopiarArticulosPendAAlbaran)');
if not AArticulosPendientes.DataTable.Active then
AArticulosPendientes.DataTable.Active := True;
// El albarán tiene que venir ya abierto y posicionado donde hay que copiar
ADetalles := AAlbaran.Detalles;
ADetallesController := TDetallesFacturaProveedorController.Create;
try
//OJO IMPORTANTE
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
//obligarle siempre a recalcular los detalles una sola vez
ADetallesController.BeginUpdate(ADetalles);
AArticulosPendientes.DataTable.First;
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
begin
APedido.Detalles.First;
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
begin
ADetallesController.Add(ADetalles, TIPO_DETALLE_CONCEPTO);
ADetalles.Edit;
ADetalles.REFERENCIA := APedido.Detalles.REFERENCIA;
ADetalles.ID_ARTICULO := APedido.Detalles.ID_ARTICULO;
ADetalles.CONCEPTO := APedido.Detalles.CONCEPTO;
ADetalles.CANTIDAD := AArticulosPendientes.CANTIDAD_PENDIENTE;
ADetalles.IMPORTE_UNIDAD := APedido.Detalles.IMPORTE_UNIDAD;
ADetalles.IMPORTE_TOTAL := APedido.Detalles.IMPORTE_TOTAL;
ADetalles.DESCUENTO := APedido.Detalles.DESCUENTO;
ADetalles.IMPORTE_PORTE := APedido.Detalles.IMPORTE_PORTE;
ADetalles.VISIBLE := APedido.Detalles.VISIBLE;
ADetalles.REFERENCIA_PROVEEDOR := APedido.Detalles.REFERENCIA_PROVEEDOR;
ADetalles.Post;
AArticulosPendientes.Next;
end;
end;
finally
ADetallesController.EndUpdate(ADetalles);
ADetallesController := NIL;
end;
end; }
procedure Inicializar;
begin