From d143a31fc6b7eb3dc002d7c6ceb86d8840bce6aa Mon Sep 17 00:00:00 2001 From: roberto Date: Fri, 19 Sep 2008 09:23:41 +0000 Subject: [PATCH] Arreglo, al eliminar una o varias facturas de cliente si tiene recibos con devoluciones la factura esta pendiente y se puede borar pero por integridad no se permite borrar, antes este caso no decia nada ahora se saca un mensaje (Ya esta hecho en ACANA) git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@598 0c75b7a4-871f-7646-8a2f-f78d34cc349f --- .../Controller/uFacturasClienteController.pas | 14 ++- .../Views/uEditorFacturaCliente.dfm | 116 +++++++++++++++--- .../Views/uEditorFacturaCliente.pas | 4 +- .../Views/uEditorFacturasCliente.dfm | 46 ++++--- .../Views/uEditorFacturasCliente.pas | 12 +- 5 files changed, 156 insertions(+), 36 deletions(-) diff --git a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas index 887c9a1d..736694c1 100644 --- a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas +++ b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas @@ -107,7 +107,7 @@ type function ElegirFacturas(AFacturas : IBizFacturaCliente; AMensaje: String; AMultiSelect: Boolean): IBizFacturaCliente; function ExtraerSeleccionados(AFacturasCliente: IBizFacturaCliente) : IBizFacturaCliente; - procedure EnviarFacturaPorEMail(AFactura : IBizFacturaCliente); + procedure EnviarFacturaPorEMail(AFactura : IBizFacturaCliente); end; implementation @@ -121,7 +121,7 @@ uses uBizDetallesAlbaranCliente, uFacturasClienteReportController, DateUtils, Forms, uFormasPagoController, uBizFormasPago, uIEditorElegirFacturasCliente, uRecibosClienteController, uBizRecibosCliente, uIntegerListUtils, - uSistemaFunc, uDialogElegirEMail, uEMailUtils; + uSistemaFunc, uDialogElegirEMail, uEMailUtils, Dialogs; {procedure CopiarArticulosPedido(AOrigen: IBizDetallesPedidoCliente; @@ -719,8 +719,14 @@ begin if bEliminado then begin - AFactura.DataTable.ApplyUpdates; - Result := True; + try + AFactura.DataTable.ApplyUpdates; + Result := True + except + //En el caso de una factura que tiene recibos con devoluciones hechas no se puede borrar aunque la factura este en situacion de pendiente + AFactura.DataTable.CancelUpdates; + Result := False; + end; end else Result := False; diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm index 13b21fa3..f00e5ead 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm @@ -13,7 +13,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente inherited JvNavPanelHeader: TJvNavPanelHeader Width = 812 Caption = 'Nueva factura de cliente' - ExplicitWidth = 829 + ExplicitWidth = 812 inherited Image1: TImage Left = 785 Picture.Data = { @@ -40,7 +40,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end inherited TBXDock: TTBXDock Width = 812 - ExplicitWidth = 829 + ExplicitWidth = 812 inherited tbxMain: TTBXToolbar ExplicitWidth = 613 inherited TBXItem2: TTBXItem @@ -84,12 +84,12 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente Width = 806 Height = 344 OnChanging = pgPaginasChanging - ExplicitWidth = 823 + ExplicitWidth = 806 ExplicitHeight = 344 inherited pagGeneral: TTabSheet ExplicitLeft = 4 ExplicitTop = 24 - ExplicitWidth = 815 + ExplicitWidth = 798 ExplicitHeight = 316 inline frViewFacturaCliente1: TfrViewFacturaCliente Left = 0 @@ -105,25 +105,37 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente ParentFont = False TabOrder = 0 ReadOnly = False - ExplicitWidth = 815 + ExplicitWidth = 798 ExplicitHeight = 316 inherited dxLayoutControl1: TdxLayoutControl Width = 798 Height = 316 - ExplicitWidth = 815 + ExplicitWidth = 798 ExplicitHeight = 316 DesignSize = ( 798 316) inherited eReferencia: TcxDBTextEdit + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 343 Width = 343 end inherited edtFecha: TcxDBDateEdit + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 343 Width = 343 end inherited memObservaciones: TcxDBMemo + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 445 ExplicitHeight = 136 Height = 136 @@ -140,32 +152,56 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente inherited edtlNombre: TcxDBTextEdit DataBinding.DataSource = frViewFacturaCliente1.DADataSource Properties.OnChange = frViewClienteFacturaedtlNombrePropertiesChange + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 224 Width = 224 end inherited edtNIFCIF: TcxDBTextEdit DataBinding.DataSource = frViewFacturaCliente1.DADataSource + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 224 Width = 224 end inherited edtCalle: TcxDBTextEdit DataBinding.DataSource = frViewFacturaCliente1.DADataSource + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 224 Width = 224 end inherited edtPoblacion: TcxDBTextEdit DataBinding.DataSource = frViewFacturaCliente1.DADataSource + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 106 Width = 106 end inherited edtProvincia: TcxDBTextEdit DataBinding.DataSource = frViewFacturaCliente1.DADataSource + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 224 Width = 224 end inherited edtCodigoPostal: TcxDBTextEdit Left = 199 DataBinding.DataSource = frViewFacturaCliente1.DADataSource + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 199 end inherited Button3: TBitBtn @@ -175,6 +211,10 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end end inherited cbFormaPago: TcxDBLookupComboBox + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 205 Width = 205 end @@ -183,6 +223,10 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente ExplicitLeft = 325 end inherited cbCuentaBancaria: TcxDBComboBox + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 343 Width = 343 end @@ -192,10 +236,6 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente object pagContenido: TTabSheet Caption = 'Contenido' ImageIndex = 1 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 815 - ExplicitHeight = 0 inline frViewDetallesFacturaCliente1: TfrViewDetallesFacturaCliente Left = 0 Top = 0 @@ -212,7 +252,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente ParentFont = False TabOrder = 0 ReadOnly = False - ExplicitWidth = 815 + ExplicitWidth = 798 ExplicitHeight = 316 inherited ToolBar1: TToolBar Width = 798 @@ -343,7 +383,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente Width = 200 end> ExplicitTop = 589 - ExplicitWidth = 829 + ExplicitWidth = 812 end inline frViewTotales1: TfrViewTotales [4] Left = 0 @@ -360,12 +400,12 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente TabOrder = 4 ReadOnly = False ExplicitTop = 426 - ExplicitWidth = 829 + ExplicitWidth = 812 ExplicitHeight = 163 inherited dxLayoutControl1: TdxLayoutControl Width = 812 LookAndFeel = frViewFacturaCliente1.dxLayoutOfficeLookAndFeel1 - ExplicitWidth = 829 + ExplicitWidth = 812 inherited Bevel1: TBevel Top = 111 Width = 73 @@ -390,7 +430,11 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end inherited ImporteDto: TcxDBCurrencyEdit Top = 131 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 131 ExplicitWidth = 184 Width = 184 @@ -398,7 +442,11 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente inherited ImporteIVA: TcxDBCurrencyEdit Left = 551 Top = 57 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 551 ExplicitTop = 57 ExplicitWidth = 249 @@ -407,7 +455,11 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente inherited ImporteTotal: TcxDBCurrencyEdit Left = 481 Top = 131 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 481 ExplicitTop = 131 ExplicitWidth = 319 @@ -415,20 +467,32 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end inherited edtDescuento: TcxDBSpinEdit Top = 131 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 131 end inherited edtIVA: TcxDBSpinEdit Left = 480 Top = 57 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 480 ExplicitTop = 57 end inherited ImporteBase: TcxDBCurrencyEdit Left = 480 Top = 30 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 480 ExplicitTop = 30 ExplicitWidth = 320 @@ -437,14 +501,22 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente inherited edtRE: TcxDBSpinEdit Left = 480 Top = 84 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 480 ExplicitTop = 84 end inherited ImporteRE: TcxDBCurrencyEdit Left = 551 Top = 84 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 551 ExplicitTop = 84 ExplicitWidth = 249 @@ -452,20 +524,32 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end inherited eImporteNeto: TcxDBCurrencyEdit Top = 30 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 30 ExplicitWidth = 255 Width = 255 end inherited ePorte: TcxDBCurrencyEdit Top = 158 + Style.LookAndFeel.SkinName = '' Style.IsFontAssigned = True + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 158 ExplicitWidth = 255 Width = 255 end inherited eIVA: TcxDBLookupComboBox Top = 57 + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 57 ExplicitWidth = 117 Width = 117 @@ -478,6 +562,10 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente end inherited cbRecargoEquivalencia: TcxDBCheckBox Top = 84 + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 84 ExplicitWidth = 255 Width = 255 diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas index 700000b5..c9e99ee5 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas @@ -155,7 +155,9 @@ begin if (Application.MessageBox(PChar(ACadena), 'Atención', MB_YESNO) = IDYES) then begin - FController.Eliminar(Factura); + //Es el caso de querer borrar una factura pendiente cuyos recibos tienen devoluciones + if not FController.Eliminar(Factura) then + Application.MessageBox('La factura no ha podido ser eliminada porque tiene recibos con pagos o devoluciones emitidas.', 'Atención', MB_OK); inherited; end; end; diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.dfm b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.dfm index dd2b03b6..d013f1df 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.dfm +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.dfm @@ -9,7 +9,7 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente inherited JvNavPanelHeader: TJvNavPanelHeader Width = 842 Caption = 'Lista de facturas de cliente' - ExplicitWidth = 640 + ExplicitWidth = 842 inherited Image1: TImage Left = 815 Picture.Data = { @@ -36,7 +36,7 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente end inherited TBXDock: TTBXDock Width = 842 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited tbxMain: TTBXToolbar ExplicitWidth = 842 object TBXSubmenuItem2: TTBXSubmenuItem [0] @@ -69,7 +69,7 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente Top = 647 Width = 842 ExplicitTop = 647 - ExplicitWidth = 640 + ExplicitWidth = 842 end inline frViewFacturasCliente1: TfrViewFacturasCliente [3] Left = 0 @@ -86,12 +86,12 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente TabOrder = 3 ReadOnly = False ExplicitTop = 102 - ExplicitWidth = 640 + ExplicitWidth = 842 ExplicitHeight = 545 inherited cxGrid: TcxGrid Width = 842 Height = 417 - ExplicitWidth = 640 + ExplicitWidth = 842 ExplicitHeight = 417 inherited cxGridView: TcxGridDBTableView DataController.Summary.DefaultGroupSummaryItems = < @@ -130,28 +130,44 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente end inherited frViewFiltroBase1: TfrViewFiltroBase Width = 842 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited TBXDockablePanel1: TTBXDockablePanel - ExplicitWidth = 640 + ExplicitWidth = 842 inherited dxLayoutControl1: TdxLayoutControl Width = 842 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited txtFiltroTodo: TcxTextEdit + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 600 Width = 600 end inherited edtFechaIniFiltro: TcxDateEdit + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitWidth = 263 Width = 263 end inherited edtFechaFinFiltro: TcxDateEdit Left = 367 + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 367 ExplicitWidth = 263 Width = 263 end inherited eLista: TcxComboBox Left = 667 + Style.LookAndFeel.SkinName = '' + StyleDisabled.LookAndFeel.SkinName = '' + StyleFocused.LookAndFeel.SkinName = '' + StyleHot.LookAndFeel.SkinName = '' ExplicitLeft = 667 ExplicitWidth = 20 Width = 20 @@ -159,10 +175,10 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente end inherited TBXAlignmentPanel1: TTBXAlignmentPanel Width = 842 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited tbxBotones: TTBXToolbar Width = 832 - ExplicitWidth = 630 + ExplicitWidth = 832 end end end @@ -170,13 +186,13 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente inherited pnlAgrupaciones: TTBXDockablePanel Top = 519 ExplicitTop = 519 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited TBXAlignmentPanel1: TTBXAlignmentPanel Width = 842 - ExplicitWidth = 640 + ExplicitWidth = 842 inherited TBXToolbar1: TTBXToolbar Width = 832 - ExplicitWidth = 630 + ExplicitWidth = 832 end end end @@ -3382,8 +3398,8 @@ inherited fEditorFacturasCliente: TfEditorFacturasCliente 82866906D6993E62F6F1C3F45D160A5305BE68FF8095CF5B4302134CFE1185EA 1FB8A1B4FF4FE32FF6FADB8B5E0000000049454E44AE426082} Instruction.Text = - 'Las siguientes facturas no han podido ser eliminadas, porque est' + - #225'n parcialmente pagadas o totalmete pagadas' + 'Las siguientes facturas no han podido ser eliminadas, porque tie' + + 'nen recibos con pagos o devoluciones emitidas' Instruction.Glyph.Data = { 0A54504E474F626A65637489504E470D0A1A0A0000000D494844520000001C00 00001C0806000000720DDF940000000970485973000017120000171201679FD2 diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas index f08d97e9..a86450e5 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas @@ -197,13 +197,21 @@ begin if Assigned(AFacturas) then begin - FController.Eliminar(AFacturas, AllItems); + if (not FController.Eliminar(AFacturas, AllItems)) + and (not AllItems) then //Es el caso de querer borrar una factura pendiente cuyos recibos tienen devoluciones + begin + JsListaFacturasNoEliminadas.Content.Clear; + JsListaFacturasNoEliminadas.Content.Add('Ref. factura: ' + AFacturas.REFERENCIA + ' ' + AFacturas.NOMBRE); + JsListaFacturasNoEliminadas.Execute; + end; + if AllItems then begin if (AFacturas.DataTable.RecordCount > 0) then begin with AFacturas.DataTable do begin + JsListaFacturasNoEliminadas.Content.Clear; First; while not EOF do begin @@ -214,7 +222,7 @@ begin JsListaFacturasNoEliminadas.Execute; end; actRefrescar.Execute; - end; + end end; ViewGrid.GotoFirst;