Skip to content

Commit

Permalink
fiyatlı stok listesi eklendi, closes #19.
Browse files Browse the repository at this point in the history
stok listesindeki sağlayıcı kodu, birim ve fiyat alanları kaldırılarak yerine ekstra alanlardan 1 ve 2 ile birincil barkod eklendi.
  • Loading branch information
mdpinar committed Feb 28, 2015
1 parent f9dfcfd commit b2b82c5
Show file tree
Hide file tree
Showing 14 changed files with 632 additions and 62 deletions.
4 changes: 0 additions & 4 deletions app/controllers/stock/reports/StockList.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public static class Parameter extends ExtraFieldsForStock {

public String excCode;

public boolean isTaxInclude = Boolean.FALSE;
public double discountRate = 0d;


public static Map<String, String> options() {
LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
options.put("s.name", Messages.get("stock.name"));
Expand Down
160 changes: 160 additions & 0 deletions app/controllers/stock/reports/StockPriceList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/**
* Copyright (c) 2015 Mustafa DUMLUPINAR, [email protected]
*
* This file is part of seyhan project.
*
* seyhan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package controllers.stock.reports;

import static play.data.Form.form;

import java.util.LinkedHashMap;
import java.util.Map;

import models.temporal.ExtraFieldsForStock;
import play.data.Form;
import play.i18n.Messages;
import play.mvc.Controller;
import play.mvc.Result;
import reports.ReportParams;
import reports.ReportService;
import reports.ReportService.ReportResult;
import utils.AuthManager;
import utils.CacheUtils;
import utils.GlobalCons;
import utils.InstantSQL;
import utils.QueryUtils;
import views.html.stocks.reports.stock_price_list;
import enums.EffectDirection;
import enums.EffectType;
import enums.ReportUnit;
import enums.Right;
import enums.RightLevel;

/**
* @author mdpinar
*/
public class StockPriceList extends Controller {

private final static Right RIGHT_SCOPE = Right.STOK_FIYATLI_LISTE;
private final static String REPORT_NAME = "PriceList";

private final static Form<StockPriceList.Parameter> parameterForm = form(StockPriceList.Parameter.class);

public static class Parameter extends ExtraFieldsForStock {

public String orderBy;
public ReportUnit unit;

public String excCode;

public models.StockPriceList priceList;

public static Map<String, String> options() {
LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
options.put("s.name", Messages.get("stock.name"));
options.put("s.code", Messages.get("stock.code"));

return options;
}

}

private static String getQueryString(Parameter params) {
StringBuilder queryBuilder = new StringBuilder(" and s.is_active = " + GlobalCons.TRUE);

queryBuilder.append(" and s.workspace = " + CacheUtils.getWorkspaceId());

if (params.providerCode != null && ! params.providerCode.isEmpty()) {
queryBuilder.append(" and s.provider_code = '");
queryBuilder.append(params.providerCode);
queryBuilder.append("'");
}

if (params.excCode != null && ! params.excCode.isEmpty()) {
queryBuilder.append(" and s.exc_code = '");
queryBuilder.append(params.excCode);
queryBuilder.append("'");
}

QueryUtils.addExtraFieldsCriterias(params, queryBuilder, "s.");

return queryBuilder.toString();
}

public static Result generate() {
Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Enable);
if (hasProblem != null) return hasProblem;

Form<StockPriceList.Parameter> filledForm = parameterForm.bindFromRequest();

if(filledForm.hasErrors()) {
return badRequest(stock_price_list.render(filledForm));
} else {

Parameter params = filledForm.get();

ReportParams repPar = new ReportParams();
repPar.modul = RIGHT_SCOPE.module.name();
repPar.reportName = REPORT_NAME;
repPar.reportUnit = params.unit;
repPar.query = getQueryString(params);
repPar.orderBy = params.orderBy;

/*
* Parametrik degerlerin gecisi
*/
repPar.paramMap.put("CATEGORY_SQL", "");
if (params.category != null && params.category.id != null) {
repPar.paramMap.put("CATEGORY_SQL", InstantSQL.buildCategorySQL(params.category.id));
}

repPar.paramMap.put("PRICE_MULTIPLIER", "");
if (params.priceList != null && params.priceList.id != null) {
models.StockPriceList spl = models.StockPriceList.findById(params.priceList.id);
if (spl.effectDirection.equals(EffectDirection.Increase)) {
if (spl.effectType.equals(EffectType.Amount)) {
repPar.paramMap.put("PRICE_MULTIPLIER", " + "+spl.effect);
} else {
repPar.paramMap.put("PRICE_MULTIPLIER", " * ((100+"+spl.effect+") / 100)");
}
} else {
if (spl.effectType.equals(EffectType.Amount)) {
repPar.paramMap.put("PRICE_MULTIPLIER", " - "+spl.effect);
} else {
repPar.paramMap.put("PRICE_MULTIPLIER", " * ((100-"+spl.effect+") / 100)");
}
}
}

ReportResult repRes = ReportService.generateReport(repPar, response());
if (repRes.error != null) {
flash("warning", repRes.error);
return ok(stock_price_list.render(filledForm));
} else {
return ok(repRes.stream);
}
}

}

public static Result index() {
Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Enable);
if (hasProblem != null) return hasProblem;

return ok(stock_price_list.render(parameterForm.fill(new Parameter())));
}

}
3 changes: 3 additions & 0 deletions app/enums/Right.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ public enum Right {

@EnumValue("STOK_LISTESI")
STOK_LISTESI(Module.stock, false, false, false),

@EnumValue("STOK_FIYATLI_LISTE")
STOK_FIYATLI_LISTE(Module.stock, false, false, false),

@EnumValue("STOK_FIS_LISTESI")
STOK_FIS_LISTESI(Module.stock, false, false, false),
Expand Down
2 changes: 1 addition & 1 deletion app/external/TCMBExchanges.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static List<TCMBRate> getRates() {
log.info("xml service connection was successfuly done.");

} catch (Exception e) {
log.error(e.getMessage(), e);
log.error(e.getMessage());
}

return result;
Expand Down
6 changes: 5 additions & 1 deletion app/menus/StockMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ public List<MenuItem> getMenu() {
subReportMenu.add(new MenuItem(Messages.get(Right.STOK_LISTESI.key),
controllers.stock.reports.routes.StockList.index().url()));
}
if (AuthManager.hasPrivilege(Right.STOK_FIYATLI_LISTE, RightLevel.Enable)) {
subReportMenu.add(new MenuItem(Messages.get(Right.STOK_FIYATLI_LISTE.key),
controllers.stock.reports.routes.StockPriceList.index().url()));
}
if (AuthManager.hasPrivilege(Right.STOK_FIS_LISTESI, RightLevel.Enable)) {
subReportMenu.add(new MenuItem(Messages.get(Right.STOK_FIS_LISTESI.key),
controllers.stock.reports.routes.ReceiptList.index().url()));
controllers.stock.reports.routes.ReceiptList.index().url()));
}

if (subReportMenu.size() > 0) subReportMenu.add(new MenuItem(MenuItemType.Divider));
Expand Down
18 changes: 0 additions & 18 deletions app/views/stocks/reports/stock_list.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

@tools.components.stock_category_select(_form)

@select(_form("price"),
options(Options.stockPrices),
'class -> "input-medium",
'_label -> Messages("price")
)

@if(global.Profiles.chosen().gnel_hasExchangeSupport) {
@select(_form("excCode"),
options(Options.currencies),
Expand All @@ -32,18 +26,6 @@
)
}

@select(_form("isTaxInclude"),
options(Options.taxStatus),
'class -> "input-small",
'_label -> Messages("tax_status")
)

@inputText(_form("discountRate"),
'_label -> Messages("stock.discount_rate"),
'class -> "input-small rate",
'maxlength -> "5"
)

@select(_form("orderBy"),
options(stock.reports.StockList.Parameter.options),
'class -> "input-medium",
Expand Down
41 changes: 41 additions & 0 deletions app/views/stocks/reports/stock_price_list.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@(_form: Form[stock.reports.StockPriceList.Parameter])

@import helper._
@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) }

@tools.templates.report_form(stock.reports.routes.StockPriceList.generate(),enums.Right.STOK_FIYATLI_LISTE) {

@select(_form("priceList.id"),
options(StockPriceList.options),
'class -> "input-medium-plus",
'_label -> Messages("stock.price_list")
)

@inputText(_form("providerCode"),
'_label -> Messages("provider_code"),
'class -> "input-medium",
'maxlength -> "30"
)

@for(aef <- models.AdminExtraFields.listAll(enums.Module.stock.name())) {
@tools.dropdowns.stock_extra_field(_form, aef.id, aef.idno, aef.name, aef.isRequired, hasAddNewButton=false)
}

@tools.components.stock_category_select(_form)

@if(global.Profiles.chosen().gnel_hasExchangeSupport) {
@select(_form("excCode"),
options(Options.currencies),
'class -> "input-small",
'_label -> Messages("currency"),
'_default -> Messages("choose")
)
}

@select(_form("orderBy"),
options(stock.reports.StockList.Parameter.options),
'class -> "input-medium",
'_label -> Messages("orderby")
)

}
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import play.Project._

name := "seyhan"

version := "1.0.4"
version := "1.0.5"

libraryDependencies ++= Seq(
jdbc,
Expand Down
24 changes: 23 additions & 1 deletion conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ enum.STOK_FIYAT_LISTESI=Price List
enum.STOK_MALIYET_FAKTORLERI=Cost Factors
enum.STOK_MALIYET_HESAPLAMALARI=Costing Calculations
enum.STOK_LISTESI=Stock List
enum.STOK_FIYAT_LISTESI=Price Listesi
enum.STOK_FIYATLI_LISTE=Stock Price List
enum.STOK_HAREKETSIZ_STOKLAR_LISTESI=Inactive Stocks List
enum.STOK_FIS_LISTESI=Stock Receipt List
enum.STOK_HAREKET_RAPORU=Trans. Report
Expand Down Expand Up @@ -1137,3 +1137,25 @@ SYS_TIME=System Time
SYS_DATE_FULL=Full System Time
PAGE_NUMBER=Page No
PAGE_COUNT=Page Count

stock.extra_field_0=Group
stock.extra_field_1=Brand
stock.extra_field_2=Model
stock.extra_field_3=Shelf
stock.extra_field_4=Colour
stock.extra_field_5=Size
stock.extra_field_6=Height
stock.extra_field_7=field7
stock.extra_field_8=field8
stock.extra_field_9=field9

contact.extra_field_0=Group
contact.extra_field_1=field1
contact.extra_field_2=field2
contact.extra_field_3=field3
contact.extra_field_4=field4
contact.extra_field_5=field5
contact.extra_field_6=field6
contact.extra_field_7=field7
contact.extra_field_8=field8
contact.extra_field_9=field9
24 changes: 23 additions & 1 deletion conf/messages.tr
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ enum.STOK_FIYAT_LISTESI=Fiyat Listesi
enum.STOK_MALIYET_FAKTORLERI=Maliyet Faktörleri
enum.STOK_MALIYET_HESAPLAMALARI=Maliyet Hesaplamaları
enum.STOK_LISTESI=Stok Listesi
enum.STOK_FIYAT_LISTESI=Fiyat Listesi
enum.STOK_FIYATLI_LISTE=Fiyatlı Stok Listesi
enum.STOK_HAREKETSIZ_STOKLAR_LISTESI=Hareketsiz Stoklar Listesi
enum.STOK_FIS_LISTESI=Fiş Listesi
enum.STOK_HAREKET_RAPORU=Hareket Raporu
Expand Down Expand Up @@ -1137,3 +1137,25 @@ SYS_TIME=Sistem Saati
SYS_DATE_FULL=Sistem Tarih ve Saati
PAGE_NUMBER=Sayfa No
PAGE_COUNT=Sayfa Sayısı

stock.extra_field_0=Gurup
stock.extra_field_1=Marka
stock.extra_field_2=Model
stock.extra_field_3=Raf
stock.extra_field_4=Renk
stock.extra_field_5=Beden
stock.extra_field_6=Boy
stock.extra_field_7=ek_alan7
stock.extra_field_8=ek_alan8
stock.extra_field_9=ek_alan9

contact.extra_field_0=Gurup
contact.extra_field_1=ek_alan1
contact.extra_field_2=ek_alan2
contact.extra_field_3=ek_alan3
contact.extra_field_4=ek_alan4
contact.extra_field_5=ek_alan5
contact.extra_field_6=ek_alan6
contact.extra_field_7=ek_alan7
contact.extra_field_8=ek_alan8
contact.extra_field_9=ek_alan9
4 changes: 4 additions & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ POST /stocks/cost_factor/:id/delete controllers.stock.CostFa
GET /stocks/report/stock_list controllers.stock.reports.StockList.index()
POST /stocks/report/stock_list controllers.stock.reports.StockList.generate()

# Stock Price List
GET /stocks/report/stock_price_list controllers.stock.reports.StockPriceList.index()
POST /stocks/report/stock_price_list controllers.stock.reports.StockPriceList.generate()

# Inactive Stocks List
GET /stocks/report/inactive_stocks_list controllers.stock.reports.InactiveStocksList.index()
POST /stocks/report/inactive_stocks_list controllers.stock.reports.InactiveStocksList.generate()
Expand Down
Loading

0 comments on commit b2b82c5

Please sign in to comment.