vormkracht10/wefact-php

PHP 包,提供与 WeFact 通信的流畅接口

v0.6.2 2023-10-09 23:16 UTC

This package is auto-updated.

Last update: 2024-09-26 06:46:42 UTC


README

GitHub release (latest by date) Tests Packagist PHP Version Support Latest Version on Packagist Total Downloads

此包提供与 WeFact API 通信的流畅接口。有关 WeFact API 的完整文档,请访问 https://www.wefact.nl/api/

目录

最低要求

  • PHP 8.1 或更高版本
  • Guzzle 7.0 或更高版本

安装

您可以通过 composer 安装此包

composer require vormkracht10/wefact-php

用法

然后您可以像这样使用此包

$weFact = new \Vormkracht10\WeFact\WeFact('your-api-key');

$response = $weFact->invoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->invoices()->listAll();

if (isset($response['invoices'])) {
  print_r($response['invoices']);
}

可用方法

债权人

列出债权人

$response = $weFact->creditors()->list();
// or use listAll to call the show method for each item
$response = $weFact->creditors()->listAll();

if (isset($response['creditors'])) {
  print_r($response['creditors']);
}

创建债权人

必需参数: CompanyNameSurName

$response = $weFact->creditors()->create([
    'CompanyName' => 'Your company name',
  ]);
if ($result['status'] == 'success') {
  print_r($response['company']);
}

更新债权人

必需参数: IdentifierCreditorCode

$result = $weFact->creditors()->edit([
    'Identifier' => $creditorId,
    'CompanyName' => 'Your company name',
  ]);

if ($result['status'] == 'error') {
  // Something went wrong
  print_r($result['errors']);
}

显示债权人

必需参数: IdentifierCreditorCode

$weFact->creditors()->show(['Identifier' => $creditorId]);
// or
$weFact->creditors()->show(['CreditorCode' => $creditorCode]);

删除债权人

必需参数: IdentifierCreditorCode

$weFact->creditors()->delete(['Identifier' => $creditorId]);
// or
$weFact->creditors()->delete(['CreditorCode' => $creditorCode]);

信用发票

列出信用发票

$weFact->creditInvoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->creditInvoices()->listAll();

创建信用发票

必需参数: InvoiceCodeCreditorCreditorCodeInvoiceLines

$weFact->creditInvoices()->create([
    'InvoiceCode' => 'your-invoice-code',
    'CreditorCode' => 'CD10001'
    'InvoiceLines' => [
        [
            'Description' => 'Your description',
            'PriceExcl' => 10,
        ],
    ],
  ])

更新信用发票

必需参数: IdentifierCreditInvoiceCode

$weFact->creditInvoices()->edit([
    'Identifier' => $creditInvoiceId,
    'Comment' => 'Your comment',
  ])

显示信用发票

必需参数: IdentifierCreditInvoiceCode

$weFact->creditInvoices()->show(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->show(['CreditInvoiceCode' => $creditInvoiceCode]);

删除信用发票

必需参数: IdentifierCreditInvoiceCode

$weFact->creditInvoices()->delete(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->delete(['CreditInvoiceCode' => $creditInvoiceCode]);

债务人

列出债务人

$weFact->debtors()->list();
// or use listAll to call the show method for each item
$response = $weFact->debtors()->listAll();

您也可以搜索债务人

$weFact->debtors()->list([
  'searchat' => 'EmailAddress',
  'searchfor' => 'example@example.com'
]);

创建债务人

必需参数: CompanyNameSurName

$weFact->debtors()->create([
    'CompanyName' => 'Your company name',
  ])

更新债务人

必需参数: IdentifierDebtorCodeCompanyNameSurName

$weFact->debtors()->edit([
    'Identifier' => $debtorId,
    'CompanyName' => 'Your company name',
  ])

显示债务人

必需参数: IdentifierDebtorCode

$weFact->debtors()->show(['Identifier' => $debtorId]);
// or
$weFact->debtors()->show(['DebtorCode' => $debtorCode]);

分组

列出分组

必需参数: Type

$weFact->groups()->list([
    'type' => 'debtor',
]);

创建分组

必需参数: TypeGroupName

$weFact->groups()->create([
    'Type' => 'debtor',
    'GroupName' => 'Your group name',
  ])

更新分组

必需参数: Identifier

$weFact->groups()->edit([
    'Identifier' => $groupId,
    'GroupName' => 'Your group name',
  ])

显示分组

必需参数: Identifier

$weFact->groups()->show(['Identifier' => $groupId]);

删除分组

必需参数: Identifier

$weFact->groups()->delete(['Identifier' => $groupId]);

发票

列出发票

$weFact->invoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->invoices()->listAll();

创建发票

必需参数: DebtorCodeDebtorCodeInvoiceLines

$weFact->invoices()->create([
    'DebtorCode' => 'DB10000',
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
    [
      'Description' => 'Your product description',
      'PriceExcl' => 100
    ]
  ])

更新发票

必需参数: IdentifierInvoiceCode

$weFact->invoices()->edit([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
    [
      'Description' => 'Your product description',
      'PriceExcl' => 100
    ]
  ])

显示发票

必需参数: IdentifierInvoiceCode

$weFact->invoices()->show(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->show(['InvoiceCode' => $invoiceCode]);

删除发票

必需参数: IdentifierInvoiceCode

$weFact->invoices()->delete(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->delete(['InvoiceCode' => $invoiceCode]);

信用

必需参数: IdentifierInvoiceCode

$weFact->invoices()->credit(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->credit(['InvoiceCode' => $invoiceCode]);

部分付款

必需参数: IdentifierInvoiceCode

$weFact->invoices()->partPayment(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->partPayment(['InvoiceCode' => $invoiceCode]);

标记发票为已付款

必需参数: IdentifierInvoiceCode

$weFact->invoices()->markAsPaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsPaid(['InvoiceCode' => $invoiceCode]);

标记发票为未付款

必需参数: IdentifierInvoiceCode

$weFact->invoices()->markAsUnpaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsUnpaid(['InvoiceCode' => $invoiceCode]);

通过电子邮件发送

必需参数: IdentifierInvoiceCode

$weFact->invoices()->sendByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendByEmail(['InvoiceCode' => $invoiceCode]);

通过电子邮件发送提醒

必需参数: IdentifierInvoiceCode

$weFact->invoices()->sendReminderByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendReminderByEmail(['InvoiceCode' => $invoiceCode]);

下载

必需参数: IdentifierInvoiceCode

$weFact->invoices()->download(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->download(['InvoiceCode' => $invoiceCode]);

锁定

必需参数: IdentifierInvoiceCode

$weFact->invoices()->block(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->block(['InvoiceCode' => $invoiceCode]);

解锁

必需参数: IdentifierInvoiceCode

$weFact->invoices()->unblock(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->unblock(['InvoiceCode' => $invoiceCode]);

计划

必需参数: IdentifierInvoiceCodeScheduledAt

$weFact->invoices()->schedule([
    'Identifier' => $invoiceId,
    'ScheduledAt' => '2020-01-01 00:00:00'
  ])
// or
$weFact->invoices()->schedule([
    'InvoiceCode' => $invoiceCode,
    'ScheduledAt' => '2020-01-01 00:00:00'
  ])

取消计划

必需参数: IdentifierInvoiceCode

$weFact->invoices()->cancelSchedule(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->cancelSchedule(['InvoiceCode' => $invoiceCode]);

暂停付款流程

必需参数: IdentifierInvoiceCode

$weFact->invoices()->paymentProcessPause(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessPause(['InvoiceCode' => $invoiceCode]);

重新激活付款流程

必需参数: IdentifierInvoiceCode

$weFact->invoices()->paymentProcessReactivate(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessReactivate(['InvoiceCode' => $invoiceCode]);

排序行

必需参数: IdentifierInvoiceCodeInvoiceLines Identifier

$weFact->invoices()->sortLines([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Identifier' => $invoiceLineId,
      ]
    ]
  ]);

添加发票行

必需参数: IdentifierInvoiceCodeInvoiceLines

$weFact->invoices()->addLine([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
  ]);

删除发票行

必需参数: IdentifierInvoiceCodeInvoiceLines Identifier

$weFact->invoices()->deleteLine([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Identifier' => $invoiceLineId,
      ]
    ]
  ]);

添加附件

必需参数:ReferenceIdentifierInvoiceCode TyoeFilenameBase64

$weFact->invoices()->addAttachment([
    'ReferenceIdentifier' => $invoiceId,
    'Type' => 'invoice',
    'Filename' => 'test.pdf',
    'Base64' => 'base64string'
  ]);

删除附件

必需参数:IdentifierFilenameReferenceIdentifierInvoiceCodeType

$weFact->invoices()->deleteAttachment([
    'Identifier' => $attachmentId,
    'ReferenceIdentifier' => $invoiceId,
    'Type' => 'invoice',
  ]);

下载附件

必需参数:IdentifierFilenameReferenceIdentifierInvoiceCodeType

$weFact->invoices()->downloadAttachment([
    'ReferenceIdentifier' => $invoiceId,
    'Filename' => 'test.pdf',
    'Type' => 'invoice',
  ]);

产品

列出产品

$weFact->products()->list();
// or use listAll to call the show method for each item
$response = $weFact->products()->listAll();

创建产品

必需参数:ProductNameProductKeyPhrasePriceExcl

$weFact->products()->create([
    'ProductName' => 'Your product name',
    'ProductKeyPhrase' => 'Your product key phrase',
    'PriceExcl' => 100
  ])

更新产品

必需参数:IdentifierProductCode

$weFact->products()->edit([
    'Identifier' => $productId,
    'ProductName' => 'Your product name',
    'ProductKeyPhrase' => 'Your product key phrase',
    'PriceExcl' => 100
  ])

显示产品

必需参数:Identifier

$weFact->products()->show(['Identifier' => $productId]);

删除产品

必需参数:IdentifierProductCode

$weFact->products()->delete(['Identifier' => $productId]);
// or
$weFact->products()->delete(['ProductCode' => $productCode]);

设置

列出设置

$weFact->settings()->list();

设置 - 成本类别

列出成本类别

$weFact->costCategories()->list();
// or use listAll to call the show method for each item
$response = $weFact->costCategories()->listAll();

创建成本类别

必需参数:Title

$weFact->costCategories()->create([
    'Title' => 'Your cost category title',
  ]);

更新成本类别

必需参数: Identifier

$weFact->costCategories()->edit([
  'Identifier' => $costCategoryId,
]);

显示成本类别

必需参数: Identifier

$weFact->costCategories()->show(['Identifier' => $costCategoryId]);

删除成本类别

必需参数: Identifier

$weFact->costCategories()->delete(['Identifier' => $costCategoryId]);

订阅

列出订阅

$weFact->subscriptions()->list();
// or use listAll to call the show method for each item
$response = $weFact->subscriptions()->listAll();

创建订阅

必需参数:DebtorDebtorCodeProductCode。当 ProductCode 为空时,需要 DescriptionPriceExclPeriodic

请注意:您可以选择传递 TerminateAfterTerminationDate 中的一个,但不能同时传递两者。TerminateAfter 包含过去已计费订阅的次数。

$weFact->subscriptions()->create([
    'DebtorCode' => 'DB10000',
    'ProductCode' => 'P0001',
    'Description' => 'Your product description',
    'PriceExcl' => 100,
    'Periodic' => 'month',
    'TerminateAfter' => 12
  ])

更新订阅

必需参数: Identifier

请注意:您可以选择传递 TerminateAfterTerminationDate 中的一个,但不能同时传递两者。TerminateAfter 包含过去已计费订阅的次数。

$weFact->subscriptions()->edit([
    'Identifier' => $subscriptionId,
    'Description' => 'Your product description',
    'PriceExcl' => 100,
    'Periodic' => 'month',
    'TerminateAfter' => 12
  ])

显示订阅

必需参数: Identifier

$weFact->subscriptions()->show(['Identifier' => $subscriptionId]);

终止订阅

必需参数: Identifier

$weFact->subscriptions()->terminate(['Identifier' => $subscriptionId]);

测试

composer test

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG

贡献

有关详细信息,请参阅 CONTRIBUTING

安全漏洞

请审查我们的安全策略,了解如何报告安全漏洞:我们的安全策略

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件