すべてのExact Online販売請求書明細をダウンロードするApp Onlineモジュール

Invantive SQLは、1,100を超えるテーブルでExact Onlineをサポートしています。さらに、Get My Reportのような製品もあり、あらかじめ定義されたレポートによって、複数の管理会社にまたがるデータを一度にダウンロードとして提供できます。

しかし、会社のユーザーが固定の独自フォーマットでレポートを取得できる、独自のレポートツールを持ちたい場合もあります。Invantive Cloudを使えば、Power BIやQlikを使わなくても、これが可能です。

このトピックでは、独自のInvantive Cloudアプリを使って、追加情報付きのすべての販売請求書明細行を一度に選択・ダウンロードする方法を紹介します。Excelダウンロード形式は、独自のピボットテーブルを使ってExact Onlineの取引活動を分析したい営業マネージャーや営業担当者によく使われる形式です。このExact Online SQLクエリは、Get My Report for Exact Onlineの販売請求書明細行モジュールです。

売上数値は、Invantive Cloud内のExact Onlineデータベースで設定されている通り、1つの財務管理会社から、または複数の管理会社から同時に取得できます。ただし、異なる管理会社の販売元帳からの財務データは、例えばユーロ建てとUSドル建てのように、基準が異なる場合があるので注意してください。

アプリの実行に3分以上かかる場合や、自動的に呼び出す必要がある場合は、Power BI向けInvantive Bridge Onlineの姉妹製品であるInvantive App Onlineを利用できます。詳しくはWat is Invantive App Online? もご覧ください。

準備

以下の準備が必要です:

  • Invantive Cloudのログインコード。
  • 1つ以上の管理会社を持つExact Onlineのログインコード。

Exact Onlineデータベースの定義

最初のステップは、Exact Onlineデータベースを定義することです。以下の手順に従うだけで簡単に行えます:

このExact OnlineデータベースはPower BI、Power Query、Azure Data Factoryに利用できるだけでなく、例えばAccess ODataや、ここでのようにInvantive Cloudアプリケーションのソースとしても同様に簡単に使用できます。

クラウドアプリケーションの定義

次のステップは、Exact Onlineから売上数値を取得するInvantive Cloud上のアプリを定義することです。以下の手順を実行してください:

  • 左メニューで「アプリケーション」を選択します:
  • 「新規」を選択します。
  • 以下のようにフィールドを入力します:
  • 「モジュール」を選択します。
  • 「新規」を選択します。
  • 以下のようにフィールドを入力します:

ExcelファイルをExact Onlineの売上数値で作成・入力する

このモジュールには、設定を指定した後、Exact Onlineの売上数値を含むExcelファイルを作成するコードが含まれます。

完全なコードはこの記事の最後に記載されています。

すぐに続けたいですか?

  • モジュールの「ソースコード」フィールドにコードを貼り付けます。
  • 上部のパンくずリストで「My First App」を選択します。
  • 「実行」を選択します。
  • Exact Onlineデータベースを選択します(複数のデータベースがある場合)。
  • 「実行」を選択します:
  • モジュールを選択します:
  • 開始日と終了日を入力します:
  • Excelファイルがダウンロードされます。

アプリのその他の例

独自アプリのその他の例は以下にあります:

売上レポートのソースコード

以下のソースコードは、Exact Onlineの売上情報をExcelワークブックとしてダウンロードするレポートツールです。変数p_runがtrueでない限り、開始日と終了日の入力画面が表示されます。入力画面によって変数p_runがtrueに設定されると、Excelワークブックがダウンロードされます。

declare
  p_run                         boolean  := false;
  p_cfn_factuur_datum_vanaf     date     := null;
  p_cfn_factuur_datum_tot       date     := null;
  --
  l_workbook                    excel_workbook;
  l_worksheet                   excel_worksheet;
  l_binary                      blob;
begin
  --
  -- パラメータを取得する。
  --
  p_run               := cast(cloud_http.get_request_query_parameter_value('p_run') as boolean);
  --
  p_cfn_factuur_datum_vanaf := to_date(cloud_http.get_request_query_parameter_value('p_cfn_factuur_datum_vanaf'), 'YYYY-MM-DD');
  p_cfn_factuur_datum_tot   := to_date(cloud_http.get_request_query_parameter_value('p_cfn_factuur_datum_tot'), 'YYYY-MM-DD');
  --
  if coalesce(p_run, false) = false
  then
    cloud_http.set_use_template(true);
    cloud_http.set_template_step_name(translate_resources('{res:itgen_parameters}'));
    cloud_http.append_line_to_response_body_text('<form>');
    cloud_http.append_line_to_response_body_text('<input type="hidden" id="p_run" name="p_run" value="true"/>');
    cloud_http.append_line_to_response_body_text('<ul>');
    cloud_http.append_line_to_response_body_text('<li><label for="p_cfn_factuur_datum_vanaf">' || translate_resources('{res:itgen_invoice_date_from}') || '</label></li><li><input id="p_cfn_factuur_datum_vanaf" name="p_cfn_factuur_datum_vanaf" type="date" value="' || to_char(add_months(trunc(sysdateutc, -1), -1), 'YYYY-MM-DD') || '"/></li>');
    cloud_http.append_line_to_response_body_text('<li><label for="p_cfn_factuur_datum_tot">' || translate_resources('{res:itgen_invoice_date_to}') || '</label></li><li><input id="p_cfn_factuur_datum_tot" name="p_cfn_factuur_datum_tot" type="date" value="' || to_char(add_months(trunc(sysdateutc, -1), +1), 'YYYY-MM-DD') || '"/></li>');
    cloud_http.append_line_to_response_body_text('<li><input type="submit" value="Start"/></li>');
    cloud_http.append_line_to_response_body_text('</ul>');
    cloud_http.append_line_to_response_body_text('</form>');
  else
    --
    -- パラメータをチェックする。
    --
    -- チェックなし。
    --
    -- Excelワークブックを作成する。
    --
    l_workbook := excel.new();
    --
    -- Exact Onlineの売上請求書明細行用のワークシートを追加する。
    --
    l_worksheet := excel.add_worksheet
    ( l_workbook
    , 'SALES SOURCE DATA'
    );
    --
    -- 売上請求書明細行のリストを作成する。
    --
    create or replace table rpt@inmemorystorage
    as
    select /*+ result_set_name("SalesInvoiceLines") */
           sie.invoicenumber
           label 'Invoice Number'
    ,      sle.LineNumber
           label 'Line Number'
    ,      sie.invoicedate
           label 'Invoice Date'
    ,      sie.ordernumber
           label 'Order Number'
    ,      sie.orderdate
           label 'Order Date'
    ,      sie.SalespersonFullName
           label 'Sales Person Full Name'
    ,      actord.code
           label 'Ordered by Code'
    ,      actord.name
           label 'Ordered by Name'
    ,      cttord.fullname
           label 'Ordered by Contact'
    ,      amrord.FullName AccountManagerFullName
           label 'Ordered by Account Manager'
    ,      actord.Email
           label 'Ordered by Email'
    ,      actdlr.code
           label 'Deliver to Company Code'
    ,      actdlr.name
           label 'Deliver to Company Name'
    ,      sie.delivertocontactpersonfullname
           label 'Deliver to Contact'
    ,      adsdlr.addressline1
           label 'Deliver to Address Line 1'
    ,      adsdlr.postcode
           label 'Deliver to Postcode'
    ,      adsdlr.city
           label 'Deliver to City'
    ,      adsdlr.country
           label 'Deliver to Country'
    ,      actdlr.email
           label 'Deliver to Email'
    ,      amrive.FullName AccountManagerFullName
           label 'Invoice Account Manager'
    ,      active.name
           label 'Invoice Company Name'
    ,      active.Email
           label 'Invoice Email'
    ,      active.AddressLine1
           label 'Invoice Address Line 1'
    ,      active.Postcode
           label 'Invoice Postcode'
    ,      active.City
           label 'Invoice City'
    ,      active.Country
           label 'Invoice Country'
    ,      sie.duedate
           label 'Due Date'
    ,      gat.Code GLAccountCode
           label 'General Ledger Account'
    ,      igp.code itemgroupcode
           label 'Item Group'
    ,      sle.itemcode
           label 'Item Code'
    ,      sle.itemdescription
           label 'Item Description'
    ,      sle.description
           label 'Description'
    ,      sim.SupplierCode
           label 'Main Supplier Code'
    ,      sim.SupplierDescription
           label 'Main Supplier Name'
    ,      sle.StartTime
           label 'Start'
    ,      sle.EndTime
           label 'End'
    ,      sle.quantity
           label 'Quantity'
    ,      sle.UnitDescription
           label 'Unit Description'
    ,      sle.NetPrice
           label 'Net Price'
    ,      sle.unitprice
           label 'Unit Price'
    ,      sle.discount * 100
           label 'Discount'
    ,      sle.unitprice * ( 1 - sle.discount )
           label 'Net Price per Unit'
    ,      sle.netamountdc
           label 'Net Price Total'
    ,      sle.unitprice * sle.discount * sle.quantity
           label 'Amount Discount'
    ,      sle.VATAmountDC
           label 'VAT Amount (EUR)'
    ,      itm.costpricecurrency
           label 'Cost Price Currency'
    ,      itm.costpricestandard
           label 'Cost Price Standard'
    ,      itm.costpricestandard * sle.quantity
           label 'Standard Cost Price Total'
    ,      itm.NetWeight
           label 'Net Weight'
    ,      itm.GrossWeight
           label 'Gross Weight'
    from   exactonlinerest..salesinvoicesbulk@eol sie
    join   exactonlinerest..salesinvoicelinesBulk@eol sle
    on     sle.division  = sie.division
    and    sle.invoiceid = sie.invoiceid
    join   ItemsIncremental@eol itm
    on     itm.division = sle.division
    and    itm.id       = sle.item
    join   ItemGroups@eol igp
    on     igp.division = itm.division
    and    igp.id       = itm.ItemGroup
    join   GLAccountsIncremental@eol gat
    on     gat.Id = sle.GLAccount
    join   AccountsIncremental@eol actord
    on     actord.division = sie.division
    and    actord.id       = sie.orderedby
    left
    outer
    join   exactonlinerest..users@eol amrord
    on     amrord.userId  = actord.AccountManager
    left
    outer
    join   ContactsIncremental@eol cttord
    on     cttord.id       = sie.orderedbycontactperson
    join   AccountsIncremental@eol actdlr
    on     actdlr.id       = sie.deliverto
    left
    outer
    join   AddressesIncremental@eol adsdlr
    on     adsdlr.id       = sie.delivertoaddress
    join   AccountsIncremental@eol active
    on     active.id       = sie.invoiceto
    left
    outer
    join   exactonlinerest..users@eol amrive
    on     amrive.userId  = actord.AccountManager
    left
    outer
    join   SupplierItems@eol sim
    on     sim.division     = sle.division
    and    sim.ItemCode     = sle.itemcode
    and    sim.MainSupplier = true
    where  sie.status = 50
    and    sie.invoicedate between coalesce(p_cfn_factuur_datum_vanaf, sie.invoicedate) and coalesce(p_cfn_factuur_datum_tot, sie.invoicedate) 
    order
    by     sie.invoicenumber
    ,      sie.ordernumber
    ,      sle.linenumber
    ;
    --
    -- 項目をExcelワークシートに配置する。
    --
    excel.fill_using_query(l_worksheet, 'select * except rowid$ from rpt@inmemorystorage');
    --
    -- タイトル付きのワークシートを追加する。
    --
    l_worksheet := excel.add_worksheet
    ( l_workbook
    , 'FILTER'
    );
    excel.set_cell_contents(l_worksheet, 'A1', 'Sales Invoices');
    excel.set_cell_contents(l_worksheet, 'A3', translate_resources('{res:itgen_user}'));
    excel.set_cell_contents(l_worksheet, 'B3', sys_context('USERENV', 'USER_FULL_NAME', 'eol'));
    --
    excel.set_cell_contents(l_worksheet, 'A4', translate_resources('{res:itgen_generated}'));
    excel.set_cell_contents(l_worksheet, 'B4', to_char(sysdateutc, 'DD-MM-YYYY HH24:MI:SS'));
    --
    excel.set_cell_contents(l_worksheet, 'A6', translate_resources('{res:itgen_invoice_date_from}'));
    excel.set_cell_contents(l_worksheet, 'B6', p_cfn_factuur_datum_vanaf);
    --
    excel.set_cell_contents(l_worksheet, 'A7', translate_resources('{res:itgen_invoice_date_to}'));
    excel.set_cell_contents(l_worksheet, 'B7', p_cfn_factuur_datum_tot);
    --
    -- 結果のXLSXファイルを取得する。
    --
    l_binary := excel.export_to_xlsx(l_workbook);
    --
    -- XLSXファイルをユーザーに返す。
    --
    cloud_http.set_response_body_binary(l_binary);
    cloud_http.set_response_content_type('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    cloud_http.set_response_header_value
    ( 'Content-Disposition'
    , 'attachment; filename="Sales Invoices Fixed Format.xlsx'
    );
  end if;
end;