<commit_before>/*
 * Axelor Business Solutions
 *
 * Copyright (C) 2018 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.apps.supplychain.service;

import java.lang.invoke.MethodHandles;
import java.time.LocalDate;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axelor.apps.account.service.config.AccountConfigService;
import com.axelor.apps.base.db.Company;
import com.axelor.apps.base.db.Currency;
import com.axelor.apps.base.db.Partner;
import com.axelor.apps.base.db.PriceList;
import com.axelor.apps.base.service.PartnerService;
import com.axelor.apps.sale.db.SaleOrder;
import com.axelor.apps.sale.db.repo.SaleOrderRepository;
import com.axelor.apps.sale.service.app.AppSaleService;
import com.axelor.apps.sale.service.saleorder.SaleOrderComputeService;
import com.axelor.apps.sale.service.saleorder.SaleOrderCreateServiceImpl;
import com.axelor.apps.sale.service.saleorder.SaleOrderService;
import com.axelor.apps.stock.db.StockLocation;
import com.axelor.apps.stock.service.StockLocationService;
import com.axelor.auth.AuthUtils;
import com.axelor.auth.db.User;
import com.axelor.exception.AxelorException;
import com.axelor.inject.Beans;
import com.axelor.team.db.Team;
import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

public class SaleOrderCreateServiceSupplychainImpl extends SaleOrderCreateServiceImpl {

	private final Logger logger = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

	protected AccountConfigService accountConfigService;
	protected SaleOrderRepository saleOrderRepository;

	@Inject
	public SaleOrderCreateServiceSupplychainImpl(PartnerService partnerService, SaleOrderRepository saleOrderRepo,
			AppSaleService appSaleService, SaleOrderService saleOrderService, SaleOrderComputeService saleOrderComputeService,
			AccountConfigService accountConfigService, SaleOrderRepository saleOrderRepository) {

		super(partnerService, saleOrderRepo,
				appSaleService, saleOrderService, saleOrderComputeService);

		this.accountConfigService = accountConfigService;
		this.saleOrderRepository = saleOrderRepository;

	}


	@Override
	public SaleOrder createSaleOrder(User salemanUser, Company company, Partner contactPartner, Currency currency,
			LocalDate deliveryDate, String internalReference, String externalReference, LocalDate orderDate,
			PriceList priceList, Partner clientPartner, Team team) throws AxelorException {
		return createSaleOrder(salemanUser, company, contactPartner, currency, deliveryDate, internalReference,
				externalReference, null, orderDate, priceList, clientPartner, team);
	}

	public SaleOrder createSaleOrder(User buyerUser, Company company, Partner contactPartner, Currency currency,
			LocalDate deliveryDate, String internalReference, String externalReference, StockLocation stockLocation, LocalDate orderDate,
			PriceList priceList, Partner clientPartner, Team team) throws AxelorException  {

		logger.debug("Création d'une commande fournisseur : Société = {},  Reference externe = {}, Client = {}",
				company.getName(), externalReference, clientPartner.getFullName());

		SaleOrder saleOrder = super.createSaleOrder(buyerUser, company, contactPartner, currency, deliveryDate, internalReference,
				externalReference, orderDate, priceList, clientPartner, team);

		if(stockLocation == null)  {
			stockLocation = Beans.get(StockLocationService.class).getPickupDefaultStockLocation(company);
		}

		saleOrder.setStockLocation(stockLocation);

		saleOrder.setPaymentMode(clientPartner.getInPaymentMode());
		saleOrder.setPaymentCondition(clientPartner.getPaymentCondition());<commit_msg>Replaced 'buyerUser' param name per 'salemanUser'<commit_after>/*
 * Axelor Business Solutions
 *
 * Copyright (C) 2018 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.apps.supplychain.service;

import java.lang.invoke.MethodHandles;
import java.time.LocalDate;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axelor.apps.account.service.config.AccountConfigService;
import com.axelor.apps.base.db.Company;
import com.axelor.apps.base.db.Currency;
import com.axelor.apps.base.db.Partner;
import com.axelor.apps.base.db.PriceList;
import com.axelor.apps.base.service.PartnerService;
import com.axelor.apps.sale.db.SaleOrder;
import com.axelor.apps.sale.db.repo.SaleOrderRepository;
import com.axelor.apps.sale.service.app.AppSaleService;
import com.axelor.apps.sale.service.saleorder.SaleOrderComputeService;
import com.axelor.apps.sale.service.saleorder.SaleOrderCreateServiceImpl;
import com.axelor.apps.sale.service.saleorder.SaleOrderService;
import com.axelor.apps.stock.db.StockLocation;
import com.axelor.apps.stock.service.StockLocationService;
import com.axelor.auth.AuthUtils;
import com.axelor.auth.db.User;
import com.axelor.exception.AxelorException;
import com.axelor.inject.Beans;
import com.axelor.team.db.Team;
import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

public class SaleOrderCreateServiceSupplychainImpl extends SaleOrderCreateServiceImpl {

	private final Logger logger = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

	protected AccountConfigService accountConfigService;
	protected SaleOrderRepository saleOrderRepository;

	@Inject
	public SaleOrderCreateServiceSupplychainImpl(PartnerService partnerService, SaleOrderRepository saleOrderRepo,
			AppSaleService appSaleService, SaleOrderService saleOrderService, SaleOrderComputeService saleOrderComputeService,
			AccountConfigService accountConfigService, SaleOrderRepository saleOrderRepository) {

		super(partnerService, saleOrderRepo,
				appSaleService, saleOrderService, saleOrderComputeService);

		this.accountConfigService = accountConfigService;
		this.saleOrderRepository = saleOrderRepository;

	}


	@Override
	public SaleOrder createSaleOrder(User salemanUser, Company company, Partner contactPartner, Currency currency,
			LocalDate deliveryDate, String internalReference, String externalReference, LocalDate orderDate,
			PriceList priceList, Partner clientPartner, Team team) throws AxelorException {
		return createSaleOrder(salemanUser, company, contactPartner, currency, deliveryDate, internalReference,
				externalReference, null, orderDate, priceList, clientPartner, team);
	}

	public SaleOrder createSaleOrder(User salemanUser, Company company, Partner contactPartner, Currency currency,
			LocalDate deliveryDate, String internalReference, String externalReference, StockLocation stockLocation, LocalDate orderDate,
			PriceList priceList, Partner clientPartner, Team team) throws AxelorException  {

		logger.debug("Création d'une commande fournisseur : Société = {},  Reference externe = {}, Client = {}",
				company.getName(), externalReference, clientPartner.getFullName());

		SaleOrder saleOrder = super.createSaleOrder(salemanUser, company, contactPartner, currency, deliveryDate, internalReference,
				externalReference, orderDate, priceList, clientPartner, team);

		if(stockLocation == null)  {
			stockLocation = Beans.get(StockLocationService.class).getPickupDefaultStockLocation(company);
		}

		saleOrder.setStockLocation(stockLocation);

		saleOrder.setPaymentMode(clientPartner.getInPaymentMode());
		saleOrder.setPaymentCondition(clientPartner.getPaymentCondition());
{'fraction_non_alphanumeric': 0.08292455033870591, 'fraction_numerical': 0.001635131978509694, 'mean_word_length': 6.207912457912458, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5049719', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2361, 'n_words': 594}