*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="saft_d406.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_saft_d406 AS _frmbase OF "..\comun\clase\_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="pgfSAFT" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pgfSAFT.Page1.cboTip" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pgfSAFT.Page1._label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pgfSAFT.Page1.cmdCitesteDate" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pgfSAFT.Page2.pgfMaster" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pgfSAFT.pgDocumenteSursa.pgfDocumenteSursa" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: ccaen
		*p: ccalintoc
		*p: cfpropr
		*p: cjudet
		*p: ctip
		*p: oparent
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		ccaen = 
		ccalintoc = 
		cfpropr = 
		cjudet = 
		ctip = 
		DoCreate = .T.
		Height = 465
		Name = "frm_saft_d406"
		oparent = .NULL.
		Width = 789
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="oparent" display="oParent"/>
		</VFPData>
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 790
		_shape1.ZOrderSet = 1
		_shape2.Height = 29
		_shape2.Left = 758
		_shape2.Name = "_shape2"
		_shape2.Top = -1
		_shape2.Width = 37
		_shape2.ZOrderSet = 2
		Lb_titlu_alb_b121.Caption = "SAFT D406"
		Lb_titlu_alb_b121.FontSize = 11
		Lb_titlu_alb_b121.Left = 4
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 3
		Lb_titlu_alb_b121.Top = 6
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 758
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 1
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 4
		Gridsort1.Left = 216
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 8
	*</PropValue>

	ADD OBJECT 'pgfSAFT' AS _pageframe WITH ;
		Anchor = 15, ;
		ErasePage = .T., ;
		Height = 440, ;
		Left = 0, ;
		Name = "pgfSAFT", ;
		PageCount = 4, ;
		TabIndex = 2, ;
		Top = 27, ;
		Width = 790, ;
		Page1.Caption = "Antet", ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Fisiere Master", ;
		Page2.Name = "Page2", ;
		Page3.Caption = "Inregistrari contabile", ;
		Page3.Name = "Page3", ;
		Page4.Caption = "Documente sursa", ;
		Page4.Name = "pgDocumenteSursa"
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="pageframe" />

	ADD OBJECT 'pgfSAFT.Page1._label1' AS _label WITH ;
		Caption = "Tip platitor", ;
		Left = 8, ;
		Name = "_label1", ;
		TabIndex = 24, ;
		Top = 5, ;
		ZOrderSet = 9
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="label" />

	ADD OBJECT 'pgfSAFT.Page1.cboTip' AS combobox WITH ;
		ControlSource = "poUnitate.tip", ;
		Left = 8, ;
		Name = "cboTip", ;
		RowSource = "LUNAR,TRIMESTRIAL,SEMESTRIAL,ANUAL", ;
		RowSourceType = 1, ;
		Style = 2, ;
		TabIndex = 1, ;
		Top = 21, ;
		Value = LUNAR, ;
		Width = 173, ;
		ZOrderSet = 5
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'pgfSAFT.Page1.cmdCitesteDate' AS cmd_executa WITH ;
		Anchor = 9, ;
		AutoSize = .F., ;
		BackColor = 113,184,255, ;
		caction = do_citeste_date, ;
		Caption = "Genereaza XML", ;
		Height = 29, ;
		Left = 587, ;
		Name = "cmdCitesteDate", ;
		TabIndex = 5, ;
		Top = 3, ;
		Width = 112, ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'pgfSAFT.Page2.pgfMaster' AS _pageframe WITH ;
		Anchor = 15, ;
		ErasePage = .T., ;
		Height = 408, ;
		Left = 0, ;
		Name = "pgfMaster", ;
		PageCount = 11, ;
		Top = 0, ;
		Width = 787, ;
		Page1.Caption = "Conturi contabile", ;
		Page1.Name = "Page1", ;
		Page1.PageOrder = 1, ;
		Page2.Caption = "Clienti", ;
		Page2.Name = "Page2", ;
		Page2.PageOrder = 2, ;
		Page3.Caption = "Taxe", ;
		Page3.Name = "pgTaxe", ;
		Page3.PageOrder = 4, ;
		Page4.Caption = "Unitati de Masura", ;
		Page4.Name = "pgUOM", ;
		Page4.PageOrder = 5, ;
		Page5.Caption = "Tipuri Analiza", ;
		Page5.Name = "pgTipAnalize", ;
		Page5.PageOrder = 6, ;
		Page6.Caption = "Tipuri Miscari", ;
		Page6.Name = "pgTipMiscari", ;
		Page6.PageOrder = 7, ;
		Page7.Caption = "Produse", ;
		Page7.Name = "pgProduse", ;
		Page7.PageOrder = 8, ;
		Page8.Caption = "Stocuri", ;
		Page8.Name = "pgStocuri", ;
		Page8.PageOrder = 9, ;
		Page9.Caption = "Proprietari", ;
		Page9.Name = "pgProprietari", ;
		Page9.PageOrder = 10, ;
		Page10.Caption = "Furnizori", ;
		Page10.Name = "pgFurnizori", ;
		Page10.PageOrder = 3, ;
		Page11.Caption = "Active", ;
		Page11.Name = "pgActive", ;
		Page11.PageOrder = 11
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="pageframe" />

	ADD OBJECT 'pgfSAFT.pgDocumenteSursa.pgfDocumenteSursa' AS _pageframe WITH ;
		Anchor = 15, ;
		ErasePage = .T., ;
		Height = 408, ;
		Left = 2, ;
		Name = "pgfDocumenteSursa", ;
		PageCount = 5, ;
		Top = -1, ;
		Width = 787, ;
		Page1.Caption = "Facturi vanzare", ;
		Page1.Name = "Page1", ;
		Page1.PageOrder = 1, ;
		Page2.Caption = "Facturi achizitie", ;
		Page2.Name = "Page2", ;
		Page2.PageOrder = 2, ;
		Page3.Caption = "Miscari bunuri", ;
		Page3.Name = "pgMiscariBunuri", ;
		Page3.PageOrder = 4, ;
		Page4.Caption = "Tranzactii cu active", ;
		Page4.Name = "pgTranzactiiActive", ;
		Page4.PageOrder = 5, ;
		Page5.Caption = "Plati", ;
		Page5.Name = "pgPlati", ;
		Page5.PageOrder = 3
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="pageframe" />
	
	PROCEDURE do_verifica
		#Define CRLF Chr(13) + Chr(10)
		Local loDate As "empty"
		Local lcCodFiscal, lcDenumire, lcFilter, lcSelect, lcWhere, llAutoVerificare, llDontCloseCursor
		Local llExperimental, llMFIN, llServiciuWebANAF, llValidare, llVerificarePlatitorTVA, lnOptiune
		Local lnRaspuns, loPartener
		lcSelect = Select()
		
		Select crsJTVA
		lcDenumire = Alltrim(Nvl(crsJTVA.denumire, ''))
		lcCodFiscal = Alltrim(Nvl(crsJTVA.cod_fiscal, ''))
		
		lnOptiune = XMENU('VERIFICA... ' + m.lcDenumire + ' - ANAF; VERIFICA TOTI PARTENERII - ANAF')
		
		If Empty(m.lnOptiune)
			Return
		Endif
		* Pot sa fac verificarea pentru un singur nume si cu formularul pentru mai multi parteneri, dar arata mai dragut informatia intr-un messagebox pentru unul singur
		If m.lnOptiune = 1 && un singur nume
			loPartener = Null
			loDate = Createobject("empty")
		
			AddProperty(loDate, "denumire",  m.lcDenumire)
			AddProperty(loDate, "cod_fiscal", m.lcCodFiscal)
			AddProperty(loDate, "tip_verificare", "ANAF_SERVICIU_WEB")
		
			lnRaspuns = VerificaCodFiscal(loDate, @lnOptiune, @loPartener)
		Else
			llDontCloseCursor = .F.
			llExperimental = .F.
			llVerificarePlatitorTVA = .F. && verific VIES pentru toti partenerii
			llMFIN = .T. && verific MFIN pentru toata lumea
			llValidare = .T. && verific algoritmul codurilor fiscale
			llAutoVerificare = .T. && lanseaza verificarea automata la activate-ul formularului de verificare
			llServiciuWebANAF = .T.
		
			lcFilter = Filter("crsJTVA")
			lcWhere = Iif(m.lnOptiune = 1, "recno() = " + Alltrim(Str(Recno())), Iif(!Empty(m.lcFilter), m.lcFilter, ".T."))
			Select Distinct id_part, cod_fiscal, denumire, Iif(Left(Upper(cod_fiscal), 2) = "RO", "RO", "  ") As ATRIBUT_FISCAL, .T. As IsCIF, .F. As codvalid ;
				From crsJTVA ;
				Where &lcWhere ;
				Into Cursor crsCoduriFiscale ;
				Order By denumire, cod_fiscal  ;
				Readwrite
		
		
			Local lcXMLParteneri
			lcXMLParteneri = ""
			Cursortoxml('crsCoduriFiscale', "lcXMLParteneri", 1, 0, 0, "1")
		
			Do verificare_parteneri With m.lcXMLParteneri, m.llValidare, m.llMFIN, m.llVerificarePlatitorTVA, m.llAutoVerificare, m.llDontCloseCursor, m.llExperimental, m.llServiciuWebANAF
		Endif && x = 1
		
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		this._pageframe1.page2.Enabled = .F.
		this._pageframe1.page3.Enabled = .F.
		this._pageframe1.page4.Enabled = .F.
		this._pageframe1.page5.Enabled = .F.
		
		this._pageframe1.page1.optPJIntocmit.Valid()
	ENDPROC

	PROCEDURE pgfSAFT.Page1.cmdCitesteDate.Click
		SET STEP ON 
		TEXT TO lcXML TEXTMERGE NOSHOW
		<?xml version="1.0" encoding="UTF-8"?>
		<!--Sample XML file generated by XMLSpy v2021 rel. 3 (x64) (http://www.altova.com)-->
		<nsSAFT:AuditFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nsSAFT="mfp:anaf:dgti:d406t:declaratie:v1" xsi:schemaLocation="urn:StandardAuditFile-Taxation-Financial:RO Romanian_SAF-T_Financial_Schema_v_2.3.xsd">
			<nsSAFT:Header>
				<nsSAFT:AuditFileVersion>1.0</nsSAFT:AuditFileVersion>
				<nsSAFT:AuditFileCountry>RO</nsSAFT:AuditFileCountry>
				<nsSAFT:AuditFileRegion>RO-B</nsSAFT:AuditFileRegion>
				<nsSAFT:AuditFileDateCreated><<gcDataora>></nsSAFT:AuditFileDateCreated>
				<nsSAFT:SoftwareCompanyName><<gcFirma>></nsSAFT:SoftwareCompanyName>
				<nsSAFT:SoftwareID>SAFT</nsSAFT:SoftwareID>
				<nsSAFT:SoftwareVersion>2.4.10</nsSAFT:SoftwareVersion>
				<nsSAFT:Company>
					<nsSAFT:RegistrationNumber><<alltrim(poFirma.cod_fiscal)>></nsSAFT:RegistrationNumber>
					<nsSAFT:Name><<alltrim(poFirma.denumire)>></nsSAFT:Name>
					<nsSAFT:Address>
						<nsSAFT:StreetName><<alltrim(poFirma.strada)>></nsSAFT:StreetName>
						<nsSAFT:Number><<alltrim(poFirma.numar)>></nsSAFT:Number>
						<nsSAFT:AdditionalAddressDetail><<alltrim(poFirma.adresa)>></nsSAFT:AdditionalAddressDetail>
						<nsSAFT:Building></nsSAFT:Building>
						<nsSAFT:City><<alltrim(poFirma.localitate)>></nsSAFT:City>
						<nsSAFT:PostalCode><<alltrim(poFirma.codpostal)>></nsSAFT:PostalCode>
						<nsSAFT:Region>RO-B</nsSAFT:Region>
						<nsSAFT:Country>RO</nsSAFT:Country>
						<nsSAFT:AddressType>PostalAddress</nsSAFT:AddressType>
					</nsSAFT:Address>
					<nsSAFT:Contact>
						<nsSAFT:ContactPerson>
							<nsSAFT:Title><<alltrim(poResponsabil.functie)>></nsSAFT:Title>
							<nsSAFT:FirstName><<alltrim(poResponsabil.prenume)>></nsSAFT:FirstName>
							<nsSAFT:LastName><<alltrim(poResponsabil.nume)>></nsSAFT:LastName>
							<nsSAFT:Salutation></nsSAFT:Salutation>
						</nsSAFT:ContactPerson>
						<nsSAFT:Telephone><<alltrim(poFirma.telefon)>></nsSAFT:Telephone>
						<nsSAFT:Email><<alltrim(poFirma.email)>></nsSAFT:Email>
						<nsSAFT:Website><<alltrim(poFirma.website)>></nsSAFT:Website>
					</nsSAFT:Contact>
					<nsSAFT:TaxRegistration>
						<nsSAFT:TaxRegistrationNumber><<alltrim(poFirma.cod_fiscal)>></nsSAFT:TaxRegistrationNumber>
						<nsSAFT:TaxType>100010</nsSAFT:TaxType>
						<nsSAFT:TaxNumber><<alltrim(poFirma.cod_fiscal)>></nsSAFT:TaxNumber>
						<nsSAFT:TaxAuthority>ANAF</nsSAFT:TaxAuthority>
						<nsSAFT:TaxVerificationDate>2021-07-03</nsSAFT:TaxVerificationDate>
					</nsSAFT:TaxRegistration>
					<nsSAFT:BankAccount>
						<nsSAFT:IBANNumber><<alltrim(poFirma.cont_banca)>></nsSAFT:IBANNumber>
					</nsSAFT:BankAccount>
				</nsSAFT:Company>
				<nsSAFT:DefaultCurrencyCode>RON</nsSAFT:DefaultCurrencyCode>
				<nsSAFT:SelectionCriteria>
					<nsSAFT:TaxReportingJurisdiction>Romania</nsSAFT:TaxReportingJurisdiction>
					<nsSAFT:CompanyEntity><<gcFirma>></nsSAFT:CompanyEntity>
					<nsSAFT:PeriodStart><<m.lnLunaI>></nsSAFT:PeriodStart>
					<nsSAFT:PeriodStartYear><<m.lnAnI>></nsSAFT:PeriodStartYear>
					<nsSAFT:PeriodEnd><<m.lnLunaF>></nsSAFT:PeriodEnd>
					<nsSAFT:PeriodEndYear><<m.lnAnF>></nsSAFT:PeriodEndYear>
				</nsSAFT:SelectionCriteria>
				<nsSAFT:HeaderComment>Fara comentarii</nsSAFT:HeaderComment>
				<nsSAFT:SegmentIndex>1</nsSAFT:SegmentIndex>
				<nsSAFT:TotalSegmentsInsequence>1</nsSAFT:TotalSegmentsInsequence>
				<nsSAFT:TaxAccountingBasis>A</nsSAFT:TaxAccountingBasis>
				<nsSAFT:TaxEntity>Company</nsSAFT:TaxEntity>
			</nsSAFT:Header>
		</nsSAFT:AuditFile>	
		ENDTEXT 
		STRTOFILE(m.lcXML,PUTFILE('Fisier','saft_d406','xml'))
	ENDPROC

ENDDEFINE
