定制 uccello/inventory 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

uccello/inventory

Composer 安装命令:

composer require uccello/inventory

包简介

This package allows to create inventory modules in a Uccello project.

README 文档

README

Thanks to this package it becomes very easy to transform an existing module into an accounting module (e.g. quote, order, invoice).

Install package

You can easily install this package using the following command line:

$ composer require uccello/inventory

$ php artisan vendor:publish --tag inventory-assets
$ php artisan vendor:publish --tag inventory-config

You can modify config/inventory.php and adapt the config.

Transform a classic module into an Inventory module

IsInventoryModule trait

Add the following lines to the model related to the module you want to transform into an Inventory Module. Here an example with Order module

<?php

  ....

  use Uccello\Inventory\Support\Traits\IsInventoryModule;

  class Order
  {
    use IsInventoryModule;

    protected $inventoryMapping = [
        'header' => [
            'total_excl_tax' => 'total_excl_tax', // Replace the value by the name of the field in your module (for automatic update)
            'total_incl_tax' => 'total_incl_tax', // Replace the value by the name of the field in your module (for automatic update)
            'total_vat' => 'total_vat', // Replace the value by the name of the field in your module (for automatic update)
        ],

      	// Replace all values by your columns names
        'lines' => [
            'related_id' => 'order_id',
            'product_uuid' => 'product_uuid',
            'label' => 'label',
            'description' => 'description',
            'vat_rate' => 'vat_rate',
            'unit_price' => 'unit_price',
            'price_type' => 'price_type',
            'quantity' => 'qty',
            'unit' => 'unit',
            'price_excl_tax' => 'price_excl_tax',
            'price_incl_tax' => 'price_incl_tax',
            'sequence' => 'sequence',
        ],
    ];

    public function lines() // This relation must be called "lines"
    {
        return $this->hasMany(OrderLine::class)->orderBy('sequence'); // Replace OrderLine by the model class you use for saving the lines
    }

    // ...
  }

Create a migration

Create a new migration and create the table that will contains all lines

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Uccello\Core\Models\Module;

class AlterOrderLinesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('order_lines', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('order_id')->nullable();
            $table->unsignedInteger('product_id')->nullable();
            $table->string('product_uuid')->nullable();
            $table->string('label')->nullable();
            $table->text('description')->nullable();
            $table->decimal('vat_rate', 5, 2)->nullable();
            $table->decimal('unit_price', 13, 2)->nullable();
            $table->string('price_type')->nullable();
            $table->decimal('qty', 13, 2)->nullable();
            $table->decimal('price', 13, 2)->nullable();
            $table->string('unit')->nullable();
            $table->decimal('price_excl_tax', 13, 2)->nullable();
            $table->decimal('price_incl_tax', 13, 2)->nullable();
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
            $table->foreign('product_id')->references('id')->on('crm_products');
        });

        // Update module data
        $module = Module::where('name', 'order')->first();
        $module->data = [
            'private' => true,
            'header' => [
                'total_excl_tax' => 'total_excl_tax',
                'total_incl_tax' => 'total_incl_tax',
                'total_vat' => 'total_vat',
            ],
            'related_modules' => [ // You can add as many modules as you want
                'product' =>  [ // Name of the related module
                    'search' => 'name', // The name of the field you want use to search from the inventory line
                  	// Replace mapping values with the name of product fields if exist
                    'mapping' => [
                        'unit_price' => 'unit_price',
                      	'label' => 'label',
                      	'description' => 'description',
                      	'vat_rate' => 'vat_rate',
                      	'unit_price' => 'unit_price',
                      	'unit' => 'unit'
                    ],
                ]
            ],
        ];
        $module->save();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_lines');

        // Update module data
        $module = Module::where('name', 'order')->first();
        $module->data = null;
        $module->save();
    }
}

Override views

  • Create or edit your module edit view (e.g. resources/views/uccello/modules/order/edit/main.blade.php):

    @extends('uccello::modules.default.edit.main')
    
    @section('other-blocks')
        @include('inventory::lines.edit')
    
        @include('inventory::total.edit')
    @endsection
  • Create or edit your module detail view (e.g. resources/views/uccello/modules/order/detail/main.blade.php):

    @extends('uccello::modules.default.detail.main')
    
    @section('other-blocks')
        @include('inventory::lines.detail')
    
        @include('inventory::total.detail')
    @endsection

License

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

uccello/inventory 适用场景与选型建议

uccello/inventory 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 uccello/inventory 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-30