CaiWuXiTong/tests/Unit/EcommerceFinance/SupplierReturnAccountingTest.php

82 lines
3.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Tests\Unit\EcommerceFinance;
use Modules\EcommerceFinance\Services\SupplierReturnAccounting;
use PHPUnit\Framework\TestCase;
class SupplierReturnAccountingTest extends TestCase
{
public function test_logistics_adjustment_keeps_supplier_net_amount_and_tracks_logistics_part(): void
{
$row = (new SupplierReturnAccounting())->enrich([
'qty' => '1',
'unit_price' => '259',
'amount' => '259',
'remark' => '原数量2件,CZ008407N1178V01*1记账物流',
'title' => '常州松宇货运',
]);
$this->assertSame('物流', $row['_accounting_target']);
$this->assertSame('转物流记账', $row['_accounting_label']);
$this->assertSame('不扣本厂家,转常州松宇货运记账', $row['_accounting_note']);
$this->assertSame(1.0, $row['_logistics_qty']);
$this->assertSame(259.0, $row['_logistics_amount']);
$this->assertSame(1.0, $row['_supplier_qty']);
$this->assertSame(259.0, $row['_supplier_amount']);
}
public function test_summary_matches_finance_and_supplier_views(): void
{
$summary = (new SupplierReturnAccounting())->summarize([
[
'qty' => '1',
'unit_price' => '259',
'amount' => '259',
'remark' => '原数量2件,CZ008407N1178V01*1记账物流',
'title' => '常州松宇货运',
],
[
'qty' => '3',
'unit_price' => '250',
'amount' => '750',
'remark' => '原数量4件,CZ008412N1178V01*1记账物流',
'title' => '常州松宇货运',
],
[
'qty' => '2',
'unit_price' => '30',
'amount' => '60',
'remark' => '不记账厂家',
'title' => '',
],
]);
$this->assertSame(3, $summary['count']);
$this->assertSame(2, $summary['supplier_rows']);
$this->assertSame(4.0, $summary['supplier_qty']);
$this->assertSame(1009.0, $summary['supplier_amount']);
$this->assertSame(2, $summary['logistics_rows']);
$this->assertSame(2.0, $summary['logistics_qty']);
$this->assertSame(509.0, $summary['logistics_amount']);
$this->assertSame(['常州松宇货运'], $summary['logistics_companies']);
$this->assertSame(1, $summary['no_bookkeeping_rows']);
}
public function test_full_amount_row_is_reduced_when_quantity_was_not_pre_split(): void
{
$row = (new SupplierReturnAccounting())->enrich([
'qty' => '4',
'unit_price' => '250',
'amount' => '1000',
'remark' => '原数量4件,CZ008412N1178V01*1记账物流',
'title' => '常州松宇货运',
]);
$this->assertSame(1.0, $row['_logistics_qty']);
$this->assertSame(250.0, $row['_logistics_amount']);
$this->assertSame(3.0, $row['_supplier_qty']);
$this->assertSame(750.0, $row['_supplier_amount']);
}
}