Merge pull request #1259 from frappe/fix-transfer-unit

fix: adjust quantity when transfer UOM is modified
This commit is contained in:
Able k Saju
2025-06-24 15:16:43 +05:30
committed by GitHub
6 changed files with 49 additions and 65 deletions
+6 -6
View File
@@ -79,6 +79,7 @@ export abstract class Invoice extends Transactional {
grandTotal?: Money;
baseGrandTotal?: Money;
outstandingAmount?: Money;
initialGrandTotal?: Money;
exchangeRate?: number;
setDiscountAmount?: boolean;
discountAmount?: Money;
@@ -869,19 +870,18 @@ export abstract class Invoice extends Transactional {
}
async getLPAddedBaseGrandTotal() {
if (!this.initialGrandTotal) {
this.initialGrandTotal = this.grandTotal;
}
const totalLotaltyAmount = await getAddedLPWithGrandTotal(
this.fyo,
this.loyaltyProgram as string,
this.loyaltyPoints as number
);
if (this.redeemLoyaltyPoints && (this.loyaltyPoints as number) > 0) {
this.grandTotal?.add(totalLotaltyAmount);
}
return this.grandTotal?.sub(totalLotaltyAmount);
return this.initialGrandTotal?.sub(totalLotaltyAmount);
}
formulas: FormulaMap = {
account: {
formula: async () => {
+1 -1
View File
@@ -513,7 +513,7 @@ export abstract class InvoiceItem extends Doc {
if (!this.prule) {
return this.itemDiscountPercent;
} else {
return this.fyo.pesa(0);
return 0;
}
}
+5 -2
View File
@@ -470,11 +470,14 @@ export class Payment extends Transactional {
for (const row of this.for ?? []) {
if (!this.fyo.singles.AccountingSettings?.enablePartialPayment) {
const amount = this.amount as Money;
const amount = (this.writeoff as Money).isZero()
? (this.amount as Money)
: (this.amountPaid as Money);
const totalAmount = this.totalAmount as Money;
if (amount.lt(totalAmount)) {
if (this.writeoff?.isZero()) {
this.amount = this.initialAmount;
this.amount = totalAmount;
row.amountPaid = this.fyo.pesa(0);
throw new ValidationError(
this.fyo.t`Enable Partial payment to pay partial amount`
-6
View File
@@ -60,12 +60,6 @@
"fieldtype": "Check",
"default": false
},
{
"fieldname": "isMultiple",
"label": "Is Multiple",
"fieldtype": "Check",
"default": false
},
{
"fieldname": "priority",
"label": "Priority",
+1 -1
View File
@@ -104,7 +104,7 @@ export default defineComponent({
},
{
fieldname: 'availableQty',
label: 'Available Qty',
label: 'Qty',
placeholder: 'Available Qty',
fieldtype: 'Float',
readOnly: true,
+36 -49
View File
@@ -87,48 +87,6 @@
<template v-if="isExapanded">
<div class="px-4 pt-6 col-span-1">
<Float
:df="{
fieldname: 'quantity',
fieldtype: 'Float',
label: 'Quantity',
}"
size="medium"
:min="0"
:border="true"
:show-label="true"
:value="row.quantity"
@change="(value:number) => setQuantity(value)"
:read-only="isReadOnly"
/>
</div>
<div class="px-4 pt-6 col-span-2 flex">
<Link
v-if="isUOMConversionEnabled"
:df="{
fieldname: 'transferUnit',
fieldtype: 'Link',
target: 'UOM',
label: t`Transfer Unit`,
}"
class="flex-1"
:show-label="true"
:border="true"
:value="row.transferUnit"
@change="(value:string) => row.set('transferUnit', value)"
:read-only="isReadOnly"
/>
<feather-icon
v-if="isUOMConversionEnabled"
name="refresh-ccw"
class="w-3.5 ml-2 mt-4 text-blue-500"
@click="row.transferUnit = row.unit"
:read-only="isReadOnly"
/>
</div>
<div class="px-4 pt-6 col-span-2">
<Int
v-if="isUOMConversionEnabled"
:df="{
@@ -145,10 +103,45 @@
/>
</div>
<div class="px-4 pt-6 col-span-2">
<Link
v-if="isUOMConversionEnabled"
:df="{
fieldname: 'transferUnit',
fieldtype: 'Link',
target: 'UOM',
label: t`Transfer Unit`,
}"
class="flex-1"
:show-label="true"
:border="true"
:value="row.transferUnit"
@change="(value:string) => row.set('transferUnit', value)"
:read-only="isReadOnly"
/>
</div>
<div class="px-4 pt-6 col-span-2">
<Float
:df="{
fieldname: 'quantity',
fieldtype: 'Float',
label: 'Quantity',
}"
size="medium"
:min="0"
:border="true"
:show-label="true"
:value="row.quantity"
@change="(value:number) => setQuantity(value)"
:read-only="isUOMConversionEnabled"
/>
</div>
<div></div>
<div></div>
<div class="px-4 pt-6 flex">
<div class="px-4 pt-6">
<Currency
:df="{
fieldtype: 'Currency',
@@ -162,12 +155,6 @@
:read-only="isRateReadOnly()"
@change="(value:Money) => setRate((row.rate = value))"
/>
<feather-icon
name="refresh-ccw"
class="w-3.5 ml-2 mt-5 text-blue-500 flex-none"
@click="row.rate= (defaultRate as Money)"
:disabled="isRateReadOnly()"
/>
</div>
<div class="px-6 pt-6 col-span-2">
<Currency