Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-05-21 12:46:02 +03:00
parent f930412413
commit d886fba6de
6 changed files with 482 additions and 33 deletions

View File

@@ -89,6 +89,18 @@ func GetProductionProductCostingOnMLPDFHandler(w http.ResponseWriter, r *http.Re
return return
} }
// Exchange rates (needed for EUR conversions in PDF summary tables)
usdRate := 0.0
eurRate := 0.0
if mssqlDB := db.GetDB(); mssqlDB != nil {
row, err := queries.GetProductionHasCostDetailExchangeRatesByDate(ctx, mssqlDB, header.MaliyetTarihi)
if err == nil {
var rateDate string
var gbpRate float64
_ = row.Scan(&rateDate, &usdRate, &eurRate, &gbpRate)
}
}
pdf := gofpdf.New("L", "mm", "A4", "") pdf := gofpdf.New("L", "mm", "A4", "")
pdf.SetMargins(8, 8, 8) pdf.SetMargins(8, 8, 8)
pdf.SetAutoPageBreak(false, 10) pdf.SetAutoPageBreak(false, 10)
@@ -98,9 +110,11 @@ func GetProductionProductCostingOnMLPDFHandler(w http.ResponseWriter, r *http.Re
} }
export := &costingPDF{ export := &costingPDF{
pdf: pdf, pdf: pdf,
header: header, header: header,
groups: groups, groups: groups,
usdRate: usdRate,
eurRate: eurRate,
} }
export.draw() export.draw()
@@ -224,6 +238,9 @@ type costingPDF struct {
pdf *gofpdf.Fpdf pdf *gofpdf.Fpdf
header models.ProductionHasCostDetailHeader header models.ProductionHasCostDetailHeader
groups []models.ProductionHasCostDetailGroup groups []models.ProductionHasCostDetailGroup
usdRate float64
eurRate float64
} }
func (c *costingPDF) draw() { func (c *costingPDF) draw() {
@@ -312,13 +329,14 @@ type pdfGroupTotalRow struct {
group string group string
try float64 try float64
usd float64 usd float64
eur float64
} }
func (c *costingPDF) drawHeaderSummaryTables() { func (c *costingPDF) drawHeaderSummaryTables() {
pdf := c.pdf pdf := c.pdf
partRows := c.computePartSummary() partRows := c.computePartSummary()
groupRows, grandTRY, grandUSD := c.computeGroupTotals() groupRows, grandTRY, grandUSD, grandEUR := c.computeGroupTotals()
// Table styling (use same brand palette as statements PDF) // Table styling (use same brand palette as statements PDF)
// colorPrimary/colorSecondary/colorDetailFill are in statements_pdf.go (same package). // colorPrimary/colorSecondary/colorDetailFill are in statements_pdf.go (same package).
@@ -332,28 +350,36 @@ func (c *costingPDF) drawHeaderSummaryTables() {
pdf.CellFormat(0, 4.8, "Parca Bazli Maliyet Ozellikleri", "", 1, "L", false, 0, "") pdf.CellFormat(0, 4.8, "Parca Bazli Maliyet Ozellikleri", "", 1, "L", false, 0, "")
partCols := []string{"Parca", "TRY", "USD", "EUR"} partCols := []string{"Parca", "TRY", "USD", "EUR"}
partW := []float64{70, 22, 22, 22} partW := []float64{70, 22, 22, 22}
// Add TOTAL row
totalTry, totalUsd, totalEur := 0.0, 0.0, 0.0
for _, r := range partRows {
totalTry += r.try
totalUsd += r.usd
totalEur += r.eur
}
partRowsWithTotal := append(partRows, pdfPartSummaryRow{name: "TOPLAM", try: totalTry, usd: totalUsd, eur: totalEur})
c.drawMiniTable(partCols, partW, func(i int) []string { c.drawMiniTable(partCols, partW, func(i int) []string {
if i >= len(partRows) { if i >= len(partRowsWithTotal) {
return nil return nil
} }
r := partRows[i] r := partRowsWithTotal[i]
return []string{r.name, pdfMoney(r.try), pdfMoney(r.usd), pdfMoney(r.eur)} return []string{r.name, pdfMoney(r.try), pdfMoney(r.usd), pdfMoney(r.eur)}
}, len(partRows), true) }, len(partRowsWithTotal), true, true)
pdf.Ln(2) pdf.Ln(2)
// Group totals table // Group totals table
pdf.SetFont("dejavu", "B", 8.2) pdf.SetFont("dejavu", "B", 8.2)
pdf.CellFormat(0, 4.8, "Grup Toplamlari", "", 1, "L", false, 0, "") pdf.CellFormat(0, 4.8, "Grup Toplamlari", "", 1, "L", false, 0, "")
gCols := []string{"Grup", "TRY", "USD"} gCols := []string{"Grup", "TRY", "USD", "EUR"}
gW := []float64{30, 22, 22} gW := []float64{30, 22, 22, 22}
totalRows := append(groupRows, pdfGroupTotalRow{group: "TOPLAM", try: grandTRY, usd: grandUSD}) totalRows := append(groupRows, pdfGroupTotalRow{group: "TOPLAM", try: grandTRY, usd: grandUSD, eur: grandEUR})
c.drawMiniTable(gCols, gW, func(i int) []string { c.drawMiniTable(gCols, gW, func(i int) []string {
if i >= len(totalRows) { if i >= len(totalRows) {
return nil return nil
} }
r := totalRows[i] r := totalRows[i]
return []string{r.group, pdfMoney(r.try), pdfMoney(r.usd)} return []string{r.group, pdfMoney(r.try), pdfMoney(r.usd), pdfMoney(r.eur)}
}, len(totalRows), true) }, len(totalRows), true, true)
pdf.Ln(2) pdf.Ln(2)
} }
@@ -372,7 +398,10 @@ func (c *costingPDF) computePartSummary() []pdfPartSummaryRow {
} }
row.try += it.LTutar row.try += it.LTutar
row.usd += it.USDTutar row.usd += it.USDTutar
row.eur += it.EURTutar // EUR isn't directly returned by the has-cost query; derive from USD using exchange rates when available.
if c.usdRate > 0 && c.eurRate > 0 {
row.eur += it.USDTutar * (c.usdRate / c.eurRate)
}
} }
} }
out := make([]pdfPartSummaryRow, 0, len(byName)) out := make([]pdfPartSummaryRow, 0, len(byName))
@@ -384,7 +413,7 @@ func (c *costingPDF) computePartSummary() []pdfPartSummaryRow {
return out return out
} }
func (c *costingPDF) computeGroupTotals() (rows []pdfGroupTotalRow, grandTRY float64, grandUSD float64) { func (c *costingPDF) computeGroupTotals() (rows []pdfGroupTotalRow, grandTRY float64, grandUSD float64, grandEUR float64) {
want := []string{"CM2", "FABRIC", "DT", "TP"} want := []string{"CM2", "FABRIC", "DT", "TP"}
by := map[string]*pdfGroupTotalRow{} by := map[string]*pdfGroupTotalRow{}
for _, w := range want { for _, w := range want {
@@ -400,6 +429,9 @@ func (c *costingPDF) computeGroupTotals() (rows []pdfGroupTotalRow, grandTRY flo
// g.TotalTutar is TRY total; g.TotalUSDTutar is USD total // g.TotalTutar is TRY total; g.TotalUSDTutar is USD total
t.try += g.TotalTutar t.try += g.TotalTutar
t.usd += g.TotalUSDTutar t.usd += g.TotalUSDTutar
if c.usdRate > 0 && c.eurRate > 0 {
t.eur += g.TotalUSDTutar * (c.usdRate / c.eurRate)
}
} }
for _, w := range want { for _, w := range want {
@@ -407,11 +439,12 @@ func (c *costingPDF) computeGroupTotals() (rows []pdfGroupTotalRow, grandTRY flo
rows = append(rows, *r) rows = append(rows, *r)
grandTRY += r.try grandTRY += r.try
grandUSD += r.usd grandUSD += r.usd
grandEUR += r.eur
} }
return rows, grandTRY, grandUSD return rows, grandTRY, grandUSD, grandEUR
} }
func (c *costingPDF) drawMiniTable(cols []string, widths []float64, rowFn func(i int) []string, rowCount int, zebra bool) { func (c *costingPDF) drawMiniTable(cols []string, widths []float64, rowFn func(i int) []string, rowCount int, zebra bool, emphasizeLastRow bool) {
pdf := c.pdf pdf := c.pdf
// Header row // Header row
@@ -433,25 +466,41 @@ func (c *costingPDF) drawMiniTable(cols []string, widths []float64, rowFn func(i
pdf.SetXY(x0, y0+hH) pdf.SetXY(x0, y0+hH)
// Data rows // Data rows
pdf.SetFont("dejavu", "", 7.4)
pdf.SetDrawColor(220, 220, 220) pdf.SetDrawColor(220, 220, 220)
for i := 0; i < rowCount; i++ { for i := 0; i < rowCount; i++ {
row := rowFn(i) row := rowFn(i)
if row == nil { if row == nil {
break break
} }
isLast := emphasizeLastRow && (i == rowCount-1)
fill := zebra && (i%2 == 1) fill := zebra && (i%2 == 1)
if fill {
pdf.SetFillColor(colorDetailFill[0], colorDetailFill[1], colorDetailFill[2]) // Style rules:
// - Total row: primary fill + bigger bold text
// - Zebra rows: detail fill
// - Normal: white
if isLast {
pdf.SetFont("dejavu", "B", 8.6)
pdf.SetTextColor(255, 255, 255)
pdf.SetFillColor(colorPrimary[0], colorPrimary[1], colorPrimary[2])
} else { } else {
pdf.SetFillColor(255, 255, 255) pdf.SetFont("dejavu", "", 7.4)
pdf.SetTextColor(30, 30, 30)
if fill {
pdf.SetFillColor(colorDetailFill[0], colorDetailFill[1], colorDetailFill[2])
} else {
pdf.SetFillColor(255, 255, 255)
}
} }
x = x0 x = x0
y := pdf.GetY() y := pdf.GetY()
rh := 5.0 rh := 5.0
if isLast {
rh = 5.6
}
for cidx, val := range row { for cidx, val := range row {
style := "" style := ""
if fill { if fill || isLast {
style = "DF" style = "DF"
} }
pdf.Rect(x, y, widths[cidx], rh, style) pdf.Rect(x, y, widths[cidx], rh, style)
@@ -465,6 +514,7 @@ func (c *costingPDF) drawMiniTable(cols []string, widths []float64, rowFn func(i
} }
pdf.SetXY(x0, y+rh) pdf.SetXY(x0, y+rh)
} }
pdf.SetTextColor(0, 0, 0)
} }
func formatDateTRDot(s string) string { func formatDateTRDot(s string) string {
@@ -503,12 +553,14 @@ func (c *costingPDF) drawGroup(g models.ProductionHasCostDetailGroup, firstGroup
"Renk", "Renk",
"Miktar", "Miktar",
"Br", "Br",
"Br\nFiyat",
"Pr\nBr",
"USD\nFiyat", "USD\nFiyat",
"USD\nTutar", "USD\nTutar",
"TRY\nFiyat", "TRY\nFiyat",
"TRY\nTutar", "TRY\nTutar",
} }
wn := []float64{8, 20, 22, 32, 70, 14, 14, 10, 16, 16, 16, 16} // sum = 250 wn := []float64{8, 20, 22, 30, 56, 14, 14, 10, 16, 12, 16, 16, 16, 16} // sum = 252
c.drawTableHeader(cols, wn) c.drawTableHeader(cols, wn)
// PDF-specific ordering: by hammadde turu no, then code. // PDF-specific ordering: by hammadde turu no, then code.
@@ -648,25 +700,39 @@ func (c *costingPDF) drawRowWithGroup(it models.ProductionHasCostDetailGroupItem
c.drawCell(x, y0, wn[7], rowH, strings.TrimSpace(it.SBirim), "C", fill) c.drawCell(x, y0, wn[7], rowH, strings.TrimSpace(it.SBirim), "C", fill)
x += wn[7] x += wn[7]
// Prefer input price if present; otherwise lFiyat.
price := it.LFiyat
cur := strings.TrimSpace(it.SDovizCinsi)
if it.FiyatGirilen != nil && *it.FiyatGirilen > 0 {
price = *it.FiyatGirilen
if strings.TrimSpace(it.FiyatDoviz) != "" {
cur = strings.TrimSpace(it.FiyatDoviz)
}
}
c.drawCell(x, y0, wn[8], rowH, pdfMoney(price), "R", fill)
x += wn[8]
c.drawCell(x, y0, wn[9], rowH, cur, "C", fill)
x += wn[9]
// Always show USD/TRY unit+total. // Always show USD/TRY unit+total.
// In URETIM schema: lFiyat/lTutar are in TRY, lDovizFiyati/usdTutar are in USD. // In URETIM schema: lFiyat/lTutar are in TRY, lDovizFiyati/usdTutar are in USD.
c.drawCell(x, y0, wn[8], rowH, pdfMoney(it.LDovizFiyati), "R", fill) c.drawCell(x, y0, wn[10], rowH, pdfMoney(it.LDovizFiyati), "R", fill)
x += wn[8] x += wn[10]
usdTotal := it.USDTutar usdTotal := it.USDTutar
if usdTotal == 0 && it.LMiktar != 0 && it.LDovizFiyati != 0 { if usdTotal == 0 && it.LMiktar != 0 && it.LDovizFiyati != 0 {
usdTotal = it.LMiktar * it.LDovizFiyati usdTotal = it.LMiktar * it.LDovizFiyati
} }
c.drawCell(x, y0, wn[9], rowH, pdfMoney(usdTotal), "R", fill) c.drawCell(x, y0, wn[11], rowH, pdfMoney(usdTotal), "R", fill)
x += wn[9] x += wn[11]
// Prefer input price if present; otherwise lFiyat. // Prefer input price if present; otherwise lFiyat.
unitTRY := it.LFiyat unitTRY := it.LFiyat
if it.FiyatGirilen != nil && *it.FiyatGirilen > 0 && strings.EqualFold(strings.TrimSpace(it.FiyatDoviz), "TRY") { if it.FiyatGirilen != nil && *it.FiyatGirilen > 0 && strings.EqualFold(strings.TrimSpace(it.FiyatDoviz), "TRY") {
unitTRY = *it.FiyatGirilen unitTRY = *it.FiyatGirilen
} }
c.drawCell(x, y0, wn[10], rowH, pdfMoney(unitTRY), "R", fill) c.drawCell(x, y0, wn[12], rowH, pdfMoney(unitTRY), "R", fill)
x += wn[10] x += wn[12]
c.drawCell(x, y0, wn[11], rowH, pdfMoney(it.LTutar), "R", fill) c.drawCell(x, y0, wn[13], rowH, pdfMoney(it.LTutar), "R", fill)
pdf.SetXY(x0, y0+rowH) pdf.SetXY(x0, y0+rowH)
} }

View File

@@ -0,0 +1,75 @@
/* eslint-disable */
/**
* THIS FILE IS GENERATED AUTOMATICALLY.
* DO NOT EDIT.
*
* You are probably looking on adding startup/initialization code.
* Use "quasar new boot <name>" and add it there.
* One boot file per concern. Then reference the file(s) in quasar.config file > boot:
* boot: ['file', ...] // do not add ".js" extension to it.
*
* Boot files are your "main.js"
**/
import { Quasar } from 'quasar'
import { markRaw } from 'vue'
import RootComponent from 'app/src/App.vue'
import createStore from 'app/src/stores/index'
import createRouter from 'app/src/router/index'
export default async function (createAppFn, quasarUserOptions) {
// Create the app instance.
// Here we inject into it the Quasar UI, the router & possibly the store.
const app = createAppFn(RootComponent)
app.use(Quasar, quasarUserOptions)
const store = typeof createStore === 'function'
? await createStore({})
: createStore
app.use(store)
const router = markRaw(
typeof createRouter === 'function'
? await createRouter({store})
: createRouter
)
// make router instance available in store
store.use(({ store }) => { store.router = router })
// Expose the app, the router and the store.
// Note that we are not mounting the app here, since bootstrapping will be
// different depending on whether we are in a browser or on the server.
return {
app,
store,
router
}
}

View File

@@ -0,0 +1,158 @@
/* eslint-disable */
/**
* THIS FILE IS GENERATED AUTOMATICALLY.
* DO NOT EDIT.
*
* You are probably looking on adding startup/initialization code.
* Use "quasar new boot <name>" and add it there.
* One boot file per concern. Then reference the file(s) in quasar.config file > boot:
* boot: ['file', ...] // do not add ".js" extension to it.
*
* Boot files are your "main.js"
**/
import { createApp } from 'vue'
import '@quasar/extras/roboto-font/roboto-font.css'
import '@quasar/extras/material-icons/material-icons.css'
// We load Quasar stylesheet file
import 'quasar/dist/quasar.sass'
import 'src/css/app.css'
import createQuasarApp from './app.js'
import quasarUserOptions from './quasar-user-options.js'
const publicPath = `/`
async function start ({
app,
router
, store
}, bootFiles) {
let hasRedirected = false
const getRedirectUrl = url => {
try { return router.resolve(url).href }
catch (err) {}
return Object(url) === url
? null
: url
}
const redirect = url => {
hasRedirected = true
if (typeof url === 'string' && /^https?:\/\//.test(url)) {
window.location.href = url
return
}
const href = getRedirectUrl(url)
// continue if we didn't fail to resolve the url
if (href !== null) {
window.location.href = href
window.location.reload()
}
}
const urlPath = window.location.href.replace(window.location.origin, '')
for (let i = 0; hasRedirected === false && i < bootFiles.length; i++) {
try {
await bootFiles[i]({
app,
router,
store,
ssrContext: null,
redirect,
urlPath,
publicPath
})
}
catch (err) {
if (err && err.url) {
redirect(err.url)
return
}
console.error('[Quasar] boot error:', err)
return
}
}
if (hasRedirected === true) return
app.use(router)
app.mount('#q-app')
}
createQuasarApp(createApp, quasarUserOptions)
.then(app => {
// eventually remove this when Cordova/Capacitor/Electron support becomes old
const [ method, mapFn ] = Promise.allSettled !== void 0
? [
'allSettled',
bootFiles => bootFiles.map(result => {
if (result.status === 'rejected') {
console.error('[Quasar] boot error:', result.reason)
return
}
return result.value.default
})
]
: [
'all',
bootFiles => bootFiles.map(entry => entry.default)
]
return Promise[ method ]([
import(/* webpackMode: "eager" */ 'boot/dayjs'),
import(/* webpackMode: "eager" */ 'boot/locale'),
import(/* webpackMode: "eager" */ 'boot/resizeObserverGuard')
]).then(bootFiles => {
const boot = mapFn(bootFiles).filter(entry => typeof entry === 'function')
start(app, boot)
})
})

View File

@@ -0,0 +1,116 @@
/* eslint-disable */
/**
* THIS FILE IS GENERATED AUTOMATICALLY.
* DO NOT EDIT.
*
* You are probably looking on adding startup/initialization code.
* Use "quasar new boot <name>" and add it there.
* One boot file per concern. Then reference the file(s) in quasar.config file > boot:
* boot: ['file', ...] // do not add ".js" extension to it.
*
* Boot files are your "main.js"
**/
import App from 'app/src/App.vue'
let appPrefetch = typeof App.preFetch === 'function'
? App.preFetch
: (
// Class components return the component options (and the preFetch hook) inside __c property
App.__c !== void 0 && typeof App.__c.preFetch === 'function'
? App.__c.preFetch
: false
)
function getMatchedComponents (to, router) {
const route = to
? (to.matched ? to : router.resolve(to).route)
: router.currentRoute.value
if (!route) { return [] }
const matched = route.matched.filter(m => m.components !== void 0)
if (matched.length === 0) { return [] }
return Array.prototype.concat.apply([], matched.map(m => {
return Object.keys(m.components).map(key => {
const comp = m.components[key]
return {
path: m.path,
c: comp
}
})
}))
}
export function addPreFetchHooks ({ router, store, publicPath }) {
// Add router hook for handling preFetch.
// Doing it after initial route is resolved so that we don't double-fetch
// the data that we already have. Using router.beforeResolve() so that all
// async components are resolved.
router.beforeResolve((to, from, next) => {
const
urlPath = window.location.href.replace(window.location.origin, ''),
matched = getMatchedComponents(to, router),
prevMatched = getMatchedComponents(from, router)
let diffed = false
const preFetchList = matched
.filter((m, i) => {
return diffed || (diffed = (
!prevMatched[i] ||
prevMatched[i].c !== m.c ||
m.path.indexOf('/:') > -1 // does it has params?
))
})
.filter(m => m.c !== void 0 && (
typeof m.c.preFetch === 'function'
// Class components return the component options (and the preFetch hook) inside __c property
|| (m.c.__c !== void 0 && typeof m.c.__c.preFetch === 'function')
))
.map(m => m.c.__c !== void 0 ? m.c.__c.preFetch : m.c.preFetch)
if (appPrefetch !== false) {
preFetchList.unshift(appPrefetch)
appPrefetch = false
}
if (preFetchList.length === 0) {
return next()
}
let hasRedirected = false
const redirect = url => {
hasRedirected = true
next(url)
}
const proceed = () => {
if (hasRedirected === false) { next() }
}
preFetchList.reduce(
(promise, preFetch) => promise.then(() => hasRedirected === false && preFetch({
store,
currentRoute: to,
previousRoute: from,
redirect,
urlPath,
publicPath
})),
Promise.resolve()
)
.then(proceed)
.catch(e => {
console.error(e)
proceed()
})
})
}

View File

@@ -0,0 +1,23 @@
/* eslint-disable */
/**
* THIS FILE IS GENERATED AUTOMATICALLY.
* DO NOT EDIT.
*
* You are probably looking on adding startup/initialization code.
* Use "quasar new boot <name>" and add it there.
* One boot file per concern. Then reference the file(s) in quasar.config file > boot:
* boot: ['file', ...] // do not add ".js" extension to it.
*
* Boot files are your "main.js"
**/
import lang from 'quasar/lang/tr.js'
import {Loading,Dialog,Notify} from 'quasar'
export default { config: {"notify":{"position":"top","timeout":2500}},lang,plugins: {Loading,Dialog,Notify} }

View File

@@ -251,12 +251,12 @@
> >
<div class="order-sub-header pcd-sub-header"> <div class="order-sub-header pcd-sub-header">
<div class="sub-left"> <div class="sub-left">
{{ grp.sAciklama3 || 'TANIMSIZ' }} <span class="pcd-sub-title">{{ grp.sAciklama3 || 'TANIMSIZ' }}</span>
<span v-if="normalizeGroupName(grp.sAciklama3) === 'FABRIC'" class="pcd-sub-mt-qty">
Toplam Miktar: {{ formatBarQuantity(resolveGroupQuantity(grp)) }} MT
</span>
</div> </div>
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)"> <div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
<span v-if="normalizeGroupName(grp.sAciklama3) === 'FABRIC'" class="pcd-sub-mt-qty">
Toplam Miktar: {{ formatBarQuantity(resolveGroupQuantity(grp)) }} MT |
</span>
Grup Toplami TRY: {{ formatBarMoney(resolveGroupTRYTutar(grp)) }} | USD: {{ formatBarMoney(resolveGroupUSDTutar(grp)) }} Grup Toplami TRY: {{ formatBarMoney(resolveGroupTRYTutar(grp)) }} | USD: {{ formatBarMoney(resolveGroupUSDTutar(grp)) }}
<q-icon <q-icon
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'" :name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
@@ -4681,6 +4681,16 @@ watch(
justify-content: flex-end; justify-content: flex-end;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.pcd-sub-header .sub-left {
display: flex;
align-items: center;
gap: 10px;
min-width: 0;
}
.pcd-sub-title {
flex: 0 1 auto;
min-width: 0;
}
.pcd-sub-right-clickable { .pcd-sub-right-clickable {
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
@@ -4694,6 +4704,7 @@ watch(
flex: 0 0 auto; flex: 0 0 auto;
white-space: nowrap; white-space: nowrap;
opacity: 0.9; opacity: 0.9;
font-weight: 900;
} }
.pcd-detail-table :deep(.q-table__middle) { .pcd-detail-table :deep(.q-table__middle) {