dcodegroup/laravel-xero-timesheet-sync
Composer 安装命令:
composer require dcodegroup/laravel-xero-timesheet-sync
包简介
This package provides the standard xero functionality for syncing timesheets from your app to Xero.
关键字:
README 文档
README
This package provides the standard xero functionality for syncing timesheets from your app to Xero.
Installation
You can install the package via composer:
composer require dcodegroup/laravel-xero-timesheet-sync
Then run the install command.
php artsian laravel-xero-timesheet-sync:install
This will publish the configuration file and the migrations.
Then run the migrations
php artsian migrate
This will add the following fields to timesheets table and create two new tables.
timesheets --- can_include_in_xero_sync tinyint(1) DEFAULT=0 units double(8,2) xero_timesheet_id unsignedbigint(255) FK >- xero_timesheets.id xero_timesheets --- id bigint(20) PK IDENTITY xerotimeable_type varchar(255) xerotimeable_id unsignedbigint xero_timesheet_guid varchar(50) NULL # The identifier returned from xero xero_employee_id varchar(50) NULL # may be redundant becuase its on the user that should be the polymporphic field. But saves a lookup status varchar(50) NULL DEFAULT=DRAFT start_date date stop_date date hours double(8,2) synced_at timestamp NULL deleted_at timestamp NULL created_at timestamp NULL updated_at timestamp NULL xero_timesheets_lines --- id bigint(20) PK IDENTITY xero_timesheet_id unsignedbigint(255) FK >- xero_timesheets.id xero-earnings_rate_id date date units double(8,2) units_override double(8,2) deleted_at timestamp NULL created_at timestamp NULL updated_at timestamp NULL
Configuration
Most of configuration has been set the fair defaults. However you can review the configuration file at config/laravel-xero-timesheet-sync.php and adjust as needed
You will need to add this field to your fillable array within the Timesheet model. Will not need this if you are extending the base timesheet model as that has guarded [].
/** * The attributes that are mass assignable. * * @var string[] */ protected $fillable = [ 'can_include_in_xero_sync', 'units', 'xero_timesheet_id' ... ];
It is suggested that you also cast the can_include_in_xero_sync as a boolean field in the Timesheet model.
/** * The attributes that should be cast. * * @var array */ //protected $casts = [ // 'can_include_in_xero_sync' => 'boolean', // ... //]; /** * Merge casts with the existing */ public function getCasts(): array { return parent::getCasts() + [ 'can_include_in_xero_sync' => 'boolean', ]; }
You should add the interface to the Timesheet::class model.
use Dcodegroup\LaravelXeroTimesheetSync\Contracts\SyncsTimesheetsToXero; class Timesheet extends BaseTimesheet implements SyncsTimesheetsToXero {
You should add the following trait to the Timesheet model.
class Timesheet extends Authenticatable { use XeroTimesheetable;
you need to implement these methods
In order for the timesheet row to be used / factored into sending to Xero the timesheets.can_include_in_xero_sync needs to be flagged / set as true or value 1.
This needs to be implemented at the local app level.
Three helper methods are provided in the XeroTimesheetable.php trait.
public function includeInXeroSync() { $this->update(['can_include_in_xero_sync', true]); } public function excludeFromXeroSync() { $this->update(['can_include_in_xero_sync', false]); } public function toggleIncludeInXeroSync() { $this->can_include_in_xero_sync = !$this->can_include_in_xero_sync; $this->save(); }
Routes
The following routes are exposed by the package
+--------+----------+-----------------------------+-----------------------------+-------------------------------------------------------------------------------------+----------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------------+-----------------------------+-------------------------------------------------------------------------------------+----------------------------------+
| | GET|HEAD | xero-timesheet-sync/preview | xero_timesheet_sync.preview | Dcodegroup\LaravelXeroTimesheetSync\Http\Controllers\XeroTimesheetPreviewController | web |
| | | | | | App\Http\Middleware\Authenticate |
| | GET|HEAD | xero-timesheet-sync/summary | xero_timesheet_sync.summary | Dcodegroup\LaravelXeroTimesheetSync\Http\Controllers\XeroTimesheetSummaryController | web |
| | | | | | App\Http\Middleware\Authenticate |
+--------+----------+-----------------------------+-----------------------------+-------------------------------------------------------------------------------------+----------------------------------+
The package exposes some routes that allow you preview timesheets for a user
You can also view a summary of the timesheets for a period
Jobs
Commands
There is a command you can run to update the Xero configurations from dcodegroup/laravel-xero-payroll-au via Laravels scheduler
php artsian laravel-xero-timesheet-sync:update-xero-configuration-data
You should add it to your app/Console/Kernel.php file to run it once a day. You could run it more often if wanted with the --force flag
/** * Define the application's command schedule. * * @param Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->command('laravel-xero-timesheet-sync:update-xero-configuration-data')->daily(); ... }
dcodegroup/laravel-xero-timesheet-sync 适用场景与选型建议
dcodegroup/laravel-xero-timesheet-sync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.59k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 09 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sync」 「laravel」 「xero」 「dcode」 「timesheets」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dcodegroup/laravel-xero-timesheet-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dcodegroup/laravel-xero-timesheet-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dcodegroup/laravel-xero-timesheet-sync 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel wrapper for Xero
An extension for using the Xero API from within Yii2
Symfony bundle wrapping the XeroPHP library
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
Sync content to other sites on element save.
Send invoices to Xero including contacts, payments and even inventory updates.
统计信息
- 总下载量: 2.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-28