1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for exports

This commit is contained in:
David Bomba 2023-10-20 09:39:25 +11:00
parent aca580780a
commit e54dec8762
5 changed files with 23 additions and 20 deletions

View File

@ -127,18 +127,18 @@ class PurchaseOrderItemExport extends BaseExport
if (str_contains($key, "item.")) {
$key = str_replace("item.", "", $key);
$tmp_key = str_replace("item.", "", $key);
if($key == 'type_id') {
$keyval = 'type';
if($tmp_key == 'type_id') {
$tmp_key = 'type';
}
if($key == 'tax_id') {
$keyval = 'tax_category';
if($tmp_key == 'tax_id') {
$tmp_key = 'tax_category';
}
if (property_exists($item, $key)) {
$item_array[$key] = $item->{$key};
if (property_exists($item, $tmp_key)) {
$item_array[$key] = $item->{$tmp_key};
} else {
$item_array[$key] = '';
}

View File

@ -133,16 +133,16 @@ class QuoteItemExport extends BaseExport
if (str_contains($key, "item.")) {
$key = str_replace("item.", "", $key);
$tmp_key = str_replace("item.", "", $key);
if($key == 'type_id')
$key = 'type';
if($tmp_key == 'type_id')
$tmp_key = 'type';
if($key == 'tax_id')
$key = 'tax_category';
if($tmp_key == 'tax_id')
$tmp_key = 'tax_category';
if (property_exists($item, $key)) {
$item_array[$key] = $item->{$key};
if (property_exists($item, $tmp_key)) {
$item_array[$key] = $item->{$tmp_key};
}
else {
$item_array[$key] = '';

View File

@ -180,8 +180,6 @@ class StoreClientRequest extends Request
public function messages()
{
return [
// 'unique' => ctrans('validation.unique', ['attribute' => ['email','number']),
//'required' => trans('validation.required', ['attribute' => 'email']),
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
'currency_code' => 'Currency code does not exist',
];

View File

@ -26,12 +26,18 @@ class StoreGroupSettingRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->can('create', GroupSetting::class) && auth()->user()->account->hasFeature(Account::FEATURE_API);
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->can('create', GroupSetting::class) && $user->account->hasFeature(Account::FEATURE_API);
}
public function rules()
{
$rules['name'] = 'required|unique:group_settings,name,null,null,company_id,'.auth()->user()->companyId();
/** @var \App\Models\User $user */
$user = auth()->user();
$rules['name'] = 'required|unique:group_settings,name,null,null,company_id,'.$user->companyId();
$rules['settings'] = new ValidClientGroupSettingsRule();

View File

@ -1171,7 +1171,7 @@ class ReportCsvGenerationTest extends TestCase
public function testQuoteItemsCustomColumnsCsvGeneration()
{
\App\Models\Quote::factory()->create([
$q = \App\Models\Quote::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'client_id' => $this->client->id,
@ -1217,7 +1217,6 @@ class ReportCsvGenerationTest extends TestCase
$csv = $response->streamedContent();
$this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name'));
$this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Quote Number'));
$this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Item Quantity'));