Ax settle payment with invoice

  1. create a payment journal
  2. mark journal with invoice
static void settledPaymentwithinoice(Args _args)
{
    CustVendOpenTransManager manager;
    LedgerJournalTrans journaltrans;
    VendTransOpen      vendtransopen;
//the payment journal 
    select firstOnly journaltrans where journaltrans.RecId == 5637195041;
    manager = CustVendOpenTransManager::construct(journaltrans);
//select a vendor invoice that open
    select firstOnly VendTransOpen;
    //manager.resetMarkedTrans();
    manager.updateTransMarked(VendTransOpen, true);

    // manager.updateAmounts(vendTransOpen, amountToSettle, amountToSettle, 0, false);



    info('Done');

}
  1. update the payment journal “ settle voucher” filed type
  2. when post. this payment will be settled with that vendor invoice you select.

Also there is a reference link. which mention the SpecTrans. this is a table that record the ready to mark invoice. once it is post , the data will be delete .
http://axhelper.blogspot.hk/2018/03/update-vendor-open-trans-to-mark-and.html

  1. after post , check it in vendtrans table


    image.png
  2. There is also tips for unsettled payment and invocie
    https://community.dynamics.com/ax/b/amirsaxspace/archive/2018/03/16/x-code-to-unsettle-payment-and-invoice

static void unSettlement(Args _args)
{
    VendTrans        vendtrans;
    VendTable        vendtable;
    VendSettlement   vendSettlement;
    Amount           remianingAmt;
    SpecTransManager specTransManager;
    //select the trans that you want to unsettlement
    select firstOnly vendtrans where vendtrans.Voucher == 'APD-18040001';
    remianingAmt = vendtrans.remainAmountCur();
    if(remianingAmt == 0)
    {
        vendtable = VendTable::find(vendtrans.AccountNum);
        select firstOnly vendSettlement 
        where vendSettlement.TransCompany == vendtrans.dataAreaId 
        && vendSettlement.TransRecId == vendtrans.RecId 
        && vendSettlement.AccountNum == vendtrans.AccountNum; 
        specTransManager = SpecTransManager::newRefTableId(VendTable, tablenum(vendSettlement), true);  
         
        specTransManager.insert(vendSettlement.DataAreaId, 
        vendSettlement.TableId, vendSettlement.RecId, 
        vendSettlement.SettleAmountCur, vendtrans.CurrencyCode);  
        
         vendSettlement.CustVendSettlement::markOffsets(specTransManager,  vendtrans.CurrencyCode, true);  
        
         if (vendtrans::reverseTransact(vendTable, null, settleDatePrinc::DateOfPayment, 
         vendSettlement.TransDate)) 
         {  
             specTransManager.deleteAll();  
         }  
    }
    
    info("done");
}
  1. after unsettlement ,check it again in vends table
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,449评论 0 10
  • 临摹老王的玫瑰花,用马可3100画的,完全没看色号,和教程,画着画着,就有新的领悟了。虽然线条还是有些杂乱,但是对...
    Cola猫咪阅读 460评论 0 1
  • “多力吃饭咯,多吃点子菜莫要紧”,“多喝水,人一天离不开水”,“少耍手机,对眼睛不好,头莫太低,对脖颈不好哎”……...
    知了矣矣阅读 367评论 1 2
  • 我好崩溃,我觉得我考不起一中。
    你的ikun阅读 179评论 0 0
  • 这个世界上到处都有缺爱的人,放眼望去整个朋友圈大片的求点赞,求拥抱,求关注,难道人类一直以来就处在孤独的状态...
    Miya姑娘阅读 380评论 0 0