<commit_before><?php

use Illuminate\Database\Seeder;
use Point\Framework\Helpers\AllocationHelper;

class FixSeeder extends Seeder
{
    public function run()
    {
        \DB::beginTransaction();

        \Point\Framework\Models\Master\AllocationReport::where('id','>',0)->delete();

        $sales_invoices = \Point\PointSales\Models\Sales\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
        foreach ($sales_invoices as $sales_invoice) {
            foreach ($sales_invoice->items as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->item_notes);
            }
        }

        $sales_invoices = \Point\PointSales\Models\Service\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
        foreach ($sales_invoices as $sales_invoice) {
            foreach ($sales_invoice->items as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->item_notes);
            }

            foreach ($sales_invoice->services as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->service_notes);
            }
        }

        $sales_invoices = Point\PointPurchasing\Models\Inventory\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
        foreach ($sales_invoices as $sales_invoice) {
            foreach ($sales_invoice->items as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->item_notes);
            }
        }

        $sales_invoices = Point\PointPurchasing\Models\Service\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
        foreach ($sales_invoices as $sales_invoice) {
            foreach ($sales_invoice->items as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->item_notes);
            }

            foreach ($sales_invoice->services as $item) {
                $total = $item->price * $item->quantity;
                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->service_notes);
            }
        }

//        $payment_orders = \Point\PointFinance\Models\PaymentOrder\PaymentOrder::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
//        foreach ($payment_orders as $order) {
//            foreach ($order->detail() as $details) {
//                AllocationHelper::save($order->formulir->id, $details->allocation_id, $detail->amount * -1, $details->notes_detail);
//            }
//        }

        $cash_details = \Point\PointFinance\Models\Cash\CashDetail::joinCash()
            ->notArchived()->notCanceled()->where('form_reference_id', NULL)->selectOriginal()->get();

        foreach ($cash_details as $detail) {
            AllocationHelper::save($detail->cash->formulir->id, $detail->allocation_id, $detail->amount, $detail->notes_detail);
        }

        $bank_details = \Point\PointFinance\Models\Bank\BankDetail::joinBank()
            ->notArchived()->notCanceled()->where('form_reference_id', NULL)->selectOriginal()->get();

        foreach ($bank_details as $detail) {
            AllocationHelper::save($detail->bank->formulir->id, $detail->allocation_id, $detail->amount, $detail->notes_detail);
        }

        \DB::commit();
    }
}<commit_msg>fix seeder for memo journal description<commit_after><?php

use Illuminate\Database\Seeder;
use Point\Framework\Helpers\AllocationHelper;
use Point\Framework\Models\Journal;
use Point\Framework\Models\Master\Item;
use Point\Framework\Models\Master\Person;
use Point\PointAccounting\Models\MemoJournal;

class FixSeeder extends Seeder
{
    public function run()
    {
        \DB::beginTransaction();

        $memoJournals = MemoJournal::all();

        foreach($memoJournals as $memo_journal) {
            Journal::where('form_journal_id', $memo_journal->formulir_id)->delete();

            foreach ($memo_journal->detail as $memo_journal_item) {
                $journal = new Journal;
                $journal->form_date = $memo_journal->formulir->form_date;
                $journal->coa_id = $memo_journal_item->coa_id;
                $journal->description = $memo_journal_item->description;
                $journal->debit = $memo_journal_item->debit;
                $journal->credit = $memo_journal_item->credit;
                $journal->form_journal_id = $memo_journal->formulir_id;
                $journal->form_reference_id = $memo_journal_item->form_reference_id ?: null;
                $journal->subledger_id = $memo_journal_item->subledger_id ?: null;
                $journal->subledger_type = $memo_journal_item->subledger_type ?: null;

                $journal->save();
            }
        }


//        $items = Item::all();
//        $index = 1;
//        foreach ($items as $item) {
//            $item->code = 'CODE-' . $index;
//            $item->name = 'ITEM NAME ' . $index;
//            $item->save();
//            $index++;
//        }
//
//        $index = 1;
//        $persons = Person::all();
//        foreach ($persons as $person) {
//            $person->code = 'CODE-' . $index;
//            $person->name = 'CUSTOMER ' . $index;
//            $person->save();
//            $index++;
//        }

//        \Point\Framework\Models\Master\AllocationReport::where('id','>',0)->delete();
//
//        $sales_invoices = \Point\PointSales\Models\Sales\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
//        foreach ($sales_invoices as $sales_invoice) {
//            foreach ($sales_invoice->items as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->item_notes);
//            }
//        }
//
//        $sales_invoices = \Point\PointSales\Models\Service\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
//        foreach ($sales_invoices as $sales_invoice) {
//            foreach ($sales_invoice->items as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->item_notes);
//            }
//
//            foreach ($sales_invoice->services as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount, $item->service_notes);
//            }
//        }
//
//        $sales_invoices = Point\PointPurchasing\Models\Inventory\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
//        foreach ($sales_invoices as $sales_invoice) {
//            foreach ($sales_invoice->items as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->item_notes);
//            }
//        }
//
//        $sales_invoices = Point\PointPurchasing\Models\Service\Invoice::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
//        foreach ($sales_invoices as $sales_invoice) {
//            foreach ($sales_invoice->items as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->item_notes);
//            }
//
//            foreach ($sales_invoice->services as $item) {
//                $total = $item->price * $item->quantity;
//                $amount = $total - ($item->price * $item->quantity * $item->discount / 100);
//                AllocationHelper::save($sales_invoice->formulir->id, $item->allocation_id, $amount * -1, $item->service_notes);
//            }
//        }
//
////        $payment_orders = \Point\PointFinance\Models\PaymentOrder\PaymentOrder::joinFormulir()->notArchived()->notCanceled()->selectOriginal()->get();
////        foreach ($payment_orders as $order) {
////            foreach ($order->detail() as $details) {
////                AllocationHelper::save($order->formulir->id, $details->allocation_id, $detail->amount * -1, $details->notes_detail);
////            }
////        }
//
//        $cash_details = \Point\PointFinance\Models\Cash\CashDetail::joinCash()
//            ->notArchived()->notCanceled()->where('form_reference_id', NULL)->selectOriginal()->get();
//
//        foreach ($cash_details as $detail) {
//            AllocationHelper::save($detail->cash->formulir->id, $detail->allocation_id, $detail->amount, $detail->notes_detail);
//        }
//
//        $bank_details = \Point\PointFinance\Models\Bank\BankDetail::joinBank()
//            ->notArchived()->notCanceled()->where('form_reference_id', NULL)->selectOriginal()->get();
//
//        foreach ($bank_details as $detail) {
//            AllocationHelper::save($detail->bank->formulir->id, $detail->allocation_id, $detail->amount, $detail->notes_detail);
//        }

        \DB::commit();
    }
}
{'fraction_non_alphanumeric': 0.17828216236579394, 'fraction_numerical': 0.004520625353173856, 'mean_word_length': 2.402435116949696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 252, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '788262', 'n_tokens_mistral': 3290, 'n_tokens_neox': 3118, 'n_words': 448}