| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace Tests\Inventory;
- use App\InventoryAccount;
- use App\Services\common\BatchUpdateService;
- use Carbon\Carbon;
- use Tests\TestCase;
- class UpdateInventoryAccount extends TestCase
- {
- public $inventoryAccounts;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->inventoryAccounts=InventoryAccount::query()->get();
- }
- public function testUpdateInventoryAccount(){
- $updateParams = [[
- 'id','processed','ignored','updated_at'
- ]];
- $updated_at=Carbon::now()->toDateTimeString();
- foreach ($this->inventoryAccounts as $inventoryAccount){
- if ($inventoryAccount->getIgnoredAmount()>0){
- $updateParams[] = [
- 'id'=>$inventoryAccount->id,
- 'processed'=>$inventoryAccount->getProcessedAmount(),
- 'ignored' => $inventoryAccount->getIgnoredAmount(),
- 'updated_at'=>$updated_at,
- ];
- }
- }
- if(count($updateParams) > 1){
- $this->batchUpdate($updateParams);
- }
- }
- public function batchUpdate($params){
- return app(BatchUpdateService::class)->batchUpdate('inventory_accounts',$params);
- }
- }
|