zoukankan      html  css  js  c++  java
  • Create & Post free text invoice by code

    Here is a sample class which is called via Dialog framework to create & post free text invoice using X++ code.

     1 public void xtest()
     2 {
     3     Dialog        dialog;
     4     DialogField   dlgCustAcc;
     5     DialogGroup   dialogPeriodLengthGroup, dialogPeriodLengthGroup1;
     6     DialogField   dlgLedgerAcc;
     7   ;
     8     dialog                   = new Dialog("Free-Text Invoice");
     9     dialogPeriodLengthGroup1 = dialog.addGroup(‘Cust Table’);
    10     dlgCustAcc               = dialog.addField(typeid(CustAccount));
    11     dialogPeriodLengthGroup  = dialog.addGroup(‘Ledger Table’);
    12     dlgLedgerAcc             = dialog.addField(typeid(LedgerAccount));
    13  
    14    
    15     if (dialog.run())
    16     {
    17         if (dlgCustAcc.value() && dlgLedgerAcc.value() != ”)
    18             FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value());
    19         else
    20              throw error(strfmt("Either CustAccount or LedgerAccount info is missing."));
    21     }
    22  }
    23  
    24 /// <summary>
    25 /// The <c>Job_FreeTxtInvoice</c> class is implemented to create/post <c>Free Text Invoice</c>.
    26 /// </summary>
    27 class FreeTxtInvoiceCreatePost
    28 {
    29 }
    30  
    31 static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount)
    32 {
    33     CustInvoiceTable    custInvoiceTable;
    34     CustInvoiceLine     custInvoiceLine;
    35     CustTable           custTable;
    36     LedgerTable         ledgerTable;
    37     CustPostInvoice     custPostInvoice;
    38     LineNum             lineNum;
    39     int                 i;
    40     ;
    41  
    42     /// <summary>
    43     /// The <c>CustInvoiceTable</c> logic is implemented to create single <c>Header</c>.
    44     /// </summary>
    45     ttsbegin;
    46     custTable = CustTable::find(_custAccount);
    47     custInvoiceTable.initFromCustTable(custTable);
    48     custInvoiceTable.insert();
    49     ttscommit;
    50  
    51     /// <summary>
    52     /// The <c>CustInvoiceLine</c> logic is implemented to create multiple <c>Invoice Lines</c>.
    53     /// </summary>
    54     for (i = 1; i <= 100; i++)
    55     {
    56         ttsbegin;
    57         ledgerTable = LedgerTable::find(_ledgerAccount);
    58         custInvoiceLine.clear();
    59         custInvoiceLine.initValue();
    60         custInvoiceLine.LedgerAccount = ledgerTable.AccountNum;
    61         custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);
    62         custInvoiceLine.AmountCur = 10.00;
    63         custInvoiceLine.Description = ‘FreeTxIv’ + int2str(i);
    64         custInvoiceLine.TaxItemGroup = ‘full’;
    65         custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
    66  
    67         //LINE NUM LOGIC.
    68         if(!lineNum)
    69         {
    70             lineNum = CustInvoiceLine::lastLineNum(custInvoiceLine.ParentRecId);
    71         }
    72  
    73         lineNum += 1;
    74         custInvoiceLine.LineNum = lineNum;
    75         custInvoiceLine.insert();
    76         ttscommit;
    77     }
    78  
    79     /// <summary>
    80     /// The <c>custPostInvoice</c> class is called for posting <c>Free-TextInvoice.</c> records.
    81     /// </summary>
    82     custPostInvoice = new CustPostInvoice(custInvoiceTable);
    83     custPostInvoice.run();
    84 }
  • 相关阅读:
    XSS漏洞攻击
    String 是值类型还是引用类型
    客户端验证不能代表服务器端验证
    PowerDesigner参照(Reference)笔记
    LazyAllocate(缓分配)与PreAllocate(预分配)
    我在delphi7下调用微软的Web Services的心得.(可以返回数据集)
    C Dungeon Master
    TimeQuest笔记
    XPStyle Button
    对XML文件的CRUD(添加,读取,搜索,修改,删除)的例子
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663603.html
Copyright © 2011-2022 走看看