\\
*Addition* Expandir origem
#INCLUDE "Protheus.ch"
USER FUNCTION FIN050INC()
LOCAL aArray := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
//Structure for PA ( Advance Payment )
aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_TIPO" , "PA" , NIL \},;
\{ "E2_NATUREZ" , "001" , NIL \},;
\{ "E2_FORNECE" , "0001" , NIL \},;
\{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VALOR" , 5000 , NIL \},;
\{ "AUTBANCO" , "001", NIL \},;
\{ "AUTAGENCIA" , "1234", NIL \},;
\{ "AUTCONTA" , "123456", NIL \} \}
\\
//Structure for other bills
aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_TIPO" , "NF" , NIL \},;
\{ "E2_NATUREZ" , "001" , NIL \},;
\{ "E2_FORNECE" , "0001" , NIL \},;
\{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VALOR" , 5000 , NIL \} \}
\\
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Inclusion, 4 - Edition, 5 - Deletion
\\
\\
If lMsErroAuto
MostraErro()
Else
Alert("Bill included successfully")
Endif
\\
Return
*Editing* Expandir origem
#INCLUDE "Protheus.ch"
USER FUNCTION FIN050ALT()
LOCAL aArray := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_VALOR" , 2000 , NIL \} \}
\\
DbSelectArea("SE2")
DbSetOrder(1)
DbSeek(xFilial("SE2")+"PAG"+"0001 "+" "+"NF") //Edition must have SE2 record positioned
\\
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 4) // 3 - Inclusion, 4 - Edition, 5 - Deletion
\\
If lMsErroAuto
MostraErro()
Else
Alert("Bill edited successfully")
Endif
\\
Return
*Deletion* Expandir origem
#INCLUDE "Protheus.ch"
USER FUNCTION FIN050EXC()
LOCAL aArray := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
DbSelectArea("SE2")
DbSetOrder(1)
DbSeek(xFilial("SE2")+"PAG"+"0001 "+" "+"NF") //Deletion must have SE2 record positioned
\\
aArray := \{ \{ "E2_PREFIXO" , SE2->E2_PREFIXO , NIL \},;
\{ "E2_NUM" , SE2->E2_NUM , NIL \} \}
\\
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 5) // 3 - Inclusion, 4 - Edition, 5 - Deletion
\\
If lMsErroAuto
MostraErro()
Else
Alert("Bill deleted successfully")
Endif
\\
Return
\\
*Addition with VA (Accessory Values)* Expandir origem
#INCLUDE "Protheus.ch"
USER FUNCTION FIN050VA()
LOCAL aArray := \{\}
LOCAL nOpc := 3 // 3-Addition, 4 Editing
\\
// Accessory value data.
LOCAL aVAAut := \{\}
LOCAL cValAce1 := "000001" // Va Code
LOCAL nValAce1 := 200 // Va Code
LOCAL cValAce2 := "000012"
LOCAL nValAce2 := 4
\\
PRIVATE lMsErroAuto := .F.
\\
aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_TIPO" , "NF" , NIL \},;
\{ "E2_NATUREZ" , "001" , NIL \},;
\{ "E2_FORNECE" , "0001" , NIL \},;
\{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VALOR" , 5000 , NIL \} \}
\\
// Array with accessory value
aAdd(aVAAut, \{cValAce1, nValAce1\})
aAdd(aVAAut, \{cValAce2, nValAce2\})
\\
MsExecAuto( \{ |a,b,c,d,e,f,g,h,i,j,k,l| FINA050(a, b, c, d, e, f, g, h, i, j, k, l)\}, aArray,, nOpc,,,,,,,,, aVAAut)
\\
If lMsErroAuto
MostraErro()
Else
If nOpc == 3
Alert("Bill successfully added!")
Else
Alert("Bill edited successfully")
EndIf
Endif
\\
Return
*Addition with PA with check* Expandir origem
#INCLUDE "Protheus.ch"
USER FUNCTION FIN050INCPA()
LOCAL aArray := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
aArray := \{ \{ "E2_PREFIXO", "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_TIPO" , "PA" , NIL \},;
\{ "E2_NATUREZ" , "001" , NIL \},;
\{ "E2_FORNECE" , "0001" , NIL \},;
\{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VALOR" , 5000 , NIL \},;
\{ "AUTBANCO" , "FIN" , NIL \},;
\{ "AUTAGENCIA" , "00015" , NIL \},;
\{ "AUTCONTA" , "0000000001" , NIL \},;
\{ "AUTMOED" , "1" , NIL \},;
\{ "AUTCHEQUE" , "124569" , NIL \}\}
\\
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Addition
\\
If lMsErroAuto
MostraErro()
Else
Alert("Bill successfully added")
Endif
\\
Return
*Addition with project apportionment (PMS)* Expandir origem
USER FUNCTION F050IPMS()
Local cPref := "FIN"
Local cNum := "210408001"
Local cPar := "1"
Local cTipo := "NF"
Local cNaturez := "FGRV01"
Local cFornec := "FGRV04"
Local cLoja := "01"
Local nValor := 1000
Local aGrvSe2 := \{\}
Local aInfProj := \{\}
Local aInfAFR := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
PREPARE COMPANY ENVIRONMENT "T1" BRANCH "D MG 01 " MODULE "FIN" TABLES "SE2","SE5","SA2","AFR","AF9","AF8"
\\
aAdd(aInfAFR, \{"AFR_PROJET", PadR("PMSU000023", TamSX3("AF9_PROJET")\[1\]), Nil\})
aAdd(aInfAFR, \{"AFR_TAREFA", "01.02", Nil\})
aAdd(aInfAFR, \{"AFR_TIPOD", PadR("0004", TamSx3("AFR_TIPOD")\[1\]), Nil\})
aAdd(aInfAFR, \{"AFR_VALOR1", nValor, Nil\})
aAdd(aInfAFR, \{"AFR_REVISA", StrZero(4, TamSX3("AFR_REVISA")\[1\]), Nil\})
aAdd(aInfAFR, \{"AFR_PREFIX", cPref, Nil\})
aAdd(aInfAFR, \{"AFR_NUM", cNum, Nil\})
aAdd(aInfAFR, \{"AFR_PARCEL", cPar, Nil\})
aAdd(aInfAFR, \{"AFR_TIPO", cTipo, Nil\})
aAdd(aInfAFR, \{"AFR_FORNEC", cFornec, Nil\})
aAdd(aInfAFR, \{"AFR_LOJA", cLoja, Nil\})
aAdd(aInfAFR, \{"AFR_DATA", Date(), Nil\})
aAdd(aInfAFR, \{"AFR_VENREA", Date(), Nil\})
aAdd(aInfProj, aInfAFR)
\\
aGrvSe2 := \{ \{ "E2_PREFIXO" , cPref , NIL \},;
\{ "E2_NUM" , cNum , NIL \},;
\{ "E2_TIPO" , cTipo , NIL \},;
\{ "E2_NATUREZ" , cNaturez , NIL \},;
\{ "E2_FORNECE" , cFornec , NIL \},;
\{ "E2_LOJA" , cLoja , NIL \},;
\{ "E2_EMISSAO" , Date() , NIL \},;
\{ "E2_VENCTO" , Date() , NIL \},;
\{ "E2_VENCREA" , Date() , NIL \},;
\{ "E2_VALOR" , nValor , NIL \},;
\{ "E2_PROJPMS" , "2" , NIL \},;
\{ "E2_HIST" , "Project Addition" , NIL \},;
\{"AUTRATAFR" , aInfProj ,Nil \} \}
\\
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aGrvSe2,, 3) // 3 - Addition, 4 - Editing, 5 - Deletion
\\
If lMsErroAuto
MostraErro()
Else
Conout("Bill successfully added!")
Endif
\\
Return
*Bills payable withholding code* Expandir origem
#INCLUDE "Protheus.ch"
\\
/*When there is any type of operation involving the entry of value in field
E2_CODRET, you need to use function SetFuName("FINA050") before running MSExecAuto(),
because a validation exists in X3_VALID -(EXISTCPO("SX5","37"+M->E2_CODRET) .AND. Iif(FUNNAME() $ "FINA050|FINA750",FA050Natur(),.T.))
of this field that will only calculate the tax by withholding code if FunName() is found in "FINA050".*/
\\
USER FUNCTION F050CODRET()
LOCAL aArray := \{\}
\\
PRIVATE lMsErroAuto := .F.
\\
//Structure for other bills
aArray := \{ \{ "E2_PREFIXO" , "PAG" , NIL \},;
\{ "E2_NUM" , "0001" , NIL \},;
\{ "E2_TIPO" , "NF" , NIL \},;
\{ "E2_NATUREZ" , "001" , NIL \},;
\{ "E2_FORNECE" , "0001" , NIL \},;
\{ "E2_EMISSAO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCTO" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VENCREA" , CtoD("17/02/2012"), NIL \},;
\{ "E2_VALOR" , 5000 , NIL \},;
\{ "E2_DIRF" , "1", NIL \},;
\{ "E2_CODRET" , "3208" , NIL \}\}
\\
SetFunName("FINA050")
MsExecAuto( \{ |x,y,z| FINA050(x,y,z)\}, aArray,, 3) // 3 - Addition, 4 - Editing, 5 - Deletion
\\
\\
If lMsErroAuto
MostraErro()
Else
Alert("Bill successfully added")
Endif
\\
Return |