Exact Online 导入 GLTransactions 自动对账

Exact Online import GLTransactions with automatic reconciliation

我正在使用我们的查询工具为 Exact Online XML API 的主题 GLTransactions 生成 XML 文件。这些文件的输入是 XML 来自 Twinfield 的审核文件(XAF 3.1 格式)。

由于 Exact Online 有混合分类帐和很多限制,因此无法直接加载银行分录。相反,当从 Twinfield 加载 XML 审计文件时,第一步是将银行交易过帐到 Exact Online 的一个单独的总帐帐户和一个单独的日记帐中。

下一步,将保留的总帐帐户的Exact Online 中的内容过帐到银行日记帐中。 Exact Online 本身生成另一半作为银行总账的关联交易行。

用于生成银行分录的查询是:

create or replace table bank@inmemorystorage
as
select case 
       when substr(tle.description, 1, instr(tle.description, '/') - 1) = 'BNK'
       then '20'
       when substr(tle.description, 1, instr(tle.description, '/') - 1) = 'BNK2'
       then '21'
       else '??'
       end
       txn_journalcode
,      txn.financialyear txn_financialyear
,      txn.financialperiod txn_financialperiod
,      txn.entrynumber txn_entrynumber
,      txn.date txn_date
,      tle.date tle_date
,      tle.linenumber tle_linenumber
,      substr(tle.description, instr(tle.description, '/') + 1, instr(tle.description, ':') - instr(tle.description, '/') - 1) tle_glaccountcode_target
,      substr(tle.description, instr(tle.description, ':') + 2) tle_description
,      trim(tle.accountcode) tle_accountcode
,      tle.glaccountcode glaccountcode_source
,      tle.amountdc tle_amountdc
,      tle.vatcode tle_vatcode
,      tle.yourref tle_yourref
from   exactonlinerest..transactionlines tle
join   exactonlinerest..transactions txn
on     tle.entryid = txn.entryid
where  tle.glaccountcode like '290%'
and    substr(tle.description, instr(tle.description, '/') + 1, instr(tle.description, ':') - instr(tle.description, '/') - 1) not like '11%' /* Not a bank account. */
order 
by     tle.entrynumber
,      tle.linenumber

select 'GLTransactions-Interim-empty.xml' 
       filename
,      stg.fileprefix 
       || chr(13)
       || '<GLTransactions>' 
       || xml 
       || chr(13)
       || '</GLTransactions>'
       || stg.filepostfix
       filecontents
from   ( select listagg
                ( chr(13)
                  || '<GLTransaction entry="'
                  || txn_entrynumber
                  || '">'
                  || chr(13)
                  || '<Journal code="'
                  || txn_journalcode
                  || '" />'
                  || chr(13)
                  || '<Date>'
                  || substr(xmlencode(txn_date), 1, 10)
                  || '</Date>'
                  || chr(13)
                  || xml
                  || chr(13)
                  || '</GLTransaction>'
                  , ''
                  ) xml
          from    ( select txn_date
                    ,      txn_journalcode
                    ,      txn_financialyear
                    ,      txn_financialperiod
                    ,      txn_entrynumber
                    ,      listagg
                           ( chr(13)
                             || '<GLTransactionLine type="40" linetype="0" line="'
                             || tle_linenumber 
                             || '" offsetline="1" status="20">'
                             || chr(13)
                             || '<Date>'
                             || substr(xmlencode(tle_date), 1, 10)
                             || '</Date>'
                             || chr(13)
                             || '<FinYear number="'
                             || txn_financialyear
                             || '" />'
                             || chr(13)
                             || '<FinPeriod number="'
                             || txn_financialperiod
                             || '" />'
                             || chr(13)
                             || '<GLAccount code="'
                             || case
                                when tle_glaccountcode_target = '1560' 
                                then '2902' /* Separate interim GL account, Twinfield does not provide separated. */
                                else xmlencode(tle_glaccountcode_target)
                                end
                             || '" />'
                             || case 
                                when tle_description is not null 
                                then chr(13)
                                     || '<Description>'
                                     || xmlencode(tle_description)
                                     || '</Description>'
                                     end
                             || case
                                when tle_accountcode is not null
                                then chr(13)
                                     || '<Account code="'
                                     || xmlencode(tle_accountcode)
                                     || '" />'
                                end
                             || chr(13)
                             || '<Amount>'
                             || '<Currency code="EUR" />'
                             || '<Value>'
                             || -1 * tle_amountdc
                             || '</Value>'
                             || case 
                                when tle_glaccountcode_target like '4%'
                                then '<VAT code="GB" />' /* GB = No VAT. */
                                else ''
                                end
                             || '</Amount>'
                             || chr(13)
                             || '</GLTransactionLine>'
                             , ''
                           )
                           xml
                    from   bank@inmemorystorage
                    group 
                    by     txn_date
                    ,      txn_journalcode
                    ,      txn_financialyear
                    ,      txn_financialperiod
                    ,      txn_entrynumber
                    )
       )
join   settings@inmemorystorage stg
on     1=1

bank@inmemorystoragetle_yourref 列中,有一个以逗号分隔的关联 sales/purchase 发票列表。

在银行日记帐上手动输入总帐交易时,您的参考内容由对帐 window 填充。但是,当我从带有交易的 Exact Online 导出 XML 文件时,您的 ref 丢失了。

目前我似乎无法通过 Exact Online 的 XML 或 REST API 自动对账这些银行日记帐中的交易。

作为解决方法,您可以 select 对帐 window 中的每个单独帐户(它们实际上都为 0 欧元),然后选择自动对帐。但是每次从 Twinfield 到 Exact Online 的转换都有太多帐户无法完成。

是否有其他方法通过 Exact Online 的 API(REST 或 XML)将发票与银行交易相关联?

如果发票和付款之间存在一对一的关系(因此只有 1 张发票和 1 笔付款),您可以在银行分录中使用 <References><InvoiceNumber>put invoice entrynumber here</InvoiceNumber></References> 以自动对帐。

另一种可能性是创建一个 XML 主题为 MatchSets 的文件(参见文档),以便之后进行匹配。

此外,你还可以说:

<References><EntryNumber>10000012</EntryNumber><InvoiceNumber>FAC0001</InvoiceNumber></References>

这在关系为 1=1 时始终有效。 如果您仅指定发票编号,匹配通常会自动失败。