Invoice imports, set auto_bill_enabled flag @ import time

This commit is contained in:
David Bomba
2026-06-06 08:41:06 +10:00
parent cb0bd6dce0
commit 6b01a2dd46
2 changed files with 31 additions and 0 deletions

View File

@@ -145,6 +145,7 @@ class InvoiceTransformer extends BaseTransformer
$this->getString($invoice_data, 'invoice.status')
))
] ?? Invoice::STATUS_SENT,
'auto_bill_enabled' => $this->company->getSetting('auto_bill_standard_invoices'),
// 'archived' => $status === 'archived',
];

View File

@@ -48,6 +48,36 @@ class InvoiceTest extends TestCase
}
public function testExplicitAutoBillDisabledOverridesCompanyDefault()
{
$settings = $this->company->settings;
$settings->auto_bill_standard_invoices = true;
$this->company->settings = $settings;
$this->company->save();
$this->client->group_settings_id = null;
$this->client->save();
$item = InvoiceItemFactory::create();
$item->quantity = 1;
$item->cost = 100;
$item->type_id = '1';
$data = [
'client_id' => $this->client->hashed_id,
'line_items' => [$item],
'auto_bill_enabled' => false,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices', $data)
->assertStatus(200);
$this->assertTrue($response->json('data.auto_bill_enabled'));
}
public function testClientIdMustBeInteger()
{
$line_items = [];