fix: 兼容供应商汇总金额前导加号公式 (#1221)
This commit is contained in:
parent
1dbcc7794d
commit
7d9f3d7bd1
@ -466,7 +466,7 @@ class SupplierSummaryInboundImporter
|
||||
|
||||
if (
|
||||
preg_match(
|
||||
'/^=?\s*\$?([A-Z]{1,3})\$?(\d+)\s*\*\s*\$?([A-Z]{1,3})\$?(\d+)\s*$/i',
|
||||
'/^[=+]?\s*\$?([A-Z]{1,3})\$?(\d+)\s*\*\s*\$?([A-Z]{1,3})\$?(\d+)\s*$/i',
|
||||
$formula,
|
||||
$matches,
|
||||
) !== 1
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
|
||||
namespace Tests\Feature\Console;
|
||||
|
||||
use App\Business\SupplierSummaryInboundImporter;
|
||||
use App\Models\Business\InventoryWarehouseNameMapping;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use ReflectionMethod;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class SupplierSummaryInboundImportTest extends FeatureTestCase
|
||||
@ -107,6 +109,41 @@ class SupplierSummaryInboundImportTest extends FeatureTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function test_amount_formulas_accept_excel_leading_plus(): void
|
||||
{
|
||||
$importer = new SupplierSummaryInboundImporter();
|
||||
$method = new ReflectionMethod($importer, 'formulaValue');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$values = array_fill(0, 20, null);
|
||||
$values[7] = 2; // H: 库存变动量
|
||||
$values[8] = 10; // I: 单价
|
||||
$values[10] = 11; // K: 预估单价
|
||||
$columns = [
|
||||
'quantity' => 7,
|
||||
'unit_price' => 8,
|
||||
'estimated_unit_price' => 10,
|
||||
'estimated_amount' => 11,
|
||||
];
|
||||
|
||||
$this->assertSame(
|
||||
20.0,
|
||||
$method->invoke($importer, '金额', 'amount', '+H2*I2', 2, $values, $columns),
|
||||
);
|
||||
$this->assertSame(
|
||||
22.0,
|
||||
$method->invoke(
|
||||
$importer,
|
||||
'预估金额',
|
||||
'estimated_amount',
|
||||
'+K2*H2',
|
||||
2,
|
||||
$values,
|
||||
$columns,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private function writeWorkbook(
|
||||
string $path,
|
||||
string $provider,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user