Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -2557,6 +2557,52 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
// =======================================================
|
||||
this.debugOrderPayload?.(header, lines, 'PRE-VALIDATE')
|
||||
|
||||
// =======================================================
|
||||
// 🧩 DUMMY CURRENCY PAYLOAD (model genişletmeden)
|
||||
// - trOrderLineCurrency için gerekli alanları satıra basar
|
||||
// - örnek satırdaki gibi: PriceVI/AmountVI = KDV dahil, Price/Amount = KDV hariç
|
||||
// =======================================================
|
||||
const r2 = (n) => Number((Number(n) || 0).toFixed(2))
|
||||
const r4 = (n) => Number((Number(n) || 0).toFixed(4))
|
||||
|
||||
for (const ln of lines) {
|
||||
const qty = Number(ln?.Qty1 || 0)
|
||||
const unitBase = Number(ln?.Price || 0) // KDV hariç birim
|
||||
const vatRate = Number(ln?.VatRate || 0)
|
||||
const exRate = Number(ln?.PriceExchangeRate || header?.ExchangeRate || 1) || 1
|
||||
|
||||
const taxBase = r2(unitBase * qty) // Amount
|
||||
const vat = r2((taxBase * vatRate) / 100) // Vat
|
||||
const net = r2(taxBase + vat) // AmountVI / NetAmount
|
||||
const unitWithVat = qty > 0 ? r4(net / qty) : r4(unitBase * (1 + vatRate / 100))
|
||||
|
||||
const docCurrency = String(ln?.DocCurrencyCode || header?.DocCurrencyCode || 'TRY').trim() || 'TRY'
|
||||
|
||||
// Backend model alanları
|
||||
ln.RelationCurrencyCode = docCurrency
|
||||
ln.DocPrice = unitWithVat
|
||||
ln.DocAmount = net
|
||||
ln.LocalPrice = unitBase
|
||||
ln.LocalAmount = taxBase
|
||||
ln.LineDiscount = Number(ln?.LineDiscount || 0)
|
||||
ln.TotalDiscount = Number(ln?.TotalDiscount || 0)
|
||||
ln.TaxBase = taxBase
|
||||
ln.Pct = Number(ln?.Pct || 0)
|
||||
ln.VatAmount = vat
|
||||
ln.VatDeducation = 0
|
||||
ln.NetAmount = net
|
||||
|
||||
// SQL kolonu isimleriyle dummy alias (decoder ignore etse de payload'da görünür)
|
||||
ln.CurrencyCode = docCurrency
|
||||
ln.ExchangeRate = exRate
|
||||
ln.PriceVI = unitWithVat
|
||||
ln.AmountVI = net
|
||||
ln.Amount = taxBase
|
||||
ln.LDiscount1 = Number(ln?.LDiscount1 || 0)
|
||||
ln.TDiscount1 = Number(ln?.TDiscount1 || 0)
|
||||
ln.Vat = vat
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
// 🧪 PRE-VALIDATE — prItemVariant ön kontrol
|
||||
// - invalid varsa CREATE/UPDATE ÇALIŞMAZ
|
||||
@@ -3337,4 +3383,3 @@ export const sharedOrderEntryRefs = {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user