• 最終編集日時: 05 August 2021

ERPへの請求書の統合

Coupa請求書をERPに統合する手順を追った説明。

はじめに

また、このドキュメントはMicrosoft Word文書としてダウンロードすることもできます。ERP.docxへのCoupa請求書

一般的なAPI設定の考慮事項

限定されたペイロード:フィールドとAPIフィルター

CoupaのAPIは、デフォルトで多くのデータを返します(例:関連オブジェクトとしての全オブジェクト)。APIが返すペイロードは非常に大きくなる、したがって処理が遅くなる可能性があります。これは、リソースの無駄遣いは言うまでもなく、無関係なデータを必要としないお客様にとって問題となる可能性があります。

Coupaには、オブジェクトのスキーマ全体とすべての関連付けの代わりに、限定されたJSONまたはXML応答を返す「フィールド」パラメーターとAPIフィルターの概念があります。

この記事で説明する使用例

請求書には通常、ERPの内部番号があります。このドキュメントでは、このERPドキュメント番号がCoupa請求書ヘッダーのカスタムフィールドであることを前提としています。この例では、カスタムフィールドは名前 cf_erp_invoice_number で作成されています ERP Invoice Number。この記事では、Coupa請求書をERPに統合するための3つの異なるオプション(作成と更新の両方)について説明します。

これらのオプションにより、Coupaからインテグレーションを監視する方法が変更されます。

  • オプション1:請求書ヘッダーで定義したカスタムフィールドに基づくシンプルな監視
  • オプション2:インテグレーション履歴記録を使用した高度な監視
  • オプション3:Coupaインテグレーションの全監視を活用

3つのオプションの場合、Coupa請求書はエクスポートフラグに基づいてERPにプッシュされます。エラーが発生した場合、請求書のインテグレーションでは、Coupa UIの請求書に手動の変更が必要です。この変更によりエクスポートフラグがリセットされるため、請求書は次の実行で検討されます。

ヒント

Coupaでは、Coupaサポートに連絡して、「変更のたびに最後にエクスポートした請求書をリセット」というオプションを有効にするよう提案しています。 この設定はUIにのみ適用されます。 APIで行われた変更は、エクスポート済みステータスを変更しません。

APIの専用インテグレーションと連絡先を作成

オプション2および3の場合、次を作成する必要があります。

  1. 実装するAPIオーケストレーションごとに専用のインテグレーション
    invoice-integration-01.png
  2. インテグレーションに失敗した場合にアラートを受け取る、インテグレーションごとに1つまたは複数のインテグレーション連絡先
    invoice-integration-contact.png
ヒント

Coupaでは、Coupaサポートに連絡して、[ドキュメントタイプ別インテグレーション履歴へのリンクを有効にする]オプションを有効にするよう提案しています。 この設定により、設定ページにリンクが追加され、ドキュメントタイプごとに完全なインテグレーション履歴が表示されます。

オプション1:カスタムフィールドに基づくシンプルな監視

説明

このシナリオでは、請求書ごとに、1つまたは複数の請求書ヘッダーカスタムフィールドに現在のインテグレーションステータスを追加します。カスタムフィールドが cf-integration-status という名前で作成されましたIntegration Status。標準請求書データテーブルを使用して、次のURLでドキュメントのインテグレーションステータスを確認します https://<your instance hostname>/invoices

invoices-01.png

オーケストレーション図

orchestration-01.png

ステップ/ APIコールの詳細

手順1

ERPで作成/更新するCoupa請求書のリストと詳細を取得します。

選択基準には、[エクスポートフラグ ]と[請求書ステータス ] が含まれています。

方法

取得

API

https://<your instance hostname>/api/invoices/

クエリパラメーター

fields=<your API filter name>
offset=10
exported=false
status[in]=approved,voided

サンプルURL

https://<your instance hostname>/api/invoices?filter=<your API filter name>&offset=10&exported=false&status[in]=approved,voided

クエリ本文のサンプル

該当なし

返答本文のサンプル

response-01.png

手順2

個別の請求書をエクスポート済みとしてマーク

方法

プット

API

https:///api/invoices/

クエリパラメーター

exported=true
fields=["id","exported"]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>?exported=true&fields=["id","exported"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


{
		"id": <Invoice id>,
		"exported": true
}

手順3

レポートおよびERPドキュメント番号のカスタムフィールドを更新する

方法

プット

API

https://<your instance hostname>/api/invoices/<Invoice id>

クエリパラメーター

fields=["id","exported",{ "custom_fields": {} }]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>?fields=["id","exported",{ "custom_fields": {} }]

クエリ本文のサンプル


{ 
		"id": <Invoice_id>,
		"exported": true,
		"custom-fields": {
		"cf-erp-invoice-number": "<Invoice number in the ERP>",
		"cf-integration-status": "Success: The Invoice was replicated in your ERP"
			}
	}

または


{
		"custom-fields": {
		"cf-integration-status": "Failure: The Invoice could not be replicated in your ERP"
	}
}

返答本文のサンプル


{ 
		"id": <Invoice_id>,
		"exported": true,
		"custom-fields": {
				"cf-erp-invoice-number": "<Invoice number in the ERP>",
				"cf-integration-status": "Success: The Invoice was replicated in your ERP"
		}
}

または


{
		"id": <Invoice id>,
		"exported": true,
		"custom-fields": {
				"cf-erp-invoice-number": null,
				"cf-integration-status": "Error[2] : The Invoice was properly replicated in your ERP"
		}
}

オプション2:インテグレーション履歴を使用した高度な監視

説明

このシナリオでは、請求書ごとに次を実行します。

  • ドキュメントの以前のインテグレーション履歴記録を解決します
  • インテグレーション履歴記録を作成
  • エラーが発生した場合のインテグレーション連絡先へのアラートを作成する

各ドキュメントにはインテグレーション履歴の詳細が含まれていますinvoice-int-hist-02.png

invoice-int-hist-01.png

ドキュメントのインテグレーションステータスを確認するには、標準請求書インテグレーション履歴データテーブルを使用します。 次のサイトで確認できます https://<your instance hostname>/integration_history_records/invoices

invoice-int-records-01.png

応答コードのフィルターを使用して、正常にレプリケートされたドキュメントと失敗したドキュメントを区別できます。

invoice-int-records-02.png

オーケストレーション図

orchestration-02.png

ステップ/ APIコールの詳細

手順1

ERPで作成/更新するCoupa請求書のリストと詳細を取得します。
選択基準には、[エクスポートフラグ ]と[請求書ステータス ] が含まれています。

方法

取得

API

https://<your instance hostname>/api/invoices/

クエリパラメーター

filter=<your API filter name>
offset=10
exported=false
status[in]=approved,voided

サンプルURL

https://<your instance hostname>/api/invoices?filter=<your API filter name>&offset=10&exported=false&status[in]=approved,voided

クエリ本文のサンプル

該当なし

返答本文のサンプル

response-02.png

手順2

個別の請求書をエクスポート済みとしてマーク

方法

プット

API

https://<your instance hostname>/api/invoices/<Invoice id>

クエリパラメーター

exported=true
fields=["id","exported"]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>?exported=true&fields=["id","exported"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


{
		"id": <Invoice id>,
		"exported": true
}

ここで、ERPでの請求書の作成/更新が行われます。

手順3a

未解決のインテグレーション履歴記録を取得

方法

取得

API

https://<your instance hostname>/api/integration_history_records

クエリパラメーター

resolved=false
document-type=InvoiceHeader
document-id=<Invoice id>
fields=["id","document-id","status","resolved"]

サンプルURL

https://<your instance hostname>/api/integration_history_records?resolved=false&document-type=InvoiceHeader&document-id=<Invoice id>&fields=["id","document-id","status","resolved"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration History Record id>,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": false
		}
]

手順3b

以前のインテグレーション履歴記録を解決

方法

プット

API

https://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve

クエリパラメーター

fields=["id","document-id","status","resolved"]

サンプルURL

https://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve?fields=["id","document-id","status","resolved"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration History Record id>,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": true
		}
]

手順4a

ERPドキュメント番号のカスタムフィールドを更新する(成功)

方法

プット

API

https://<your instance hostname>/api/invoices/<Invoice id>

クエリパラメーター

fields=["id","exported",{ "custom_fields": {} }]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>&fields=["id","exported",{ "custom_fields": {} }]

クエリ本文のサンプル


{
		"custom-fields": {
		"cf-erp-invoice-number": "<Invoice number in the ERP>"
		}
}

返答本文のサンプル


{
		"id": <Invoice id>,
		"exported": true,
		"custom-fields": {
		"cf-erp-invoice-number": "<Invoice number in the ERP>"
		}
}

手順4b

インテグレーション履歴を作成(成功)

方法

プット

API

https://<your instance hostname>/api/integration_history_records

クエリパラメーター

fields=["id","document-id","status"]

サンプルURL

https://<your instance hostname>/api/integration_history_records?fields=["id","document-id","status"]

クエリ本文のサンプル


{
		"document-type": "InvoiceHeader",
		"document-id": <Invoice id>,
		"document-status":"<Invoice status>",
		"contact-alert-type": "Functional",
		"status": "Success",
		"integration": {"code":"<Customer Integration id>"},
		"responses": [
				{
						"response-code": "Success-1234",
						"response-message": "The integration in the ERP went well"
				}
		]
}

返答本文のサンプル


{
		"id": <New Integration History Record id>,
		"document-id": <Invoice id>,
		"status": "Success"
}

手順4c

インテグレーション履歴(エラー)を作成し、インテグレーション連絡先にアラートを送信します

方法

プット

API

https://<your instance hostname>/api/integration_history_records/create_alert

クエリパラメーター

fields=["id","document-id","status"]

サンプルURL

https://<your instance hostname>/api/integration_history_records/create_alert?fields=["id","document-id","status"]

クエリ本文のサンプル


{
		"document-type": "InvoiceHeader",
		"document-id": <Invoice id>,
		"document-status":"<Invoice status>",
		"contact-alert-type": "Functional",
		"status": "Error",
		"integration": {"code":"<Customer Integration id>"},
		"responses": [
				{
						"response-code": "Failure-CC",
						"response-message": "Header: Period is currently closed for Booking"
				},
				{
				"response-code": "Failure-CC",
				"response-message": "Line 1: Cost center CA234 is closed for invoicing"
				}
		]
}

返答本文のサンプル


{
		"id": <New Integration History Record id>,
		"document-id": <Invoice id>,
		"status": "Error"
}

オプション3:Coupaインテグレーションの完全監視を活用

説明

このシナリオでは、追跡するインテグレーション実行を作成します

  • インテグレーションのステータス(保留中/開始済み/エラー済み/成功/失敗)
  • 処理された請求書の総数
  • 成功とエラーの数
  • インテグレーションエラーとそのステータスのリスト(解決済みかどうか)

請求書ごとに以下を行います。

  • ドキュメントの以前のインテグレーション履歴記録を解決します
  • インテグレーション履歴記録を作成
  • エラーが発生した場合は、インテグレーションエラーとインテグレーション連絡先へのアラートを作成します

次のURLを使用して、インテグレーションのすべてのインテグレーション実行を監視できますhttps://<your instance hostname>/integrations/<your integration id>/integration_runs

po-api-integration-01.png

標準請求書インテグレーションエラーデータテーブルを使用して、インテグレーションエラーが解決待ちのすべての請求書を一覧表示します。 次のサイトで確認できます https://<your instance hostname>/integration_errors

inoice-int-records-03.png

オーケストレーション図

orchestration-03.png

ステップ/ APIコールの詳細

手順1

インテグレーション実行を作成

方法

投稿

API

https://<your instance hostname>/api/integration_runs

クエリパラメーター

該当なし

クエリ本文のサンプル


{
		"integration": {
				"code": "{{integration_code}}"
		}
}

返答本文のサンプル


{
		"id": <Integration Run ID>,
		...
}

手順2

ERPで作成/更新するCoupa請求書のリストと詳細を取得します。
選択基準には、[エクスポートフラグ ]と[請求書ステータス ] が含まれています。

方法

取得

API

https://<your instance hostname>/api/invoices/

クエリパラメーター

filter=<your API filter name>
offset=10
exported=false
status[in]=approved,voided

サンプルURL

https://<your instance hostname>/api/invoices?filter=<your API filter name>&offset=10&exported=false&status[in]=approved,voided

クエリ本文のサンプル

該当なし

返答本文のサンプル

response-03.png

手順3

インテグレーション実行の開始

方法

プット

API

https://<your instance hostname>/api/integration_runs/<Integration Run ID>/run

クエリパラメーター

該当なし

クエリ本文のサンプル


{
		"total_records": <Total Number of Invoices from Step 2>
}

返答本文のサンプル


{
		"id": <Integration Run ID>,
		...
}

手順4

個別の請求書をエクスポート済みとしてマーク

方法

プット

API

https://<your instance hostname>/api/invoices/<Invoice id>

クエリパラメーター

exported=true
fields=["id","exported"]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>?exported=true&fields=["id","exported"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


{
		"id": <Invoice id>,
		"exported": true
}

ここで、ERPでの請求書の作成/更新が行われます。

手順5a

未解決のインテグレーション履歴記録を取得

方法

取得

API

https://<your instance hostname>/api/integration_history_records

クエリパラメーター

resolved=false
document-type=InvoiceHeader
document-id=<Invoice id>
fields=["id","document-id","status","resolved"]

サンプルURL

https://<your instance hostname>/api/integration_history_records?resolved=false&document-type=InvoiceHeader&document-id=<Invoice id>&fields=["id","document-id","status","resolved"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration History Record id>,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": false
		}
]

手順5b

以前のインテグレーション履歴記録を解決

方法

プット

API

https://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve

クエリパラメーター

fields=["id","document-id","status","resolved"]

サンプルURL

https://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve?fields=["id","document-id","status","resolved"]

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration History Record id>,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": true
		}
]

手順6a

未解決のインテグレーションエラーレコードを取得

方法

取得

API

https://<your instance hostname>/api/integration_errors

クエリパラメーター

resolved=false
document-type=InvoiceHeader
document-id=<Invoice id>

サンプルURL

https://<your instance hostname>/api/integration_errors?resolved=false&document-type=InvoiceHeader&document-id=<Invoice id>

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration Error Record id>,
				"document-type": ”InvoiceHeader”,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": false
				...
		}
]

手順6b

以前のインテグレーション履歴記録を解決

方法

プット

API

https:///api/integration_errors//resolve

クエリパラメーター

該当なし

クエリ本文のサンプル

該当なし

返答本文のサンプル


[
		{
				"id": <Old Integration Error Record id>,
				"document-id": <Invoice id>,
				"status": "Error",
				"resolved": true
				...
		}
]

手順7a

ERPドキュメント番号のカスタムフィールドを更新する(成功)

方法

プット

API

https://<your instance hostname>/api/invoices/<Invoice id>

クエリパラメーター

fields=["id","exported",{ "custom_fields": {} }]

サンプルURL

https://<your instance hostname>/api/invoices/<Invoice id>?fields=["id","exported",{ "custom_fields": {} }]

クエリ本文のサンプル


{
		"custom-fields": {
		"cf-erp-invoice-number": "<Invoice number in the ERP>"
		}
}

返答本文のサンプル


{
		"id": <Invoice id>,
		"exported": true,
		"custom-fields": {
				"cf-erp-invoice-number": "<Invoice number in the ERP>"
		}
}

手順7b

インテグレーション履歴を作成(成功)
インテグレーション実行を参照する必要があります

方法

プット

API

https://<your instance hostname>/api/integration_history_records

クエリパラメーター

fields=["id","document-id","status"]

サンプルURL

https://<your instance hostname>/api/integration_history_records?fields=["id","document-id","status"]

クエリ本文のサンプル


{
		"document-type": "InvoiceHeader",
		"document-id": <Invoice id>,
		"document-status":"<Invoice status>",
		"contact-alert-type": "Functional",
		"status": "Success",
		"integration": {"code":"<Customer Integration id>"},
		"integration-run": {"id":<Integration Run ID>},
		"responses": [
				{
						"response-code": "Success-1234",
						"response-message": "The integration in the ERP went well"
				}
		]
}

返答本文のサンプル


{
		"id": <New Integration History Record id>,
		"document-id": <Invoice id>,
		"status": "Success"
}

手順7c

インテグレーションエラーを作成し、インテグレーション連絡先にアラート
インテグレーション実行を参照する必要があります

方法

プット

API

https://<your instance hostname>/api/integration_errors/create_alert

クエリパラメーター

該当なし

クエリ本文のサンプル


{
		"document-type": "InvoiceHeader",
		"document-id": <Invoice id>,
		"document-status":"<Invoice status>",
		"contact-alert-type": "Functional",
		"status": "Error",
		"integration-run-id": "<Integration Run ID>",
		"responses": [
				{
						"response-code": "Failure-CC",
						"response-message": "Header: Period is currently closed for Booking"
				},
				{
						"response-code": "Failure-CC",
						"response-message": "Line 1: Cost center CA234 is closed for invoicing"
				}
		]
}

返答本文のサンプル


{
		"id": <New Integration Error Record id>,
		"document-id": <Invoice id>,
		"status": "Error"
		...
}

手順8

インテグレーション実行を正常に終了

方法

プット

API

https://<your instance hostname>/api/integration_runs/<Integration Run ID>/success

クエリパラメーター

該当なし

クエリ本文のサンプル

該当なし

返答本文のサンプル


{
		"id": <Integration Run ID>,
		"status": "successful"
		...
}

インテグレーション実行中に一般的な障害が発生した場合。

手順x

インテグレーション実行の失敗を発生させる

方法

プット

API

https://<your instance hostname>/api/integration_runs/<Integration Run ID>/fail

クエリパラメーター

該当なし

クエリ本文のサンプル

該当なし

返答本文のサンプル


{
		"id": <Integration Run ID>,
		"status": "failed"
		...
}

このページに表示されている一部、または全ての内容は、機械翻訳によるものです。ご了承ください。

関連アイテム


Coupa Core API

CoupaのRESTful APIは、お客様のデータをCoupaプラットフォームで読み取り、編集し、統合するための堅牢なアクセスを提供します。

APIの開始

Coupa APIの使用に関する一般情報、およびCSVの使用を検討するタイミング。

OAuth 2.0およびOIDCへの移行

Coupaは従来のAPIキーを廃止し、OAuth 2.0 / OIDCの使用を必要としています。R34以降、新しいAPIキーは発行されず、R35ではAPIキーはサポートされなくなります。

リソース

参照データ、トランザクションデータ、共有リソースなど、オブジェクトのタイプ別にAPIエンドポイントを整理しました。