mirror of
https://github.com/frappe/books.git
synced 2025-01-22 22:58:28 +00:00
incr: add stock indicator text
- move inventory reports to Inventory
This commit is contained in:
parent
bea9d86b91
commit
a879f04ad5
@ -24,6 +24,14 @@ export function format(
|
|||||||
|
|
||||||
const field: Field = getField(df);
|
const field: Field = getField(df);
|
||||||
|
|
||||||
|
if (field.fieldtype === FieldTypeEnum.Float) {
|
||||||
|
return Number(value).toFixed(fyo.singles.SystemSettings?.displayPrecision);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.fieldtype === FieldTypeEnum.Int) {
|
||||||
|
return Math.trunc(Number(value)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (field.fieldtype === FieldTypeEnum.Currency) {
|
if (field.fieldtype === FieldTypeEnum.Currency) {
|
||||||
return formatCurrency(value, field, doc, fyo);
|
return formatCurrency(value, field, doc, fyo);
|
||||||
}
|
}
|
||||||
@ -60,7 +68,9 @@ function toDatetime(value: DocValue) {
|
|||||||
function formatDatetime(value: DocValue, fyo: Fyo): string {
|
function formatDatetime(value: DocValue, fyo: Fyo): string {
|
||||||
const dateFormat =
|
const dateFormat =
|
||||||
(fyo.singles.SystemSettings?.dateFormat as string) ?? DEFAULT_DATE_FORMAT;
|
(fyo.singles.SystemSettings?.dateFormat as string) ?? DEFAULT_DATE_FORMAT;
|
||||||
const formattedDatetime = toDatetime(value).toFormat(`${dateFormat} HH:mm:ss`);
|
const formattedDatetime = toDatetime(value).toFormat(
|
||||||
|
`${dateFormat} HH:mm:ss`
|
||||||
|
);
|
||||||
|
|
||||||
if (value === 'Invalid DateTime') {
|
if (value === 'Invalid DateTime') {
|
||||||
return '';
|
return '';
|
||||||
|
@ -7,14 +7,14 @@ import {
|
|||||||
DefaultMap,
|
DefaultMap,
|
||||||
FiltersMap,
|
FiltersMap,
|
||||||
FormulaMap,
|
FormulaMap,
|
||||||
HiddenMap
|
HiddenMap,
|
||||||
} from 'fyo/model/types';
|
} from 'fyo/model/types';
|
||||||
import { DEFAULT_CURRENCY } from 'fyo/utils/consts';
|
import { DEFAULT_CURRENCY } from 'fyo/utils/consts';
|
||||||
import { ValidationError } from 'fyo/utils/errors';
|
import { ValidationError } from 'fyo/utils/errors';
|
||||||
import {
|
import {
|
||||||
getExchangeRate,
|
getExchangeRate,
|
||||||
getInvoiceActions,
|
getInvoiceActions,
|
||||||
getNumberSeries
|
getNumberSeries,
|
||||||
} from 'models/helpers';
|
} from 'models/helpers';
|
||||||
import { InventorySettings } from 'models/inventory/InventorySettings';
|
import { InventorySettings } from 'models/inventory/InventorySettings';
|
||||||
import { StockTransfer } from 'models/inventory/StockTransfer';
|
import { StockTransfer } from 'models/inventory/StockTransfer';
|
||||||
@ -22,10 +22,7 @@ import { Transactional } from 'models/Transactional/Transactional';
|
|||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
import { FieldTypeEnum, Schema } from 'schemas/types';
|
import { FieldTypeEnum, Schema } from 'schemas/types';
|
||||||
import {
|
import { getIsNullOrUndef, joinMapLists, safeParseFloat } from 'utils';
|
||||||
getIsNullOrUndef, joinMapLists,
|
|
||||||
safeParseFloat
|
|
||||||
} from 'utils';
|
|
||||||
import { Defaults } from '../Defaults/Defaults';
|
import { Defaults } from '../Defaults/Defaults';
|
||||||
import { InvoiceItem } from '../InvoiceItem/InvoiceItem';
|
import { InvoiceItem } from '../InvoiceItem/InvoiceItem';
|
||||||
import { Item } from '../Item/Item';
|
import { Item } from '../Item/Item';
|
||||||
@ -396,6 +393,13 @@ export abstract class Invoice extends Transactional {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTotalQuantity() {
|
||||||
|
return (this.items ?? []).reduce(
|
||||||
|
(acc, item) => acc + (item.quantity ?? 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
getStockNotTransferred() {
|
getStockNotTransferred() {
|
||||||
return (this.items ?? []).reduce(
|
return (this.items ?? []).reduce(
|
||||||
(acc, item) => (item.stockNotTransferred ?? 0) + acc,
|
(acc, item) => (item.stockNotTransferred ?? 0) + acc,
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
DefaultMap,
|
DefaultMap,
|
||||||
FiltersMap,
|
FiltersMap,
|
||||||
FormulaMap,
|
FormulaMap,
|
||||||
ListViewSettings
|
ListViewSettings,
|
||||||
} from 'fyo/model/types';
|
} from 'fyo/model/types';
|
||||||
import { getDocStatusListColumn, getLedgerLinkAction } from 'models/helpers';
|
import { getDocStatusListColumn, getLedgerLinkAction } from 'models/helpers';
|
||||||
import { LedgerPosting } from 'models/Transactional/LedgerPosting';
|
import { LedgerPosting } from 'models/Transactional/LedgerPosting';
|
||||||
@ -50,9 +50,32 @@ export class StockMovement extends Transfer {
|
|||||||
date: () => new Date(),
|
date: () => new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static getListViewSettings(): ListViewSettings {
|
static getListViewSettings(fyo: Fyo): ListViewSettings {
|
||||||
return {
|
return {
|
||||||
columns: ['name', getDocStatusListColumn(), 'date', 'movementType'],
|
columns: [
|
||||||
|
'name',
|
||||||
|
getDocStatusListColumn(),
|
||||||
|
'date',
|
||||||
|
{
|
||||||
|
label: fyo.t`Movement Type`,
|
||||||
|
fieldname: 'movementType',
|
||||||
|
fieldtype: 'Select',
|
||||||
|
size: 'small',
|
||||||
|
render(doc) {
|
||||||
|
const movementType = doc.movementType as MovementType;
|
||||||
|
const label =
|
||||||
|
{
|
||||||
|
[MovementType.MaterialIssue]: fyo.t`Material Issue`,
|
||||||
|
[MovementType.MaterialReceipt]: fyo.t`Material Receipt`,
|
||||||
|
[MovementType.MaterialTransfer]: fyo.t`Material Transfer`,
|
||||||
|
}[movementType] ?? '';
|
||||||
|
|
||||||
|
return {
|
||||||
|
template: `<span>${label}</span>`,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +130,15 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<div class="flex justify-between text-base m-4 gap-12">
|
<div class="flex justify-between text-base m-4 gap-12">
|
||||||
<div class="w-1/2 flex flex-col justify-between">
|
<div class="w-1/2 flex flex-col justify-between">
|
||||||
<!-- Discount Note -->
|
<!-- Info Note -->
|
||||||
<p v-if="discountNote?.length" class="text-gray-600 text-sm">
|
<p v-if="discountNote?.length" class="text-gray-600 text-sm">
|
||||||
{{ discountNote }}
|
{{ discountNote }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p v-if="stockTransferText?.length" class="text-gray-600 text-sm">
|
||||||
|
{{ stockTransferText }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<!-- Form Terms-->
|
<!-- Form Terms-->
|
||||||
<FormControl
|
<FormControl
|
||||||
:border="true"
|
:border="true"
|
||||||
@ -309,7 +314,6 @@ import { docsPathMap } from 'src/utils/misc';
|
|||||||
import {
|
import {
|
||||||
docsPath,
|
docsPath,
|
||||||
getGroupedActionsForDoc,
|
getGroupedActionsForDoc,
|
||||||
getStatus,
|
|
||||||
routeTo,
|
routeTo,
|
||||||
showMessageDialog,
|
showMessageDialog,
|
||||||
} from 'src/utils/ui';
|
} from 'src/utils/ui';
|
||||||
@ -355,6 +359,27 @@ export default {
|
|||||||
this.chstatus = !this.chstatus;
|
this.chstatus = !this.chstatus;
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
stockTransferText() {
|
||||||
|
if (!this.fyo.singles.AccountingSettings.enableInventory) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.doc.submitted) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalQuantity = this.doc.getTotalQuantity();
|
||||||
|
const stockNotTransferred = this.doc.stockNotTransferred;
|
||||||
|
|
||||||
|
if (stockNotTransferred === 0) {
|
||||||
|
return this.t`Stock has been transferred`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stn = this.fyo.format(stockNotTransferred, 'Float');
|
||||||
|
const tq = this.fyo.format(totalQuantity, 'Float');
|
||||||
|
|
||||||
|
return this.t`Stock qty. ${stn} out of ${tq} left to transfer`;
|
||||||
|
},
|
||||||
groupedActions() {
|
groupedActions() {
|
||||||
const actions = getGroupedActionsForDoc(this.doc);
|
const actions = getGroupedActionsForDoc(this.doc);
|
||||||
const group = this.t`View`;
|
const group = this.t`View`;
|
||||||
|
@ -46,7 +46,7 @@ import PageHeader from 'src/components/PageHeader.vue';
|
|||||||
import { fyo } from 'src/initFyo';
|
import { fyo } from 'src/initFyo';
|
||||||
import { docsPathMap } from 'src/utils/misc';
|
import { docsPathMap } from 'src/utils/misc';
|
||||||
import { docsPath, routeTo } from 'src/utils/ui';
|
import { docsPath, routeTo } from 'src/utils/ui';
|
||||||
import List from './List';
|
import List from './List.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ListView',
|
name: 'ListView',
|
||||||
|
@ -85,13 +85,23 @@ async function getInventorySidebar(): Promise<SidebarRoot[]> {
|
|||||||
route: '/list/PurchaseReceipt',
|
route: '/list/PurchaseReceipt',
|
||||||
schemaName: 'PurchaseReceipt',
|
schemaName: 'PurchaseReceipt',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: t`Stock Ledger`,
|
||||||
|
name: 'stock-ledger',
|
||||||
|
route: '/report/StockLedger',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t`Stock Balance`,
|
||||||
|
name: 'stock-balance',
|
||||||
|
route: '/report/StockBalance',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getReportSidebar() {
|
async function getReportSidebar() {
|
||||||
const reports = {
|
return {
|
||||||
label: t`Reports`,
|
label: t`Reports`,
|
||||||
name: 'reports',
|
name: 'reports',
|
||||||
icon: 'reports',
|
icon: 'reports',
|
||||||
@ -119,24 +129,6 @@ async function getReportSidebar() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasInventory = !!fyo.singles.AccountingSettings?.enableInventory;
|
|
||||||
if (hasInventory) {
|
|
||||||
reports.items.push(
|
|
||||||
{
|
|
||||||
label: t`Stock Ledger`,
|
|
||||||
name: 'stock-ledger',
|
|
||||||
route: '/report/StockLedger',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t`Stock Balance`,
|
|
||||||
name: 'stock-balance',
|
|
||||||
route: '/report/StockBalance',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return reports;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCompleteSidebar(): Promise<SidebarConfig> {
|
async function getCompleteSidebar(): Promise<SidebarConfig> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user