<commit_before>package gdrj

import (
	"errors"

	"github.com/eaciit/orm/v1"
	"github.com/eaciit/toolkit"
)

var (
	NetMarginPLCode   string = "PL24NM"
	NetMarginPLHeader string = "Net Margin"
)

type PLModel struct {
	orm.ModelBase `json:"-" bson:"-"`
	ID            string `json:"_id" bson:"_id"` //PLCode
	OrderIndex    string
	PLHeader1     string
	PLHeader2     string
	PLHeader3     string
	Amount        float64
	GLReff        string
}

func (t *PLModel) RecordID() interface{} {
	return t.ID
}

func (t *PLModel) TableName() string {
	return "plmodel"
}

func PLModelGetByID(id string) *PLModel {
	t := new(PLModel)
	DB().GetById(t, id)
	return t
}

func PLModelGetAll() ([]*PLModel, error) {
	cursor, err := DB().Find(new(PLModel), nil)
	if err != nil {
		return nil, err
	}

	result := []*PLModel{}
	err = cursor.Fetch(&result, 0, false)
	if err != nil {
		return nil, err
	}
	cursor.Close()

	hasNetMargin := false
	for _, each := range result {
		// put Adv & Promo below the Gross Margin
		if each.ID == "PL32A" {
			each.OrderIndex = "PL0027A"
		}

		// if net margin is not yet added to pnl
		if each.PLHeader3 == NetMarginPLHeader && !hasNetMargin {
			hasNetMargin = true
		}
	}

	// if net margin is not yet added to pnl
	// inject fake one, the amount will be calculated from gross sales - a&p
	if !hasNetMargin {
		plNetMargin := new(PLModel)
		plNetMargin.ID = NetMarginPLCode
		plNetMargin.PLHeader1 = NetMarginPLHeader
		plNetMargin.PLHeader2 = plNetMargin.PLHeader1
		plNetMargin.PLHeader3 = plNetMargin.PLHeader1
		plNetMargin.OrderIndex = "PL0027B"<commit_msg>no message<commit_after>package gdrj

import (
	"errors"

	"github.com/eaciit/orm/v1"
	"github.com/eaciit/toolkit"
)

var (
	NetMarginPLCode   string = "PL74D"
	NetMarginPLHeader string = "Net Margin"
)

type PLModel struct {
	orm.ModelBase `json:"-" bson:"-"`
	ID            string `json:"_id" bson:"_id"` //PLCode
	OrderIndex    string
	PLHeader1     string
	PLHeader2     string
	PLHeader3     string
	Amount        float64
	GLReff        string
}

func (t *PLModel) RecordID() interface{} {
	return t.ID
}

func (t *PLModel) TableName() string {
	return "plmodel"
}

func PLModelGetByID(id string) *PLModel {
	t := new(PLModel)
	DB().GetById(t, id)
	return t
}

func PLModelGetAll() ([]*PLModel, error) {
	cursor, err := DB().Find(new(PLModel), nil)
	if err != nil {
		return nil, err
	}

	result := []*PLModel{}
	err = cursor.Fetch(&result, 0, false)
	if err != nil {
		return nil, err
	}
	cursor.Close()

	hasNetMargin := false
	for _, each := range result {
		// put Adv & Promo below the Gross Margin
		if each.ID == "PL32A" {
			each.OrderIndex = "PL0027A"
		}

		// if net margin is not yet added to pnl
		if each.PLHeader3 == NetMarginPLHeader && !hasNetMargin {
			hasNetMargin = true
		}
	}

	// if net margin is not yet added to pnl
	// inject fake one, the amount will be calculated from gross sales - a&p
	if !hasNetMargin {
		plNetMargin := new(PLModel)
		plNetMargin.ID = NetMarginPLCode
		plNetMargin.PLHeader1 = NetMarginPLHeader
		plNetMargin.PLHeader2 = plNetMargin.PLHeader1
		plNetMargin.PLHeader3 = plNetMargin.PLHeader1
		plNetMargin.OrderIndex = "PL0027C"
{'fraction_non_alphanumeric': 0.11931818181818182, 'fraction_numerical': 0.015782828282828284, 'mean_word_length': 3.353021978021978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1628150', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1193, 'n_words': 312}