ok, disculpas por el desorden y la falta de info, es que estuve todo el dia de ayer programando y estaba medio saturado. El tema es asi, esta parte es para cerrar una venta que puede ser toda en efectivo
, o parte en efectivo y el resto que falta va a una cuenta corriente. Entonces cuando llamo a
Código Delphi
[-] cierravta:=TFCierreVenta.create(self);
cierravta.ETotalvta.Text:=floattostrf(VPTotal_venta,ffNumber,10,2);
cierravta.EEfectivo.Text:=floattostrf(VPTotal_venta,ffNumber,10,2);
try
if cierravta.showmodal=mrOK then
muestro dos TEdits uno con el monto total y otro para ingresar el efectivo asi
Código Delphi
[-]procedure TFCierreventa.EEfectivoKeyPress(Sender: TObject; var Key: Char);
begin
if (key in ['a'..'z'])or(key in ['A'..'Z'])then
key:=#0;
if (key=#13)and(EEfectivo.text<>'') then
begin
Key:=#0;
FEfectivo:=strtofloat(EEfectivo.Text);
ModalResult:=mrOK;
end;
end;
luego analizo si se pago todo el monto o solo una parte y hay que acumular en cta cte asi
Código Delphi
[-]if roundto(VPTotal_venta,-2)>roundto(cierravta.efectivo,-2) then
begin
acumula_total_venta(costo,precio);
porcentage_pago_efectivo:=roundto(cierravta.efectivo/VPTotal_venta,-2);
incctacte:=TFIngresoctacte.create(self);
incctacte.ctacte:=cierravta.efectivo;
try
if incctacte.showmodal=mrOK then
entonces en incctacte pregunto por el cliente al cual se le computara el monto
Código Delphi
[-]procedure TFIngresoCtaCte.BIncorporarClick(Sender: TObject);
begin
try
if verifica_limite_cuenta then
begin
with modulodatos do
begin
if not ibtransaction1.InTransaction then
IBtransaction1.StartTransaction;
if not IBTClientes.Active then
IBTClientes.open;
IBTClientes.Locate('COD_CLIENTE',VPRid_cliente,[]);
IBTClientes.Edit;
IBTclientes.fieldbyname('SALDO').AsFloat:=IBTclientes.fieldbyname('SALDO').AsFloat+FPrincipal.VPtota l_venta-Fctacte;
IbTClientes.Post;
IBtransaction1.CommitRetaining;
end;
FPrincipal.inserta_en_vtadiaria('cc');
end;
except
on e:exception do
begin
Modulodatos.IBTransaction1.RollbackRetaining;
showmessage('Error al actualizar la cuenta en TFIngresoCtaCte.BIncorporarClick --'+e.message);
ModalResult:=mrabort;
end;
end;
end;
la funcion verifica_limite_cuenta es esta
Código Delphi
[-]function TFIngresoCtaCte.verifica_limite_cuenta: boolean;
begin
if VPRCli_saldo+Fprincipal.VPtotal_ventathen
begin
result:=true;
end
else
begin
if messagedlg('El cliente supera el límite de cuenta otorgado. Permite la compra?',mtWarning,mbOKCancel,0)=mrOK then
begin
result:=true
end
else
begin
result:=false;
FPrincipal.inicializa_ingreso;
FPrincipal.inicializa_venta;
showmessage('Venta cancelada.');
end;
end;
end;
por lo que no modifico el valor que se hace =0. Gracias y de nuevo disculpas.
Fede