Skip to content

Commit

Permalink
Merge pull request #23 from ingrammicro/v15-development
Browse files Browse the repository at this point in the history
Record ID must be specified by vendor
  • Loading branch information
marcserrat authored Mar 18, 2019
2 parents 2637a02 + b135ac7 commit 6057883
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class UploadUsage extends \Connect\UsageAutomation
date_default_timezone_set('UTC'); //reporting must be always based on UTC
$usages = [];
array_push($usages, new Connect\Usage\FileUsageRecord([
'record_id' => 'unique record value',
'item_search_criteria' => 'item.mpn', //Possible values are item.mpn or item.local_id
'item_search_value' => 'SKUA', //Value defined as MPN on vendor portal
'quantity' => 1, //Quantity to be reported
Expand Down
1 change: 1 addition & 0 deletions src/Usage/FileUsageRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class FileUsageRecord extends \Connect\Model
{
public $record_id;
public $item_search_criteria;
public $item_search_value;
public $quantity;
Expand Down
11 changes: 5 additions & 6 deletions src/UsageAutomation.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ public function createUsageFile(Usage\File $usageFile)

}


/**
* @return Spreadsheet
* @throws Usage\FileCreationException
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
private function createUsageSpreadSheet()
{
Expand Down Expand Up @@ -293,16 +294,14 @@ private function uploadSpreadSheet(
/**
* @param $fileusagerecords
* @return Spreadsheet
* @throws Usage\FileCreationException
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
private function createAndPopulateSpreadSheet(
$fileusagerecords
) {
private function createAndPopulateSpreadSheet( $fileusagerecords )
{
$spreadSheet = $this->createUsageSpreadSheet();
$spreadSheet->setActiveSheetIndexByName('usage_records');
for ($i = 0; $i < count($fileusagerecords); $i++) {
$spreadSheet->getActiveSheet()->setCellValue('A' . ($i + 2), $i + 1);
$spreadSheet->getActiveSheet()->setCellValue('A' . ($i + 2), $fileusagerecords[$i]->record_id);
$spreadSheet->getActiveSheet()->setCellValue('B' . ($i + 2), $fileusagerecords[$i]->item_search_criteria);
$spreadSheet->getActiveSheet()->setCellValue('C' . ($i + 2), $fileusagerecords[$i]->item_search_value);
$spreadSheet->getActiveSheet()->setCellValue('D' . ($i + 2), $fileusagerecords[$i]->quantity);
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/UsageAutomationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function processUsageForListing($listing)
date_default_timezone_set('UTC');
$usages = [];
array_push($usages, new FileUsageRecord([
'record_id' => '123',
'item_search_criteria' => 'item.mpn',
'item_search_value' => 'SKUA',
'quantity' => 1,
Expand Down

0 comments on commit 6057883

Please sign in to comment.