chrislorando/laravel-accurate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chrislorando/laravel-accurate

Composer 安装命令:

composer require chrislorando/laravel-accurate

包简介

Laravel package for Accurate Online API integration.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel package for integrating with the Accurate Online accounting API. Provides OAuth 2.0 authentication, database management, and a fluent API client.

📘 Refer to the Accurate Online API Documentation for full API reference.

Installation

You can install the package via composer:

composer require chrislorando/laravel-accurate

You can publish and run the migrations with:

php artisan vendor:publish --tag="accurate-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="accurate-config"

This is the contents of the published config file:

return [
    'client_id' => env('ACCURATE_CLIENT_ID'),
    'client_secret' => env('ACCURATE_CLIENT_SECRET'),
    'redirect_uri' => env('ACCURATE_REDIRECT_URI'),
    'base_url' => env('ACCURATE_BASE_URL', 'https://account.accurate.id'),
    'timeout' => 30,
    'verify_ssl' => true,
    'scopes' => ['item_view', 'invoice_view', 'customer_view'],
];

Usage

OAuth Connect Flow

Add the following environment variables to your .env:

ACCURATE_BASE_URL=https://account.accurate.id
ACCURATE_CLIENT_ID=your-client-id
ACCURATE_CLIENT_SECRET=your-client-secret
ACCURATE_REDIRECT_URI=https://your-app.test/accurate/callback

Then register the callback route in your routes/web.php:

use ChrisLorando\LaravelAccurate\Http\Controllers\CallbackController;

Route::get('accurate/callback', CallbackController::class)->name('accurate.callback');

Then visit /accurate/connect to start the OAuth flow.

Using the Facade

use ChrisLorando\LaravelAccurate\Facades\Accurate;

// Get the authorization URL
$url = Accurate::authorizationUrl();

// Get database list for a connection
$databases = Accurate::connection('default')->databases();

// Open a specific database
$db = Accurate::connection('default')->openDatabase('123456');

Resource API (Item)

Every Accurate resource (item, customer, invoice, etc.) exposes CRUD operations via a consistent resource class.

Basic CRUD

$items = Accurate::connection('default')
    ->openDatabase('2759883')
    ->items();

// List all items
$all = $items->list(['sp.pageSize' => 20]);

// Get a single item by ID
$detail = $items->detail('53');

// Create or update an item
$saved = $items->save([
    'name'     => 'Kabel USB-C',
    'itemType' => 'INVENTORY',
    'unit1Name'=> 'Pcs',
]);

// Delete an item by ID
$items->delete('53');

// Bulk save (max 100 items per request)
$items->bulkSave([
    'data' => [
        ['name' => 'Item A', 'itemType' => 'INVENTORY'],
        ['name' => 'Item B', 'itemType' => 'INVENTORY'],
    ],
]);

Query Builder

Fluent query builder with filter, sort, pagination, and shorthand operators:

$results = Accurate::connection('default')
    ->openDatabase('2759883')
    ->items()
    ->query()
    ->select('id', 'no', 'name', 'unit1NameWarehouse')
    ->where('keywords', 'like', 'Kabel')     // CONTAIN search
    ->where('itemType', 'INVENTORY')         // EQUAL (default)
    ->where('unitPrice', '>', 10000)         // GREATER_THAN
    ->orderBy('name', 'asc')
    ->limit(20)
    ->page(1)
    ->get();

// Get single record (or null)
$first = Accurate::connection('default')
    ->openDatabase('2759883')
    ->items()
    ->query()
    ->select('id', 'name')
    ->orderBy('id', 'desc')
    ->first();

// Paginate with metadata (sp.page, sp.pageSize, sp.totalPage, sp.totalData)
$paged = Accurate::connection('default')
    ->openDatabase('2759883')
    ->items()
    ->query()
    ->select('id', 'name')
    ->where('keywords', 'like', 'Kabel')
    ->limit(10)
    ->paginate();

// $paged['data']  → array of items
// $paged['sp']    → pagination metadata (page, pageSize, totalPage, totalData)

Shorthand Operator Mapping

Argument Accurate Operator Example
2-arg where(field, value) EQUAL where('itemType', 'INVENTORY')
> / gt GREATER_THAN where('price', '>', 100)
>= / gte GREATER_EQUAL_THAN where('price', '>=', 100)
< / lt LESS_THAN where('price', '<', 100)
<= / lte LESS_EQUAL_THAN where('price', '<=', 100)
!= / <> NOT_EQUAL where('name', '!=', 'test')
like / LIKE CONTAIN where('keywords', 'like', 'Kabel')
between BETWEEN where('price', 'between', [1,100])
not_between NOT_BETWEEN where('price', 'not_between', [1,100])
empty EMPTY where('name', 'empty')
not_empty NOT_EMPTY where('name', 'not_empty')
Accurate-native pass-through where('name', 'EQUAL', 'test')

Note: CONTAIN operator only works on filter.keywords field. Use where('keywords', 'like', '...') for partial text search.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

chrislorando/laravel-accurate 适用场景与选型建议

chrislorando/laravel-accurate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Accounting」 「accurate」 「accurate-online」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 chrislorando/laravel-accurate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 chrislorando/laravel-accurate 我们能提供哪些服务?
定制开发 / 二次开发

基于 chrislorando/laravel-accurate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15