-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExpenseTableCreateDoc.txt
35 lines (32 loc) · 1.39 KB
/
ExpenseTableCreateDoc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
static void BtOrTestCreateExpense(Args _args)
{
TrvExpTable trvExpTable;
NumberSeq numberSequence; //Trav_11, the number is set in NumberSequence table
TrvExpNumber trvExpNumber;
RecId creatingWorker = HcmWorker::findByPersonnelNumber("000056").RecId;//Person Number: 000056 => Oat
TrvDestination trvDestination = "Thailand";
TrvTravelTxtEDT txt2 = "Travel Test V6";
RecId legalEntityRecId = CompanyInfo::find().RecId;
//Get number sequence object
numberSequence = NumberSeq::newGetNumFromCode("Trav_11", NumberSeqScopeFactory::createLegalEntityScope(legalEntityRecId), true);
trvExpNumber = numberSequence.num();//Get the next number
numberSequence.used();//To reserve the number
try
{
ttsBegin;
trvExpTable.initValue();//Prefill default date from AX
trvExpTable.ApprovalStatus = TrvAppStatus::Pending;
trvExpTable.CreatingWorker = creatingWorker;
trvExpTable.Destination = trvDestination;
trvExpTable.ExpNumber = trvExpNumber;
trvExpTable.Txt2 = txt2;
trvExpTable.VendAccount = "V500364";//This is map in Worker form under Expense management/Map worker to vendor
trvExpTable.insert();
ttsCommit;
info("Expense Created");
}
catch
{
error("Expense failed");
}
}