Satınalma Siparişleri

This commit is contained in:
Sedat ÖZTÜRK 2026-10-11 17:01:11 +03:00
parent dae0a55e16
commit 8a3a00ae62
40 changed files with 21073 additions and 0 deletions

View file

@ -16893,6 +16893,576 @@
"IsEnabled": true, "IsEnabled": true,
"MultiTenancySide": 3, "MultiTenancySide": 3,
"Modules": "Prc" "Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Prc.PurchaseAgreementLine",
"Order": 7,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Create",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Update",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Delete",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Export",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Import",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreementLine.Note",
"ParentName": "App.Prc.PurchaseAgreementLine",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.Orders",
"ParentName": null,
"DisplayName": "App.Prc.Orders",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement",
"ParentName": "App.Prc.Orders",
"DisplayName": "App.Prc.PurchaseAgreement",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Create",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Update",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Delete",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Export",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Import",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseAgreement.Note",
"ParentName": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Prc.PurchaseOrderLine",
"Order": 7,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Create",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Update",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Delete",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Export",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Import",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderLine.Note",
"ParentName": "App.Prc.PurchaseOrderLine",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Prc.PurchaseOrderQuote",
"Order": 8,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Create",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Update",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Delete",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Export",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Import",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderQuote.Note",
"ParentName": "App.Prc.PurchaseOrderQuote",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Prc.PurchaseOrderOther",
"Order": 9,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Create",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Update",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Delete",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Export",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Import",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderOther.Note",
"ParentName": "App.Prc.PurchaseOrderOther",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Prc.PurchaseOrderAlternative",
"Order": 10,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Create",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Update",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Delete",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Export",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Import",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrderAlternative.Note",
"ParentName": "App.Prc.PurchaseOrderAlternative",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq",
"ParentName": "App.Prc.Orders",
"DisplayName": "App.Prc.PurchaseRfq",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Create",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Update",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Delete",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Export",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Import",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseRfq.Note",
"ParentName": "App.Prc.PurchaseRfq",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder",
"ParentName": "App.Prc.Orders",
"DisplayName": "App.Prc.PurchaseOrder",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Create",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Create",
"Order": 1,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Update",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Update",
"Order": 2,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Delete",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Delete",
"Order": 3,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Export",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Export",
"Order": 4,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Import",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Import",
"Order": 5,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
},
{
"GroupName": "App.Prc",
"Name": "App.Prc.PurchaseOrder.Note",
"ParentName": "App.Prc.PurchaseOrder",
"DisplayName": "App.Platform.Note",
"Order": 6,
"IsEnabled": true,
"MultiTenancySide": 3,
"Modules": "Prc"
} }
] ]
} }

View file

@ -58,6 +58,34 @@
"StartNumber": 1, "StartNumber": 1,
"LastPeriodKey": null, "LastPeriodKey": null,
"FormatTemplate": "{Prefix}{Number}{Suffix}" "FormatTemplate": "{Prefix}{Number}{Suffix}"
},
{
"Id": "47556a76-69d9-4529-9b8e-b319d9155d3d",
"Name": "PurchaseAgreement1",
"Prefix": "BO",
"Suffix": "",
"IsActive": true,
"PaddingSize": 5,
"IncrementStep": 1,
"NextNumber": 2,
"ResetPeriod": 0,
"StartNumber": 1,
"LastPeriodKey": null,
"FormatTemplate": "{Prefix}{Number}{Suffix}"
},
{
"Id": "939648b0-db87-4be0-a50d-62fd06e5a9b2",
"Name": "PurchaseOrder1",
"Prefix": "P",
"Suffix": "",
"IsActive": true,
"PaddingSize": 5,
"IncrementStep": 1,
"NextNumber": 1,
"ResetPeriod": 0,
"StartNumber": 1,
"LastPeriodKey": null,
"FormatTemplate": "{Prefix}{Number}{Suffix}"
} }
] ]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -2928,6 +2928,50 @@
"IsDisabled": false, "IsDisabled": false,
"ElementId": null, "ElementId": null,
"ModuleId": "Prc" "ModuleId": "Prc"
},
{
"ParentCode": "App.Prc",
"Code": "App.Prc.Orders",
"DisplayName": "App.Prc.Orders",
"Order": 3,
"Url": null,
"Icon": "FcShop",
"RequiredPermissionName": null,
"IsDisabled": false,
"ModuleId": "Prc"
},
{
"ParentCode": "App.Prc.Orders",
"Code": "App.Prc.PurchaseAgreement",
"DisplayName": "App.Prc.PurchaseAgreement",
"Order": 1,
"Url": "/admin/list/App.Prc.PurchaseAgreement",
"Icon": "FcRules",
"RequiredPermissionName": "App.Prc.PurchaseAgreement",
"IsDisabled": false,
"ModuleId": "Prc"
},
{
"ParentCode": "App.Prc.Orders",
"Code": "App.Prc.PurchaseRfq",
"DisplayName": "App.Prc.PurchaseRfq",
"Order": 2,
"Url": "/admin/list/App.Prc.PurchaseRfq",
"Icon": "FcDocument",
"RequiredPermissionName": "App.Prc.PurchaseRfq",
"IsDisabled": false,
"ModuleId": "Prc"
},
{
"ParentCode": "App.Prc.Orders",
"Code": "App.Prc.PurchaseOrder",
"DisplayName": "App.Prc.PurchaseOrder",
"Order": 3,
"Url": "/admin/list/App.Prc.PurchaseOrder",
"Icon": "FcPaid",
"RequiredPermissionName": "App.Prc.PurchaseOrder",
"IsDisabled": false,
"ModuleId": "Prc"
} }
] ]
} }

View file

@ -152,6 +152,89 @@ Yönetim › Tanımlamalar › Onaycılar (onay yeri Satınalma); Yönetim › R
- Numaratör: `App.Definitions.Sequence` › `MaterialRequest`. - Numaratör: `App.Definitions.Sequence` › `MaterialRequest`.
- Geri alma: Wizard Manager'da talep bazlı silme (alt form en son değil, önce listeler); tablolar yalnız açık onayla düşürülür. - Geri alma: Wizard Manager'da talep bazlı silme (alt form en son değil, önce listeler); tablolar yalnız açık onayla düşürülür.
<!-- module-doc:section App.Prc.Orders -->
## Siparişler (`App.Prc.Orders`)
### 1. Amaç ve kapsam
Satınalma ekibinin onaylanmış malzeme taleplerinden tedarikçilere teklif talebi (RFQ) açması, gelen teklifi işlemesi, teklifi satınalma siparişine çevirmesi ve tedarikçiyle çerçeve sözleşme (kapsamlı sipariş / ihale) yönetmesi. Kullanıcılar satınalma personeli ve alıcılardır. Mal kabul (makbuz), tedarikçi faturası, alınan/faturalanan miktar takibi ve analitik dağılım kapsam dışıdır.
### 2. Analiz ve kararlar
- Teklif talebi ve satınalma siparişi tek belgedir (`Prc_T_PurchaseOrder`); numara aşamalar boyunca korunur. Durum: Draft (Teklif Talebi) › Sent (Gönderildi) › Purchase (Satınalma Siparişi) / Cancelled.
- Numaratörler: `PurchaseOrder1` (P00001), `PurchaseAgreement1` (BO00001).
- Firma kolonu açılmadı (kiracı kapsamı). Bakım Talebi, Mali Durum, Analitik Dağılım, Alınan/Kalan/Faturalanan, Faturalama Durumu ve Fatura Yükle kullanıcı kararıyla kapsam dışı.
- Vergi kalemde tek oran (%); ürünün `PurchaseTaxRate`'inden gelir.
- Platformda buton yordam çağıramadığı için durum işlemleri formdaki **İşlem** alanıyla (`PendingAction`) yapılır; kayıtta çalışır ve alan temizlenir. "Talepten Aktar" da formdaki Malzeme Talebi alanı + kaydet ile çalışır.
- Gönderim: tedarikçinin kontak e-postasına platform bildirim kuyruğu (`Adm_T_Notification`, kanal Mail) üzerinden; kalemler e-posta gövdesinde tablo olarak gider (kuyruk ek dosya taşımaz).
- Talep ilişkisi kalem düzeyinde (`MaterialRequestItemId`); aktarım kopyalamadır, talep değişmez; iptal olmayan başka belgede yer alan kalem tekrar aktarılmaz.
- Sözleşme seçilen boş teklif, sözleşmenin kalan (sipariş edilmemiş) miktarlarıyla dolar.
- Widget'lar: OTD % tüm zamanlar üzerinden; "Sipariş Verilecek Günler" kartı üretilmedi (iki sağlayıcıda ortak tarih farkı yok). Demo veri girilmedi.
### 3. Menü ve ekranlar
Satınalma (`App.Prc`) › Siparişler (`App.Prc.Orders`):
| Ekran | Kod | Not |
| --- | --- | --- |
| Sözleşmeler | `App.Prc.PurchaseAgreement` | sekme: Ürünler; satırda Yeni Teklif (Teklif Talepleri'ni açar) |
| Teklif Talepleri | `App.Prc.PurchaseRfq` | tüm durumlar; sekmeler Ürünler, Tedarikçi Teklifi, Diğer Bilgiler, Teklifler |
| Satınalma Siparişleri | `App.Prc.PurchaseOrder` | Status = Purchase; ekle/sil kapalı; sekmeler Ürünler, Diğer Bilgiler, Teklifler |
Menüsüz alt formlar: `App.Prc.PurchaseAgreementLine`, `App.Prc.PurchaseOrderLine`, `App.Prc.PurchaseOrderQuote`, `App.Prc.PurchaseOrderOther`, `App.Prc.PurchaseOrderAlternative`.
### 4. Veri modeli
Tüm tablolar kiracı + tam audit + soft delete.
- `Prc_T_PurchaseAgreement`: AgreementNo, SupplierId, BuyerUserId, AgreementType (Blanket/Tender), CurrencyId, StartDate, EndDate, Reference, OperationTypeId, Terms, Status (Draft/Confirmed/Closed/Cancelled).
- `Prc_T_PurchaseAgreementLine`: AgreementId (FK cascade), ProductId, Description, Quantity, UomId, UnitPrice.
- `Prc_T_PurchaseOrder`: OrderNo, SupplierId, SupplierReference, AgreementId, MaterialRequestId (aktarım seçimi, kayıttan sonra boşalır), CurrencyId, OrderDeadline, ExpectedArrival, RequireConfirmation, OperationTypeId, ConfirmDate, ArrivalDate, SupplierResponse, QuoteDate, QuotedByUserId, QuoteValidUntil, BuyerUserId, SourceDocument, ProjectId, IncotermId, IncotermLocation, PaymentTermId, Terms, UntaxedAmount, TaxAmount, TotalAmount, Status, PendingAction, LastSentDate.
- `Prc_T_PurchaseOrderLine`: PurchaseOrderId (FK cascade), ProductId, Description, Quantity, UomId, UnitPrice, TaxRate, Amount, MaterialRequestItemId.
- Görünümler: `Prc_V_PurchaseAgreementLine` (OrderedQuantity), `Prc_V_PurchaseOrderAlternative` (Teklifler sekmesi), `Prc_V_MaterialRequestImportable` (aktarılabilir talepler).
- Yordamlar: `Prc_P_PurchaseOrderAfterSave`, `Prc_P_PurchaseOrderRecalc`, `Prc_P_PurchaseOrderImportRequest`, `Prc_P_PurchaseRfqFromAgreement`, `Prc_P_PurchaseOrderSetStatus`, `Prc_P_PurchaseOrderSend`.
### 5. İş kuralları ve hesaplar
- Kayıt sonrası `Prc_P_PurchaseOrderAfterSave`: boş ödeme/teslimat koşulu ve Incoterm konumu tedarikçinin Satınalma sekmesinden dolar (alıcı yalnız ilk kayıtta); sözleşme seçili ve kalem yoksa sözleşme kalemleri; Malzeme Talebi seçiliyse aktarım; tutarlar; İşlem.
- Tutar = Miktar × Birim Fiyat; KDV = Σ(Tutar × Oran/100); Toplam = Vergi Hariç + KDV. Kalem her eklenip/değişip/silindiğinde yeniden hesaplanır. Kaynak, kalemlerin talep numaralarıdır.
- Aktarım: talep Onaylandı; kalem Karşılama = Satınalma, Durum = Bekliyor; başka iptal olmayan belgede olmayan kalemler. Fiyat: sözleşme kalemi › tedarikçi fiyatı (`Inv_T_ProductSupplier`) › 0. Aktarılacak kalem yoksa hata.
- İşlemler: Gönder (iptal dışında; kalem ve tedarikçi e-postası şart; Draft ise Sent olur, LastSentDate yazılır) · Siparişi Onayla (Draft/Sent → Purchase, ConfirmDate) · İptal · Taslak olarak ayarla (yalnız Cancelled → Draft).
- İptal edilmiş belge değiştirilemez (Taslak işlemi hariç), kalem eklenemez/silinemez. Gönderilmiş teklif ve sipariş silinemez.
- Tedarikçi Teklifi'nde yanıt Bekleniyor dışına alınınca boş teklif tarihi ve teklifi veren dolar.
- Sözleşmede bitiş tarihi başlangıçtan önce olamaz.
### 6. Yetki ve görünürlük
Yetki ağacı: `App.Prc` › `App.Prc.Orders` › her liste (+ Create/Update/Delete/Export/Import/Note). Alt formların yetkisi taşıyan listenin altındadır; ortak sekmeler (Ürünler, Diğer Bilgiler, Teklifler) Teklif Talepleri'nin altına bağlandı — Satınalma Siparişleri kullanıcılarına bu sekme yetkileri de verilmelidir. Kiracı kapsamlı, şube filtresi yok.
### 7. Entegrasyonlar
Yönetim › Tanımlamalar › Kontaklar (tedarikçi, e-posta, Satınalma sekmesi varsayılanları); Envanter (Ürünler, tedarikçi fiyatları, Operasyon Türleri); Satınalma › Tanımlamalar (Ödeme Koşulları, Teslimat Koşulları); Proje modülü (Proje); Malzeme Talepleri (aktarım); Bildirimler (`Prc.RfqSent`, `Prc.PurchaseOrderSent`; NotificationWorker kuyruğu gönderir); Diziler.
### 8. Akış örneği
1. Ali'nin SRO00015 talebi onaylanır (2 satınalma kalemi).
2. Satınalma Teklif Talepleri'nde yeni kayıt açar, tedarikçi "3K Kutu" seçer (para birimi ve koşullar dolar), Talepten Aktar'da SRO00015'i seçip kaydeder; iki kalem fiyatlarıyla gelir, Kaynak = SRO00015.
3. İşlem = E-posta ile Gönder, kaydet: tedarikçiye e-posta kuyruğa alınır, durum Gönderildi.
4. Tedarikçi Teklifi sekmesinde yanıt = Teklif Verildi; fiyatlar Ürünler sekmesinde güncellenir.
5. İşlem = Siparişi Onayla: belge Satınalma Siparişleri'ne düşer; gerekirse İşlem = E-posta ile Gönder ile PO gönderilir. Mal gelince Varış girilir.
### 9. Sık sorulanlar
- **Butonlar nerede?** Durum işlemleri formdaki İşlem alanındadır; seçip kaydedin.
- **Talep listede çıkmıyor?** Talep onaylanmış olmalı ve aktarılabilir (Satınalma, Bekliyor, başka belgede olmayan) kalemi bulunmalı.
- **E-posta gitmedi?** Tedarikçinin kontak e-postasını ve Bildirimler ekranındaki satırı (IsSent) kontrol edin; NotificationWorker aktif olmalı.
- **Sözleşme seçince kalem gelmedi?** Yalnız kalemi olmayan belgeye ve kalan miktarı olan sözleşme kalemleri gelir.
### 10. Dosyalar ve geri alma
- Tablolar: `sql/object/Prc_T_PurchaseAgreement.sql`, `Prc_T_PurchaseAgreementLine.sql`, `Prc_T_PurchaseOrder.sql`, `Prc_T_PurchaseOrderLine.sql` (+ postgres).
- Görünüm/yordam: `Prc_V_PurchaseAgreementLine`, `Prc_V_PurchaseOrderAlternative`, `Prc_V_MaterialRequestImportable`, `Prc_P_PurchaseOrder{AfterSave,Recalc,ImportRequest,SetStatus,Send}`, `Prc_P_PurchaseRfqFromAgreement` (sql + postgres object).
- Wizard'lar: `Prc_PurchaseAgreementLine.json`, `Prc_PurchaseAgreement.json`, `Prc_PurchaseOrderLine.json`, `Prc_PurchaseOrderQuote.json`, `Prc_PurchaseOrderOther.json`, `Prc_PurchaseOrderAlternative.json`, `Prc_PurchaseRfq.json`, `Prc_PurchaseOrder.json`.
- Veri: Diziler `PurchaseOrder1`, `PurchaseAgreement1`; Bildirim Türleri `Prc.RfqSent`, `Prc.PurchaseOrderSent`.
- Geri alma: önce ana ekranlar (`Prc_PurchaseRfq`, `Prc_PurchaseOrder`, `Prc_PurchaseAgreement`), sonra alt formlar `delete_wizard` ile silinir; tablolar yalnız açık onayla düşürülür.
<!-- module-doc:auto:begin --> <!-- module-doc:auto:begin -->
## Ek — Ekran envanteri (otomatik) ## Ek — Ekran envanteri (otomatik)
@ -459,4 +542,251 @@ Yönetim › Tanımlamalar › Onaycılar (onay yeri Satınalma); Yönetim › R
| `PurchaseResponsibleUserId` | Satınalma Sorumlusu | dxSelectBox | | ✓ | sorgu: AbpUsers | | `PurchaseResponsibleUserId` | Satınalma Sorumlusu | dxSelectBox | | ✓ | sorgu: AbpUsers |
| `LineStatus` | Satır Durumu | dxSelectBox | ✓ | ✓ | liste: Waiting, Done, Cancelled | | `LineStatus` | Satır Durumu | dxSelectBox | ✓ | ✓ | liste: Waiting, Done, Cancelled |
### Siparişler (`App.Prc.Orders`)
#### Sözleşmeler — `App.Prc.PurchaseAgreement`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseAgreement.json` |
| Yol | Liste (Wizard) |
| Menü | `App.Prc.Orders` › `App.Prc.PurchaseAgreement` (sıra 1) |
| Yetki | `App.Prc.PurchaseAgreement` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Sözleşmeler — tedarikçilerle yapılan kapsamlı sipariş ve ihale sözleşmeleri; anlaşılan miktar ve birim fiyatlarıyla. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseAgreement` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✓ · düzenle ✓ · sil ✓ · popup |
| Kapsam | Kiracı |
| Alt formlar | `App.Prc.PurchaseAgreementLine` (Id → AgreementId) |
| Widget'lar | `App.Prc.AgreementStatus.Draft`, `App.Prc.AgreementStatus.Confirmed`, `App.Prc.AgreementStatus.Closed`, `App.Prc.AgreementStatus.Cancelled` |
| Komutlar | UpdateBefore: SQL |
| Form varsayılanları | AgreementNo=PurchaseAgreement1, BuyerUserId=@USERID, CurrencyId=TRY, StartDate=@NOW, Status=Draft |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `AgreementNo` | Sözleşme | dxTextBox | ✓ | ✓ | |
| `SupplierId` | Tedarikçi | dxSelectBox | ✓ | ✓ | sorgu: Adm_T_Contact |
| `BuyerUserId` | Alıcı | dxSelectBox | ✓ | ✓ | sorgu: AbpUsers |
| `AgreementType` | Sözleşme Türü | dxSelectBox | ✓ | ✓ | liste: Blanket, Tender |
| `CurrencyId` | Kur | dxSelectBox | ✓ | ✓ | sorgu: Sas_H_Currency |
| `StartDate` | Başlama Tarihi | dxDateBox | | ✓ | |
| `EndDate` | Bitiş Tarihi | dxDateBox | | ✓ | |
| `Reference` | Referans | dxTextBox | | ✓ | |
| `OperationTypeId` | Operasyon Türü | dxSelectBox | | ✓ | sorgu: Inv_T_OperationType |
| `Status` | Durumu | dxSelectBox | ✓ | ✓ | liste: Draft, Confirmed, Closed, Cancelled |
| `Terms` | Şartlar ve Koşullar | dxHtmlEditor | | ✓ | |
#### Teklif Talepleri — `App.Prc.PurchaseRfq`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseRfq.json` |
| Yol | Liste (Wizard) |
| Menü | `App.Prc.Orders` › `App.Prc.PurchaseRfq` (sıra 2) |
| Yetki | `App.Prc.PurchaseRfq` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Teklif Talepleri — her durumdaki satınalma belgeleri: Teklif Talebi, Teklif Talebi Gönderildi, Satınalma Siparişi ve İptal Edildi. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseOrder` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✓ · düzenle ✓ · sil ✓ · popup |
| Kapsam | Kiracı |
| Alt formlar | `App.Prc.PurchaseOrderLine` (Id → PurchaseOrderId), `App.Prc.PurchaseOrderQuote` (Id → Id), `App.Prc.PurchaseOrderOther` (Id → Id), `App.Prc.PurchaseOrderAlternative` (Id → BaseOrderId) |
| Widget'lar | `App.Prc.OrderStatus.Draft`, `App.Prc.OrderStatus.Sent`, `App.Prc.PurchaseOrder.Widget.LateRfq`, `App.Prc.PurchaseOrder.Widget.NotAcknowledged`, `App.Prc.PurchaseOrder.Widget.LateReceipt`, `App.Prc.PurchaseOrder.Widget.Otd` |
| Komutlar | InsertAfter: `Prc_P_PurchaseOrderAfterSave` · UpdateBefore: SQL · UpdateAfter: `Prc_P_PurchaseOrderAfterSave` · DeleteBefore: SQL |
| Form varsayılanları | OrderNo=PurchaseOrder1, BuyerUserId=@USERID, CurrencyId=TRY, RequireConfirmation=false, Status=Draft |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `OrderNo` | Referans | dxTextBox | ✓ | ✓ | |
| `Status` | Durumu | dxSelectBox | ✓ | ✓ | liste: Draft, Sent, Purchase, Cancelled |
| `SupplierId` | Tedarikçi | dxSelectBox | ✓ | ✓ | sorgu: Adm_T_Contact · script |
| `OrderDeadline` | Sipariş Zaman Sınırı | dxDateBox | | ✓ | |
| `SupplierReference` | Tedarikçi Referansı | dxTextBox | | ✓ | |
| `ExpectedArrival` | Beklenen Geliş | dxDateBox | | ✓ | |
| `AgreementId` | Sözleşme | dxSelectBox | | ✓ | sorgu: Prc_T_PurchaseAgreement (← SupplierId) |
| `RequireConfirmation` | Onay İsteyin | dxCheckBox | | ✓ | |
| `CurrencyId` | Para Birimi | dxSelectBox | ✓ | ✓ | sorgu: Sas_H_Currency |
| `OperationTypeId` | Teslim Alacak | dxSelectBox | | ✓ | sorgu: Inv_T_OperationType |
| `MaterialRequestId` | Talepten Aktar | dxSelectBox | | ✓ | sorgu: Prc_V_MaterialRequestImportable |
| `PendingAction` | İşlem | dxSelectBox | | ✓ | liste: Send, Confirm, Cancel, Draft |
| `SupplierResponse` | Tedarikçi Yanıtı | dxSelectBox | | | liste: Waiting, Quoted, NotQuoted |
| `BuyerUserId` | Alıcı | dxSelectBox | | | sorgu: AbpUsers |
| `SourceDocument` | Kaynak | dxTextBox | | | |
| `UntaxedAmount` | Vergi Hariç Tutar | dxNumberBox | | ✓ | |
| `TaxAmount` | KDV | dxNumberBox | | ✓ | |
| `TotalAmount` | Toplam | dxNumberBox | | ✓ | |
| `LastSentDate` | Son Gönderim | dxDateBox | | | |
| `Terms` | Şart ve Koşullar | dxTextArea | | ✓ | |
#### Satınalma Siparişleri — `App.Prc.PurchaseOrder`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseOrder.json` |
| Yol | Liste (Wizard) |
| Menü | `App.Prc.Orders` › `App.Prc.PurchaseOrder` (sıra 3) |
| Yetki | `App.Prc.PurchaseOrder` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Satınalma Siparişleri — siparişe çevrilmiş teklif talepleri. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseOrder` · filtre `"IsDeleted" = 'false' AND "Status" = 'Purchase'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✗ · düzenle ✓ · sil ✗ · popup |
| Kapsam | Kiracı |
| Alt formlar | `App.Prc.PurchaseOrderLine` (Id → PurchaseOrderId), `App.Prc.PurchaseOrderOther` (Id → Id), `App.Prc.PurchaseOrderAlternative` (Id → BaseOrderId) |
| Widget'lar | `App.Prc.PurchaseOrder.Widget.LateReceipt`, `App.Prc.PurchaseOrder.Widget.AwaitingArrival`, `App.Widget.TotalRevenue` |
| Komutlar | UpdateAfter: `Prc_P_PurchaseOrderAfterSave` |
| Form varsayılanları | CurrencyId=TRY, Status=Draft, UntaxedAmount=0, TaxAmount=0, TotalAmount=0 |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `OrderNo` | Referans | dxTextBox | ✓ | ✓ | |
| `SupplierId` | Tedarikçi | dxSelectBox | ✓ | ✓ | sorgu: Adm_T_Contact |
| `ConfirmDate` | Onaylama Tarihi | dxDateBox | | ✓ | |
| `ExpectedArrival` | Beklenen Geliş | dxDateBox | | ✓ | |
| `SupplierReference` | Tedarikçi Referansı | dxTextBox | | ✓ | |
| `ArrivalDate` | Varış | dxDateBox | | ✓ | |
| `AgreementId` | Sözleşme | dxSelectBox | | ✓ | sorgu: Prc_T_PurchaseAgreement |
| `OperationTypeId` | Teslim Alacak | dxSelectBox | | ✓ | sorgu: Inv_T_OperationType |
| `CurrencyId` | Para Birimi | dxTextBox | ✓ | ✓ | |
| `MaterialRequestId` | Talepten Aktar | dxSelectBox | | ✓ | sorgu: Prc_V_MaterialRequestImportable |
| `PendingAction` | İşlem | dxSelectBox | | ✓ | liste: Send, Cancel |
| `Status` | Durumu | dxSelectBox | | | liste: Draft, Sent, Purchase, Cancelled |
| `BuyerUserId` | Alıcı | dxSelectBox | | | sorgu: AbpUsers |
| `SourceDocument` | Kaynak | dxTextBox | | | |
| `UntaxedAmount` | Vergi Hariç Tutar | dxNumberBox | | ✓ | |
| `TaxAmount` | KDV | dxNumberBox | | ✓ | |
| `TotalAmount` | Toplam | dxNumberBox | | ✓ | |
| `LastSentDate` | Son Gönderim | dxDateBox | | | |
| `Terms` | Şart ve Koşullar | dxTextArea | | ✓ | |
#### Sözleşme Kalemleri — `App.Prc.PurchaseAgreementLine`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseAgreementLine.json` |
| Yol | Liste (Wizard) |
| Menü | Menüsüz (alt form) |
| Yetki | `App.Prc.PurchaseAgreementLine` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Sözleşme Kalemleri — satınalma sözleşmesinin ürünleri, miktarları ve anlaşılan birim fiyatları. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseAgreementLine` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✓ · düzenle ✓ · sil ✓ · popup |
| Kapsam | Kiracı |
| Form varsayılanları | Quantity=1 |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `AgreementId` | Sözleşme | dxTextBox | | | |
| `ProductId` | Ürün | dxSelectBox | ✓ | ✓ | sorgu: Inv_T_Product · script |
| `Quantity` | Miktar | dxNumberBox | ✓ | ✓ | |
| `UomId` | Birim | dxSelectBox | ✓ | ✓ | sorgu: Adm_T_Uom |
| `UnitPrice` | Birim Fiyat | dxNumberBox | ✓ | ✓ | |
| `Description` | Açıklama | dxTextArea | | ✓ | |
#### Sipariş Kalemleri — `App.Prc.PurchaseOrderLine`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseOrderLine.json` |
| Yol | Liste (Wizard) |
| Menü | Menüsüz (alt form) |
| Yetki | `App.Prc.PurchaseOrderLine` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Sipariş Kalemleri — teklif talebinin ya da satınalma siparişinin ürünleri. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseOrderLine` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✓ · düzenle ✓ · sil ✓ · popup |
| Kapsam | Kiracı |
| Komutlar | InsertBefore: SQL · InsertAfter: `Prc_P_PurchaseOrderRecalc` · UpdateBefore: SQL · UpdateAfter: `Prc_P_PurchaseOrderRecalc` · DeleteBefore: SQL · DeleteAfter: `Prc_P_PurchaseOrderRecalc` |
| Form varsayılanları | Quantity=1 |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `PurchaseOrderId` | Satınalma Siparişi | dxTextBox | | | |
| `ProductId` | Ürün | dxSelectBox | ✓ | ✓ | sorgu: Inv_T_Product · script |
| `Description` | Açıklama | dxTextBox | | ✓ | |
| `Quantity` | Miktar | dxNumberBox | ✓ | ✓ | |
| `UomId` | Birim | dxSelectBox | ✓ | ✓ | sorgu: Adm_T_Uom |
| `UnitPrice` | Birim Fiyat | dxNumberBox | ✓ | ✓ | |
| `TaxRate` | Vergiler (%) | dxNumberBox | ✓ | ✓ | |
| `Amount` | Tutar | dxNumberBox | | ✓ | script |
| `MaterialRequestItemId` | Talep | dxSelectBox | | ✓ | sorgu: Prc_T_MaterialRequestItem |
#### Tedarikçi Teklifi — `App.Prc.PurchaseOrderQuote`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseOrderQuote.json` |
| Yol | Liste (Wizard) |
| Menü | Menüsüz (alt form) |
| Yetki | `App.Prc.PurchaseOrderQuote` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Tedarikçi Teklifi — tedarikçinin teklif talebine verdiği yanıt. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseOrder` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✗ · düzenle ✓ · sil ✗ · popup |
| Kapsam | Kiracı |
| Komutlar | UpdateAfter: SQL |
| Form varsayılanları | SupplierResponse=Waiting |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `SupplierResponse` | Tedarikçi Yanıtı | dxSelectBox | ✓ | ✓ | liste: Waiting, Quoted, NotQuoted |
| `QuoteValidUntil` | Teklif Geçerliliği | dxDateBox | | ✓ | |
| `QuoteDate` | Teklif Tarihi | dxDateBox | | ✓ | |
| `QuotedByUserId` | Teklifi Veren | dxSelectBox | | ✓ | sorgu: AbpUsers |
#### Diğer Bilgiler — `App.Prc.PurchaseOrderOther`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseOrderOther.json` |
| Yol | Liste (Wizard) |
| Menü | Menüsüz (alt form) |
| Yetki | `App.Prc.PurchaseOrderOther` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Diğer Bilgiler — teklif talebinin ya da satınalma siparişinin alıcı, kaynak, proje ve ticari koşulları. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_T_PurchaseOrder` · filtre `"IsDeleted" = 'false'` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✗ · düzenle ✓ · sil ✗ · popup |
| Kapsam | Kiracı |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `BuyerUserId` | Alıcı | dxSelectBox | ✓ | ✓ | sorgu: AbpUsers |
| `PaymentTermId` | Ödeme Koşulları | dxSelectBox | | ✓ | sorgu: Prc_T_PaymentTerm |
| `SourceDocument` | Kaynak | dxTextBox | | ✓ | |
| `ProjectId` | Proje | dxSelectBox | | ✓ | sorgu: Prj_T_Project |
| `IncotermId` | Teslimat Koşulu | dxSelectBox | | ✓ | sorgu: Prc_T_Incoterm |
| `IncotermLocation` | Incoterm Konumu | dxTextBox | | ✓ | |
#### Teklifler — `App.Prc.PurchaseOrderAlternative`
| Özellik | Değer |
| --- | --- |
| Wizard | `wizard/Prc_PurchaseOrderAlternative.json` |
| Yol | Liste (Wizard) |
| Menü | Menüsüz (alt form) |
| Yetki | `App.Prc.PurchaseOrderAlternative` + `.Create`, `.Update`, `.Delete`, `.Export`, `.Import`, `.Note` |
| Açıklama | Teklifler — açık belgeyle aynı malzeme talebinin kalemlerini taşıyan diğer teklif talepleri ve siparişler. |
| Geliştirme talebi | Satınalma -> Siparişler |
| Kaynak | `Prc_V_PurchaseOrderAlternative` |
| Görünümler | Grid, Card, Pivot, Chart (açılış grid) |
| Düzenleme | ekle ✗ · düzenle ✗ · sil ✗ · popup |
| Kapsam | Kiracı |
| Alan | Başlık | Editör | Zorunlu | Formda | Kaynak |
| --- | --- | --- | --- | --- | --- |
| `BaseOrderId` | Ana Belge | dxTextBox | | | |
| `OrderNo` | Referans | dxTextBox | | | |
| `SupplierId` | Tedarikçi | dxSelectBox | | | sorgu: Adm_T_Contact |
| `SupplierResponse` | Tedarikçi Yanıtı | dxSelectBox | | | liste: Waiting, Quoted, NotQuoted |
| `OrderDeadline` | Sipariş Zaman Sınırı | dxDateBox | | | |
| `ExpectedArrival` | Beklenen Geliş | dxDateBox | | | |
| `TotalAmount` | Toplam | dxNumberBox | | | |
| `CurrencyId` | Para Birimi | dxTextBox | | | |
| `Status` | Durumu | dxSelectBox | | | liste: Draft, Sent, Purchase, Cancelled |
<!-- module-doc:auto:end --> <!-- module-doc:auto:end -->

View file

@ -0,0 +1,20 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseOrderAfterSave"(p_id uuid, p_user_id uuid DEFAULT NULL)
LANGUAGE plpgsql AS $$
DECLARE v_req uuid; v_act varchar(16); v_agr uuid;
BEGIN
UPDATE "Prc_T_PurchaseOrder" o SET
"PaymentTermId" = COALESCE(o."PaymentTermId", c."PurchasePaymentTermId"),
"IncotermId" = COALESCE(o."IncotermId", c."PurchaseIncotermId"),
"IncotermLocation" = COALESCE(o."IncotermLocation", c."PurchaseIncotermLocation"),
"BuyerUserId" = CASE WHEN o."LastModificationTime" IS NULL AND c."BuyerUserId" IS NOT NULL THEN c."BuyerUserId" ELSE o."BuyerUserId" END
FROM "Adm_T_Contact" c
WHERE o."Id" = p_id AND c."Id" = o."SupplierId";
SELECT "MaterialRequestId", "PendingAction", "AgreementId" INTO v_req, v_act, v_agr
FROM "Prc_T_PurchaseOrder" WHERE "Id" = p_id;
IF v_agr IS NOT NULL THEN CALL public."Prc_P_PurchaseRfqFromAgreement"(p_id); END IF;
IF v_req IS NOT NULL THEN CALL public."Prc_P_PurchaseOrderImportRequest"(p_id); END IF;
CALL public."Prc_P_PurchaseOrderRecalc"(p_id);
IF v_act IS NOT NULL THEN CALL public."Prc_P_PurchaseOrderSetStatus"(p_id, v_act, p_user_id); END IF;
END;
$$;

View file

@ -0,0 +1,40 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseOrderImportRequest"(p_id uuid)
LANGUAGE plpgsql AS $$
DECLARE v_req uuid; v_tenant uuid; v_supplier uuid; v_agr uuid; v_status varchar(16); v_cnt int;
BEGIN
SELECT "MaterialRequestId", "TenantId", "SupplierId", "AgreementId", "Status"
INTO v_req, v_tenant, v_supplier, v_agr, v_status
FROM "Prc_T_PurchaseOrder" WHERE "Id" = p_id;
IF v_req IS NULL THEN RETURN; END IF;
IF v_status = 'Cancelled' THEN
RAISE EXCEPTION 'İptal edilmiş belgeye talepten aktarım yapılamaz.';
END IF;
INSERT INTO "Prc_T_PurchaseOrderLine" ("Id", "TenantId", "PurchaseOrderId", "ProductId", "Description", "Quantity", "UomId",
"UnitPrice", "TaxRate", "Amount", "MaterialRequestItemId", "CreationTime", "IsDeleted")
SELECT gen_random_uuid(), v_tenant, p_id, i."ProductId", i."RequestReason", i."Quantity", i."UomId",
COALESCE((SELECT al."UnitPrice" FROM "Prc_T_PurchaseAgreementLine" al
WHERE al."AgreementId" = v_agr AND al."ProductId" = i."ProductId" AND al."IsDeleted" = false LIMIT 1),
(SELECT ps."Price" FROM "Inv_T_ProductSupplier" ps
WHERE ps."ProductId" = i."ProductId" AND ps."ContactId" = v_supplier AND ps."IsDeleted" = false
ORDER BY ps."MinQuantity" LIMIT 1), 0),
COALESCE(p."PurchaseTaxRate", 0), 0, i."Id", CURRENT_TIMESTAMP, false
FROM "Prc_T_MaterialRequestItem" i
INNER JOIN "Prc_T_MaterialRequest" r ON r."Id" = i."MaterialRequestId"
LEFT JOIN "Inv_T_Product" p ON p."Id" = i."ProductId"
WHERE i."MaterialRequestId" = v_req AND i."IsDeleted" = false
AND r."ApprovalStatus" = 'Onaylandı'
AND i."FulfillmentMethod" = 'Purchase' AND i."LineStatus" = 'Waiting'
AND NOT EXISTS (SELECT 1 FROM "Prc_T_PurchaseOrderLine" ol
INNER JOIN "Prc_T_PurchaseOrder" o ON o."Id" = ol."PurchaseOrderId"
WHERE ol."MaterialRequestItemId" = i."Id" AND ol."IsDeleted" = false
AND o."IsDeleted" = false AND o."Status" <> 'Cancelled');
GET DIAGNOSTICS v_cnt = ROW_COUNT;
UPDATE "Prc_T_PurchaseOrder" SET "MaterialRequestId" = NULL WHERE "Id" = p_id;
IF v_cnt = 0 THEN
RAISE EXCEPTION 'Seçilen talepte aktarılacak kalem yok (onaylı, Satınalma ile karşılanacak, bekleyen ve başka belgede olmayan kalem bulunamadı).';
END IF;
END;
$$;

View file

@ -0,0 +1,20 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseOrderRecalc"(p_id uuid)
LANGUAGE plpgsql AS $$
BEGIN
UPDATE "Prc_T_PurchaseOrderLine" SET "Amount" = ROUND("Quantity" * "UnitPrice", 2)
WHERE "PurchaseOrderId" = p_id AND "IsDeleted" = false;
UPDATE "Prc_T_PurchaseOrder" o SET
"UntaxedAmount" = COALESCE((SELECT SUM(l."Amount") FROM "Prc_T_PurchaseOrderLine" l WHERE l."PurchaseOrderId" = p_id AND l."IsDeleted" = false), 0),
"TaxAmount" = COALESCE((SELECT SUM(ROUND(l."Amount" * l."TaxRate" / 100, 2)) FROM "Prc_T_PurchaseOrderLine" l WHERE l."PurchaseOrderId" = p_id AND l."IsDeleted" = false), 0),
"SourceDocument" = (SELECT string_agg(s."RequestNo", ', ' ORDER BY s."RequestNo")
FROM (SELECT DISTINCT r."RequestNo"
FROM "Prc_T_PurchaseOrderLine" l
INNER JOIN "Prc_T_MaterialRequestItem" i ON i."Id" = l."MaterialRequestItemId"
INNER JOIN "Prc_T_MaterialRequest" r ON r."Id" = i."MaterialRequestId"
WHERE l."PurchaseOrderId" = p_id AND l."IsDeleted" = false) s)
WHERE o."Id" = p_id;
UPDATE "Prc_T_PurchaseOrder" SET "TotalAmount" = "UntaxedAmount" + "TaxAmount" WHERE "Id" = p_id;
END;
$$;

View file

@ -0,0 +1,45 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseOrderSend"(p_id uuid, p_user_id uuid DEFAULT NULL)
LANGUAGE plpgsql AS $$
DECLARE v_tenant uuid; v_no varchar(32); v_status varchar(16); v_email varchar(256); v_supplier varchar(256);
v_type_name varchar(64); v_type uuid; v_subject varchar(256); v_lines text; v_total numeric; v_cur varchar(8);
BEGIN
SELECT o."TenantId", o."OrderNo", o."Status", c."Email", c."Name", o."TotalAmount", o."CurrencyId"
INTO v_tenant, v_no, v_status, v_email, v_supplier, v_total, v_cur
FROM "Prc_T_PurchaseOrder" o LEFT JOIN "Adm_T_Contact" c ON c."Id" = o."SupplierId"
WHERE o."Id" = p_id;
IF NOT EXISTS (SELECT 1 FROM "Prc_T_PurchaseOrderLine" WHERE "PurchaseOrderId" = p_id AND "IsDeleted" = false) THEN
RAISE EXCEPTION 'Kalemi olmayan belge gönderilemez.';
END IF;
IF COALESCE(v_email, '') = '' THEN
RAISE EXCEPTION 'Tedarikçinin kontak kartında e-posta adresi yok.';
END IF;
IF v_status = 'Purchase' THEN v_type_name := 'Prc.PurchaseOrderSent'; v_subject := 'Satınalma Siparişi ' || v_no;
ELSE v_type_name := 'Prc.RfqSent'; v_subject := 'Teklif Talebi ' || v_no; END IF;
SELECT "Id" INTO v_type FROM "Adm_T_NotificationType"
WHERE "Name" = v_type_name AND "IsDeleted" = false AND ("TenantId" = v_tenant OR ("TenantId" IS NULL AND v_tenant IS NULL)) LIMIT 1;
SELECT string_agg('<tr><td>' || COALESCE(p."Name", '') || '</td><td>' || COALESCE(l."Description", '') || '</td><td style="text-align:right">'
|| TRIM(TO_CHAR(l."Quantity", 'FM999G999G990D##')) || ' ' || l."UomId" || '</td><td style="text-align:right">'
|| TRIM(TO_CHAR(l."UnitPrice", 'FM999G999G990D00')) || '</td><td style="text-align:right">%'
|| TRIM(TO_CHAR(l."TaxRate", 'FM990')) || '</td><td style="text-align:right">'
|| TRIM(TO_CHAR(l."Amount", 'FM999G999G990D00')) || '</td></tr>', '' ORDER BY l."CreationTime")
INTO v_lines
FROM "Prc_T_PurchaseOrderLine" l LEFT JOIN "Inv_T_Product" p ON p."Id" = l."ProductId"
WHERE l."PurchaseOrderId" = p_id AND l."IsDeleted" = false;
INSERT INTO "Adm_T_Notification" ("Id", "TenantId", "NotificationTypeId", "NotificationChannel", "Identifier", "Subject", "Message",
"IsSent", "IsRead", "CreationTime", "CreatorId", "IsDeleted")
VALUES (gen_random_uuid(), v_tenant, v_type, 'Mail', v_email, v_subject,
'<p>Sayın ' || COALESCE(v_supplier, '') || ',</p><p>' || v_subject || ' aşağıda bilgilerinize sunulmuştur.</p>'
|| '<table border="1" cellpadding="4" cellspacing="0"><tr><th>Ürün</th><th>Açıklama</th><th>Miktar</th><th>Birim Fiyat</th><th>KDV</th><th>Tutar</th></tr>'
|| COALESCE(v_lines, '') || '</table><p><b>Toplam: ' || TRIM(TO_CHAR(v_total, 'FM999G999G990D00')) || ' ' || v_cur || '</b></p>',
false, false, CURRENT_TIMESTAMP, p_user_id, false);
UPDATE "Prc_T_PurchaseOrder" SET "LastSentDate" = CURRENT_TIMESTAMP,
"Status" = CASE WHEN "Status" = 'Draft' THEN 'Sent' ELSE "Status" END
WHERE "Id" = p_id;
END;
$$;

View file

@ -0,0 +1,24 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseOrderSetStatus"(p_id uuid, p_action varchar, p_user_id uuid DEFAULT NULL)
LANGUAGE plpgsql AS $$
DECLARE v_status varchar(16);
BEGIN
SELECT "Status" INTO v_status FROM "Prc_T_PurchaseOrder" WHERE "Id" = p_id;
UPDATE "Prc_T_PurchaseOrder" SET "PendingAction" = NULL WHERE "Id" = p_id;
IF p_action = 'Send' THEN
IF v_status = 'Cancelled' THEN RAISE EXCEPTION 'İptal edilmiş belge gönderilemez.'; END IF;
CALL public."Prc_P_PurchaseOrderSend"(p_id, p_user_id);
ELSIF p_action = 'Confirm' THEN
IF v_status NOT IN ('Draft', 'Sent') THEN RAISE EXCEPTION 'Yalnız teklif aşamasındaki belge siparişe çevrilebilir.'; END IF;
IF NOT EXISTS (SELECT 1 FROM "Prc_T_PurchaseOrderLine" WHERE "PurchaseOrderId" = p_id AND "IsDeleted" = false) THEN
RAISE EXCEPTION 'Kalemi olmayan teklif onaylanamaz.';
END IF;
UPDATE "Prc_T_PurchaseOrder" SET "Status" = 'Purchase', "ConfirmDate" = CURRENT_TIMESTAMP WHERE "Id" = p_id;
ELSIF p_action = 'Cancel' THEN
UPDATE "Prc_T_PurchaseOrder" SET "Status" = 'Cancelled' WHERE "Id" = p_id;
ELSIF p_action = 'Draft' THEN
IF v_status <> 'Cancelled' THEN RAISE EXCEPTION 'Yalnız iptal edilmiş belge taslağa alınabilir.'; END IF;
UPDATE "Prc_T_PurchaseOrder" SET "Status" = 'Draft', "ConfirmDate" = NULL WHERE "Id" = p_id;
END IF;
END;
$$;

View file

@ -0,0 +1,19 @@
CREATE OR REPLACE PROCEDURE public."Prc_P_PurchaseRfqFromAgreement"(p_id uuid)
LANGUAGE plpgsql AS $$
DECLARE v_agr uuid; v_tenant uuid;
BEGIN
SELECT "AgreementId", "TenantId" INTO v_agr, v_tenant FROM "Prc_T_PurchaseOrder" WHERE "Id" = p_id;
IF v_agr IS NULL THEN RETURN; END IF;
IF EXISTS (SELECT 1 FROM "Prc_T_PurchaseOrderLine" WHERE "PurchaseOrderId" = p_id AND "IsDeleted" = false) THEN RETURN; END IF;
INSERT INTO "Prc_T_PurchaseOrderLine" ("Id", "TenantId", "PurchaseOrderId", "ProductId", "Description", "Quantity", "UomId",
"UnitPrice", "TaxRate", "Amount", "CreationTime", "IsDeleted")
SELECT gen_random_uuid(), v_tenant, p_id, al."ProductId", al."Description",
GREATEST(al."Quantity" - al."OrderedQuantity", 0), al."UomId", al."UnitPrice",
COALESCE(p."PurchaseTaxRate", 0), 0, CURRENT_TIMESTAMP, false
FROM "Prc_V_PurchaseAgreementLine" al
LEFT JOIN "Inv_T_Product" p ON p."Id" = al."ProductId"
WHERE al."AgreementId" = v_agr AND al."IsDeleted" = false
AND al."Quantity" - al."OrderedQuantity" > 0;
END;
$$;

View file

@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS public."Prc_T_PurchaseAgreement"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"AgreementNo" varchar(32) NOT NULL,
"SupplierId" uuid NOT NULL,
"BuyerUserId" uuid NOT NULL,
"AgreementType" varchar(16) NOT NULL DEFAULT 'Blanket',
"CurrencyId" varchar(8) NOT NULL DEFAULT 'TRY',
"StartDate" date NULL,
"EndDate" date NULL,
"Reference" varchar(64) NULL,
"OperationTypeId" uuid NULL,
"Terms" text NULL,
"Status" varchar(16) NOT NULL DEFAULT 'Draft',
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prc_T_PurchaseAgreement" PRIMARY KEY ("Id")
);

View file

@ -0,0 +1,27 @@
CREATE TABLE IF NOT EXISTS public."Prc_T_PurchaseAgreementLine"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"AgreementId" uuid NOT NULL,
"ProductId" uuid NOT NULL,
"Description" varchar(512) NULL,
"Quantity" numeric(18, 4) NOT NULL DEFAULT 1,
"UomId" varchar(50) NOT NULL DEFAULT 'Adet',
"UnitPrice" numeric(18, 4) NOT NULL DEFAULT 0,
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prc_T_PurchaseAgreementLine" PRIMARY KEY ("Id")
);
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_Prc_T_PurchaseAgreementLine_AgreementId') THEN
ALTER TABLE public."Prc_T_PurchaseAgreementLine" ADD CONSTRAINT "FK_Prc_T_PurchaseAgreementLine_AgreementId" FOREIGN KEY ("AgreementId") REFERENCES public."Prc_T_PurchaseAgreement" ("Id") ON DELETE CASCADE ON UPDATE NO ACTION;
END IF;
END
$$;

View file

@ -0,0 +1,42 @@
CREATE TABLE IF NOT EXISTS public."Prc_T_PurchaseOrder"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"OrderNo" varchar(32) NOT NULL,
"SupplierId" uuid NOT NULL,
"SupplierReference" varchar(64) NULL,
"AgreementId" uuid NULL,
"MaterialRequestId" uuid NULL,
"CurrencyId" varchar(8) NOT NULL DEFAULT 'TRY',
"OrderDeadline" timestamp NULL,
"ExpectedArrival" timestamp NULL,
"RequireConfirmation" boolean NOT NULL DEFAULT FALSE,
"OperationTypeId" uuid NULL,
"ConfirmDate" timestamp NULL,
"ArrivalDate" timestamp NULL,
"SupplierResponse" varchar(16) NOT NULL DEFAULT 'Waiting',
"QuoteDate" timestamp NULL,
"QuotedByUserId" uuid NULL,
"QuoteValidUntil" date NULL,
"BuyerUserId" uuid NOT NULL,
"SourceDocument" varchar(512) NULL,
"ProjectId" uuid NULL,
"IncotermId" uuid NULL,
"IncotermLocation" varchar(128) NULL,
"PaymentTermId" uuid NULL,
"Terms" text NULL,
"UntaxedAmount" numeric(18, 4) NOT NULL DEFAULT 0,
"TaxAmount" numeric(18, 4) NOT NULL DEFAULT 0,
"TotalAmount" numeric(18, 4) NOT NULL DEFAULT 0,
"Status" varchar(16) NOT NULL DEFAULT 'Draft',
"PendingAction" varchar(16) NULL,
"LastSentDate" timestamp NULL,
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prc_T_PurchaseOrder" PRIMARY KEY ("Id")
);

View file

@ -0,0 +1,30 @@
CREATE TABLE IF NOT EXISTS public."Prc_T_PurchaseOrderLine"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"PurchaseOrderId" uuid NOT NULL,
"ProductId" uuid NOT NULL,
"Description" varchar(512) NULL,
"Quantity" numeric(18, 4) NOT NULL DEFAULT 1,
"UomId" varchar(50) NOT NULL DEFAULT 'Adet',
"UnitPrice" numeric(18, 4) NOT NULL DEFAULT 0,
"TaxRate" numeric(18, 4) NOT NULL DEFAULT 20,
"Amount" numeric(18, 4) NOT NULL DEFAULT 0,
"MaterialRequestItemId" uuid NULL,
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prc_T_PurchaseOrderLine" PRIMARY KEY ("Id")
);
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_Prc_T_PurchaseOrderLine_PurchaseOrderId') THEN
ALTER TABLE public."Prc_T_PurchaseOrderLine" ADD CONSTRAINT "FK_Prc_T_PurchaseOrderLine_PurchaseOrderId" FOREIGN KEY ("PurchaseOrderId") REFERENCES public."Prc_T_PurchaseOrder" ("Id") ON DELETE CASCADE ON UPDATE NO ACTION;
END IF;
END
$$;

View file

@ -0,0 +1,11 @@
CREATE OR REPLACE VIEW public."Prc_V_MaterialRequestImportable" AS
SELECT r."Id", r."TenantId", r."RequestNo", r."RequesterUserId", r."RequestDate",
(SELECT COUNT(*) FROM "Prc_T_MaterialRequestItem" i
WHERE i."MaterialRequestId" = r."Id" AND i."IsDeleted" = false
AND i."FulfillmentMethod" = 'Purchase' AND i."LineStatus" = 'Waiting'
AND NOT EXISTS (SELECT 1 FROM "Prc_T_PurchaseOrderLine" ol
INNER JOIN "Prc_T_PurchaseOrder" o ON o."Id" = ol."PurchaseOrderId"
WHERE ol."MaterialRequestItemId" = i."Id" AND ol."IsDeleted" = false
AND o."IsDeleted" = false AND o."Status" <> 'Cancelled')) AS "ImportableCount"
FROM "Prc_T_MaterialRequest" r
WHERE r."IsDeleted" = false AND r."ApprovalStatus" = 'Onaylandı';

View file

@ -0,0 +1,9 @@
CREATE OR REPLACE VIEW public."Prc_V_PurchaseAgreementLine" AS
SELECT l."Id", l."TenantId", l."AgreementId", l."ProductId", l."Description", l."Quantity", l."UomId", l."UnitPrice",
COALESCE((SELECT SUM(ol."Quantity")
FROM "Prc_T_PurchaseOrderLine" ol
INNER JOIN "Prc_T_PurchaseOrder" o ON o."Id" = ol."PurchaseOrderId"
WHERE o."AgreementId" = l."AgreementId" AND ol."ProductId" = l."ProductId"
AND o."Status" = 'Purchase' AND o."IsDeleted" = false AND ol."IsDeleted" = false), 0) AS "OrderedQuantity",
l."CreationTime", l."CreatorId", l."LastModificationTime", l."LastModifierId", l."IsDeleted", l."DeletionTime", l."DeleterId"
FROM "Prc_T_PurchaseAgreementLine" l;

View file

@ -0,0 +1,10 @@
CREATE OR REPLACE VIEW public."Prc_V_PurchaseOrderAlternative" AS
SELECT DISTINCT b."Id" AS "BaseOrderId", x."Id", x."TenantId", x."OrderNo", x."SupplierId", x."Status", x."SupplierResponse",
x."OrderDeadline", x."ExpectedArrival", x."TotalAmount", x."CurrencyId", x."IsDeleted"
FROM "Prc_T_PurchaseOrder" b
INNER JOIN "Prc_T_PurchaseOrderLine" bl ON bl."PurchaseOrderId" = b."Id" AND bl."IsDeleted" = false AND bl."MaterialRequestItemId" IS NOT NULL
INNER JOIN "Prc_T_MaterialRequestItem" bi ON bi."Id" = bl."MaterialRequestItemId"
INNER JOIN "Prc_T_MaterialRequestItem" xi ON xi."MaterialRequestId" = bi."MaterialRequestId"
INNER JOIN "Prc_T_PurchaseOrderLine" xl ON xl."MaterialRequestItemId" = xi."Id" AND xl."IsDeleted" = false
INNER JOIN "Prc_T_PurchaseOrder" x ON x."Id" = xl."PurchaseOrderId" AND x."Id" <> b."Id"
WHERE b."IsDeleted" = false;

View file

@ -0,0 +1,23 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseOrderAfterSave]
@Id uniqueidentifier,
@UserId uniqueidentifier = NULL
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Req uniqueidentifier, @Act nvarchar(16), @Agr uniqueidentifier;
UPDATE o SET
PaymentTermId = ISNULL(o.PaymentTermId, c.PurchasePaymentTermId),
IncotermId = ISNULL(o.IncotermId, c.PurchaseIncotermId),
IncotermLocation = ISNULL(o.IncotermLocation, c.PurchaseIncotermLocation),
BuyerUserId = CASE WHEN o.LastModificationTime IS NULL AND c.BuyerUserId IS NOT NULL THEN c.BuyerUserId ELSE o.BuyerUserId END
FROM Prc_T_PurchaseOrder o
INNER JOIN Adm_T_Contact c ON c.Id = o.SupplierId
WHERE o.Id = @Id;
SELECT @Req = MaterialRequestId, @Act = PendingAction, @Agr = AgreementId FROM Prc_T_PurchaseOrder WHERE Id = @Id;
IF @Agr IS NOT NULL EXEC Prc_P_PurchaseRfqFromAgreement @Id;
IF @Req IS NOT NULL EXEC Prc_P_PurchaseOrderImportRequest @Id;
EXEC Prc_P_PurchaseOrderRecalc @Id;
IF @Act IS NOT NULL EXEC Prc_P_PurchaseOrderSetStatus @Id, @Act, @UserId;
END

View file

@ -0,0 +1,39 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseOrderImportRequest]
@Id uniqueidentifier
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Req uniqueidentifier, @Tenant uniqueidentifier, @Supplier uniqueidentifier, @Agr uniqueidentifier, @Status nvarchar(16), @Cnt int;
SELECT @Req = MaterialRequestId, @Tenant = TenantId, @Supplier = SupplierId, @Agr = AgreementId, @Status = Status
FROM Prc_T_PurchaseOrder WHERE Id = @Id;
IF @Req IS NULL RETURN;
IF @Status = 'Cancelled'
THROW 50101, N'İptal edilmiş belgeye talepten aktarım yapılamaz.', 1;
INSERT INTO Prc_T_PurchaseOrderLine (Id, TenantId, PurchaseOrderId, ProductId, Description, Quantity, UomId,
UnitPrice, TaxRate, Amount, MaterialRequestItemId, CreationTime, IsDeleted)
SELECT NEWID(), @Tenant, @Id, i.ProductId, i.RequestReason, i.Quantity, i.UomId,
COALESCE((SELECT TOP 1 al.UnitPrice FROM Prc_T_PurchaseAgreementLine al
WHERE al.AgreementId = @Agr AND al.ProductId = i.ProductId AND al.IsDeleted = 0),
(SELECT TOP 1 ps.Price FROM Inv_T_ProductSupplier ps
WHERE ps.ProductId = i.ProductId AND ps.ContactId = @Supplier AND ps.IsDeleted = 0
ORDER BY ps.MinQuantity), 0),
ISNULL(p.PurchaseTaxRate, 0), 0, i.Id, GETUTCDATE(), 0
FROM Prc_T_MaterialRequestItem i
INNER JOIN Prc_T_MaterialRequest r ON r.Id = i.MaterialRequestId
LEFT JOIN Inv_T_Product p ON p.Id = i.ProductId
WHERE i.MaterialRequestId = @Req AND i.IsDeleted = 0
AND r.ApprovalStatus = N'Onaylandı'
AND i.FulfillmentMethod = 'Purchase' AND i.LineStatus = 'Waiting'
AND NOT EXISTS (SELECT 1 FROM Prc_T_PurchaseOrderLine ol
INNER JOIN Prc_T_PurchaseOrder o ON o.Id = ol.PurchaseOrderId
WHERE ol.MaterialRequestItemId = i.Id AND ol.IsDeleted = 0
AND o.IsDeleted = 0 AND o.Status <> 'Cancelled');
SET @Cnt = @@ROWCOUNT;
UPDATE Prc_T_PurchaseOrder SET MaterialRequestId = NULL WHERE Id = @Id;
IF @Cnt = 0
THROW 50102, N'Seçilen talepte aktarılacak kalem yok (onaylı, Satınalma ile karşılanacak, bekleyen ve başka belgede olmayan kalem bulunamadı).', 1;
END

View file

@ -0,0 +1,23 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseOrderRecalc]
@Id uniqueidentifier
AS
BEGIN
SET NOCOUNT ON;
UPDATE Prc_T_PurchaseOrderLine SET Amount = ROUND(Quantity * UnitPrice, 2)
WHERE PurchaseOrderId = @Id AND IsDeleted = 0;
UPDATE o SET
UntaxedAmount = ISNULL((SELECT SUM(l.Amount) FROM Prc_T_PurchaseOrderLine l WHERE l.PurchaseOrderId = @Id AND l.IsDeleted = 0), 0),
TaxAmount = ISNULL((SELECT SUM(ROUND(l.Amount * l.TaxRate / 100, 2)) FROM Prc_T_PurchaseOrderLine l WHERE l.PurchaseOrderId = @Id AND l.IsDeleted = 0), 0),
SourceDocument = STUFF((SELECT DISTINCT N', ' + r.RequestNo
FROM Prc_T_PurchaseOrderLine l
INNER JOIN Prc_T_MaterialRequestItem i ON i.Id = l.MaterialRequestItemId
INNER JOIN Prc_T_MaterialRequest r ON r.Id = i.MaterialRequestId
WHERE l.PurchaseOrderId = @Id AND l.IsDeleted = 0
FOR XML PATH(''), TYPE).value('.', 'nvarchar(512)'), 1, 2, N'')
FROM Prc_T_PurchaseOrder o
WHERE o.Id = @Id;
UPDATE Prc_T_PurchaseOrder SET TotalAmount = UntaxedAmount + TaxAmount WHERE Id = @Id;
END

View file

@ -0,0 +1,50 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseOrderSend]
@Id uniqueidentifier,
@UserId uniqueidentifier = NULL
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Tenant uniqueidentifier, @No nvarchar(32), @Status nvarchar(16), @Email nvarchar(256), @Supplier nvarchar(256),
@TypeName nvarchar(64), @Type uniqueidentifier, @Subject nvarchar(256), @Lines nvarchar(max), @Total decimal(18,4), @Cur nvarchar(8);
SELECT @Tenant = o.TenantId, @No = o.OrderNo, @Status = o.Status, @Email = c.Email, @Supplier = c.Name,
@Total = o.TotalAmount, @Cur = o.CurrencyId
FROM Prc_T_PurchaseOrder o LEFT JOIN Adm_T_Contact c ON c.Id = o.SupplierId
WHERE o.Id = @Id;
IF NOT EXISTS (SELECT 1 FROM Prc_T_PurchaseOrderLine WHERE PurchaseOrderId = @Id AND IsDeleted = 0)
THROW 50111, N'Kalemi olmayan belge gönderilemez.', 1;
IF ISNULL(@Email, N'') = N''
THROW 50112, N'Tedarikçinin kontak kartında e-posta adresi yok.', 1;
IF @Status = 'Purchase'
SELECT @TypeName = N'Prc.PurchaseOrderSent', @Subject = N'Satınalma Siparişi ' + @No;
ELSE
SELECT @TypeName = N'Prc.RfqSent', @Subject = N'Teklif Talebi ' + @No;
SELECT TOP 1 @Type = Id FROM Adm_T_NotificationType
WHERE Name = @TypeName AND IsDeleted = 0 AND (TenantId = @Tenant OR (TenantId IS NULL AND @Tenant IS NULL));
SELECT @Lines = (SELECT N'<tr><td>' + ISNULL(p.Name, N'') + N'</td><td>' + ISNULL(l.Description, N'') + N'</td><td style="text-align:right">'
+ FORMAT(l.Quantity, 'N2', 'tr-TR') + N' ' + l.UomId + N'</td><td style="text-align:right">'
+ FORMAT(l.UnitPrice, 'N2', 'tr-TR') + N'</td><td style="text-align:right">%'
+ FORMAT(l.TaxRate, 'N0', 'tr-TR') + N'</td><td style="text-align:right">'
+ FORMAT(l.Amount, 'N2', 'tr-TR') + N'</td></tr>'
FROM Prc_T_PurchaseOrderLine l LEFT JOIN Inv_T_Product p ON p.Id = l.ProductId
WHERE l.PurchaseOrderId = @Id AND l.IsDeleted = 0
ORDER BY l.CreationTime
FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)');
INSERT INTO Adm_T_Notification (Id, TenantId, NotificationTypeId, NotificationChannel, Identifier, Subject, Message,
IsSent, IsRead, CreationTime, CreatorId, IsDeleted)
VALUES (NEWID(), @Tenant, @Type, N'Mail', @Email, @Subject,
N'<p>Sayın ' + ISNULL(@Supplier, N'') + N',</p><p>' + @Subject + N' aşağıda bilgilerinize sunulmuştur.</p>'
+ N'<table border="1" cellpadding="4" cellspacing="0"><tr><th>Ürün</th><th>Açıklama</th><th>Miktar</th><th>Birim Fiyat</th><th>KDV</th><th>Tutar</th></tr>'
+ ISNULL(@Lines, N'') + N'</table><p><b>Toplam: ' + FORMAT(@Total, 'N2', 'tr-TR') + N' ' + @Cur + N'</b></p>',
0, 0, GETUTCDATE(), @UserId, 0);
UPDATE Prc_T_PurchaseOrder
SET LastSentDate = GETUTCDATE(),
Status = CASE WHEN Status = 'Draft' THEN 'Sent' ELSE Status END
WHERE Id = @Id;
END

View file

@ -0,0 +1,31 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseOrderSetStatus]
@Id uniqueidentifier,
@Action nvarchar(16),
@UserId uniqueidentifier = NULL
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Status nvarchar(16);
SELECT @Status = Status FROM Prc_T_PurchaseOrder WHERE Id = @Id;
UPDATE Prc_T_PurchaseOrder SET PendingAction = NULL WHERE Id = @Id;
IF @Action = 'Send'
BEGIN
IF @Status = 'Cancelled' THROW 50121, N'İptal edilmiş belge gönderilemez.', 1;
EXEC Prc_P_PurchaseOrderSend @Id, @UserId;
END
ELSE IF @Action = 'Confirm'
BEGIN
IF @Status NOT IN ('Draft', 'Sent') THROW 50122, N'Yalnız teklif aşamasındaki belge siparişe çevrilebilir.', 1;
IF NOT EXISTS (SELECT 1 FROM Prc_T_PurchaseOrderLine WHERE PurchaseOrderId = @Id AND IsDeleted = 0)
THROW 50123, N'Kalemi olmayan teklif onaylanamaz.', 1;
UPDATE Prc_T_PurchaseOrder SET Status = 'Purchase', ConfirmDate = GETUTCDATE() WHERE Id = @Id;
END
ELSE IF @Action = 'Cancel'
UPDATE Prc_T_PurchaseOrder SET Status = 'Cancelled' WHERE Id = @Id;
ELSE IF @Action = 'Draft'
BEGIN
IF @Status <> 'Cancelled' THROW 50124, N'Yalnız iptal edilmiş belge taslağa alınabilir.', 1;
UPDATE Prc_T_PurchaseOrder SET Status = 'Draft', ConfirmDate = NULL WHERE Id = @Id;
END
END

View file

@ -0,0 +1,20 @@
CREATE OR ALTER PROCEDURE [dbo].[Prc_P_PurchaseRfqFromAgreement]
@Id uniqueidentifier
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Agr uniqueidentifier, @Tenant uniqueidentifier;
SELECT @Agr = AgreementId, @Tenant = TenantId FROM Prc_T_PurchaseOrder WHERE Id = @Id;
IF @Agr IS NULL RETURN;
IF EXISTS (SELECT 1 FROM Prc_T_PurchaseOrderLine WHERE PurchaseOrderId = @Id AND IsDeleted = 0) RETURN;
INSERT INTO Prc_T_PurchaseOrderLine (Id, TenantId, PurchaseOrderId, ProductId, Description, Quantity, UomId,
UnitPrice, TaxRate, Amount, CreationTime, IsDeleted)
SELECT NEWID(), @Tenant, @Id, al.ProductId, al.Description,
CASE WHEN al.Quantity - al.OrderedQuantity > 0 THEN al.Quantity - al.OrderedQuantity ELSE 0 END,
al.UomId, al.UnitPrice, ISNULL(p.PurchaseTaxRate, 0), 0, GETUTCDATE(), 0
FROM Prc_V_PurchaseAgreementLine al
LEFT JOIN Inv_T_Product p ON p.Id = al.ProductId
WHERE al.AgreementId = @Agr AND al.IsDeleted = 0
AND al.Quantity - al.OrderedQuantity > 0;
END

View file

@ -0,0 +1,31 @@
IF OBJECT_ID(N'[dbo].[Prc_T_PurchaseAgreement]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_PurchaseAgreement]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[AgreementNo] nvarchar(32) NOT NULL,
[SupplierId] uniqueidentifier NOT NULL,
[BuyerUserId] uniqueidentifier NOT NULL,
[AgreementType] nvarchar(16) NOT NULL DEFAULT 'Blanket',
[CurrencyId] nvarchar(8) NOT NULL DEFAULT 'TRY',
[StartDate] date NULL,
[EndDate] date NULL,
[Reference] nvarchar(64) NULL,
[OperationTypeId] uniqueidentifier NULL,
[Terms] nvarchar(MAX) NULL,
[Status] nvarchar(16) NOT NULL DEFAULT 'Draft',
[CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(),
[CreatorId] uniqueidentifier NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierId] uniqueidentifier NULL,
[IsDeleted] bit NOT NULL DEFAULT 0,
[DeletionTime] datetime2 NULL,
[DeleterId] uniqueidentifier NULL,
CONSTRAINT [PK_Prc_T_PurchaseAgreement] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

View file

@ -0,0 +1,32 @@
IF OBJECT_ID(N'[dbo].[Prc_T_PurchaseAgreementLine]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_PurchaseAgreementLine]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[AgreementId] uniqueidentifier NOT NULL,
[ProductId] uniqueidentifier NOT NULL,
[Description] nvarchar(512) NULL,
[Quantity] decimal(18, 4) NOT NULL DEFAULT 1,
[UomId] nvarchar(50) NOT NULL DEFAULT 'Adet',
[UnitPrice] decimal(18, 4) NOT NULL DEFAULT 0,
[CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(),
[CreatorId] uniqueidentifier NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierId] uniqueidentifier NULL,
[IsDeleted] bit NOT NULL DEFAULT 0,
[DeletionTime] datetime2 NULL,
[DeleterId] uniqueidentifier NULL,
CONSTRAINT [PK_Prc_T_PurchaseAgreementLine] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF OBJECT_ID(N'[dbo].[FK_Prc_T_PurchaseAgreementLine_AgreementId]', 'F') IS NULL
BEGIN
ALTER TABLE [dbo].[Prc_T_PurchaseAgreementLine] ADD CONSTRAINT [FK_Prc_T_PurchaseAgreementLine_AgreementId] FOREIGN KEY ([AgreementId]) REFERENCES [dbo].[Prc_T_PurchaseAgreement] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION;
END
GO

View file

@ -0,0 +1,49 @@
IF OBJECT_ID(N'[dbo].[Prc_T_PurchaseOrder]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_PurchaseOrder]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[OrderNo] nvarchar(32) NOT NULL,
[SupplierId] uniqueidentifier NOT NULL,
[SupplierReference] nvarchar(64) NULL,
[AgreementId] uniqueidentifier NULL,
[MaterialRequestId] uniqueidentifier NULL,
[CurrencyId] nvarchar(8) NOT NULL DEFAULT 'TRY',
[OrderDeadline] datetime NULL,
[ExpectedArrival] datetime NULL,
[RequireConfirmation] bit NOT NULL DEFAULT 0,
[OperationTypeId] uniqueidentifier NULL,
[ConfirmDate] datetime NULL,
[ArrivalDate] datetime NULL,
[SupplierResponse] nvarchar(16) NOT NULL DEFAULT 'Waiting',
[QuoteDate] datetime NULL,
[QuotedByUserId] uniqueidentifier NULL,
[QuoteValidUntil] date NULL,
[BuyerUserId] uniqueidentifier NOT NULL,
[SourceDocument] nvarchar(512) NULL,
[ProjectId] uniqueidentifier NULL,
[IncotermId] uniqueidentifier NULL,
[IncotermLocation] nvarchar(128) NULL,
[PaymentTermId] uniqueidentifier NULL,
[Terms] nvarchar(MAX) NULL,
[UntaxedAmount] decimal(18, 4) NOT NULL DEFAULT 0,
[TaxAmount] decimal(18, 4) NOT NULL DEFAULT 0,
[TotalAmount] decimal(18, 4) NOT NULL DEFAULT 0,
[Status] nvarchar(16) NOT NULL DEFAULT 'Draft',
[PendingAction] nvarchar(16) NULL,
[LastSentDate] datetime NULL,
[CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(),
[CreatorId] uniqueidentifier NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierId] uniqueidentifier NULL,
[IsDeleted] bit NOT NULL DEFAULT 0,
[DeletionTime] datetime2 NULL,
[DeleterId] uniqueidentifier NULL,
CONSTRAINT [PK_Prc_T_PurchaseOrder] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

View file

@ -0,0 +1,35 @@
IF OBJECT_ID(N'[dbo].[Prc_T_PurchaseOrderLine]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_PurchaseOrderLine]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[PurchaseOrderId] uniqueidentifier NOT NULL,
[ProductId] uniqueidentifier NOT NULL,
[Description] nvarchar(512) NULL,
[Quantity] decimal(18, 4) NOT NULL DEFAULT 1,
[UomId] nvarchar(50) NOT NULL DEFAULT 'Adet',
[UnitPrice] decimal(18, 4) NOT NULL DEFAULT 0,
[TaxRate] decimal(18, 4) NOT NULL DEFAULT 20,
[Amount] decimal(18, 4) NOT NULL DEFAULT 0,
[MaterialRequestItemId] uniqueidentifier NULL,
[CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(),
[CreatorId] uniqueidentifier NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierId] uniqueidentifier NULL,
[IsDeleted] bit NOT NULL DEFAULT 0,
[DeletionTime] datetime2 NULL,
[DeleterId] uniqueidentifier NULL,
CONSTRAINT [PK_Prc_T_PurchaseOrderLine] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF OBJECT_ID(N'[dbo].[FK_Prc_T_PurchaseOrderLine_PurchaseOrderId]', 'F') IS NULL
BEGIN
ALTER TABLE [dbo].[Prc_T_PurchaseOrderLine] ADD CONSTRAINT [FK_Prc_T_PurchaseOrderLine_PurchaseOrderId] FOREIGN KEY ([PurchaseOrderId]) REFERENCES [dbo].[Prc_T_PurchaseOrder] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION;
END
GO

View file

@ -0,0 +1,11 @@
CREATE OR ALTER VIEW [dbo].[Prc_V_MaterialRequestImportable] AS
SELECT r.Id, r.TenantId, r.RequestNo, r.RequesterUserId, r.RequestDate,
(SELECT COUNT(*) FROM Prc_T_MaterialRequestItem i
WHERE i.MaterialRequestId = r.Id AND i.IsDeleted = 0
AND i.FulfillmentMethod = 'Purchase' AND i.LineStatus = 'Waiting'
AND NOT EXISTS (SELECT 1 FROM Prc_T_PurchaseOrderLine ol
INNER JOIN Prc_T_PurchaseOrder o ON o.Id = ol.PurchaseOrderId
WHERE ol.MaterialRequestItemId = i.Id AND ol.IsDeleted = 0
AND o.IsDeleted = 0 AND o.Status <> 'Cancelled')) AS ImportableCount
FROM Prc_T_MaterialRequest r
WHERE r.IsDeleted = 0 AND r.ApprovalStatus = N'Onaylandı'

View file

@ -0,0 +1,9 @@
CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseAgreementLine] AS
SELECT l.Id, l.TenantId, l.AgreementId, l.ProductId, l.Description, l.Quantity, l.UomId, l.UnitPrice,
ISNULL((SELECT SUM(ol.Quantity)
FROM Prc_T_PurchaseOrderLine ol
INNER JOIN Prc_T_PurchaseOrder o ON o.Id = ol.PurchaseOrderId
WHERE o.AgreementId = l.AgreementId AND ol.ProductId = l.ProductId
AND o.Status = 'Purchase' AND o.IsDeleted = 0 AND ol.IsDeleted = 0), 0) AS OrderedQuantity,
l.CreationTime, l.CreatorId, l.LastModificationTime, l.LastModifierId, l.IsDeleted, l.DeletionTime, l.DeleterId
FROM Prc_T_PurchaseAgreementLine l

View file

@ -0,0 +1,10 @@
CREATE OR ALTER VIEW [dbo].[Prc_V_PurchaseOrderAlternative] AS
SELECT DISTINCT b.Id AS BaseOrderId, x.Id, x.TenantId, x.OrderNo, x.SupplierId, x.Status, x.SupplierResponse,
x.OrderDeadline, x.ExpectedArrival, x.TotalAmount, x.CurrencyId, x.IsDeleted
FROM Prc_T_PurchaseOrder b
INNER JOIN Prc_T_PurchaseOrderLine bl ON bl.PurchaseOrderId = b.Id AND bl.IsDeleted = 0 AND bl.MaterialRequestItemId IS NOT NULL
INNER JOIN Prc_T_MaterialRequestItem bi ON bi.Id = bl.MaterialRequestItemId
INNER JOIN Prc_T_MaterialRequestItem xi ON xi.MaterialRequestId = bi.MaterialRequestId
INNER JOIN Prc_T_PurchaseOrderLine xl ON xl.MaterialRequestItemId = xi.Id AND xl.IsDeleted = 0
INNER JOIN Prc_T_PurchaseOrder x ON x.Id = xl.PurchaseOrderId AND x.Id <> b.Id
WHERE b.IsDeleted = 0

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff