共用方式為


X++ 業務執行階段函式

備註

社區興趣小組現在已從 Yammer 轉移到 Microsoft Viva Engage。 若要加入 Viva Engage 社群並參與最新的討論,請填寫 [ 要求存取財務和營運 Viva Engage 社群 表單 」 ,並選擇您要加入的社群。

本文說明商務執行階段函式。

這些函數輸入財務資料並計算公式。

c術語

計算目前投資價值產生目標值所需的期間數。

語法

real cTerm(real interest, real future_value, real current_value)

參數

參數 Description
利息 利率。
future_value 目標值。
current_value 當前的投資價值。

返回值

達到 future_value所需的期間數。

備註

current_valuefuture_value參數必須具有相同的前綴符號(加號或減號)。

Example

static void cTermExample(Args _arg)
{
    real r;
    ;
    r = cTerm(10.0, 500.00, 100.00);
    print "The cTerm is " + num2Str(r, 2, 2, 1, 1);
    pause;
}

ddb

計算資產的加速折舊。

語法

real ddb(real price, real scrap, real life, int period)

參數

參數 Description
價格 資產的購買價格。
報廢 已沖銷的資產的剩餘價值。
生命 資產的預期生命週期。
period 計算折舊的期間。

返回值

資產的折舊。

備註

特定期間的賬面價值等於購買價格減去前幾期的累計折舊:

  • 期間 1 的賬面價值 = 價格
  • 期間 2 的帳面價值 = 期間 1 的帳面價值 – 期間 1 的折舊
  • 期間 n 的帳面價值 = 期間 (n–1) 的帳面價值 – 期間 (n–1) 的折舊

折舊的計算有三種變化:如果期間 > 壽命:

  • 折舊 = 0

若(期間n的賬面價值)-((期間n的賬面價值)×2÷壽命) < 剩餘價值:

  • 折舊 =(第 n 期的賬面價值)– 殘值

在所有其他情況下: 折舊 = (期間 n 的帳面價值) × 2 ÷ 壽命 sydsln 函數也會計算資產的折舊。 sydddb 函數可為前幾年提供較高的折舊,而 sln 則計算線性折舊。

ddb(12000,2000,10,1); //Returns the value 2400.
ddb(12000,2000,10,3); //Returns the value 1536.

dg

計算出資比例,以銷售價格和購買價格為基礎。 如果 銷售 參數的值為 0.0,則無法進行計算。

語法

real dg(real sale, real purchase)

參數

參數 Description
售價。
購買 購買價格。

返回值

貢獻比例。

備註

dg(1000,300); //Returns the value 0.7.
dg(100,30); //Returns the value 0.7.
dg(20000, 11000); //Returns the value 0.45.

fV

計算投資的未來價值。

語法

real fV(real amount, real interest, real life)

參數

參數 Description
金額 每個期間內支付的金額。
利息 利率。
生命 投資期間數。

返回值

投資的未來價值。

備註

fV(100,0.14,10); //Returns the value 1933.73.
fV(400,0.10,5); //Returns the value 2442.04.

IDG

根據購買價格和出資比例計算銷售價格。

real idg(real purchase, real contribution_ratio)

參數

參數 Description
購買 購買價格。
contribution_ratio 貢獻比例。

返回值

售價。

備註

如果貢獻比率等於 1.0,則無法進行計算。 idg 函數是 dg 函數的倒數。

idg(300,0.7); //Returns the value 1000.
idg(11000,0.45); //Returns the value 20000.

intvMax

擷取指定期間的間隔數,當期間被分割成 func 參數所指定的部分時。

int intvMax(date input_date, date ref_date, int func)

參數

參數 Description
input_date 期間的結束,必須晚於 ref_date 參數。
ref_date 時期的開始。
功能 指出除法單位的 IntvScale 系統列舉值。

備註

以下是 func 參數的可能值:

  • None
  • 年月日
  • 年月
  • 月日
  • Day
  • 年季
  • 季度
  • 年份週
  • 平日

Example

static void intvMaxExample()
{
    date refDate = str2Date("4/9/2007", 213);
    date inputDate = str2Date("10/5/2007", 213);
    int numberOfIntervals;
    ;
    numberOfIntervals = intvMax(inputDate, refDate, intvScale::YearMonth);
    print numberOfIntervals;
    pause;
}

intv名稱

傳回間隔的名稱,即指定日期之前的指定間隔數。

str intvName(date input_date, int col, enum func)

參數

參數 Description
input_date 第一個間隔中的日期。
col input_date 參數所指定日期之前的間隔數。
功能 intvScale 列舉值。

返回值

間隔的名稱。

備註

例如,如果 func 參數是 IntvScale::WeekDay 列舉值,這個方法會傳回工作日的名稱。 如果 func 參數是 IntvScale::Week 列舉值,這個方法會傳回包含週數的字串。

Example

static void intvNameExample(Args _args)
{
    date refDate = 2672010;
    str name;
    ;
    name = intvName(refDate, 3,  intvScale::WeekDay);
    Global::info(strfmt("%1 is the output, which indicates the day of the week 3 days after 26\7\2010.", name));
}
/**** Infolog display.
Message (09:56:55 am)
Thu is the output, which indicates the day of the week 3 days after 2672010.
****/

intv否

當您將時間劃分為指定的間隔時,計算兩個日期之間的間隔數。

語法

int intvNo(date input_date, date ref_date, int func)

參數

參數 Description
input_date 指出期間結束的日期
ref_date 指出期間開始的日期。
功能 intvScale 列舉值。

返回值

ref_dateinput_date 參數所指定的日期之間的間隔數。

Example

static void intvNoExample(Args _args)
{
    date inputDate = str2Date("1/1/2007", 213);
    date refDate = str2Date("3/1/2007", 213);
    int noOfIntervals;
    ;
    noOfIntervals = intvNo(refDate, inputDate, intvScale::Month);
    print noOfIntervals;
    pause;
    //noOfIntervals now holds the difference in months between March and January (2).
}

intv規範

傳回期間的正規化日期。

語法

date intvNorm(date input_date, date ref_date, int func)

參數

參數 Description
input_date 期間的結束,必須晚於 ref_date 參數所指定的日期。
ref_date 時期的開始。
功能 指出間隔除法單位的 intvScale 列舉值。

返回值

期間的正規化日期。

備註

傳回的日期將等於 ref_date 參數所指定日期存在的間隔中第一天的日期。

Example

static void example()
{
    print intvNorm(today(), today()-1, IntVScale::WeekDay);
    pause;
}

PMT

計算每個期間必須支付的償還貸款的金額。

語法

real pmt(real principal, real interest, real life)

參數

參數 Description
主體 最初借入的金額。
利息 每個期間套用至借入金額的利息。
生命 償還貸款的期間數。

返回值

每個時期必須支付的金額。

備註

生命利息參數必須以相同的時間單位表示。 壽命參數的值必須大於 0.0

Example

pmt(4000,0.14,4); //Returns the value 1372.82.
pmt(10000,0.10,20); //Returns the value 1174.60.

pt

擷取數字的總和加上該數字的指定百分比。

語法

real pt(real amount, real percentage)

參數

參數 Description
金額 原始編號。
百分比 百分比補充。

返回值

等於 ((金額 *× *百分比) + 金額) 的數字。

備註

pt(2000.0,0.10); //Returns the value 2200.0.
pt(20.0,0.10); //Returns the value 22.0.

光伏

計算年金的現值,其中在多個期間收到金額並扣除每個期間的利率。

語法

real pv(real amount, real interest, real life)

參數

參數 Description
金額 每個期間支付的金額。
利息 利率。
生命 支付 金額 參數所指定值的次數。

返回值

年金的當前價值。

備註

pv(300,0.14,4); //Returns the value 874.11.

價格

計算目前投資價值在指定期間內達到未來價值所需的利息。

語法

real rate(real _future_value, real _current_value, real _terms)

參數

參數 Description
_future_value 投資的未來價值。
_current_value 投資的當前價值。
_terms 投資跨越的期間數。

返回值

計算出的利率。

備註

rate(10000,1000,20); //Returns the value 0.12.

SLN

擷取每個折舊期間指定資產的固定折舊金額。

語法

real sln(real price, real scrap, real life)

參數

參數 Description
價格 資產的購買價格。
報廢 資產的廢料價值。
生命 資產預期生命週期中的期間數。

返回值

折舊金額。

Example

static void slnExample(Args _arg)
{
    real r;
    ;
    r = sln(100.00, 50.00, 50.00);
    print r;
    pause;
}

西德

計算資產在指定期間內的折舊。

語法

real syd(real _price, real _scrap, real _life, int _period)

參數

參數 Description
_價 資產的購買價格。
_報廢 資產的廢料價值。
_生命 資產的預期壽命 (期間數)。
_時 計算折舊的期間。

返回值

指定期間內的折舊金額。

備註

sln 函數相比, syd 函數可以允許資產加速折舊。 與 ddb 函數一樣,這可以在資產生命週期的早期實現更高的折舊。

Example

在下列範例中,是針對購買價格為 10,000、廢料價值為 2,000、壽命為 5 的資產計算定期折舊。 相較之下, sln(10000,2000,5) 會計算每個期間的 1600.00。

// Returns the value 2666.67 (for the 1st period).
syd(10000,2000,5,1);
// Returns the value 2133.33 (for the 2nd period).
syd(10000,2000,5,2);
// Returns the value 1600.00 (for the 3rd period).
syd(10000,2000,5,3);
// Returns the value 1066.67 (for the 4th period).
syd(10000,2000,5,4);
// Returns the value 533.33 (for 5th - and final- period).
syd(10000,2000,5,5);

術語

計算投資必須執行的期間數。

語法

real term(real amount, real interest, real future_value)

參數

參數 Description
金額 定期投資的金額。
利息 每個期間的利率。
future_value 投資預期的未來價值

返回值

投資必須執行的期間數。

Example

static void termExample(Args _args)
{
    print term(400,0.08,5000);  //returns the value '9.01'.
    print term(100,0.14,3000);  //returns the value '12.58'.
    pause;
}