This commit is contained in:
David Arranz 2007-12-03 12:38:11 +00:00
parent 9702e7f548
commit 807d058e16

View File

@ -69,6 +69,7 @@ end;
procedure DesglosarPorte(ImportePorte: Currency; ADetalles: IDAStronglyTypedDataTable);
var
Unidades: Integer;
Cantidad_Articulos: Integer;
ImporteUnidad: Currency;
ImporteSobrante: Currency;
ABookmark : TBookmark;
@ -82,10 +83,14 @@ begin
ADetalles.DataTable.First;
Unidades := 0;
Cantidad_Articulos := 0;
while not ADetalles.DataTable.eof do
begin
if (ADetalles.DataTable.FieldByName(CAMPO_ID_ARTICULOS).AsInteger > 0) then
begin
Unidades := Unidades + ADetalles.DataTable.FieldByName(CAMPO_CANTIDAD).AsInteger;
Inc(Cantidad_Articulos);
end;
ADetalles.DataTable.Next;
end;
@ -101,15 +106,17 @@ begin
if (ADetalles.DataTable.FieldByName(CAMPO_ID_ARTICULOS).AsInteger > 0) then
begin
ADetalles.DataTable.Edit;
ADetalles.DataTable.FieldByName(CAMPO_IMPORTE_PORTE).AsCurrency := ImporteUnidad;
if (Cantidad_Articulos > 1) then
ADetalles.DataTable.FieldByName(CAMPO_IMPORTE_PORTE).AsCurrency := ImporteUnidad
else
ADetalles.DataTable.FieldByName(CAMPO_IMPORTE_PORTE).AsCurrency := ImporteUnidad + ImporteSobrante;
Dec(Cantidad_Articulos);
ADetalles.DataTable.Post;
end;
ADetalles.DataTable.Next;
end;
ADetalles.DataTable.Edit;
ADetalles.DataTable.FieldByName(CAMPO_IMPORTE_PORTE).AsCurrency := ImporteUnidad + ImporteSobrante;
ADetalles.DataTable.Post;
finally
ADetalles.DataTable.EnableEventHandlers;