Merge pull request #1225 from ableksaju/fix-enable-pos-without-inventory

fix: enable pos without inventory
This commit is contained in:
Able k Saju
2025-05-29 11:54:26 +05:30
committed by GitHub
9 changed files with 44 additions and 10 deletions
@@ -8,6 +8,8 @@ import {
ValidationMap,
} from 'fyo/model/types';
import { validateEmail } from 'fyo/model/validationFunction';
import { InventorySettings } from 'models/inventory/InventorySettings';
import { ModelNameEnum } from 'models/types';
import { createDiscountAccount } from 'src/setup/setupInstance';
import { getCountryInfo } from 'utils/misc';
@@ -21,7 +23,7 @@ export class AccountingSettings extends Doc {
enableInvoiceReturns?: boolean;
enableLoyaltyProgram?: boolean;
enablePricingRule?: boolean;
enablePointOfSale?: boolean;
enablePointOfSaleWithOutInventory?: boolean;
static filters: FiltersMap = {
writeOffAccount: () => ({
@@ -62,8 +64,8 @@ export class AccountingSettings extends Doc {
enableLoyaltyProgram: () => {
return !!this.enableLoyaltyProgram;
},
enablePointOfSale: () => {
return !!this.enablePointOfSale;
enablePointOfSaleWithOutInventory: () => {
return !!this.enablePointOfSaleWithOutInventory;
},
};
@@ -84,5 +86,22 @@ export class AccountingSettings extends Doc {
if (discountingEnabled && discountAccountNotSet) {
await createDiscountAccount(this.fyo);
}
if (
ch.changed == 'enablePointOfSaleWithOutInventory' &&
this.enablePointOfSaleWithOutInventory
) {
const inventorySettings = (await this.fyo.doc.getDoc(
ModelNameEnum.InventorySettings
)) as InventorySettings;
await inventorySettings.set('enableBatches', true);
await inventorySettings.set('enableUomConversions', true);
await inventorySettings.set('enableSerialNumber', true);
await inventorySettings.set('enableBarcodes', true);
await inventorySettings.set('enablePointOfSale', true);
await inventorySettings.sync();
}
}
}
+1 -1
View File
@@ -108,7 +108,7 @@ export class Defaults extends Doc {
}
getPointOfSaleHidden() {
return () => !this.fyo.singles.AccountingSettings?.enablePointOfSale;
return () => !this.fyo.singles.InventorySettings?.enablePointOfSale;
}
hidden: HiddenMap = {
+4 -1
View File
@@ -1530,7 +1530,10 @@ export abstract class Invoice extends Transactional {
}
)) as PricingRule[];
if (pricingRuleDocsForItem[0].isCouponCodeBased) {
if (
pricingRuleDocsForItem.length &&
pricingRuleDocsForItem[0].isCouponCodeBased
) {
if (!this.coupons?.length) {
continue;
}
+4
View File
@@ -12,6 +12,7 @@ export class InventorySettings extends Doc {
enableSerialNumber?: boolean;
enableUomConversions?: boolean;
enableStockReturns?: boolean;
enablePointOfSale?: boolean;
static filters: FiltersMap = {
stockInHand: () => ({
@@ -44,5 +45,8 @@ export class InventorySettings extends Doc {
enableStockReturns: () => {
return !!this.enableStockReturns;
},
enablePointOfSale: () => {
return !!this.fyo.singles.POSSettings?.isShiftOpen;
},
};
}
@@ -45,5 +45,7 @@ export class POSSettings extends Doc {
itemWeightDigits: () =>
!this.fyo.singles.InventorySettings?.enableBarcodes ||
!this.weightEnabledBarcode,
itemVisibility: () =>
!this.fyo.singles.AccountingSettings?.enablePointOfSaleWithOutInventory,
};
}
+2 -2
View File
@@ -129,8 +129,8 @@
"section": "Features"
},
{
"fieldname": "enablePointOfSale",
"label": "Enable Point of Sale",
"fieldname": "enablePointOfSaleWithOutInventory",
"label": "Enable POS Without Inventory",
"fieldtype": "Check",
"default": false,
"section": "Features"
@@ -63,6 +63,13 @@
"fieldtype": "Check",
"default": false,
"section": "Features"
},
{
"fieldname": "enablePointOfSale",
"label": "Enable Point of Sale",
"fieldtype": "Check",
"default": false,
"section": "Features"
}
]
}
+1 -2
View File
@@ -155,8 +155,7 @@ export default defineComponent({
const enableInventory =
!!this.fyo.singles.AccountingSettings?.enableInventory;
const enablePOS =
!!this.fyo.singles.AccountingSettings?.enablePointOfSale;
const enablePOS = !!this.fyo.singles.InventorySettings?.enablePointOfSale;
return [
ModelNameEnum.AccountingSettings,
+1 -1
View File
@@ -107,7 +107,7 @@ function getPOSSidebar() {
name: 'pos',
route: '/pos',
icon: 'pos',
hidden: () => !fyo.singles.AccountingSettings?.enablePointOfSale,
hidden: () => !fyo.singles.InventorySettings?.enablePointOfSale,
};
}