ekmungai / eloquent-ifrs

Eloquent Double Entry Accounting with a focus on IFRS Compliant Reporting
MIT License
334 stars 68 forks source link

EntityScope bug #91

Closed martuico closed 2 years ago

martuico commented 2 years ago

Hi, I keep having this issue.

Screen Shot 2021-09-10 at 3 15 12 PM

ekmungai commented 2 years ago

Hi @martuico,

I've since made some changes to that part of the so I can't really tell what is happening. Could you please post the contents of EntityScope.php?

Cheers.

martuico commented 2 years ago

I force entity_id in Vat to create the error comes from entity id. Also Vat class has error when doing eloquent function like Vat::whereCode()->first() it shoes same error

martuico commented 2 years ago

Also when saving transaction Screen Shot 2021-09-10 at 10 28 54 PM

I tried doing this code $newLineRow = LineItem::with('vat')->whereId($accLineitem->id)->first(); $transaction->addLineItem($newLineRow);

this is whole function code ` $transaction = ($request->get('transaction_type') === 'ES' || $request->get('transaction_type') === 'PO') ? null : Transaction::getType($request->get('transaction_type'));

    $headerClass = ($transaction) ? "IFRS\Transactions\\" . \str_replace(' ', '', $transaction) : '';
    // return response()->json($headerClass);
    //Create Trasasction
    if (class_exists($headerClass)) {
        $transaction = new $headerClass([
            "account_id" => $request->get('account_id'),
            "transaction_date" => Carbon::now(),
            "narration" => $request->get('narration'),
        ]);
    }
    $lineItems = [];
    foreach ($request->get('line_items') as $item) {
        $lineItem = [
            "amount" => $item['amount'],
            "vat_id" => $item['vat_id'],
            "account_id" => $item['account_id'],
            "narration" => $item['description'],
            "quantity" => $item['quantity']
        ];

        if (class_exists($headerClass) && $transaction) {
            $accLineitem = new LineItem($lineItem);
            $accLineitem->save();
            $accLineitem->attributes();
        }
        // $lineItem = LineItem::create();
        $newLineRow = LineItem::with('vat')->whereId($accLineitem->id)->first();
        $transaction->addLineItem($newLineRow);
        $lineItems[] = $accLineitem;
    }
    Log::info($transaction);
    if (class_exists($headerClass) && $transaction) {
        $transaction->post();
    }

`

martuico commented 2 years ago

Found the issue its on my end there's missing data