diff --git a/models/baseModels/InvoiceItem/InvoiceItem.ts b/models/baseModels/InvoiceItem/InvoiceItem.ts
index 137c467d..c9fb0375 100644
--- a/models/baseModels/InvoiceItem/InvoiceItem.ts
+++ b/models/baseModels/InvoiceItem/InvoiceItem.ts
@@ -36,6 +36,7 @@ export abstract class InvoiceItem extends Doc {
transferUnit?: string;
quantity?: number;
transferQuantity?: number;
+ qty?: number;
unitConversionFactor?: number;
batch?: string;
@@ -231,13 +232,28 @@ export abstract class InvoiceItem extends Doc {
},
transferQuantity: {
formula: (fieldname) => {
+ if (fieldname === 'qty') {
+ return this.qty;
+ }
if (fieldname === 'quantity' || this.unit === this.transferUnit) {
return this.quantity;
}
return this.transferQuantity;
},
- dependsOn: ['item', 'quantity'],
+ dependsOn: ['item', 'quantity', 'qty'],
+ },
+ qty: {
+ formula: (fieldname) => {
+ if (fieldname === 'transferQuantity') {
+ return this.transferQuantity;
+ }
+ if (fieldname === 'quantity' || this.unit === this.transferUnit) {
+ return this.quantity;
+ }
+ return this.transferQuantity;
+ },
+ dependsOn: ['transferQuantity', 'quantity'],
},
quantity: {
formula: async (fieldname) => {
diff --git a/schemas/app/InvoiceItem.json b/schemas/app/InvoiceItem.json
index 9ce000a4..aac6b964 100644
--- a/schemas/app/InvoiceItem.json
+++ b/schemas/app/InvoiceItem.json
@@ -44,6 +44,13 @@
"default": 1,
"required": true
},
+ {
+ "fieldname": "qty",
+ "label": "Qty",
+ "fieldtype": "Float",
+ "default": 1,
+ "computed": true
+ },
{
"fieldname": "unit",
"label": "Stock Unit",
@@ -140,7 +147,7 @@
"readOnly": true
}
],
- "tableFields": ["item", "tax", "quantity", "rate", "amount"],
+ "tableFields": ["item", "tax", "qty", "rate", "amount"],
"keywordFields": ["item", "tax"],
"quickEditFields": [
"item",
diff --git a/src/components/POS/Classic/SelectedItemRow.vue b/src/components/POS/Classic/SelectedItemRow.vue
index ae7ac4ff..1face039 100644
--- a/src/components/POS/Classic/SelectedItemRow.vue
+++ b/src/components/POS/Classic/SelectedItemRow.vue
@@ -36,7 +36,7 @@
}"
size="small"
:border="false"
- :value="row.quantity"
+ :value="getDisplayTransferQuantity()"
:read-only="true"
/>
@@ -70,13 +70,13 @@
@@ -133,18 +133,19 @@
-
row.set('transferUnit', value)"
:read-only="isReadOnly"
/>
@@ -295,10 +296,11 @@ import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem';
import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice';
import { showToast } from 'src/utils/interactive';
import { ModelNameEnum } from 'models/types';
+import AutoComplete from 'src/components/Controls/AutoComplete.vue';
export default defineComponent({
name: 'SelectedItemRow',
- components: { Currency, Data, Float, Int, Link, Text },
+ components: { Currency, Data, Float, Int, Link, Text, AutoComplete },
props: {
row: { type: SalesInvoiceItem, required: true },
batchAdded: { type: Boolean, default: false },
@@ -321,6 +323,7 @@ export default defineComponent({
defaultRate: this.row.rate as Money,
profileDiscountSetting: null as boolean | null,
profileRateSetting: null as boolean | null,
+ transferUnitOptions: [] as Array<{ label: string; value: string }>,
};
},
watch: {
@@ -333,6 +336,16 @@ export default defineComponent({
},
immediate: true,
},
+ 'row.item': {
+ async handler(newItem) {
+ if (newItem) {
+ await this.updateTransferUnitOptions();
+ } else {
+ this.transferUnitOptions = [];
+ }
+ },
+ immediate: true,
+ },
},
computed: {
isUOMConversionEnabled(): boolean {
@@ -394,6 +407,37 @@ export default defineComponent({
this.setQuantity(newQuantity);
},
+ async updateTransferUnitOptions() {
+ if (!this.row.item) {
+ this.transferUnitOptions = [];
+ return;
+ }
+
+ const itemDoc = await fyo.doc.getDoc('Item', this.row.item as string);
+
+ const conversions = (itemDoc?.uomConversions ?? []) as Array<{
+ uom: string;
+ conversionFactor: number;
+ }>;
+
+ const allowedUoms = new Set
();
+
+ if (typeof itemDoc?.unit === 'string') {
+ allowedUoms.add(itemDoc.unit);
+ }
+
+ for (const c of conversions) {
+ if (typeof c.uom === 'string') {
+ allowedUoms.add(c.uom);
+ }
+ }
+
+ this.transferUnitOptions = [...allowedUoms].map((uom) => ({
+ label: uom,
+ value: uom,
+ }));
+ },
+
async getAvailableQtyInBatch(): Promise {
if (!this.row.batch) {
return 0;
diff --git a/src/components/POS/Classic/SelectedItemTable.vue b/src/components/POS/Classic/SelectedItemTable.vue
index 9bc78eb6..811cbbfe 100644
--- a/src/components/POS/Classic/SelectedItemTable.vue
+++ b/src/components/POS/Classic/SelectedItemTable.vue
@@ -125,7 +125,7 @@ export default defineComponent({
},
{
fieldname: 'unit',
- label: 'Stock Unit',
+ label: 'Unit Type',
placeholder: 'Unit',
fieldtype: 'Link',
required: true,
diff --git a/templates/Basic.template.html b/templates/Basic.template.html
index 8402f928..3152b417 100644
--- a/templates/Basic.template.html
+++ b/templates/Basic.template.html
@@ -60,12 +60,12 @@
- {{ t`Item` }}
- {{ t`Description` }}
-
+
{{ t`Item` }}
+
{{ t`Description` }}
+
{{ t`HSN/SAC` }}
-
{{ t`Quantity` }}
+
{{ t`Qty` }}
{{ t`Rate` }}
{{ t`Amount` }}
@@ -76,14 +76,17 @@
v-for="row in doc.items"
:key="row.name"
>
-
{{ row.item }}
-
+
{{ row.item }}
+
{{ row.description }}
-
+
{{ row.hsnCode }}
-
{{ row.quantity }}
+
+
{{ row.transferUnit }} {{ row.qty }}
+
{{ row.qty }}
+
{{ row.rate }}
{{ row.amount }}
diff --git a/templates/Business.Shipment.template.html b/templates/Business.Shipment.template.html
index d897d278..b497c8a3 100644
--- a/templates/Business.Shipment.template.html
+++ b/templates/Business.Shipment.template.html
@@ -81,7 +81,13 @@
{{ row.hsnCode }}
{{ row.location }}
-
{{ row.quantity }}
+
+
{{ row.quantity }}
+
+ ({{row.transferQuantity}} of {{ row.transferUnit }})
+
+
({{row.quantity}} of {{ row.unit }})
+
{{ row.rate }}
{{ row.amount }}
diff --git a/templates/Business.template.html b/templates/Business.template.html
index 57122c0a..11438d99 100644
--- a/templates/Business.template.html
+++ b/templates/Business.template.html
@@ -60,10 +60,10 @@
- {{ t`Item` }}
- {{ t`Description` }}
- {{ t`HSN/SAC` }}
- {{ t`Quantity` }}
+ {{ t`Item` }}
+ {{ t`Description` }}
+ {{ t`HSN/SAC` }}
+ {{ t`Qty` }}
{{ t`Rate` }}
{{ t`Amount` }}
@@ -74,10 +74,13 @@
v-for="row in doc.items"
:key="row.name"
>
- {{ row.item }}
- {{ row.description }}
- {{ row.hsnCode }}
- {{ row.quantity }}
+ {{ row.item }}
+ {{ row.description }}
+ {{ row.hsnCode }}
+
+
{{ row.transferUnit }} {{ row.qty }}
+
{{ row.qty }}
+
{{ row.rate }}
{{ row.amount }}
diff --git a/templates/Minimal.template.html b/templates/Minimal.template.html
index b8282358..e30ebfbc 100644
--- a/templates/Minimal.template.html
+++ b/templates/Minimal.template.html
@@ -98,24 +98,27 @@
text-gray-800
"
>
-
{{ t`Item` }}
-
+
{{ t`Item` }}
+
{{ t`Description` }}
-
{{ t`HSN/SAC` }}
-
{{ t`Quantity` }}
+
{{ t`HSN/SAC` }}
+
{{ t`Qty` }}
{{ t`Rate` }}
{{ t`Amount`}}
- {{ row.item }}
-
+
{{ row.item }}
+
{{ row.description }}
-
{{ row.hsnCode }}
-
{{ row.quantity }}
+
{{ row.hsnCode }}
+
+
{{ row.transferUnit }} {{ row.qty }}
+
{{ row.qty }}
+
{{ row.rate }}
{{ row.amount }}