@ollie_123 Schedule two tasks? One that runs every month to process monthly invoices, and a second that runs every week to process weekly invoices.
Scheduled Invoices With Kernal Command
Hi All
I hope you're all well.
I'm trying to create a command that creates and sends an invoice invoice based on the orders placed by a company on a weekly or monthly basis based on the payment type the company has been set at.
i.e payment_type_id => '3' is weekly i.e payment_type_id => '4' is monthly
For reference, there is the invoices & invoice_line_items tables
Which an invoice & its line items are created from an Order and order_line_items tables
So far i've got
//Get companies on monthly payments
$companies = DB::table('companies')
->join('orders', 'companies.id', '=', 'orders.company_id')
->where('companies.payment_type_id', '3')
->where('orders.invoice_id', NULL)
->get();
foreach($companies as $company)
{
foreach($company->orders as $order)
{
// Create Invoice Here
}
}
The bit i'm struggling to get my head round is how i can create all of the orders & order line items into one invoice & invoice line items as ideally i would like each order & line item to be under the same invoice reference.
i.e
invoices
id |company_incr_inv | description |.....
1 | 200 | PC Build. |.....
2 | 200 | PC Repair |.....
3 | 200 | PC Service |.....
invoice_line_items
id |invoice_id | item_name |.....
1 | 1 | Nvidia X. |.....
2 | 1 | Graphics Card |.....
3 | 1 | HDMI Input |.....
4 | 2 | Screen Repl |.....
4 | 3 | Something |.....
Thank you in advance.
Please or to participate in this conversation.