*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="frm_import_note_a4200.scx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
#INCLUDE "comun.h"

DEFINE CLASS dataenvironment AS dataenvironment 
 	*< CLASSDATA: Baseclass="dataenvironment" Timestamp="" Scale="" Uniqueid="" ClassIcon="1" />

	*<PropValue>
		DataSource = .NULL.
		Height = 200
		Left = 1
		Name = "Dataenvironment"
		Top = 220
		Width = 520
	*</PropValue>

ENDDEFINE

DEFINE CLASS form1 AS form 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="lblInfo" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCodAMEF.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCodAMEF.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCasa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCasa.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCodFiscal.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCodFiscal.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cTipAMEF.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cTipAMEF.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cClient.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cClient.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cAcont4111.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cAcont4111.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cAcont442x.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cAcont442x.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cBanca.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cBanca.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cSectie.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cSectie.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cDstChlt.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cDstChlt.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCasaC.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdAMEF.cCasaC.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column6.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column7.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column7.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column8.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column8.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column9.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column9.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column10.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column10.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column11.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdZ.Column11.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdTVA.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cCota.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cCota.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cCont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cCont.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cAcont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.cAcont.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareConturi.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cTip.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cTip.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cCont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cCont.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cAcont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.cAcont.Text1a" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConfigurareIncasari.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdImport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdGenereazaNote" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Check1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Check2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdSterge" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: completeazaclientiroa
		*m: connectroa
		*m: creeazanote
		*m: disconnectroa
		*m: exportdate
		*m: getidpart
		*m: loadsettings
		*m: modificanote
		*m: prelucreazafisierebreeze
		*m: refreshamef
		*m: savesettings
		*m: scrienote
		*m: sql_temp_insert
		*m: sql_temp_insert_values
		*m: sterge_import
		*m: templatexlsx
		*m: trace
		*m: verificaimport
		*p: lcontafin		&& Formularul se apeleaza din Contafin sau din ROA
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		Caption = "Import fisiere Z A4200"
		DoCreate = .T.
		Height = 418
		Icon = ..\comun\grafice\note.ico
		lcontafin = .F.
		Left = 0
		MaxButton = .F.
		MinButton = .F.
		Name = "Form1"
		ShowWindow = 0
		Top = 0
		Width = 824
		WindowState = 2
		WindowType = 1
		_memberdata = <VFPData>
			<memberdata name="verificaimport" display="VerificaImport"/>
			<memberdata name="modificanote" display="ModificaNote"/>
			<memberdata name="getidpart" display="GetIdPart"/>
			<memberdata name="savesettings" display="SaveSettings"/>
			<memberdata name="loadsettings" display="LoadSettings"/>
			<memberdata name="lcontafin" display="lContafin"/>
		</VFPData>
	*</PropValue>

	ADD OBJECT '_label1' AS _label WITH ;
		Caption = "Documente Z", ;
		FontBold = .T., ;
		Left = 344, ;
		Name = "_label1", ;
		TabIndex = 5, ;
		Top = 43
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="label" />

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 0, ;
		Left = 298, ;
		Name = "But_sterge1", ;
		Top = 33, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Check1' AS checkbox WITH ;
		Alignment = 0, ;
		Anchor = 4, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Configurare conturi venit / AMEF", ;
		Height = 17, ;
		Left = 344, ;
		Name = "Check1", ;
		Top = 279, ;
		Value = .T., ;
		Width = 191
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Check2' AS checkbox WITH ;
		Alignment = 0, ;
		Anchor = 12, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Configurare conturi incasari / AMEF", ;
		Height = 17, ;
		Left = 557, ;
		Name = "Check2", ;
		Top = 278, ;
		Value = .T., ;
		Width = 210
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cmdGenereazaNote' AS commandbutton WITH ;
		Anchor = 9, ;
		AutoSize = .F., ;
		Caption = "Genereaza note", ;
		Enabled = .F., ;
		FontBold = .T., ;
		Height = 52, ;
		Left = 619, ;
		Name = "cmdGenereazaNote", ;
		Picture = ..\comun\grafice\note16.ico, ;
		PicturePosition = 7, ;
		TabIndex = 2, ;
		Top = 7, ;
		Width = 98
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdImport' AS commandbutton WITH ;
		Anchor = 9, ;
		AutoSize = .F., ;
		Caption = "Import Z-uri", ;
		FontBold = .T., ;
		Height = 52, ;
		Left = 520, ;
		Name = "cmdImport", ;
		Picture = ..\comun\grafice\inbox.ico, ;
		PicturePosition = 7, ;
		TabIndex = 1, ;
		Top = 8, ;
		Width = 98
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdSterge' AS commandbutton WITH ;
		Anchor = 9, ;
		AutoSize = .F., ;
		Caption = "Sterge import", ;
		Enabled = .T., ;
		FontBold = .T., ;
		Height = 52, ;
		Left = 718, ;
		Name = "cmdSterge", ;
		Picture = ..\comun\grafice\erase01.ico, ;
		PicturePosition = 7, ;
		TabIndex = 2, ;
		Top = 6, ;
		Width = 98
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'grdAMEF' AS grid WITH ;
		Anchor = 7, ;
		ColumnCount = 11, ;
		DeleteMark = .F., ;
		Height = 348, ;
		HighlightStyle = 2, ;
		Left = 9, ;
		Name = "grdAMEF", ;
		Panel = 1, ;
		RecordSource = "cAMEF", ;
		TabIndex = 4, ;
		Top = 62, ;
		Width = 317, ;
		Column1.ControlSource = "codamef", ;
		Column1.Name = "cCodAMEF", ;
		Column2.BackColor = 190,225,255, ;
		Column2.ColumnOrder = 4, ;
		Column2.ControlSource = "casa", ;
		Column2.CurrentControl = "Text1a", ;
		Column2.Format = "K", ;
		Column2.InputMask = "", ;
		Column2.Name = "cCasa", ;
		Column2.ToolTipText = "DblClick pentru modificare", ;
		Column2.Width = 143, ;
		Column3.ColumnOrder = 2, ;
		Column3.ControlSource = "cod_fiscal", ;
		Column3.Name = "cCodFiscal", ;
		Column4.ColumnOrder = 11, ;
		Column4.ControlSource = "tipamef", ;
		Column4.Name = "cTipAMEF", ;
		Column5.BackColor = 190,225,255, ;
		Column5.ColumnOrder = 3, ;
		Column5.ControlSource = "client", ;
		Column5.Name = "cClient", ;
		Column5.ToolTipText = "DblClick pentru modificare", ;
		Column5.Width = 156, ;
		Column6.BackColor = 190,225,255, ;
		Column6.ColumnOrder = 9, ;
		Column6.ControlSource = "acont4111", ;
		Column6.Name = "cAcont4111", ;
		Column6.ToolTipText = "DblClick pentru modificare", ;
		Column7.BackColor = 190,225,255, ;
		Column7.ColumnOrder = 10, ;
		Column7.ControlSource = "acont442x", ;
		Column7.Name = "cAcont442x", ;
		Column7.ToolTipText = "DblClick pentru modificare", ;
		Column8.BackColor = 190,225,255, ;
		Column8.ColumnOrder = 6, ;
		Column8.ControlSource = "banca", ;
		Column8.Format = "K", ;
		Column8.Name = "cBanca", ;
		Column8.ToolTipText = "DblClick pentru modificare", ;
		Column8.Width = 196, ;
		Column9.BackColor = 190,225,255, ;
		Column9.ColumnOrder = 7, ;
		Column9.ControlSource = "sectie", ;
		Column9.Name = "cSectie", ;
		Column9.Width = 129, ;
		Column10.BackColor = 190,225,255, ;
		Column10.ColumnOrder = 8, ;
		Column10.ControlSource = "dst_chlt", ;
		Column10.Name = "cDstChlt", ;
		Column10.Width = 101, ;
		Column11.BackColor = 190,225,255, ;
		Column11.ColumnOrder = 5, ;
		Column11.ControlSource = "casac", ;
		Column11.Format = "K", ;
		Column11.Name = "cCasaC", ;
		Column11.Width = 106
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdAMEF.cAcont4111.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Analitic 4111", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cAcont4111.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cAcont442x.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Analitic 4427", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cAcont442x.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cBanca.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Banca", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cBanca.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cCasa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Casa", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cCasa.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cCasaC.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Casa centrala", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cCasaC.Text1' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cClient.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Client", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cClient.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cCodAMEF.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod AMEF", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cCodAMEF.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cCodFiscal.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod fiscal", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cCodFiscal.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cDstChlt.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip venit", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cDstChlt.Text1' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cSectie.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Sectie", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cSectie.Text1' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdAMEF.cTipAMEF.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip AMEF", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdAMEF.cTipAMEF.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareConturi' AS grid WITH ;
		Anchor = 14, ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		Height = 111, ;
		HighlightStyle = 2, ;
		Left = 342, ;
		Name = "grdConfigurareConturi", ;
		Panel = 1, ;
		RecordSource = "cConfigConturiVenit", ;
		TabIndex = 9, ;
		Top = 299, ;
		Width = 194, ;
		Column1.ControlSource = "cota", ;
		Column1.Name = "cCota", ;
		Column1.Width = 65, ;
		Column2.BackColor = 190,225,255, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "cont", ;
		Column2.Name = "cCont", ;
		Column2.ToolTipText = "DblClick pentru modificare", ;
		Column2.Width = 48, ;
		Column3.BackColor = 190,225,255, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "acont", ;
		Column3.Name = "cAcont", ;
		Column3.Width = 45, ;
		Column4.ControlSource = "codamef", ;
		Column4.Name = "Column1", ;
		Column4.Width = 118
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdConfigurareConturi.cAcont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Acont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareConturi.cAcont.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareConturi.cCont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareConturi.cCont.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareConturi.cCota.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cota TVA", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareConturi.cCota.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareConturi.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod AMEF", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareConturi.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareIncasari' AS grid WITH ;
		Anchor = 12, ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		Height = 111, ;
		HighlightStyle = 2, ;
		Left = 554, ;
		Name = "grdConfigurareIncasari", ;
		Panel = 1, ;
		RecordSource = "cConfigConturiIncasari", ;
		TabIndex = 10, ;
		Top = 299, ;
		Width = 263, ;
		Column1.ControlSource = "tip", ;
		Column1.Name = "cTip", ;
		Column1.Width = 121, ;
		Column2.BackColor = 190,225,255, ;
		Column2.ControlSource = "cont", ;
		Column2.Name = "cCont", ;
		Column2.ToolTipText = "DblClick pentru modificare", ;
		Column2.Width = 55, ;
		Column3.BackColor = 190,225,255, ;
		Column3.ControlSource = "acont", ;
		Column3.Name = "cAcont", ;
		Column3.ToolTipText = "DblCLick pentru modificare", ;
		Column3.Width = 51, ;
		Column4.ControlSource = "codamef", ;
		Column4.Name = "Column1", ;
		Column4.Width = 119
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdConfigurareIncasari.cAcont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Acont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareIncasari.cAcont.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareIncasari.cCont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareIncasari.cCont.Text1a' AS textbox WITH ;
		BackColor = 190,225,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1a"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareIncasari.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod AMEF", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareIncasari.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConfigurareIncasari.cTip.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip incasare", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConfigurareIncasari.cTip.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdTVA' AS grid WITH ;
		Anchor = 8, ;
		ColumnCount = 3, ;
		DeleteMark = .F., ;
		Height = 111, ;
		HighlightStyle = 2, ;
		Left = 554, ;
		Name = "grdTVA", ;
		RecordSource = "cZetTVA", ;
		TabIndex = 4, ;
		Top = 62, ;
		Width = 263, ;
		Column1.ControlSource = "cota", ;
		Column1.Name = "Column1", ;
		Column2.ControlSource = "valtva", ;
		Column2.Format = "RK", ;
		Column2.InputMask = "999 999 999.99", ;
		Column2.Name = "Column2", ;
		Column3.ControlSource = "valctva", ;
		Column3.Format = "RK", ;
		Column3.InputMask = "999 999 999.99", ;
		Column3.Name = "Column3"
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdTVA.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cota TVA", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdTVA.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdTVA.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "TVA", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdTVA.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdTVA.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "TOTAL", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdTVA.Column3.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ' AS grid WITH ;
		Anchor = 15, ;
		ColumnCount = 11, ;
		DeleteMark = .F., ;
		HeaderHeight = 48, ;
		Height = 193, ;
		HighlightStyle = 2, ;
		Left = 332, ;
		Name = "grdZ", ;
		Panel = 1, ;
		RecordSource = "cZet", ;
		TabIndex = 3, ;
		Top = 62, ;
		Width = 221, ;
		Column1.ControlSource = "nract", ;
		Column1.Name = "Column1", ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "dataact", ;
		Column2.Name = "Column2", ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "nrb", ;
		Column3.Name = "Column3", ;
		Column3.Width = 62, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "valctva-valtva", ;
		Column4.Format = "RK", ;
		Column4.InputMask = "999 999 999.99", ;
		Column4.Name = "Column4", ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "valtva", ;
		Column5.Format = "RK", ;
		Column5.InputMask = "999 999 999.99", ;
		Column5.Name = "Column5", ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "valctva", ;
		Column6.Format = "RK", ;
		Column6.InputMask = "999 999 999.99", ;
		Column6.Name = "Column6", ;
		Column6.Width = 78, ;
		Column7.ColumnOrder = 8, ;
		Column7.ControlSource = "vnumerar", ;
		Column7.Format = "RK", ;
		Column7.InputMask = "999 999 999.99", ;
		Column7.Name = "Column7", ;
		Column8.ColumnOrder = 9, ;
		Column8.ControlSource = "vcard", ;
		Column8.Format = "RK", ;
		Column8.InputMask = "999 999 999.99", ;
		Column8.Name = "Column8", ;
		Column9.ColumnOrder = 10, ;
		Column9.ControlSource = "vtichete", ;
		Column9.Format = "RK", ;
		Column9.InputMask = "999 999 999.99", ;
		Column9.Name = "Column9", ;
		Column10.ColumnOrder = 11, ;
		Column10.ControlSource = "vbon", ;
		Column10.Format = "RK", ;
		Column10.InputMask = "999 999 999.99", ;
		Column10.Name = "Column10", ;
		Column10.Width = 93, ;
		Column11.ColumnOrder = 4, ;
		Column11.ControlSource = "nrbc", ;
		Column11.Name = "Column11", ;
		Column11.ReadOnly = .T., ;
		Column11.Width = 68
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdZ.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. doc.", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column10.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat bonuri/tichete valorice", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column10.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column11.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Numar bonuri cu CIF", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column11.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Numar bonuri", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column3.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare fara TVA", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column4.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "TVA", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column5.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare cu TVA", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column6.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column7.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat numerar", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column7.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column8.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat card", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column8.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdZ.Column9.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat tichete de masa", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdZ.Column9.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Dublu click pe coloane pentru editare", ;
		ForeColor = 0,64,128, ;
		Height = 17, ;
		Left = 11, ;
		Name = "Label1", ;
		Top = 43, ;
		Width = 205
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblInfo' AS _label WITH ;
		Caption = "Case marcat", ;
		FontBold = .T., ;
		Left = 12, ;
		Name = "lblInfo", ;
		TabIndex = 5, ;
		Top = 23
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="label" />
	
	PROCEDURE completeazaclientiroa
	ENDPROC

	PROCEDURE connectroa
	ENDPROC

	PROCEDURE creeazanote
		* 17.02.2022
		* cZetTVA join dupa nract si dataact
		
		* Creeaza actactan cu note contabile vanzari
		Local lnIdPartCasa, llSucces, lnIdSet, llTVAIncasare, llContafin
		Local lcContTVA, lcSql, ldDataCurenta, ldDataIreg, ldLastData, lnCota, lnIdBaza, lnIdTVA, lnProcTVA
		Local lcCasa, lcCasaDefault, lcClient, lcCont4111, lcContBonuri, lcContCard, lcContNumerar
		Local lcContTichete, lnIdBaza1, lnIdBaza2, lnIdTVA1, lnIdTVA2, lnRaspuns
		Local lcBanca, lcCodAMEF, lcContBanca
		Local lnRn
		Private pnTVAIncasare, pnIdFdoc, pcFdoc, pcDenumire, pnIdPart
		
		If Type('gnIdSucursala') = 'U'
			Local gnIdSucursala
			gnIdSucursala = 0
		Endif
		If Type('gcSucursala') = 'U'
			Local gcSucursala
			gcSucursala = Iif(!Empty(Nvl(m.gnIdSucursala, 0)), m.gcFirma, '')
		Endif
		
		llContafin = This.lContafin
		pnTVAIncasare = 0
		pnIdFdoc = 0
		pcFdoc = 'BON CASA'
		lnIdSet = 50100
		pnIdPart = 0
		pcDenumire = ''
		llSucces = .F.
		llTVAIncasare = .F.
		lcCont4111 = Iif(m.llContafin, '411', '4111')
		lcContNumerar = '5311'
		lcContCard = '5125'
		lcContTichete = '5328'
		lcContBonuri = '5328'
		lcContBanca = '5121'
		
		If m.llContafin
			* FDOC
			If Used('fdoc')
				Select fdoc
				Locate For tip_doc = 'B' && B - BON CASA FARA COD FISCAL
				If Found()
					pcFdoc = Alltrim(fdoc)
				Else
					AMESSAGEBOX("Nu exista nici un fel document cu [TIP DOC 394 = 'B']", 0 + 48, _Screen.Caption)
				Endif
			Endif
		Else
			lcSql = [SELECT id_fdoc, fel_document from nom_fdoc where tip_doc = 'B']
			llSucces = goExecutor.oExecuta(m.lcSql, 'cFdocTemp')
			If m.llSucces
				If Reccount('cFdocTemp') > 0
					Select cFdocTemp
					Go Top
					pnIdFdoc = id_fdoc
					pcFdoc = Alltrim(Nvl(fel_document, ''))
				Else
					AMESSAGEBOX("Nu exista nici un fel document cu [TIP DOC 394 = 'B']", 0 + 48, _Screen.Caption)
				Endif
			Endif && llSucces
			Use In (Select('cFdocTemp'))
		Endif && llContafin
		
		**************************
		* CASE
		**************************
		Select cAMEF
		Locate For Empty(Nvl(casa, ''))
		If Found()
			lnRaspuns = AMESSAGEBOX('Completati numele casei 5311 la toate AMEF!' + Chr(13) + Chr(13) + ;
				  'Doriti sa completati numele casei 5311 la AMEF care nu au numele casei?', 3 + 32, _Screen.Caption)
			If m.lnRaspuns = 6
				lcCasaDefault = 'CENTRALA'
				If m.llContafin
					If  Used('casanume')
						Select casanume
						Locate For 'CENTRALA' $ casa
						If !Found()
							Locate For !Empty(casa)
						Endif
						lcCasaDefault = Iif(!Empty(casa), Alltrim(casa), m.lcCasaDefault)
					Endif
					lcCasa = Upper(Alltrim(Inputbox('Numele casei', 'Numele casei (ex: "CENTRALA" sau "CASA [CODAMEF]")', m.lcCasaDefault)))
					If Empty(m.lcCasa)
						Return
					Endif
					Update cAMEF Set casa = Strtran(m.lcCasa, '[CODAMEF]', Alltrim(codamef), 1, 1, 1) Where Empty(casa)
		
				Else
					Local loCauta
					loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Casa??lAdaugCorespondente=>1??cTipuriParteneri=>22]))
					If Empty(Nvl(loCauta.id_part, 0))
						Return
					Endif
					Update cAMEF Set casa = loCauta.nume, id_casa = loCauta.id_part
				Endif
			Else
				If m.lnRaspuns = 2 && cancel
					Return
				Endif
			Endif
		Endif
		Update cAMEF Set casa = Upper(Nvl(casa, ''))
		
		
		**************************
		* CLIENTI
		**************************
		Select cAMEF
		Locate For Empty(Nvl(client, ''))
		If Found()
			lnRaspuns = AMESSAGEBOX('Completati numele clientului la toate AMEF!' + Chr(13) + Chr(13) + ;
				  'Doriti sa completati numele clientului la AMEF care nu au numele clientului?', 3 + 32, _Screen.Caption)
			If m.lnRaspuns = 6
				If m.llContafin
					lcClient = Upper(Alltrim(Inputbox('Nume client', 'Nume client (ex: "CLIENTI DIVERSI" sau "CLIENTI [CODAMEF]")', 'CLIENTI [CODAMEF]')))
					If Empty(m.lcClient)
						Return
					Endif
					Update cAMEF Set client = Strtran(m.lcClient, '[CODAMEF]', Alltrim(codamef), 1, 1, 1) Where Empty(client)
				Else
					Local loCauta
					loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Client??lAdaugCorespondente=>1??cTipuriParteneri=>16]))
					If Empty(Nvl(loCauta.id_part, 0))
						Return
					Endif
					Update cAMEF Set client = loCauta.nume, id_client = loCauta.id_part
				Endif
			Else
				If m.lnRaspuns = 2 && cancel
					Return
				Endif
			Endif
		Endif
		Update cAMEF Set client = Upper(Nvl(client, ''))
		
		
		**************************
		* BANCA
		**************************
		Select Distinct a.codamef From cAMEF a Join cConfigConturiIncasari i On a.codamef = i.codamef Where Empty(Nvl(a.banca, '')) And i.tipp = 1 And i.Cont = '5121' Into Cursor cBancaTemp
		If _Tally > 0
			lnRaspuns = AMESSAGEBOX('Completati numele bancii la toate AMEF pentru incasarile cu card!' + Chr(13) + Chr(13) + ;
				  'Doriti sa completati numele bancii la AMEF care nu au numele bancii?', 3 + 32, _Screen.Caption)
			If m.lnRaspuns = 6
				If m.llContafin
					lcBanca = Upper(Alltrim(Inputbox('Nume banca', 'Nume banca', 'CONT CARD LEI')))
					If Empty(m.lcBanca)
						Return
					Endif
					Select cBancaTemp
					Scan
						lcCodAMEF = Alltrim(codamef)
						Update cAMEF Set banca = m.lcBanca Where codamef = m.lcCodAMEF And Empty(banca)
					Endscan
				Else
					Local loCauta
					loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Banca??lAdaugCorespondente=>1??cTipuriParteneri=>24]))
					If Empty(Nvl(loCauta.id_part, 0))
						Return
					Endif
					Update cAMEF Set banca = loCauta.nume, id_banca = loCauta.id_part
				Endif
			Else
				If m.lnRaspuns = 2 && cancel
					Use In (Select('cBancaTemp'))
					Return
				Endif
			Endif
		Endif
		Use In (Select('cBancaTemp'))
		Update cAMEF Set banca = Upper(Nvl(banca, ''))
		
		
		*** CONTURI VENIT
		Select * From cConfigConturiVenit Where Empty(Nvl(Cont, '')) Into Cursor cVerifContTemp
		If _Tally > 0
			AMESSAGEBOX('Completati contul de venit 7xx pe toate cotele TVA la fiecare AMEF!', 0 + 48, _Screen.Caption)
			Use In (Select('cVerifContTemp'))
			Return
		Endif
		Use In (Select('cVerifContTemp'))
		
		
		*** CONTURI INCASARI
		Select * From cConfigConturiIncasari Where Empty(Nvl(Cont, '')) Into Cursor cVerifContTemp
		If _Tally > 0
			AMESSAGEBOX('Completati contul incasare 5xx la fiecare AMEF!', 0 + 48, _Screen.Caption)
			Use In (Select('cVerifContTemp'))
			Return
		Endif
		Use In (Select('cVerifContTemp'))
		
		*!*	*******************************
		*!*	* ID_PART
		*!*	*******************************
		*!*	Select Distinct 1 as tip, casa As denumire, id_casa as id_part ;
		*!*		From cAMEF ;
		*!*		Where !Empty(Nvl(casa, '')) ;
		*!*		Union ;
		*!*	Select Distinct 2 as tip, banca As denumire, id_banca as id_part ;
		*!*		From cAMEF ;
		*!*		Where !Empty(Nvl(casa, '')) ;
		*!*		Union ;	
		*!*	Select Distinct 3 as tip, client As denumire, id_client As id_part ;
		*!*		From cAMEF ;
		*!*		Where !Empty(Nvl(client, '')) ;
		*!*		Into Cursor cParteneri Readwrite
		
		*!*	Select cParteneri
		*!*	Locate For Inlist(denumire, 'CENTRALA', 'CASA LEI')
		*!*	If !Found()
		*!*		Insert Into cParteneri (denumire, id_part) Values ('CENTRALA', 0)
		*!*		Insert Into cParteneri (denumire, id_part) Values ('CASA LEI', 0)
		*!*	Endif
		*!*	Select cParteneri
		*!*	Index On denumire Tag denumire
		
		
		*!*	Select cParteneri
		*!*	SCAN FOR !EMPTY(NVL(id_part, 0))
		*!*		If m.llContafin
		*!*			&& CONTAFIN
		*!*			Select cParteneri
		*!*			Replace id_part With Recno()
		*!*			llSucces = .T.
		*!*		Else
		*!*			&& ROA		
		*!*			pcDenumire = Alltrim(denumire)
		*!*			lcSql = [SELECT MAX(ID_PART) AS ID_PART FROM nom_parteneri WHERE STERS = 0 AND INACTIV = 0 AND denumire = ?pcDenumire]
		*!*			pnIdPart = 0
		*!*			llSucces = goExecutor.oSelecteaza2Value(m.lcSql, @pnIdPart)
		*!*			If m.llSucces AND !EMPTY(NVL(m.pnIdPart,0))
		*!*				Replace id_part With Nvl(m.pnIdPart, 0) In cParteneri
		*!*			ELSE
		*!*				IF m.llSucces AND EMPTY(NVL(m.pnIdPart,0))
		*!*					AMESSAGEBOX('Nu s-a gasit partenerul ' + m.pcDenumire + '!',0+16,_screen.Caption)
		*!*					llSucces = .F.				
		*!*				ENDIF 
		*!*				*Thisform.trace('Eroare la selectia partener casa/banca ROA ' + m.pcDenumire + " " + goExecutor.oPrelucrareEroare())
		*!*				Exit
		*!*			Endif
		*!*		Endif && .T.
		*!*	Endscan
		
		If m.llSucces
		
			* Selectez monetarele facturat defalcate pe cote TVA
			Select 1 As tip, a.codamef, z.nract, z.dataact, ;
				a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb, ;
				T.cota As proctva, ;
				Max(v.Cont) As cont7xx, Max(v.acont) As acont7xx, ;
				Sum(T.valtva) As valtva, Sum(T.valctva - T.valtva) As valftva, Sum(T.valctva) As valctva, ;
				Cast(0 As N(16, 2)) As vnumerar, ;
				Cast(0 As N(16, 2)) As vcard, ;
				Cast(0 As N(16, 2)) As vtichete, ;
				Cast(0 As N(16, 2)) As vbon, ;
				Space(4) As contNumerar, Space(4) As acontNumerar, ;
				Space(4) As contCard, Space(4) As acontCard, ;
				Space(4) As contTichete, Space(4) As acontTichete, ;
				Space(4) As contBonuri, Space(4) As acontBonuri ;
				From cAMEF a Join cZet z On a.codamef = z.codamef ;
				Join cZetTVA T On z.codamef = T.codamef And z.filename = T.filename AND z.nract = t.nract AND z.dataact = t.dataact ;
				Left Join cConfigConturiVenit v On T.codamef = v.codamef And T.cota = v.cota ;
				Group By a.codamef, z.nract, z.dataact, a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb, T.cota ;
				Into Cursor cIesiri Readwrite
		
			* Selectez monetarele incasat 
			Select 2 As tip, a.codamef, z.nract, z.dataact, ;
				a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb, ;
				Max(z.vnumerar) As vnumerar, Max(z.vcard) As vcard, Max(z.vtichete) As vtichete, Max(z.vbon) As bon, ;
				Cast(Max(Iif(i.tipp = 3, i.Cont, "")) As C(4)) As contNumerar, Cast(Max(Iif(i.tipp = 3, i.acont, "")) As C(4)) As acontNumerar, ;
				Cast(Max(Iif(i.tipp = 1, i.Cont, "")) As C(4)) As contCard, Cast(Max(Iif(i.tipp = 1, i.acont, "")) As C(4)) As acontCard, ;
				Cast(Max(Iif(i.tipp = 4, i.Cont, "")) As C(4)) As contTichete, Cast(Max(Iif(i.tipp = 4, i.acont, "")) As C(4)) As acontTichete, ;
				Cast(Max(Iif(i.tipp = 5, i.Cont, "")) As C(4)) As contBonuri, Cast(Max(Iif(i.tipp = 5, i.acont, "")) As C(4)) As acontBonuri ;
				From cAMEF a Join cZet z On a.codamef = z.codamef ;
				Left Join cConfigConturiIncasari i On z.codamef = i.codamef ;
				Group By a.codamef, z.nract, z.dataact, a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb ;
				Into Cursor cZetTemp
		
			Select cIesiri
			Append From Dbf('cZetTemp')
			Use In (Select('cZetTemp'))
		
			* Selectez monetarele transfer in casa centrala, daca este completata casa centrala si este diferita de casa AMEF
			Select 3 As tip, a.codamef, z.nract, z.dataact, ;
				a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb, ;
				Max(z.vnumerar) As vnumerar, ;
				Cast(Max(Iif(i.tipp = 3, i.Cont, "")) As C(4)) As contNumerar, Cast(Max(Iif(i.tipp = 3, i.acont, "")) As C(4)) As acontNumerar ;
				From cAMEF a Join cZet z On a.codamef = z.codamef ;
				Left Join cConfigConturiIncasari i On z.codamef = i.codamef ;
				Where !Empty(Nvl(a.casac, '')) And Nvl(a.casac, '') <> Nvl(a.casa, '') ;
				Group By  a.codamef, z.nract, z.dataact, ;
				a.acont4111, a.acont442x, a.id_client, a.client, ;
				a.id_casa, a.casa, a.id_casac, a.casac, a.id_banca, a.banca, ;
				a.id_sectie, a.sectie, a.id_venchelt, a.dst_chlt, z.nrb ;
				Into Cursor cZetTemp
		
			Select cIesiri
			Append From Dbf('cZetTemp')
			Use In (Select('cZetTemp'))
		
		Endif && llSucces
		
		If m.llSucces
			lcContTVA = Iif(m.llTVAIncasare, '4428', '4427')
			Create Cursor cNote (Id N(1), scd C(4), scc C(4), proctva N(2), id_jtva1 N(4) Null, id_jtva2 N(4) Null)
			For lnCota = 1 To 8
				Do Case
					Case lnCota = 1
						lnProcTVA = 24
						lnIdBaza1 = 15 && fara TVA Incsare
						lnIdTVA1 = 16
						lnIdBaza2 = 21 && cu TVA Incasare
						lnIdTVA2 = 22
		
					Case lnCota = 2
						lnProcTVA = 20
						lnIdBaza1 = 27 && fara TVA Incsare
						lnIdTVA1 = 28
						lnIdBaza2 = 29 && cu TVA Incasare
						lnIdTVA2 = 30
					Case lnCota = 3
						lnProcTVA = 19
						lnIdBaza1 = 1 && fara TVA Incsare
						lnIdTVA1 = 2
						lnIdBaza2 = 31 && cu TVA Incasare
						lnIdTVA2 = 32
					Case lnCota = 4
						lnProcTVA = 9
						lnIdBaza1 = 3 && fara TVA Incsare
						lnIdTVA1 = 4
						lnIdBaza2 = 23 && cu TVA Incasare
						lnIdTVA2 = 24
					Case lnCota = 5
						lnProcTVA = 5
						lnIdBaza1 = 13 && fara TVA Incsare
						lnIdTVA1 = 14
						lnIdBaza2 = 25 && cu TVA Incasare
						lnIdTVA2 = 26
					Case lnCota = 6
						lnProcTVA = 21
						lnIdBaza1 = 35 && fara TVA Incsare
						lnIdTVA1 = 36
						lnIdBaza2 = 37 && cu TVA Incasare
						lnIdTVA2 = 38
					Case lnCota = 7
						lnProcTVA = 11
						lnIdBaza1 = 39 && fara TVA Incsare
						lnIdTVA1 = 40
						lnIdBaza2 = 41 && cu TVA Incasare
						lnIdTVA2 = 42				
					Case lnCota = 8
						lnProcTVA = 0
						lnIdBaza1 = 11 && fara TVA Incsare
						lnIdTVA1 = 0
						lnIdBaza2 = 11 && cu TVA Incasare
						lnIdTVA2 = 0
				Endcase
				* Baza
				Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (1, m.lcCont4111, '707', m.lnProcTVA, m.lnIdBaza1, m.lnIdBaza2)
		
				* TVA
				If lnProcTVA <> 0
					Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (2, m.lcCont4111, m.lcContTVA, m.lnProcTVA, m.lnIdTVA1, m.lnIdTVA2)
				Endif
			Endfor
		
			* Note incasari
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (3, m.lcContCard, m.lcCont4111, 0, Null, Null) && card
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (4, m.lcContNumerar, m.lcCont4111, 0, Null, Null) && numerar
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (5, m.lcContTichete, m.lcCont4111, 0, Null, Null) && tichete de masa
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (6, m.lcContBonuri, m.lcCont4111, 0, Null, Null) && bonuri valorice
		
			* Note transfer casa centrala
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (7, "581", m.lcContNumerar, 0, Null, Null) && transfer 581 = 5311 casa AMEF
			Insert Into cNote (Id, scd, scc, proctva, id_jtva1, id_jtva2) Values (8, m.lcContNumerar, "581", 0, Null, Null) && transfer 5311 = 581 casa Centrala
		
			ldLastData = Gomonth(Date(m.gnAn, m.gnLuna, 1), 1) - 1
			ldDataCurenta = Date()
			ldDataIreg = Iif(Year(m.ldDataCurenta) <> m.gnAn Or Month(m.ldDataCurenta) <> m.gnLuna, m.ldLastData, m.ldDataCurenta)
		
			Select i.codamef, i.nrb, N.Id As nrcrt, lnIdSet As id_set, m.gnAn As an, m.gnLuna As luna, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', i.cont7xx, N.scd), ;
					Iif(N.Id = 2, N.scd, ;
					  Iif(N.Id = 3, Iif(!Empty(i.vcard), i.contCard, m.lcContCard), ;
						Iif(N.Id = 4, Iif(!Empty(i.vnumerar), i.contNumerar, m.lcContNumerar), ;
						  Iif(N.Id = 5, Iif(!Empty(i.vtichete), i.contTichete, m.lcContTichete),  ;
							Iif(N.Id = 6, Iif(!Empty(i.vbon), i.contBonuri, m.lcContBonuri), ;
							  Iif(N.Id = 7, N.scd, ;
								Iif(N.Id = 8, N.scd, m.lcContNumerar)))))))) As C(4)) As scd, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', i.acont7xx, i.acont4111), ;
					Iif(N.Id = 2, i.acont4111, ;
					  Iif(N.Id = 3, Iif(!Empty(i.vcard), i.acontCard, ''), ;
						Iif(N.Id = 4, Iif(!Empty(i.vnumerar), i.acontNumerar, ''), ;
						  Iif(N.Id = 5, Iif(!Empty(i.vtichete), i.acontTichete, ''),  ;
							Iif(N.Id = 6, Iif(!Empty(i.vbon), i.acontBonuri, ''), ;
							  Iif(N.Id = 7, '', ;
								Iif(N.Id = 8, '', '')))))))) As C(4)) As ascd, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', N.scd, i.cont7xx), ;
					Iif(N.Id = 2, m.lcContTVA,	N.scc)) As C(4)) As scc, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', i.acont4111, i.acont7xx), ;
					Iif(N.Id = 2, i.acont442x, ;
					  Iif(Between(N.Id, 3, 6), i.acont4111, ''))) As C(4)) As ascc, ;
				i.dataact, 1 + Round(i.proctva / 100, 2) As proc_tva, ;
				Iif(!m.llTVAIncasare, N.id_jtva1, N.id_jtva2) As id_jtva_coloana, ;
				i.nract, '' As serie_act, i.dataact As datascad, i.dataact As dataireg, ;
				i.client As client, ;
				Cast(Iif(Inlist(N.Id, 4, 7), i.casa, ;
					Iif(N.Id = 8, i.casac, '')) As C(30)) As casa, ;
				Cast(Iif(N.Id = 3 And i.contCard = m.lcContBanca, i.banca, '') As C(30)) As banca, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', 0, i.id_client), ;
					Iif(N.Id = 2, i.id_client, ;
					  Iif(N.Id = 3, i.id_banca, ;
						Iif(N.Id = 4, i.id_casa, ;
						  Iif(N.Id = 8, i.id_casac, 0))))) As N(10)) As id_partd, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', '', i.client), ;
					Iif(N.Id = 2, i.client, ;
					  Iif(N.Id = 3, i.banca, ;
						Iif(N.Id = 4, i.casa, ;
						  Iif(N.Id = 8, i.casac, ''))))) As C(100)) As partd, ;
				Cast(Iif(N.Id = 1, Iif(Inlist(i.cont7xx, '667', '419'), i.id_client, 0), ;
					Iif(N.Id = 2, 0, ;
					  Iif(Between(N.Id, 3, 6), i.id_client, ;
						Iif(N.Id = 7, i.id_casa, 0)))) As N(10)) As id_partc, ;
				Cast(Iif(N.Id = 1, Iif(Inlist(i.cont7xx, '667', '419'), i.client, ''), ;
					Iif(N.Id = 2, '', ;
					  Iif(Between(N.Id, 3, 6), i.client, ;
						Iif(N.Id = 7, i.casa, '')))) As C(100)) As partc, ;
				Cast(0 As N(14)) As pereche, Cast(Iif(N.Id >= 3, i.nract, 0) As N(14)) As pereche2, ;
				Cast(0 As N(14)) As pereched, Cast(Iif(N.Id >= 3, i.nract, 0) As N(14)) As perechec, ;
				Cast(Iif(N.Id = 1, Iif(i.cont7xx = '667', - i.valftva, i.valftva), ;
					Iif(N.Id = 2, valtva, ;
					  Iif(N.Id = 3, vcard, ;
						Iif(N.Id = 4, vnumerar, ;
						  Iif(N.Id = 5, vtichete, ;
							Iif(N.Id = 6, vbon, ;
							  Iif(Inlist(N.Id, 7, 8), vnumerar, 0))))))) As N(20, 2)) As suma, ;
				Cast(Null As i) As id_sucursala, Space(100) As sucursala, ;
				Cast(m.pnIdFdoc As N(5)) As id_fdoc, pcFdoc As fdoc, ;
				i.id_sectie, i.sectie, i.id_venchelt, i.dst_chlt, ;
				Cast(0 As i) As id_factd,  Cast(Iif(Between(N.Id, 3, 6), -1, 0) As i) As id_factc, Cast(0 As i) As id_fact, pnTVAIncasare As tva_incasare, Cast(0 As i) As cod ;
				From cIesiri i Left Join cNote N On ((i.tip = 1 And i.proctva = N.proctva And N.Id <= 2) Or ;
				  (i.tip = 2 And N.proctva = 0 And Between(N.Id, 3, 6))  Or ;
				  (i.tip = 3 And N.proctva = 0 And Between(N.Id, 7, 8))) ;
				Into Cursor actactanTemp Readwrite
		
			Use In (Select('cNote'))
		
			Select CAST(0 as I) as rn, nrcrt, id_set, an, luna, dataact, datascad, dataireg, serie_act, nract, proc_tva, id_jtva_coloana As id_jtva, id_jtva_coloana, scd, ascd, scc, ascc, ;
				id_partd, partd, id_partc, partc, client As nume, banca As nume_2, casa As nume_3, Padr(codamef, 100, ' ') as explicatia, Padr(codamef, 100, ' ') As explicatia4, nrb, pereche, pereche2, pereched, perechec, ;
				id_sucursala, sucursala, id_fdoc, fdoc, id_factd, id_factc, id_fact, tva_incasare, cod, ;
				id_sectie, sectie, id_venchelt, dst_chlt, ;
				Sum(suma) As suma ;
				From actactanTemp ;
				Group By nrcrt, id_set, an, luna, dataact, datascad, dataireg, serie_act, nract, proc_tva, id_jtva_coloana, scd, ascd, scc, ascc, ;
				id_partd, partd, id_partc, partc, client, banca, casa, codamef, nrb, pereche, pereche2, pereched, perechec, ;
				id_sucursala, sucursala, id_fdoc, fdoc, id_factd, id_factc, id_fact, tva_incasare, cod, ;
				id_sectie, sectie, id_venchelt, dst_chlt ;
				Order By id_set, an, luna, codamef, dataact, datascad, dataireg, serie_act, nract, nrcrt, proc_tva ;
				Into Cursor actactan Readwrite
		
			Use In (Select('cActTemp'))
			
			* Dadea eroare cand puneam cast(m.gnIdSucursala as I)
			Update actactan Set id_sucursala = m.gnIdSucursala, sucursala = m.gcSucursala
			SELECT actactan
			REPLACE ALL rn WITH RECNO() 
		
			* Completez nr bonuri pe prima inregistrare de la fiecare monetar
			Select explicatia, dataact, nract, Min(rn) As rn From actactan Group By explicatia, dataact, nract Into Cursor cActTemp
			Select cActTemp
			Scan
				lnRn = rn
				Update actactan Set explicatia = ALLTRIM(explicatia) + ' *BON=' + Alltrim(Str(nrb)) + '*' Where rn = m.lnRn
			Endscan
			USE IN (SELECT('cActTemp'))
			
		
			Delete From actactan Where suma = 0
			If m.llContafin
				Update actactan Set id_jtva = Nvl(id_jtva, 0), id_partd = 0, id_partc = 0
			Endif
		
			Use In (Select('actactantemp'))
		
			llSucces = .T.
		Endif
		
		Return m.llSucces
		
	ENDPROC

	PROCEDURE Destroy
		USE IN (SELECT('cConfigConturiVenit'))
		USE IN (SELECT('cConfigConturiIncasari')) 
		
		USE IN (SELECT('cZetTVA'))
		USE IN (SELECT('cZet'))
		USE IN (SELECT('cAMEF'))
		
	ENDPROC

	PROCEDURE disconnectroa
	ENDPROC

	PROCEDURE exportdate
	ENDPROC

	PROCEDURE getidpart
		LPARAMETERS tcDenumire
		LOCAL lcDenumire, lnId
		lnId = 0
		lcDenumire = ALLTRIM(m.tcDenumire)
		IF USED('cParteneri')
			IF SEEK(m.lcDenumire, 'cParteneri','denumire')
				lnId = cParteneri.id_part
			ENDIF 
		ENDIF 
		RETURN m.lnId
	ENDPROC

	PROCEDURE Init
		LPARAMETERS tlContafin
		
		IF PCOUNT() > 0
			this.lContafin = m.tlContafin
		ENDIF 
		
		DODEFAULT()
		
		*!*	This.grdAMEF.ReadOnly = .F.
		*!*		WITH this.grdAMEF
		*!*			.cCodAMEF.ReadOnly = .T.
		*!*			.cCodFiscal.ReadOnly = .T.	
		*!*			.cTipAMEF.ReadOnly = .T.
		*!*			.cClient.ReadOnly = .F.
		*!*			.cClient.text1a.ReadOnly = .F.
		*!*			.cCasa.ReadOnly = .F.
		*!*			.cBanca.ReadOnly = .F.
		*!*			.cAcont4111.ReadOnly = .F.
		*!*			.cAcont442x.ReadOnly = .F.
		*!*		ENDWITH 
		
		*!*	this.grdConfigurareConturi.ReadOnly = .F.
		*!*	this.grdConfigurareConturi.cCota.ReadOnly = .T. 
		*!*	this.grdConfigurareConturi.cCont.ReadOnly = .F.
		*!*	this.grdConfigurareConturi.cAcont.ReadOnly = .F.
		
		*!*	this.grdConfigurareIncasari.ReadOnly = .F.
		*!*	this.grdConfigurareIncasari.cTip.ReadOnly = .T.
		*!*	this.grdConfigurareIncasari.cCont.ReadOnly = .F.
		*!*	this.grdConfigurareIncasari.cAcont.ReadOnly = .F.
	ENDPROC

	PROCEDURE Load
		CREATE CURSOR cAMEF (codamef C(20), cod_fiscal C(20), tipamef C(20), casa C(30), casac C(30), banca C(30), client C(70), acont4111 C(4), acont442x C(4), id_casa I, id_casac I, id_banca I, id_client I, sectie C(30), dst_chlt C(30), id_sectie I, id_venchelt I)
		CREATE CURSOR cZet (codamef C(20), filename C(250), ctext M, nract N(20), dataact D, nrb N(10), nrbc N(10), valctva N(16,2), valtva N(16,2), vcard N(16,2), vnumerar N(16,2), vtichete N(16,2), vbon N(16,2)) && cursor Z-uri
		CREATE CURSOR cZetTVA (codamef C(20), filename C(250), nract N(20), dataact D, cota N(5,2), valtva N(16,2), valctva N(16,2)) && cursor cu sume defalcate pe cote TVA pentru fiecare Z
		
		* Trebuie sa citesc configurarile pentru fiecare AMEF
		CREATE CURSOR cConfigConturiVenit(codamef C(20), cota N(5,2), cont C(4), acont C(4))
		CREATE CURSOR cConfigConturiIncasari(codamef C(20), tipp N(1), tip C(50), cont C(4), acont C(4))
		
		This.LoadSettings()
		
		Select cConfigConturiVenit
		Set Filter To codamef = cAMEF.codamef
		
		Select cConfigConturiIncasari
		Set Filter To codamef = cAMEF.codamef
		
		
		SELECT cZet
		
	ENDPROC

	PROCEDURE loadsettings
		* Incarc setarile pe fiecare AMEF
		
		Local lcAMEF, lcConturiIncasari, lcConturiVenit, llContafin
		lcAMEF = ''
		lcCOnturiIncasari = ''
		lcConturiVenit = ''
		llContafin = This.lContafin
		If m.llContafin
			lcAMEF = citeste_optiune("OPTIUNI_FIRMA", 'A4200_AMEF', "CHARACTER", "", "A4200 setari AMEF")
			lcConturiVenit = citeste_optiune("OPTIUNI_FIRMA", 'A4200_VENITURI', "CHARACTER", "", "A4200 setari venituri")
			lcConturiIncasari = citeste_optiune("OPTIUNI_FIRMA", 'A4200_INCASARI', "CHARACTER", "", "A4200 setari incasari")
		ELSE 
			lcAMEF = citeste_optiune('A4200_AMEF', .T.)
			lcConturiVenit = citeste_optiune('A4200_VENITURI', .T.)
			lcConturiIncasari = citeste_optiune('A4200_INCASARI', .T.)
		Endif
		
		If !Empty(m.lcAMEF)
			XMLTOCURSOR(m.lcAMEF, 'cAMEFTemp')
			SELECT cAMEF
			APPEND FROM DBF('cAMEFTemp')
			USE IN (SELECT('cAMEFTemp'))
			GO TOP IN cAMEF
		ENDIF
		
		If !Empty(m.lcConturiVenit)
			XMLTOCURSOR(m.lcConturiVenit, 'cConfigConturiVenitTemp')
			SELECT cConfigConturiVenit
			APPEND FROM DBF('cConfigConturiVenitTemp')
			USE IN (SELECT('cConfigConturiVenitTemp'))
			GO TOP IN cConfigConturiVenit
		ENDIF
		
		If !Empty(m.lcConturiIncasari)
			XMLTOCURSOR(m.lcConturiIncasari, 'cConfigConturiIncasariTemp')
			SELECT cConfigConturiIncasari
			APPEND FROM DBF('cConfigConturiIncasariTemp')
			USE IN (SELECT('cConfigConturiIncasariTemp'))
			GO TOP IN cConfigConturiIncasari
		Endif
	ENDPROC

	PROCEDURE modificanote
		Local loForm As [frm_modific2007]
		Local llMaximize, llNotaNoua, lnIdSet, llSucces, lcSelect
		Local lcSql, lnSucces
		Local ldDataAct, llFurnizorTVAI, lnIdJtva, lnTaxCode
		Private pnCod
		
		llSucces = .T.
		lnIdSet = 50100
		lcSelect = Select()
		
		update_jtva_coloane("JV", 'crsExplicatiiTVATemp', 1)
		
		lcSql = [SELECT * FROM vact WHERE 1=2]
		llSucces = goExecutor.oExecuta(m.lcSql, 'actactan_temp')
		If m.llSucces
			Select actactan_temp
			Append From Dbf('actactan')
			Use In (Select('actactan'))
		
			Select .F. As ales, a.explicatia4 As amef, Iif(!Empty(Nvl(a.id_jtva_coloana, 0)), 1, 0) As Cu_tva, Cast(0 As N(2)) As tipnota, a.*, b.denumire As explicatie_tva_2 ;
				From actactan_temp a Left Join crsExplicatiiTVATemp b On a.id_jtva_coloana = b.id_jtva_coloana ;
				Into Cursor tact Readwrite
		
			Update tact Set explicatie_tva = explicatie_tva_2, explicatia4 = ''
			
			* Actualizez taxcode SAFT in functie de furnizori RTVAI
			IF m.gl406
				SELECT tact 
				SCAN FOR !EMPTY(id_jtva_coloana)
					lnIdJtva = id_jtva_coloana
					ldDataAct = dataact
					llFurnizorTVAI = .F.
					lnTaxCode = GetTaxCode(m.gnAn, m.gnLuna, m.ldDataAct, m.lnIdJtva, m.llFurnizorTVAI)
					SELECT tact 
					REPLACE taxcode WITH m.lnTaxCode 
				ENDSCAN 
		
				UPDATE tact SET paymentcode = '42' WHERE LEFT(scd,3) = '512' OR LEFT(scc,3) = '512' && plata in contul bancar
				UPDATE tact SET paymentcode = '10' WHERE scd = '5311' && plata numerar		
			ENDIF 	
		Endif && llSucces
		
		If m.llSucces
			Select tact
			Go Top
			llNotaNoua = .T.
			llMaximize = .T.
			loForm = Createobject([frm_modific2007], m.lnIdSet, m.llNotaNoua)
			loForm.lb_titlu_alb_b121.Caption = 'Import monetare fisiere casa marcat A4200'
			Select tact
			loForm.Show(1, m.llMaximize)
		
			If buton = 1
				Use In (Select('actactan'))
		
				Update tact Set id_jtva_coloana = Null, PROC_TVA = 0 Where Cu_tva = 0
		
				lnSucces = SQLSetprop(m.gnhandle, "Transactions", 2)
				llSucces = (m.lnSucces > 0)
				If m.llSucces
					* Generez coduri pentru fiecare AMEF (explicatie = CODAMEF) 
					* Generez coduri pentru fiecare Z. Daca se doreste modificarea unui Z, sa se poata face individual, nu pe tot importul.
		
					lcSql = [SELECT seq_cod.nextval FROM dual]
					Select Distinct amef, nract From tact Into Cursor cCodTemp
					Select cCodTemp
					Scan
						Wait Window 'Salvare nota AMEF ' + Transform(Recno()) + '/' + Transform(Reccount()) Nowait
						pnCod = 0
						llSucces = goExecutor.oSelecteaza2Value(m.lcSql, @pnCod)
						If m.llSucces
							Update tact Set cod = m.pnCod Where amef = cCodTemp.amef AND nract = cCodTemp.nract
		
							Select * From tact Where cod = m.pnCod Into Cursor actactan Readwrite
		
							Select actactan
							lnSucces  = OSCRIE_IN_FISIERE(0, .F., .F., .T.)
							llSucces = (m.lnSucces > 0)
							Use In (Select('actactan'))
							If !m.llSucces
								Exit
							Endif
						Else
							Exit
						Endif
					Endscan && cCodTemp
					Use In (Select('cCodTemp'))
				Endif && llSucces
		
		
				If !m.llSucces
					lcSql = "ROLLBACK"
				Else
					lcSql = "COMMIT"
				Endif
				lnSucces = goExecutor.oExecute(m.lcSql)
				llSucces = (m.lnSucces > 0)
				If !m.llSucces
					AMESSAGEBOX(lcSql + Chr(13) + goExecutor.cEroare, 0 + 16, "Eroare")
				Endif
		
				lnSucces = SQLSetprop(gnhandle, "Transactions", 1)
				llSucces = (m.lnSucces > 0)
				If !m.llSucces
					AMESSAGEBOX('Programul nu a reusit sa treaca pe tranzactie automata. Iesiti din program si intrati din nou!', 0 + 48, 'Atentie!')
				Endif
			Else
				llSucces = .F.
			Endif && buton = 1
		Endif && llSucces
		
		Use In (Select('crsExplicatiiTVATemp'))
		Select (m.lcSelect)
		Return m.llSucces
		 
	ENDPROC

	PROCEDURE prelucreazafisierebreeze
	ENDPROC

	PROCEDURE refreshamef
		Go Top In cZet
		Thisform.grdZ.Refresh
		
		Go Top In cZetTVA
		Thisform.grdTVA.Refresh
		
		Go Top In cConfigConturiVenit
		Thisform.grdConfigurareConturi.Refresh
		
		Go Top In cConfigConturiIncasari
		Thisform.grdConfigurareIncasari.Refresh
		
	ENDPROC

	PROCEDURE savesettings
		* Salvez setarile pe fiecare AMEF
		
		Local lcAMEF, lcConturiIncasari, lcConturiVenit, llContafin, lcFilter
		lcAMEF = ''
		lcConturiIncasari = ''
		lcConturiVenit = ''
		llContafin = This.lContafin
		
		Cursortoxml('cAMEF', "lcAMEF", 1, 1 + 2, 0, "1")
		
		SELECT cConfigConturiVenit
		lcFilter = FILTER()
		SET FILTER TO 
		Cursortoxml('cConfigConturiVenit', "lcConturiVenit", 1, 1 + 2, 0, "1")
		SET FILTER TO &lcFilter
		
		SELECT cConfigConturiIncasari
		lcFilter = FILTER()
		SET FILTER TO 
		Cursortoxml('cConfigConturiIncasari', "lcConturiIncasari", 1, 1 + 2, 0, "1")
		SET FILTER TO &lcFilter
		
		If m.llContafin
			= citeste_optiune("OPTIUNI_FIRMA", 'A4200_AMEF', "CHARACTER", m.lcAMEF, "A4200 setari AMEF", .T.)
			= citeste_optiune("OPTIUNI_FIRMA", 'A4200_VENITURI', "CHARACTER", m.lcConturiVenit, "A4200 setari venituri", .T.)
			= citeste_optiune("OPTIUNI_FIRMA", 'A4200_INCASARI', "CHARACTER", m.lcConturiIncasari, "A4200 setari incasari", .T.)
		ELSE
			= scrie_optiune('A4200_AMEF', m.lcAMEF, "A4200 setari AMEF", .T.)	
			= scrie_optiune('A4200_VENITURI', m.lcConturiVenit, "A4200 setari venituri", .T.)	
			= scrie_optiune('A4200_INCASARI', m.lcConturiIncasari, "A4200 setari incasari", .T.)			
		Endif
	ENDPROC

	PROCEDURE scrienote
		Local lcMesaj, lcSql, lnHandle, lnSucces, lnSucces2
		Private gnAn, gnIdSucursala, gnIdUtil, gnLuna
		lnSucces = SQLSetprop(m.lnHandle, "Transactions", 2)
		
		if lnSucces > 0
			&& Creez note pentru fiecare luna/an
			Select Distinct an, luna From actactan Order By an, luna Into Cursor cAnLuna
			Select cAnLuna
			Scan
				*gnAn = an
				*gnLuna = luna
				*gnIdUtil = - 3
				*gnIdSucursala = Null
		
				if m.lnSucces > 0
					lcSql = [begin pack_contafin.init_scriere_act_rul_local(?gnIdUtil,?gnAn,?gnLuna, 1,0,?gnIdSucursala); end;]
					lnSucces = goExecutor.oExecute(m.lcSql)
				Endif
		
				if lnSucces > 0
					SELECT * FROM actactan WHERE an = m.gnAn AND luna = m.gnLuna INTO CURSOR cAct NOFILTER 
					lnSucces = This.sql_temp_insert('cAct', 'ACT_TEMP')
					USE IN (SELECT('cAct'))
				Endif
		
				if lnSucces > 0
					Private pcMesajRefacereNota
					pcMesajRefacereNota = ""
					lcSql = [begin pack_contafin.final_scriere_act_rul_local(?gnIdUtil, ?gnAn, ?gnLuna, NULL, 0, 1, ?@pcMesajRefacereNota); end;]
					lnSucces = goExecutor.oExecute(m.lcSql)
					If !Empty(Nvl(pcMesajRefacereNota, ''))
						This.trace(m.pcMesajRefacereNota)
						AMESSAGEBOX(m.pcMesajRefacereNota, 0 + 48, 'Atentie')
					Endif
					Release pcMesajRefacereNota
				ELSE
					lcMesaj = goExecutor.cEroare
					This.Trace(m.lcMesaj)
					AMESSAGEBOX(m.lcMesaj,0+48, _screen.Caption )
					EXIT 	
				ENDIF && lnSucces
			Endscan && cAnLuna
		
			Use In (Select('cAnLuna'))
		
			if lnSucces > 0
				lnSucces2 = goExecutor.oExecute('COMMIT')
				IF lnSucces2 <> 1
					lnSucces = 0
				ENDIF 
			Else
				lnSucces2 = goExecutor.oExecute('ROLLBACK')
			Endif
		
			If lnSucces2 <> 1
				This.trace(goExecutor.cEroare)
				AMESSAGEBOX(lcSql + Chr(13) + goExecutor.cEroare, 0 + 16, "Eroare")
			ELSE
				This.trace('Import realizat cu succes!')	
			Endif
		
			lnSucces3 = SQLSetprop(m.lnHandle, "Transactions", 1)
		
			If lnSucces3 <> 1
				lcMesaj = 'Programul nu a reusit sa treaca pe tranzactie automata. Iesiti din program si intrati din nou!'
				This.trace(m.lcMesaj)
				AMESSAGEBOX(m.lcMesaj, 0 + 48, 'Atentie!')
			Endif
		Endif && lnSucces
		
		Return m.lnSucces
		
	ENDPROC

	PROCEDURE sql_temp_insert
		Lparameters tcAlias, tcTableName
		
		Local lcAlias, lcCursor, lnSucces
		Local lcDate, lcFieldName, lcFieldType, lcFieldValue, lcFields, lcInsert, lcMesaj, lcNumber, lcSql
		Local lcString, lcTableName, lcValues, lnCount
		Local lnField
		
		Private poIreg, pcTableName
		Local lcVariable
		
		If Empty(tcAlias)
			lcAlias = 'ACTACTAN'
		Else
			lcAlias = Upper(Alltrim(tcAlias))
		Endif
		If Empty(tcTableName)
			pcTableName = 'ACT_TEMP'
		Else
			pcTableName = Upper(Alltrim(tcTableName))
		Endif
		
		lcCursor = 'crs_Coloane'
		lcSql = [SELECT COLUMN_NAME AS COLOANA from user_tab_columns WHERE table_name = ?pcTableName]
		lnSucces = goExecutor.oExecute(m.lcSql, m.lcCursor)
		If m.lnSucces <> 1
			lcMesaj = 'Eroare la selectare coloane din ' + m.lcTableName + Chr(13) + goExecutor.cEroare
			This.trace(m.lcMesaj)
			AMESSAGEBOX(m.lcMesaj, 0 + 16, 'Eroare')
		Endif
		
		If m.lnSucces = 1
			Select (lcAlias)
			lnCount = Fcount()
			lcFields = []
			lcValues = []
			lcInsert = []
			For lnField = 1 To lnCount
				Select (lcAlias)
				lcFieldName = Upper(Alltrim(Field(lnField)))
				lcFieldType = Type(lcFieldName)
				lcFieldValue = Evaluate(lcFieldName)
				If lcFieldType = 'C'
					lcVariable = '?ALLTRIM(poIreg.' + lcFieldName + ')'
				Else
					lcVariable = '?poIreg.' + lcFieldName
				Endif
		
				Select CRS_COLOANE
				Locate For Upper(Alltrim(COLOANA)) == lcFieldName
				If !Found()
					Loop
				Endif
				lcFields = lcFields + [,] + lcFieldName
				lcValues = lcValues + [,] + lcVariable
			Endfor
		
			lcFields = Substr(lcFields, 2)
			lcValues = Substr(lcValues, 2)
		
			&& INSERT INTO ACT_TEMP
			lcInsert = [INSERT INTO ] + m.pcTableName + [ (] + m.lcFields + [) VALUES (] + m.lcValues + [)]
		
			Select (lcAlias)
			Scan
				Scatter Name poIreg
				IF MOD(RECNO(), 100) = 0
					This.trace(' Inregistrare ' + TRANSFORM(RECNO()) + ' / ' + TRANSFORM(RECCOUNT()) + ' ...')
				ENDIF 
				&& FAC NULL ID-URILE CU VALOARE 0
				If TYPE('poReg.id_sucursala') = 'N' AND poIreg.id_sucursala = 0
					poIreg.id_sucursala = Null
				Endif
		
				lnSucces = goExecutor.oExecute(m.lcInsert)
				If lnSucces <> 1
					This.trace(goExecutor.cEroare)
					AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
					Exit
				Endif
		
			Endscan
		Endif
		
		Use In (Select('crs_coloane'))
		
		Return m.lnSucces
		
	ENDPROC

	PROCEDURE sql_temp_insert_values
		* daca se doreste insert into act_temp cu valori in loc de ?
		* trebuie decomentata sectiunea cu valori
		Lparameters tcAlias, tcTableName
		
		Local lcAlias, lcCursor, lnSucces
		Local lcDate, lcFieldName, lcFieldType, lcFieldValue, lcFields, lcInsert, lcMesaj, lcNumber, lcSql
		Local lcString, lcTableName, lcValues, lnCount
		Local lnField
		
		Private poIreg, pcTableName
		Local lcVariable
		
		If Empty(tcAlias)
			lcAlias = 'ACTACTAN'
		Else
			lcAlias = Upper(Alltrim(tcAlias))
		Endif
		If Empty(tcTableName)
			pcTableName = 'ACT_TEMP'
		Else
			pcTableName = Upper(Alltrim(tcTableName))
		Endif
		
		lcCursor = 'crs_Coloane'
		lcSql = [SELECT COLUMN_NAME AS COLOANA from user_tab_columns WHERE table_name = ?pcTableName]
		lnSucces = goExecutor.oExecute(m.lcSql, m.lcCursor)
		If m.lnSucces <> 1
			lcMesaj = 'Eroare la selectare coloane din ' + m.pcTableName + Chr(13) + goExecutor.cEroare
			This.trace(m.lcMesaj)
			AMESSAGEBOX(m.lcMesaj, 0 + 16, 'Eroare')
		Endif
		
		If m.lnSucces = 1
			Select (lcAlias)
			lnCount = Fcount()
			Scan
				lcFields = []
				lcValues = []
				lcInsert = []
				Scatter Name poIreg
		
				For lnField = 1 To lnCount
					Select (lcAlias)
					lcFieldName = Upper(Alltrim(Field(lnField)))
					lcFieldType = Type(lcFieldName)
					lcFieldValue = Evaluate(lcFieldName)
					If lcFieldType = 'C'
						lcVariable = '?ALLTRIM(poIreg.' + lcFieldName + ')'
					Else
						lcVariable = '?poIreg.' + lcFieldName
					Endif
		
					Select CRS_COLOANE
					Locate For Upper(Alltrim(COLOANA)) == lcFieldName
					If !Found()
						Loop
					Endif
					lcFields = lcFields + [,] + lcFieldName
					lcNumber = '0'
					lcDate = ''
					lcString = ''
		
					&& FAC NULL ID-URILE CU VALOARE 0
					If Inlist(lcFieldName, 'ID_SUCURSALA')
						If poIreg.id_sucursala = 0
							poIreg.id_sucursala = Null
						Endif
					Endif
					lcValues = lcValues + [,] + lcVariable
		
					*!*				DO CASE
					*!*					CASE lcFieldType = 'N'
					*!*						IF EMPTY(lcFieldValue) OR ISNULL(lcFieldValue)
					*!*							lcNumber = '0'
					*!*						ELSE
					*!*							lcNumber = ALLTRIM(STR(lcFieldValue,24,4))
					*!*						ENDIF
		
					*!*						lcValues = lcValues + [,] + lcNumber
					*!*					CASE lcFieldType = 'C'
					*!*						IF EMPTY(lcFieldValue) OR ISNULL(lcFieldValue)
					*!*							lcString = ''
					*!*						ELSE
					*!*							lcString = ALLTRIM(lcFieldValue)
					*!*						ENDIF
		
					*!*						lcValues = lcValues + [,] + ['] + lcString + [']
					*!*					CASE INLIST(lcFieldType,'D','T')
					*!*						IF EMPTY(lcFieldValue) OR ISNULL(lcFieldValue)
					*!*							lcDate = ''
					*!*						ELSE
					*!*							lcDate = DTOS(lcFieldValue)
					*!*						ENDIF
					*!*						lcValues = lcValues + [,] + [TO_DATE('] + lcDate + [','YYYY-MM-DD')]
					*!*				ENDCASE
		
				Endfor
		
				lcFields = Substr(lcFields, 2)
				lcValues = Substr(lcValues, 2)
		
				&& INSERT INTO ACT_TEMP
				lcInsert = [INSERT INTO ] + m.pcTableName + [ (] + lcFields + [) VALUES (] + lcValues + [)]
				lnSucces = goExecutor.oExecute(m.lcInsert)
				If lnSucces <> 1
					This.Trace(goExecutor.cEroare)
					AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
					Exit
				Endif
		
			Endscan
		Endif
		
		Use In (SELECT('crs_coloane'))
		
		Return m.lnSucces
		
		
		
	ENDPROC

	PROCEDURE sterge_import
		Local lcCursor, lcMesaj, lcSql, llContinuare, lnDocumente, lnPercent, lnSucces
		PRIVATE pnCod
		llContinuare = .F.
		lcSql = [select distinct cod from act where an=?gnAn and Luna=?gnLuna and id_set=50100 and sters=0]
		lcCursor = [cCoduri]
		lnSucces = goExecutor.oExecute(m.lcSql, m.lcCursor)
		If m.lnSucces > 0
			Select(m.lcCursor)
			lnDocumente = Reccount()
			If m.lnDocumente > 0
				llContinuare = (AMessagebox('Doriti sa stergeti ' + Alltrim(Str(m.lnDocumente)) + ' document(e), tip operatie 50100, din luna ' + Padl(m.gnLuna, 2, '0') + '/' + Alltrim(Str(m.gnAn)) + '?', 4 + 32, _Screen.Caption) = 6)
			Else
				AMessagebox('Nu sunt inregistrari in luna ' + Padl(m.gnLuna, 2, '0') + '/' + Alltrim(Str(m.gnAn)), 0 + 64, _Screen.Caption)
				llContinuare = .F.
			Endif
		Else
			AMessagebox(goExector.cEroare, 0 + 48, _Screen.Caption )
			This.Trace(goExecutor.cEroare)
			llContinuare = .F.
		Endif
		
		If !m.llContinuare
			lnSucces = -1
			Use In (Select(m.lcCursor))
			RETURN (m.lnSucces > 0)
		Endif
		
		lnSucces = SQLSetprop(m.gnhandle, "Transactions", 2)
		
		If lnSucces > 0
			lcSql = [begin pack_contafin.init_scriere_act_rul_local(?gnIdUtil,?gnAn,?gnLuna, 1,0,?gnIdSucursala); end;]
			lnSucces = goExecutor.oExecute(lcSql)
			If lnSucces > 0
				Select cCoduri
				Scan
					pnCod = cod
					If Mod(Recno(), 10) = 0
						lnPercent = Round(Recno() / Reccount() * 100, 0)
						WAIT WINDOW 'Stergere ' + Alltrim(Str(m.lnPercent)) + '%' NOWAIT 
						*This.Trace('Stergere ' + Alltrim(Str(m.lnPercent)) + '%')
					Endif
		
		
					lcSql = [begin pack_contafin.sterge_document(?pnCod); end;]
					lnSucces = goExecutor.oExecute(lcSql)
					If lnSucces < 0
						This.Trace(goExecutor.cEroare)
						Exit
					Endif
				Endscan
			Else
				This.Trace(goExecutor.cEroare)
			Endif
		Else
			This.Trace(goExecutor.cEroare)
		Endif
		
		If lnSucces < 0
			goExecutor.oExecute('ROLLBACK')
			lcMesaj = 'Stergerea nu s-a efectuat!'
		Else
			goExecutor.oExecute('COMMIT')
			lcMesaj = 'Stergerea s-a efectuat cu succes'
		Endif
		
		SQLSetprop(m.gnhandle, "Transactions", 1)
		
		*This.Trace(m.lcMesaj)
		AMessagebox(m.lcMesaj, 0 + 48, _Screen.Caption)
		
		RETURN (m.lnSucces > 0)
		
	ENDPROC

	PROCEDURE templatexlsx
	ENDPROC

	PROCEDURE trace
		LPARAMETERS tcMessage
		AMESSAGEBOX(tcMessage)
		*!*	This.edtInfo.Value = This.edtInfo.Value + TRANSFORM(NVL(tcMessage,'')) + CHR(13) + CHR(10)
		*!*	this.edtInfo.SelStart = LEN(this.edtInfo.Value)
		*!*	This.edtInfo.Refresh()
	ENDPROC

	PROCEDURE verificaimport
		* Verifica daca mai exista inregistrari 50100 in luna curenta
		Local llExista, lcSelect, lcSql, llSucces
		Private pnReturnValue
		pnReturnValue = 0
		lcSelect = SELECT()
		llContafin = Thisform.lContafin 
		If m.llContafin
			Select act
			Locate For id_set = m.lnIdSet
			llExista = Found()
		Else
		
			lcSql = [select COUNT(*) as nr from act where an=?gnAn and luna = ?gnLuna and id_set=50100 and sters=0]
			llSucces = goExecutor.oSelecteaza2Value(m.lcSql, @pnReturnValue)
			If !m.llSucces
				pnReturnValue = 1 && ca sa nu mai continue importul
			Endif
			llExista = (m.pnReturnValue > 0)
		Endif
		
		Select (m.lcSelect)
		Return m.llExista
		
		
	ENDPROC

	PROCEDURE But_sterge1.Click
		SELECT cAMEF
		lcCodAMEF = ALLTRIM(NVL(codamef,''))
		IF EMPTY(m.lcCodAMEF)
			RETURN
		ENDIF 
		IF AMESSAGEBOX('Doriti sa stergeti AMEF ' + m.lcCodAMEF + '?', 4+32, _screen.caption) = 6
			DELETE FROM cConfigConturiVenit WHERE codamef = m.lcCodAMEF
			DELETE FROM cConfigConturiIncasari WHERE codamef = m.lcCodAMEF
			DELETE FROM cZetTVA WHERE codamef = m.lcCodAMEF
			DELETE FROM cZet WHERE codamef = m.lcCodAMEF
			DELETE FROM cAMEF WHERE codamef = m.lcCodAMEF	
		ENDIF 
		Thisform.grdAMEF.SetFocus()
		thisform.Refresh()
	ENDPROC

	PROCEDURE Check1.Valid
		SELECT cconfigconturivenit
		IF this.Value = .T.
			Set Filter To codamef = cAMEF.codamef
		ELSE
			SET FILTER TO 
		ENDIF 
		thisform.grdConfigurareConturi.Refresh
	ENDPROC

	PROCEDURE Check2.Valid
		SELECT cConfigConturiIncasari
		IF this.Value = .T.
			Set Filter To codamef = cAMEF.codamef
		ELSE
			SET FILTER TO 
		ENDIF 
		thisform.grdConfigurareIncasari.Refresh
	ENDPROC

	PROCEDURE cmdGenereazaNote.Click
		Local llSucces, lnSucces, lnButon, llContafin, lnIdSet
		Local lcCodAMEF, llExistaNote
		llSucces = .T.
		lnIdSet = 50100
		llContafin = Thisform.lContafin
		
		Thisform.SaveSettings()
		
		* verific daca mai exista import 50100
		llExistaNote = Thisform.VerificaImport()
		If m.llExistaNote
			If AMESSAGEBOX('Atentie! Exista deja note contabile generate dintr-un import anterior [tip operatie 50100]!' + Chr(13) + ;
					'Doriti sa continuati?', 4 + 32, _Screen.Caption) <> 6
				llSucces = .F.
			Endif
		Endif
		If m.llSucces
			llSucces = Thisform.Creeazanote()
		Endif
		
		If m.llSucces
			If m.llContafin
				lnButon = viz_verificare_note_contabile() && proceduri_comune.prg
				llSucces = (m.buton = 1)
				If m.llSucces
					If Used('act')
						* optional, dau coduri la fiecare grup de note de la aceeasi casa de marcat
						Select cAMEF
						Scan
							lcCodAMEF = Alltrim(codamef)
							Do CODARE
							Update actactan Set cod = m.cod Where Alltrim(explicatia) = m.lcCodAMEF
						Endscan
		
						lnSucces = scrie_in_fisiere('')
						llSucces = (m.lnSucces > 0)
					ELSE
						llSucces = .F.	
					Endif && used
				Endif && m.llSucces
			Else	
				llSucces = Thisform.ModificaNote()
			Endif
		Endif
		
		If m.llSucces
			Thisform.cmdGenereazaNote.Enabled = .F.	
			AMessagebox('S-au inregistrat monetarele!', 0 + 64, _Screen.Caption)
		Else
			AMessagebox('Nu s-au inregistrat monetarele!', 0 + 64, _Screen.Caption)
		Endif
		
		Thisform.SaveSettings()
		
		Return m.llSucces
		
	ENDPROC

	PROCEDURE cmdImport.Click
		*!* 03.02.2021
		*!* tratare conversie xmltocursor tipp = .T. in loc de tipp = 1
		
		Local lcCIF, lcCodAMEF, lcDataZ, lcDirector, lcFile, lcFileName, lcIdM, lcIdR, lcNrB, lcNrBC
		Local lcNrRapF, lcNrRapI, lcText, lcTipA, lcTipAMEF, lcTotB, lcTotTVA, lcXml, ldDataZ, llParsed
		Local lnAn, lnCota, lnFile, lnFiles, lnLuna, lnNrB, lnNrBC, lnNrZ, lnRecords, lnValTva, lnValcTva, lnZi, loZ
		Local lcAcont, lcCont, lcContAcont, lcCota, lnRaspuns, lnOptiune
		
		lnOptiune = xmenu('Fisiere A4200;Fisiere *.xlsx')
		If Empty(m.lnOptiune)
			Return
		Endif
		If m.lnOptiune = 1 && A4200
		
			lcDirector = Getdir("", "Alegeti directorul cu fisiere A4200", "Fisiere A4200", 64)
			If Empty(m.lcDirector)
				Return
			Endif
			lcDirector = Addbs(m.lcDirector)
			*!*	lcScheleton = m.lcDirector + "*.*"
			*!*	lnFiles = ADIR(laFiles, lcScheleton)
			Local Array laFiles[1]
			lnFiles = xdir(@laFiles, m.lcDirector, '*')
		
			lcCIF = ""
			lcIdM = ""
			lcCodAMEF = ""
			lcNrRapI = ""
			lcNrRapF = ""
			lcTipAMEF = ""
			lcTipA = "UZUAL"
		
			* Scanez fisierele
			* Daca gasesc fisierul OPIS (<mReg></mReg>) citesc datele dar nu il introduc in cZet
			* Alte fisiere, verific daca exista sectiunea <rB></rB>
			For lnFile = 1 To m.lnFiles
				lcFile = laFiles[m.lnFile]
				lcFileName = Justfname(m.lcFile)
				Wait Window Alltrim(Str(m.lnFile)) + '/' + Alltrim(Str(m.lnFiles)) + ' ' + m.lcFileName Nowait
				If !File(m.lcFile)
					AMESSAGEBOX('Nu exista fisierul ' + m.lcFile,0+48,_Screen.Caption)
					Loop
				Endif
				lcText = Filetostr(m.lcFile)
				llParsed = .F.
		
				* FISIER Z
				lcXml = Strextract(m.lcText, '<rB', "</rB>", 1, 1 + 4)
		
				If !Empty(m.lcXml)
					*!*		<rB idR="1000313707202009011101330348" monRef="RON" nrA="0" nrAv="0" nrB="24" nrBC="0" nrM="0" nrR="0" sume_serv_in="150.00" sume_serv_out="150.00" totA="0.00" totB="2516.00" totBC="0.00" totM="0.00" totNet="0.00" totR="0.00" totTaxe="0.00" totTva="0.00" totTvaC="0.00">
					*!*			<pl monPl="RON" tipP="3" valPl="2516.00"></pl>
					*!*			<coteZ cota="0" tva="0.00" valOp="2516.00"></coteZ>
					*!*		</rB>
					* Valori totale
					lcIdR = Strextract(m.lcXml, [idr="], ["], 1, 1) && numar identificare raport fiscal,
					* NNNNNNNNNNAAAALLZZHHMMSSRRRR: 10 caractere = numarul de identificare AMEF, 14 caractere = dataora Z, 4 caractere = numarul Z
					lcCodAMEF = Left(m.lcIdR, 10)
		
					lcDataZ = Substr(m.lcIdR, 11, 14)
					lnAn = 	Int(Val(Substr(m.lcDataZ, 1, 4)))
					lnLuna = Int(Val(Substr(m.lcDataZ, 5, 2)))
					lnZi = Int(Val(Substr(m.lcDataZ, 7, 2)))
					ldDataZ = Date(m.lnAn, m.lnLuna, m.lnZi)
					lnNrZ = Int(Val(Substr(m.lcIdR, 25, 4)))
		
					lcNrB = Strextract(m.lcXml, [nrb="], ["], 1, 1) && numar bonuri
					lnNrB = Int(Val(m.lcNrB))
					lcNrBC = Strextract(m.lcXml, [nrbc="], ["], 1, 1)	&& numar bonuri cu CIF
					lnNrBC = Int(Val(m.lcNrBC))
					lcTotB = Strextract(m.lcXml, [totb="], ["], 1, 1) && valoare totala bonuri
					lnValcTva = Val(m.lcTotB)
					lcTotTVA = Strextract(m.lcXml, [tottva="], ["], 1, 1) && valoare TVA bonuri
					lnValTva = Val(m.lcTotTVA)
		
					Select cZet
					Locate For codamef = m.lcCodAMEF And nract = m.lnNrZ And dataact = m.ldDataZ
					If !Found()
						Append Blank
						Replace codamef With m.lcCodAMEF, filename With m.lcFileName, ctext With m.lcXml, nract With m.lnNrZ, dataact With m.ldDataZ, nrb With m.lnNrB, nrbc With m.lnNrBC, valctva With m.lnValcTva, valtva With m.lnValTva
		
		
						* * Pentru fiecare fisier Z, extrag valorile totale, valorile pe cote TVA, valorile incasate pe tipuri de plata
						lnRecords = Xmltocursor(m.lcXml, 'crsZ')
						If _Tally > 0
							Select crsZ
							Scan
								Scatter Name loZ
								* Valori incasate pe tipuri de plata
								If Type('loZ.valpl') <> 'U' And !Empty(loZ.valpl)
									* tip plata 1=CARD;2=AVANS NUMERAR;3=NUMERAR;4=TICHETE MASA;5=BONURI VALORICE;6=VOUCHER;7=CREDIT;8=METODE MODERNE;9=ALTE
		
									* Cateodata, Tipp este convertit in .T. daca valoarea este "1"
									If Type('loZ.tipp') = 'L'
										loZ.tipp = Iif(loZ.tipp, 1, 0)
									Endif
		
									If Type('loZ.tipp') = 'C'
										loZ.tipp = Int(Val(loZ.tipp))
									Endif
		
									Do Case
										Case loZ.tipp = 1
											Replace vcard With loZ.valpl In cZet
										Case Inlist(loZ.tipp, 0, 2, 3)
											Replace vnumerar With loZ.valpl In cZet
										Case loZ.tipp = 4
											Replace vtichete With loZ.valpl In cZet
										Otherwise && tipp = 5
											Replace vbon With loZ.valpl In cZet
									Endcase
								Endif
		
								* Valori pe cote TVA
								If !Empty(loZ.valop)
									lnCota = Iif(Type('loZ.cota') = 'N', loZ.cota, 0)
									Insert Into cZetTVA (codamef, filename, nract, dataact, cota, valtva, valctva) Values (m.lcCodAMEF, m.lcFileName, m.lnNrZ, m.ldDataZ, m.lnCota, loZ.tva, loZ.valop)
								Endif
							Endscan && crsZ
						Endif && _tally
						Use In (Select('crsZ'))
					Endif && found()
		
					llParsed = .T.
				Endif && !Empty(m.lcXml)
		
				* OPIS. introduc in cAMEF
				If !m.llParsed
					lcXml = Strextract(m.lcText, '<mReg', "</mReg>", 1, 1 + 4)
					If Empty(m.lcXml)
						lcXml = Strextract(m.lcText, '<mReg', "/>", 1, 1 + 4)
					Endif
					If !Empty(m.lcXml)
						* <mReg cif="26872380" idM="100031370720201005124111" nrRapI="348" nrRapF="373" tip_amef="U" xmlns="mfp:anaf:dgti:a4200:declaratie:v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></mreg>
						lcCIF = Strextract(m.lcXml, [cif="], ["], 1, 1)
						lcIdM = Strextract(m.lcXml, [idm="], ["], 1, 1) && NNNNNNNNNNAAAALLZZHHMMSS 10 caractere = numarul de identificare AMEF, 14 caractere = dataora
						lcCodAMEF = Left(m.lcIdM, 10)
						lcNrRapI = Strextract(m.lcXml, [nrrapi="], ["], 1, 1)
						lcNrRapF = Strextract(m.lcXml, [nrrapf="], ["], 1, 1)
						lcTipAMEF = Strextract(m.lcXml, [tip_amef="], ["], 1, 1) && U
						lcTipAMEF = Upper(m.lcTipAMEF)
						lcTipA = Iif(m.lcTipAMEF = 'U', 'UZUAL', Iif(m.lcTipAMEF = 'S', 'VALUTAR', Iif(m.lcTipAMEF = 'A', 'AEROPORT', Iif(m.lcTipAMEF = 'T', 'TAXIMETRIE', 'UZUAL'))))
		
						If !m.lcCIF$gofirma.cod_fiscal
							If AMESSAGEBOX('AMEF ' + m.lcCodAMEF + ' (' + m.lcFileName + ') are CIF (' + m.lcCIF + ') diferit fata de cel al firmei (' + Alltrim(gofirma.cod_fiscal) + ')!' + Chr(13) + ;
									'Doriti sa continuati?',4+32,_Screen.Caption) <> 6
								Exit
							Endif
						Endif
		
						Select cAMEF
						Locate For codamef = m.lcCodAMEF
						If !Found()
							Append Blank
							Replace codamef With m.lcCodAMEF
						Endif
						Select cAMEF
						Replace codamef With m.lcCodAMEF, cod_fiscal With m.lcCIF, tipamef With m.lcTipA
					Endif
				Endif
			Endfor
		
		Else && xlsx
		
			AMESSAGEBOX('Alegeti fisierul xlsx completat cu incasarile de la casa de marcat pentru import.' + Chr(13) + Chr(10) + ;
				'Atentie! Pagina cu facturi din fisierul xlsx trebuie sa se numeasca "Sheet1"!' + Chr(13) + Chr(10) + Chr(13) + Chr(10) + ;
				'Tabelul poate fi de forma: ' + Chr(13) + Chr(10) + ;
				'codamef,dataz,nrb,numerar,card,valoare_cu_tva_0,valoare_cu_tva_5,valoare_tva_5,valoare_cu_tva_9,valoare_tva_9,valoare_cu_tva_19,valoare_tva_19' + Chr(13) + Chr(10) + ;
				'sau de forma:' + Chr(13) + Chr(10) + ;
				'cif,codamef,dataz,nrz,nrb,nrbc,totb,tottva,tipamef,tipp1,valpl1,tip2,valpl2,tipp3,valpl3,tipp4,valpl4,cota1,valop1,tva1,cota2,valop2,tva2,cota3,valop3,tva3,cota4,valop4,tva4', ;
				0+64,_Screen.Caption)
		
			lcFile=Getfile('xlsx','Fisier xlsx','Alege', 0,'Fisier xlsx cu facturi')
			If Empty(m.lcFile)
				lnSucces = -1
				Return m.lnSucces
			Endif
		
			* Import first sheet
			importfromxlsx(m.lcFile,2,'Sheet1',.T.,.T.,1,'cIncasari')
		
			If Used('cIncasari')
				Create Cursor cIncasariTemp (codamef C(100), dataz C(10), nrb C(10), nrbc C(10), totb C(30), tottva C(30), tipamef C(10), ;
					numerar C(30), card C(30), tichete C(30), bonuri C(30), ;
					tipp1 C(10), valpl1 C(30), tipp2 C(10), valpl2 C(30), tipp3 C(10), valpl3 C(30), tipp4 C(10), valpl4 C(30), ;
					valoare_cu_tva_0 C(30), valoare_cu_tva_5 C(30), valoare_cu_tva_9 C(30), valoare_cu_tva_19 C(30), ;
					valoare_tva_5 C(30), valoare_tva_9 C(30), valoare_tva_19 C(30), ;
					cota1 C(5), valop1 C(30), tva1 C(30), ;
					cota2 C(5), valop2 C(30), tva2 C(30), ;
					cota3 C(5), valop3 C(30), tva3 C(30), ;
					cota4 C(5), valop4 C(30), tva4 C(30))
		
				Select cIncasariTemp
				Append From Dbf('cIncasari')
		
				Select Upper(Alltrim(codamef)) As codamef, ;
					Ctod(dataz) As dataz, ;
					CAST(Int(Val(nrb)) As N(10,0)) As nrb, ;
					CAST(Int(Val(nrbc)) As N(10,0)) As nrbc, ;
					CAST(Round(Val(totb),2) As N(18,2)) As totb, ;
					CAST(Round(Val(tottva),2) As N(18,2)) As tottva, ;
					CAST(Iif(Empty(tipamef), 'U', tipamef) As C(1)) As tipamef, ;
					CAST(Round(Val(numerar),2) As N(18,2)) As numerar, ;
					CAST(Round(Val(card),2) As N(18,2)) As card, ;
					CAST(Round(Val(tichete),2) As N(18,2)) As tichete, ;
					CAST(Round(Val(bonuri),2) As N(18,2)) As bonuri, ;
					CAST(Int(Val(tipp1)) As N(1)) As tipp1, ;
					CAST(Round(Val(valpl1),2) As N(18,2)) As valpl1, ;
					CAST(Int(Val(tipp2)) As N(1)) As tipp2, ;
					CAST(Round(Val(valpl2),2) As N(18,2)) As valpl2, ;
					CAST(Int(Val(tipp3)) As N(1)) As tipp3, ;
					CAST(Round(Val(valpl3),2) As N(18,2)) As valpl3, ;
					CAST(Int(Val(tipp4)) As N(1)) As tipp4, ;
					CAST(Round(Val(valpl4),2) As N(18,2)) As valpl4, ;
					CAST(0 As N(1)) As tipp, ;
					CAST(0 As N(18,2)) As valpl, ;
					CAST(Round(Val(valoare_cu_tva_0),2) As N(18,2)) As valoare_cu_tva_0, ;
					CAST(Round(Val(valoare_cu_tva_5),2) As N(18,2)) As valoare_cu_tva_5, ;
					CAST(Round(Val(valoare_tva_5),2) As N(18,2)) As valoare_tva_5, ;
					CAST(Round(Val(valoare_cu_tva_9),2) As N(18,2)) As valoare_cu_tva_9, ;
					CAST(Round(Val(valoare_tva_9),2) As N(18,2)) As valoare_tva_9, ;
					CAST(Round(Val(valoare_cu_tva_19),2) As N(18,2)) As valoare_cu_tva_19, ;
					CAST(Round(Val(valoare_tva_19),2) As N(18,2)) As valoare_tva_19, ;
					CAST(Int(Val(cota1)) As N(5)) As cota1, ;
					CAST(Round(Val(valop1),2) As N(18,2)) As valop1, ;
					CAST(Round(Val(tva1),2) As N(18,2)) As tva1, ;
					CAST(Int(Val(cota2)) As N(5)) As cota2, ;
					CAST(Round(Val(valop2),2) As N(18,2)) As valop2, ;
					CAST(Round(Val(tva2),2) As N(18,2)) As tva2, ;
					CAST(Int(Val(cota3)) As N(5)) As cota3, ;
					CAST(Round(Val(valop3),2) As N(18,2)) As valop3, ;
					CAST(Round(Val(tva3),2) As N(18,2)) As tva3, ;
					CAST(Int(Val(cota4)) As N(5)) As cota4, ;
					CAST(Round(Val(valop4),2) As N(18,2)) As valop4, ;
					CAST(Round(Val(tva4),2) As N(18,2)) As tva4, ;
					CAST(0 As N(5)) As cota, ;
					CAST(0 As N(18,2)) As valop, ;
					CAST(0 As N(18,2)) As tva ;
					From cIncasariTemp Into Cursor cIncasari2 Readwrite
		
				Use In (Select('cIncasariTemp'))
		
				* Completez coloanele detaliate ca sa ajung la aceleasi informatii ca in fisierele A4200
				Select cIncasari2
				Locate For valpl1 <> 0 Or valpl2 <> 0 Or valpl3 <> 0 Or valpl4 <> 0
				llPlatiSimple = !Found()
				Locate For valop1 <> 0 Or valop2 <> 0 Or valop3 <> 0 Or valop4 <> 0
				llTVASimple = !Found()
		
		
				If m.llPlatiSimple
					* tip plata 1=CARD;2=AVANS NUMERAR;3=NUMERAR;4=TICHETE MASA;5=BONURI VALORICE;6=VOUCHER;7=CREDIT;8=METODE MODERNE;9=ALTE
					Update cIncasari2 Set totb = numerar+card+tichete+bonuri, tottva = valoare_tva_5 + valoare_tva_9 + valoare_tva_19
					Update cIncasari2 Set tipp1 = 1, valpl1 = card Where card <> 0
					Update cIncasari2 Set tipp2 = 3, valpl2 = numerar Where numerar <> 0
					Update cIncasari2 Set tipp3 = 4, valpl3 = tichete Where tichete <> 0
					Update cIncasari2 Set tipp4 = 5, valpl4 = bonuri Where bonuri <> 0
				Endif
				If m.llTVASimple
					Update cIncasari2 Set cota1 = 0, valop1 = valoare_cu_tva_0, tva1 = 0 Where valoare_cu_tva_0 <> 0
					Update cIncasari2 Set cota2 = 5, valop2 = valoare_cu_tva_5, tva2 = valoare_tva_5 Where valoare_cu_tva_5 <> 0
					Update cIncasari2 Set cota3 = 9, valop3 = valoare_cu_tva_9, tva3 = valoare_tva_9 Where valoare_cu_tva_9 <> 0
					Update cIncasari2 Set cota4 = 19, valop4 = valoare_cu_tva_19, tva4 = valoare_tva_19 Where valoare_cu_tva_19 <> 0
				Endif
				Select * From cIncasari2 Where totb <> valop1 + valop2 + valop3 + valop4 Into Cursor cDiferente
				If _Tally = 0
		
					Select codamef, Max(tipamef) As tipamef From cIncasari2 Where !Empty(dataz) Group By codamef Into Cursor cCodAMEF
					Select cCodAMEF
					Scan
						lcCIF = Alltrim(gofirma.cod_fiscal)
						lcCodAMEF = codamef
						lcNrRapI = ''
						lcNrRapF = ''
						lcTipAMEF = Upper(Alltrim(tipamef))
						lcTipA = Iif(m.lcTipAMEF = 'U', 'UZUAL', Iif(m.lcTipAMEF = 'S', 'VALUTAR', Iif(m.lcTipAMEF = 'A', 'AEROPORT', Iif(m.lcTipAMEF = 'T', 'TAXIMETRIE', 'UZUAL'))))
						lcFileName = ''
		
						Select cAMEF
						Locate For codamef = m.lcCodAMEF
						If !Found()
							Append Blank
							Replace codamef With m.lcCodAMEF
						Endif
						Select cAMEF
						Replace codamef With m.lcCodAMEF, cod_fiscal With m.lcCIF, tipamef With m.lcTipA
		
						Select * From cIncasari2 Where codamef = m.lcCodAMEF Order By dataz Into Cursor cIncasariAMEF
						Select cIncasariAMEF
						Scan
							Scatter Name loZ
							ldDataZ = dataz
							lnNrZ = Int(Val(Dtos(dataz)))
							lnNrB = nrb
							lnNrBC = nrbc
							lnValcTva = totb
							lnValTva = tottva
		
							Select cZet
							Locate For codamef = m.lcCodAMEF And nract = m.lnNrZ And dataact = m.ldDataZ
							If !Found()
								Append Blank
								Replace codamef With m.lcCodAMEF, filename With '', ctext With '', nract With m.lnNrZ, dataact With m.ldDataZ, nrb With m.lnNrB, nrbc With m.lnNrBC, valctva With m.lnValcTva, valtva With m.lnValTva
		
		
								* Valori incasate pe tipuri de plata
								For lnTipPlata = 1 To 4
									lcTipPlata = Alltrim(Str(m.lnTipPlata))
									loZ.valpl = Evaluate('loZ.valpl' + m.lcTipPlata)
									loZ.tipp = Evaluate('loZ.tipp' + m.lcTipPlata)
		
									loZ.valop = Evaluate('loZ.valop' + m.lcTipPlata)
									loZ.tva = Evaluate('loZ.tva' + m.lcTipPlata)
		
									If !Empty(loZ.valpl)
										* tip plata 1=CARD;2=AVANS NUMERAR;3=NUMERAR;4=TICHETE MASA;5=BONURI VALORICE;6=VOUCHER;7=CREDIT;8=METODE MODERNE;9=ALTE
										Do Case
											Case loZ.tipp = 1
												Replace vcard With loZ.valpl In cZet
											Case Inlist(loZ.tipp, 2, 3)
												Replace vnumerar With loZ.valpl In cZet
											Case loZ.tipp = 4
												Replace vtichete With loZ.valpl In cZet
											Otherwise && tipp = 5
												Replace vbon With loZ.valpl In cZet
										Endcase
									Endif
		
									* Valori pe cote TVA
									If !Empty(loZ.valop)
										lnCota = Iif(Type('loZ.cota') = 'N', loZ.cota, 0)
										Insert Into cZetTVA (codamef, filename, nract, dataact, cota, valtva, valctva) Values (m.lcCodAMEF, m.lcFileName, m.lnNrZ, m.ldDataZ, m.lnCota, loZ.tva, loZ.valop)							
									Endif
								Endfor && lnTipPlata
							Endif && found()
						Endscan && cIncasariAMEF
		
						Use In (Select('cIncasariAMEF'))
					Endscan && cCodAMEF
				Else
					lcMesaj = 'Diferente intre valoarea totala a Z-urilor si valorile pe cote TVA'
					Select cDiferente
					Scan
						lcMesaj = lcMesaj + Chr(13) + Chr(10) + 'AMEF: ' + Alltrim(codamef) + ' - valoare totala: ' + Transform(totb) + ' ; valoare pe cote TVA ' + Transform(valop1 + valop2 + valop3 + valop4)
					Endscan
					AMESSAGEBOX(m.lcMesaj,0+48,_Screen.Caption)
				Endif && _tally
				Use In (Select('cDiferente'))
		
				Use In (Select('cCodAMEF'))
				Use In (Select('cIncasari2'))
			Endif && used('cIncasari2')
		
			Use In (Select('cIncasari'))
		Endif && lnOptiune
		
		* Sterg inregistrarile daca nu am importat un codamef pentru ca are alt cod fiscal decat CUI-ul firmei
		Delete From cZet Where codamef Not In (Select codamef From cAMEF)
		Delete From cZetTVA Where codamef Not In (Select codamef From cAMEF)
		
		* Adaug cote TVA in cConfigConturiVenit
		Select cConfigConturiVenit
		lcFilter = Filter()
		Set Filter To
		Select Distinct codamef, cota From cZetTVA Into Cursor cCoteTemp
		Select cCoteTemp
		Scan
			lcCodAMEF = codamef
			lnCota = cota
			Select cConfigConturiVenit
			Locate For codamef = m.lcCodAMEF And cota = m.lnCota
			If !Found()
				Insert Into cConfigConturiVenit(codamef, cota) Values (m.lcCodAMEF, m.lnCota)
			Endif
		Endscan
		
		Use In (Select('cCoteTemp'))
		Select cConfigConturiVenit
		Set Filter To &lcFilter
		
		* Completez conturi 7xx in cConfigConturiVenit
		Select Distinct cota From cConfigConturiVenit Where Empty(Cont) Into Cursor cConturiTemp
		If _Tally > 0
			lnRaspuns = AMESSAGEBOX('Doriti sa completati contul de venituri pentru toate cotele TVA (Yes) sau pe fiecare cota in parte (No)', 3 + 32, _Screen.Caption)
			Do Case
				Case lnRaspuns = 6
					lcContAcont = Inputbox('Cont 7xx.xxx', 'Cont venituri', '707')
					lcCont = Getwordnum(m.lcContAcont, 1, '.')
					lcAcont = Getwordnum(m.lcContAcont, 2, '.')
					Update cConfigConturiVenit Set Cont = m.lcCont, acont = m.lcAcont Where Empty(Cont)
				Case lnRaspuns = 7
					Select cConturiTemp
					Scan
						lnCota = cota
						lcCota = Alltrim(Str(m.lnCota)) + '%'
						lcContAcont = Inputbox('Cont 7xx.xxx ' + m.lcCota, 'Cont venituri', '707')
						lcCont = Getwordnum(m.lcContAcont, 1, '.')
						lcAcont = Getwordnum(m.lcContAcont, 2, '.')
						Update cConfigConturiVenit Set Cont = m.lcCont, acont = m.lcAcont Where cota = m.lnCota And Empty(Cont)
					Endscan
			Endcase
		Endif && _tally
		Use In (Select('cConturiTemp'))
		
		Go Top In cConfigConturiVenit
		
		* Completez conturi incasari pentru fiecare casa
		Select cConfigConturiIncasari
		lcFilter = Filter()
		Set Filter To
		
		Select cAMEF
		Scan
			lcCodAMEF = codamef
		
			Select cConfigConturiIncasari
			Locate For codamef = m.lcCodAMEF And tipp = 1
			If !Found()
				Insert Into cConfigConturiIncasari (codamef, tipp, tip, Cont) Values (m.lcCodAMEF, 1, 'Card', '')
			Endif
			Locate For codamef = m.lcCodAMEF And tipp = 3
			If !Found()
				Insert Into cConfigConturiIncasari (codamef, tipp, tip, Cont) Values (m.lcCodAMEF, 3, 'Numerar', '5311')
			Endif
			Locate For codamef = m.lcCodAMEF And tipp = 4
			If !Found()
				Insert Into cConfigConturiIncasari (codamef, tipp, tip, Cont) Values (m.lcCodAMEF, 4, 'Tichete', '5328')
			Endif
			Locate For codamef = m.lcCodAMEF And tipp = 5
			If !Found()
				Insert Into cConfigConturiIncasari (codamef, tipp, tip, Cont) Values (m.lcCodAMEF, 5, 'Bonuri', '5328')
			Endif
		Endscan
		
		Select cConfigConturiIncasari
		Set Filter To &lcFilter
		
		* Completez conturi 5125 / 5121 pentru incasarile cu card
		Select Distinct codamef From cConfigConturiIncasari Where tipp = 1 And Empty(Cont) Into Cursor cConturiTemp
		If _Tally > 0
			lnRaspuns = AMESSAGEBOX('Doriti sa completati contul pentru incasari CARD?', 4 + 32, _Screen.Caption)
			If m.lnRaspuns = 6
				lcContAcont = Inputbox('Cont 5125.xxx/5121.xxx', 'Cont incasari CARD', '5121')
				lcCont = Getwordnum(m.lcContAcont, 1, '.')
				lcAcont = Getwordnum(m.lcContAcont, 2, '.')
				Update cConfigConturiIncasari Set Cont = m.lcCont, acont = m.lcAcont Where tipp = 1 And Empty(Cont)
			Endif
		Endif && _tally
		Use In (Select('cConturiTemp'))
		
		Go Top In cConfigConturiIncasari
		
		Go Top In cAMEF
		Go Top In cZet
		Go Top In cZetTVA
		
		Select cZet
		Set Filter To codamef = cAMEF.codamef
		
		Select cZetTVA
		Set Filter To codamef = cZet.codamef And filename = cZet.filename
		
		Thisform.cmdGenereazaNote.Enabled = .T.
		
		Thisform.RefreshAMEF()
		
		Thisform.SaveSettings()
		
		Thisform.Refresh
		
	ENDPROC

	PROCEDURE cmdSterge.Click
		Thisform.Sterge_import()
	ENDPROC

	PROCEDURE grdAMEF.AfterRowColChange
		LPARAMETERS nColIndex
		
		
		IF INLIST(this.RowColChange, 1, 3)
			Thisform.RefreshAMEF()
		ENDIF 	
		SELECT cAMEF
		
	ENDPROC

	PROCEDURE grdAMEF.cAcont4111.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		IF AMESSAGEBOX('Doriti sa completati contul analitic pentru toate AMEF care nu au cont analitic 4111?',4+32,_screen.Caption) = 6
			REPLACE &lcControlSource WITH m.lcText FOR EMPTY(&lcControlSource)
		ELSE 	
			REPLACE &lcControlSource WITH m.lcText
		ENDIF 	
	ENDPROC

	PROCEDURE grdAMEF.cAcont4111.Text1a.When
		this.ReadOnly = .F.
	ENDPROC

	PROCEDURE grdAMEF.cAcont442x.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		IF AMESSAGEBOX('Doriti sa completati contul analitic pentru toate AMEF care nu au cont analitic 4427?',4+32,_screen.Caption) = 6
			REPLACE &lcControlSource WITH m.lcText FOR EMPTY(&lcControlSource)
		ELSE 	
			REPLACE &lcControlSource WITH m.lcText	
		ENDIF 	
	ENDPROC

	PROCEDURE grdAMEF.cAcont442x.Text1a.When
		this.ReadOnly = .F.
	ENDPROC

	PROCEDURE grdAMEF.cBanca.Text1a.DblClick
		IF thisform.lContafin
			LOCAL lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = this.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = alltrim(EVALUATE(m.lcControlSource))
			lcCaption = this.Parent.Header1.Caption
			lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
			SELECT (lcAlias)
			REPLACE &lcControlSource WITH m.lcText
		ELSE
			LOCAL loCauta
		
			loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Client??lAdaugCorespondente=>1??cTipuriParteneri=>24]))
			SELECT cAMEF
			REPLACE id_banca WITH locauta.id_part, banca WITH locauta.nume
		ENDIF 	
	ENDPROC

	PROCEDURE grdAMEF.cBanca.Text1a.When
		this.ReadOnly = .F.
	ENDPROC

	PROCEDURE grdAMEF.cCasa.Text1a.DblClick
		IF thisform.lContafin
			LOCAL lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = this.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = alltrim(EVALUATE(m.lcControlSource))
			lcCaption = this.Parent.Header1.Caption
			lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
			SELECT (lcAlias)
			REPLACE &lcControlSource WITH m.lcText
		ELSE
			LOCAL loCauta
		
			loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Client??lAdaugCorespondente=>1??cTipuriParteneri=>22]))
			SELECT cAMEF
			REPLACE id_casa WITH locauta.id_part, casa WITH locauta.nume
		ENDIF 	
		
	ENDPROC

	PROCEDURE grdAMEF.cCasa.Text1a.When
		this.ReadOnly = .F.
	ENDPROC

	PROCEDURE grdAMEF.cCasaC.Text1.DblClick
		IF thisform.lContafin
			LOCAL lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = this.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = alltrim(EVALUATE(m.lcControlSource))
			lcCaption = this.Parent.Header1.Caption
			lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
			SELECT (lcAlias)
			REPLACE &lcControlSource WITH m.lcText
		ELSE
			LOCAL loCauta
		
			loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Client??lAdaugCorespondente=>1??cTipuriParteneri=>22]))
			SELECT cAMEF
			REPLACE id_casac WITH locauta.id_part, casac WITH locauta.nume
		ENDIF 	
		
	ENDPROC

	PROCEDURE grdAMEF.cClient.Text1a.DblClick
		IF thisform.lContafin
			LOCAL lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = this.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = alltrim(EVALUATE(m.lcControlSource))
			lcCaption = this.Parent.Header1.Caption
			lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
			SELECT (lcAlias)
			REPLACE &lcControlSource WITH m.lcText
		ELSE
			LOCAL loCauta
		
			loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Client??lAdaugCorespondente=>1??cTipuriParteneri=>16]))
			SELECT cAMEF
			REPLACE id_client WITH locauta.id_part, client WITH locauta.nume
		ENDIF 	
	ENDPROC

	PROCEDURE grdAMEF.cClient.Text1a.When
		this.ReadOnly = .F.
	ENDPROC

	PROCEDURE grdAMEF.cDstChlt.Text1.DblClick
		Local loCauta
		If Thisform.lContafin
			Local lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = This.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = Alltrim(Evaluate(m.lcControlSource))
			lcCaption = This.Parent.Header1.Caption
			lcText = Inputbox(m.lcCaption, m.lcCaption, m.lcText)
			Select (lcAlias)
			Replace &lcControlSource With m.lcText
		Else
			loCauta = caut_venchelt()
			If !Empty(Nvl(loCauta.id_venchelt, 0))
				Select cAMEF
				Replace id_venchelt With loCauta.id_venchelt, dst_chlt With loCauta.explicatie
			Endif
		Endif
	ENDPROC

	PROCEDURE grdAMEF.cSectie.Text1.DblClick
		Local loCauta
		If Thisform.lContafin
			Local lcText, lcCaption, lcAlias, lcControlSource
			lcAlias = This.Parent.Parent.RecordSource
			lcControlSource = This.ControlSource
			lcText = Alltrim(Evaluate(m.lcControlSource))
			lcCaption = This.Parent.Header1.Caption
			lcText = Inputbox(m.lcCaption, m.lcCaption, m.lcText)
			Select (lcAlias)
			Replace &lcControlSource With m.lcText
		Else
			loCauta = caut_sectie()
			If !Empty(Nvl(loCauta.id_sectie, 0))
				Select cAMEF
				Replace id_sectie With loCauta.id_sectie, sectie With loCauta.sectie
			Endif
		Endif
	ENDPROC

	PROCEDURE grdAMEF.Init
		*
	ENDPROC

	PROCEDURE grdConfigurareConturi.cAcont.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		IF AMESSAGEBOX('Doriti sa completati contul analitic pentru toate inregistrarile care nu au cont analitic?',4+32,_screen.Caption) = 6
			REPLACE &lcControlSource WITH m.lcText FOR EMPTY(&lcControlSource)
		ELSE 	
			REPLACE &lcControlSource WITH m.lcText
		ENDIF 	
		
	ENDPROC

	PROCEDURE grdConfigurareConturi.cCont.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		IF AMESSAGEBOX('Doriti sa completati contul 7xx pentru toate AMEF care nu au cont?',4+32,_screen.Caption) = 6
			REPLACE &lcControlSource WITH m.lcText FOR EMPTY(&lcControlSource)
		ELSE 	
			REPLACE &lcControlSource WITH m.lcText
		ENDIF 	
		
	ENDPROC

	PROCEDURE grdConfigurareConturi.Init
		*
	ENDPROC

	PROCEDURE grdConfigurareIncasari.cAcont.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		REPLACE &lcControlSource WITH m.lcText
		
	ENDPROC

	PROCEDURE grdConfigurareIncasari.cCont.Text1a.DblClick
		LOCAL lcText, lcCaption, lcAlias, lcControlSource
		lcAlias = this.Parent.Parent.RecordSource
		lcControlSource = This.ControlSource
		lcText = alltrim(EVALUATE(m.lcControlSource))
		lcCaption = this.Parent.Header1.Caption
		lcText = INPUTBOX(m.lcCaption, m.lcCaption, m.lcText)
		SELECT (lcAlias)
		REPLACE &lcControlSource WITH m.lcText
		
	ENDPROC

	PROCEDURE grdConfigurareIncasari.Init
		*
	ENDPROC

	PROCEDURE grdTVA.Init
		*
	ENDPROC

	PROCEDURE grdZ.AfterRowColChange
		LPARAMETERS nColIndex
		
		
		IF INLIST(this.RowColChange, 1, 3)
			GO TOP IN cZetTVA 
			Thisform.grdTVA.Refresh
		ENDIF 	
	ENDPROC

	PROCEDURE grdZ.Init
		*
	ENDPROC

ENDDEFINE
