美文网首页
Ax settle payment with invoice

Ax settle payment with invoice

作者: axxxxxxxx | 来源:发表于2018-04-25 17:40 被阅读0次
    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

    相关文章

      网友评论

          本文标题:Ax settle payment with invoice

          本文链接:https://www.haomeiwen.com/subject/kamylftx.html