feat: 注册种菜报销工单明细批处理 #895

Merged
qiuxiang merged 1 commits from feature/qiuxiang-planting-october-batch-import into main 2026-11-05 14:42:47 +08:00
4 changed files with 45 additions and 1 deletions

View File

@ -23,6 +23,7 @@
"jst-order-labels:import",
"business:import-jushuitan-shop-balances",
"pinduoduo-bills:import-authoritative",
"planting-details:sync-work-orders",
"planting-details:import",
"product-catalog:import-authoritative-export",
"product:monthly-weighted-average:base",

View File

@ -8,7 +8,7 @@ is_import=0
CAIWU_BATCH_CALLER_DIR="$PWD"
export CAIWU_BATCH_CALLER_DIR
case "${1:-}" in
*:import|*:import-*|*:import:*|product:monthly-weighted-average:base) is_import=1 ;;
*:import|*:import-*|*:import:*|product:monthly-weighted-average:base|planting-details:sync-work-orders) is_import=1 ;;
jushuitan:sync-shipping|store-receipt:order-match:sync|store-receipt:product-cost:sync|store-receipt:auto-resync|order-data:warm-shop-candidates|business-mirror:sync-tables|business-mirror:sync-ding-process-details|business-mirror:process-ding-refresh-requests|business-mirror:index-work-order-waybills|business-mirror:refresh-paid-sales|account-bills:exports:run|finance-ledger:recalculate|product:monthly-weighted-average:auto|product:monthly-weighted-average:compute|product:monthly-weighted-average:report|finance:monthly-weighted-product-cost:auto) ;;
*) echo 'Unsupported finance batch command' >&2; exit 64 ;;
esac

View File

@ -108,6 +108,36 @@ class FinanceBatchIsolationTest extends TestCase
}
}
public function test_planting_work_order_sync_uses_the_isolated_import_entry(): void
{
$directory = sys_get_temp_dir() . '/caiwu-planting-import-' . bin2hex(random_bytes(6));
mkdir($directory);
file_put_contents($directory . '/run-finance-import.py', '');
file_put_contents(
$directory . '/python3',
'#!/bin/sh' . "\n" . 'printf "%s\n" "$@" > "$CAIWU_CAPTURE"' . "\n",
);
chmod($directory . '/python3', 0700);
try {
$process = $this->runBatch($directory, [
'planting-details:sync-work-orders',
'--month=2026-10',
]);
$this->assertTrue($process->isSuccessful(), $process->getErrorOutput());
$arguments = file($directory . '/called', FILE_IGNORE_NEW_LINES);
$this->assertContains($directory . '/run-finance-import.py', $arguments);
$this->assertContains('planting-details:sync-work-orders', $arguments);
$this->assertContains('--month=2026-10', $arguments);
} finally {
foreach (glob($directory . '/*') as $path) {
unlink($path);
}
rmdir($directory);
}
}
public function test_business_mirror_history_backfill_runs_in_the_isolated_batch_profile(): void
{
$directory = sys_get_temp_dir() . '/caiwu-mirror-batch-' . bin2hex(random_bytes(6));

View File

@ -51,6 +51,19 @@ class FinanceImportRuntimeTest extends TestCase
(new RequireImportBatchContainer())->handle($this->starting('product:monthly-weighted-average:base'));
}
public function test_work_order_sync_is_registered_as_a_protected_import(): void
{
config([
'finance_batch.import_commands' => [
'planting-details:sync-work-orders',
],
]);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('run-finance-batch.sh');
(new RequireImportBatchContainer())->handle($this->starting('planting-details:sync-work-orders'));
}
public function test_production_batch_runtime_can_import_and_health_checks_stay_available(): void
{
$listener = new RequireImportBatchContainer();