Add new invoice for member frontend
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
philipp lang 2024-02-11 20:21:33 +01:00
parent b0e4017780
commit b80b7ea600
7 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,7 @@ class MemberNewInvoiceAction
return [
'year' => 'required|integer|gte:0',
'subscription_id' => 'required|exists:subscriptions,id',
'member_id' => 'required|exists:members,id',
];
}
@ -40,7 +41,7 @@ class MemberNewInvoiceAction
public function asController(ActionRequest $request, Member $member): JsonResponse
{
$payload = $this->handle($member, Subscription::find($request->input('subscription_id')), $request->input('year'));
$payload = $this->handle(Member::find($request->member_id), Subscription::find($request->input('subscription_id')), $request->input('year'));
return response()->json($payload);
}
}

View File

@ -69,6 +69,7 @@ class Invoice extends Model
'description' => str($child->name)->replace('{name}', $member->firstname . ' ' . $member->lastname)->replace('{year}', (string) $year),
'price' => $child->amount,
'member_id' => $member->id,
'id' => null,
]);
}
}

View File

@ -56,6 +56,7 @@ class InvoiceResource extends JsonResource
'mass-store' => route('invoice.mass-store'),
'store' => route('invoice.store'),
'masspdf' => route('invoice.masspdf'),
'newInvoiceAttributes' => route('invoice.new-invoice-attributes')
],
'vias' => BillKind::forSelect(),
'statuses' => InvoiceStatus::forSelect(),

View File

@ -36,7 +36,13 @@
</ui-popup>
<ui-popup v-if="single !== null" :heading="`Rechnung ${single.id ? 'bearbeiten' : 'erstellen'}`" inner-width="max-w-4xl" @close="cancel">
<form class="grid grid-cols-2 gap-3 mt-4" @submit.prevent="submit">
<ui-box heading="Empfänger" container-class="grid grid-cols-2 gap-3 col-span-full">
<ui-box heading="Für Mitglied anlegen" container-class="flex space-x-3" class="col-span-full">
<f-select id="forMemberMember" v-model="forMember.member_id" name="forMemberMember" :options="meta.members" label="Mitglied"></f-select>
<f-select id="forMemberSubscription" v-model="forMember.subscription_id" name="forMemberSubscription" :options="meta.subscriptions" label="Beitrag"></f-select>
<f-text id="forMemberYear" v-model="forMember.year" name="forMemberYear" label="Jahr"></f-text>
<ui-icon-button class="btn-primary self-end mb-2" icon="save" @click="saveForMember">Speichern</ui-icon-button>
</ui-box>
<ui-box heading=" Empfänger" container-class="grid grid-cols-2 gap-3 col-span-full">
<f-text id="to_name" v-model="single.to.name" name="to_name" label="Name" class="col-span-full" required></f-text>
<f-text id="to_address" v-model="single.to.address" name="to_address" label="Adresse" class="col-span-full" required></f-text>
<f-text id="to_zip" v-model="single.to.zip" name="to_zip" label="PLZ" required></f-text>
@ -113,6 +119,11 @@ const props = defineProps(indexProps);
var {axios, meta, data, reloadPage, create, single, edit, cancel, submit, remove} = useIndex(props.data, 'invoice');
const massstore = ref(null);
const deleting = ref(null);
const forMember = ref({member_id: null, subscription_id: null, year: null});
async function saveForMember() {
single.value = (await axios.post(meta.value.links.newInvoiceAttributes, forMember.value)).data;
}
async function sendMassstore() {
await axios.post(meta.value.links['mass-store'], massstore.value);

View File

@ -115,7 +115,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::get('/invoice/{invoice}/pdf', DisplayPdfAction::class)->name('invoice.pdf');
Route::get('/invoice/{invoice}/rememberpdf', DisplayRememberpdfAction::class)->name('invoice.rememberpdf');
Route::get('/invoice/masspdf', MassPostPdfAction::class)->name('invoice.masspdf');
Route::post('/member/{member}/new-invoice', MemberNewInvoiceAction::class)->name('member.new-invoice');
Route::post('/invoice/new-invoice-attributes', MemberNewInvoiceAction::class)->name('invoice.new-invoice-attributes');
// ----------------------------- invoice-position ------------------------------

View File

@ -49,6 +49,7 @@ class InvoiceIndexActionTest extends TestCase
->assertInertiaPath('data.data.0.links.update', route('invoice.update', ['invoice' => $invoice]))
->assertInertiaPath('data.data.0.links.destroy', route('invoice.destroy', ['invoice' => $invoice]))
->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store'))
->assertInertiaPath('data.meta.links.newInvoiceAttributes', route('invoice.new-invoice-attributes'))
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
->assertInertiaPath('data.meta.links.masspdf', route('invoice.masspdf'))
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])

View File

@ -30,7 +30,7 @@ class MemberNewInvoiceActionTest extends TestCase
->emailBillKind()
->create(['firstname' => 'Max', 'lastname' => 'Muster', 'address' => 'Maxstr 4', 'zip' => '33445', 'location' => 'Solingen', 'email' => 'lala@b.de']);
$this->post(route('member.new-invoice', ['member' => $member]), ['year' => 2019, 'subscription_id' => $subscription->id])
$this->post(route('invoice.new-invoice-attributes'), ['member_id' => $member->id, 'year' => 2019, 'subscription_id' => $subscription->id])
->assertOk()
->assertJsonPath('greeting', 'Liebe Familie Muster')
->assertJsonPath('to.address', 'Maxstr 4')